Revision 43245
Added by Claudio Atzori almost 8 years ago
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/utils/MetadataReference.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.index.utils; |
|
2 |
|
|
3 |
import com.google.common.collect.ComparisonChain; |
|
4 |
|
|
5 |
/** |
|
6 |
* Container class for metadata format, layout and interpretation. |
|
7 |
* |
|
8 |
* @author claudio |
|
9 |
*/ |
|
10 |
public class MetadataReference { |
|
11 |
|
|
12 |
/** |
|
13 |
* Metadata format. |
|
14 |
*/ |
|
15 |
private String format; |
|
16 |
|
|
17 |
/** |
|
18 |
* Metadata layout. |
|
19 |
*/ |
|
20 |
private String layout; |
|
21 |
|
|
22 |
/** |
|
23 |
* Metadata interpretation. |
|
24 |
*/ |
|
25 |
private String interpretation; |
|
26 |
|
|
27 |
/** |
|
28 |
* Constructor for MetadataReference. |
|
29 |
* |
|
30 |
* @param format Metadata format |
|
31 |
* @param layout Metadata layout |
|
32 |
* @param interpretation Metadata interpretation |
|
33 |
*/ |
|
34 |
public MetadataReference(final String format, final String layout, final String interpretation) { |
|
35 |
this.format = format; |
|
36 |
this.layout = layout; |
|
37 |
this.interpretation = interpretation; |
|
38 |
} |
|
39 |
|
|
40 |
public String getFormat() { |
|
41 |
return format; |
|
42 |
} |
|
43 |
|
|
44 |
public String getLayout() { |
|
45 |
return layout; |
|
46 |
} |
|
47 |
|
|
48 |
public String getInterpretation() { |
|
49 |
return interpretation; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public boolean equals(final Object that) { |
|
54 |
|
|
55 |
if (!(that instanceof MetadataReference)) |
|
56 |
return false; |
|
57 |
|
|
58 |
final MetadataReference mdRef = (MetadataReference) that; |
|
59 |
|
|
60 |
return ComparisonChain.start() |
|
61 |
.compare(this.format, mdRef.getFormat()) |
|
62 |
.compare(this.layout, mdRef.getLayout()) |
|
63 |
.compare(this.interpretation, mdRef.getInterpretation()) |
|
64 |
.result() == 0; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public int hashCode() { |
|
69 |
return getFormat().hashCode() + getLayout().hashCode() + getInterpretation().hashCode(); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String toString() { |
|
74 |
return getFormat() + "_" + getLayout() + "_" + getInterpretation(); |
|
75 |
} |
|
76 |
|
|
77 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/utils/MetadataReferenceFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.index.utils; |
|
2 |
|
|
3 |
public class MetadataReferenceFactory { |
|
4 |
|
|
5 |
public MetadataReference getMetadata(final String format, final String layout, final String interpretation) { |
|
6 |
return new MetadataReference(format, layout, interpretation); |
|
7 |
} |
|
8 |
|
|
9 |
public MetadataReference decodeMetadata(final String encoded) { |
|
10 |
String[] split = encoded.split("@"); |
|
11 |
if (split.length == 3) return getMetadata(split[0], split[1], split[2]); |
|
12 |
|
|
13 |
throw new IllegalStateException("malformed metadata reference: " + encoded); |
|
14 |
} |
|
15 |
|
|
16 |
} |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/OAIStoreActions.java | ||
---|---|---|
1 |
package eu.dnetlib.oai.actions; |
|
2 |
|
|
3 |
public enum OAIStoreActions { |
|
4 |
SYNC, COUNT_SETS, REFRESH_CONFIG, ENSURE_INDEXES, CREATE_STORE, CREATE_OAI_INDEX, DROP_STORE |
|
5 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/utils/MetadataReference.java | ||
---|---|---|
1 |
package eu.dnetlib.utils; |
|
2 |
|
|
3 |
import com.google.common.collect.ComparisonChain; |
|
4 |
|
|
5 |
/** |
|
6 |
* Container class for metadata format, layout and interpretation. |
|
7 |
* |
|
8 |
* @author claudio |
|
9 |
*/ |
|
10 |
public class MetadataReference { |
|
11 |
|
|
12 |
/** |
|
13 |
* Metadata format. |
|
14 |
*/ |
|
15 |
private String format; |
|
16 |
|
|
17 |
/** |
|
18 |
* Metadata layout. |
|
19 |
*/ |
|
20 |
private String layout; |
|
21 |
|
|
22 |
/** |
|
23 |
* Metadata interpretation. |
|
24 |
*/ |
|
25 |
private String interpretation; |
|
26 |
|
|
27 |
/** |
|
28 |
* Constructor for MetadataReference. |
|
29 |
* |
|
30 |
* @param format Metadata format |
|
31 |
* @param layout Metadata layout |
|
32 |
* @param interpretation Metadata interpretation |
|
33 |
*/ |
|
34 |
public MetadataReference(final String format, final String layout, final String interpretation) { |
|
35 |
this.format = format; |
|
36 |
this.layout = layout; |
|
37 |
this.interpretation = interpretation; |
|
38 |
} |
|
39 |
|
|
40 |
public String getFormat() { |
|
41 |
return format; |
|
42 |
} |
|
43 |
|
|
44 |
public String getLayout() { |
|
45 |
return layout; |
|
46 |
} |
|
47 |
|
|
48 |
public String getInterpretation() { |
|
49 |
return interpretation; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public boolean equals(final Object that) { |
|
54 |
|
|
55 |
if (!(that instanceof MetadataReference)) |
|
56 |
return false; |
|
57 |
|
|
58 |
final MetadataReference mdRef = (MetadataReference) that; |
|
59 |
|
|
60 |
return ComparisonChain.start() |
|
61 |
.compare(this.format, mdRef.getFormat()) |
|
62 |
.compare(this.layout, mdRef.getLayout()) |
|
63 |
.compare(this.interpretation, mdRef.getInterpretation()) |
|
64 |
.result() == 0; |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public int hashCode() { |
|
69 |
return getFormat().hashCode() + getLayout().hashCode() + getInterpretation().hashCode(); |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public String toString() { |
|
74 |
return getFormat() + "_" + getLayout() + "_" + getInterpretation(); |
|
75 |
} |
|
76 |
|
|
77 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/utils/MetadataReferenceFactory.java | ||
---|---|---|
1 |
package eu.dnetlib.utils; |
|
2 |
|
|
3 |
public class MetadataReferenceFactory { |
|
4 |
|
|
5 |
public MetadataReference getMetadata(final String format, final String layout, final String interpretation) { |
|
6 |
return new MetadataReference(format, layout, interpretation); |
|
7 |
} |
|
8 |
|
|
9 |
public MetadataReference decodeMetadata(final String encoded) { |
|
10 |
return decodeMetadata(encoded, "@"); |
|
11 |
} |
|
12 |
|
|
13 |
public MetadataReference decodeMetadata(final String encoded, final String separator) { |
|
14 |
String[] split = encoded.split(separator); |
|
15 |
if (split.length == 3) return getMetadata(split[0], split[1], split[2]); |
|
16 |
|
|
17 |
throw new IllegalStateException("malformed metadata reference: " + encoded); |
|
18 |
} |
|
19 |
|
|
20 |
public static MetadataReference decode(final String encoded, final String separator) { |
|
21 |
return new MetadataReferenceFactory().decodeMetadata(encoded, separator); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/action/CreateIndexAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.action; |
2 | 2 |
|
3 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
3 |
import eu.dnetlib.utils.MetadataReference; |
|
4 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
5 | 5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction; |
6 | 6 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/DropStoreAction.java | ||
---|---|---|
3 | 3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
4 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
5 | 5 |
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO; |
6 |
import eu.dnetlib.utils.MetadataReference; |
|
7 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
6 | 8 |
import org.apache.commons.lang3.StringUtils; |
7 | 9 |
import org.apache.commons.logging.Log; |
8 | 10 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
17 | 19 |
|
18 | 20 |
@Override |
19 | 21 |
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception { |
20 |
final String mdformat = job.getParameters().get("format"); |
|
21 |
final String layout = job.getParameters().get("layout"); |
|
22 |
final String interp = job.getParameters().get("interpretation"); |
|
22 |
|
|
23 | 23 |
final String dbName = job.getParameters().get("oai_dbName"); |
24 | 24 |
final String set = job.getParameters().get("set"); |
25 | 25 |
boolean deleted = false; |
26 |
|
|
27 |
final String collectionName = job.getParameters().get("oai_collectionName"); |
|
28 |
final MetadataReference mdRef = MetadataReferenceFactory.decode(collectionName, MDREF_SEPARATOR); |
|
29 |
|
|
26 | 30 |
if (StringUtils.isNotBlank(set)) { |
27 |
deleted = this.mongoPublisherStoreDAO.deleteFromStore(mdformat, interp, layout, dbName, set);
|
|
31 |
deleted = this.mongoPublisherStoreDAO.deleteFromStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName, set);
|
|
28 | 32 |
} else { |
29 |
deleted = this.mongoPublisherStoreDAO.deleteStore(mdformat, interp, layout, dbName);
|
|
33 |
deleted = this.mongoPublisherStoreDAO.deleteStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName);
|
|
30 | 34 |
} |
31 | 35 |
if (deleted) { |
32 | 36 |
log.info("OAI Deletion succeded on db " + dbName); |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/sync/OAIStoreSynchronizer.java | ||
---|---|---|
5 | 5 |
import eu.dnetlib.oai.conf.OAIConfigurationExistReader; |
6 | 6 |
import eu.dnetlib.oai.mongo.MongoPublisherStore; |
7 | 7 |
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO; |
8 |
import eu.dnetlib.rmi.provision.MDFInfo; |
|
9 | 8 |
import eu.dnetlib.rmi.provision.OaiPublisherException; |
10 | 9 |
import eu.dnetlib.rmi.provision.OaiPublisherRuntimeException; |
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import org.apache.commons.logging.Log; |
12 | 12 |
import org.apache.commons.logging.LogFactory; |
13 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
24 | 24 |
private MongoPublisherStoreDAO publisherStoreDAO; |
25 | 25 |
|
26 | 26 |
public void synchronize(final Iterable<String> records, |
27 |
final MDFInfo sourceMetadataFormat,
|
|
27 |
final MetadataReference sourceMetadataFormat,
|
|
28 | 28 |
final String recordSource, |
29 | 29 |
final String dbName, |
30 | 30 |
final boolean alwaysNewRecord, |
... | ... | |
45 | 45 |
/** |
46 | 46 |
* Gets the OAI store for the given source metadata format. If the store does not exists, then a new one is created. |
47 | 47 |
* |
48 |
* @param sourceMetadataFormat MDFInfo about the metadata format of the store to get
|
|
48 |
* @param mdRef MDFInfo about the metadata format of the store to get
|
|
49 | 49 |
* @return a MongoPublisherStore instance |
50 | 50 |
*/ |
51 |
private MongoPublisherStore getStore(final MDFInfo sourceMetadataFormat, final String dbName, final boolean alwaysNewRecord) {
|
|
51 |
private MongoPublisherStore getStore(final MetadataReference mdRef, final String dbName, final boolean alwaysNewRecord) {
|
|
52 | 52 |
this.publisherStoreDAO.setAlwaysNewRecord(alwaysNewRecord); |
53 |
MongoPublisherStore store = this.publisherStoreDAO.getStore(sourceMetadataFormat.getSourceFormatName(), |
|
54 |
sourceMetadataFormat.getSourceFormatInterpretation(), sourceMetadataFormat.getSourceFormatLayout(), dbName); |
|
53 |
MongoPublisherStore store = this.publisherStoreDAO.getStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName); |
|
55 | 54 |
if (store == null) { |
56 |
log.debug("Creating store for metadata format: \n" + sourceMetadataFormat + " in db: " + dbName);
|
|
55 |
log.debug("Creating store for metadata format: \n" + mdRef + " in db: " + dbName);
|
|
57 | 56 |
try { |
58 |
store = this.publisherStoreDAO.createStore(sourceMetadataFormat.getSourceFormatName(), sourceMetadataFormat.getSourceFormatInterpretation(), |
|
59 |
sourceMetadataFormat.getSourceFormatLayout(), dbName); |
|
57 |
store = this.publisherStoreDAO.createStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName); |
|
60 | 58 |
log.debug("Created store with id: " + store.getId()); |
61 | 59 |
} catch (OaiPublisherException e) { |
62 | 60 |
throw new OaiPublisherRuntimeException(e); |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/CountSetsAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.oai.actions; |
2 | 2 |
|
3 |
import java.util.concurrent.Callable; |
|
4 |
|
|
5 |
import org.springframework.beans.factory.annotation.Autowired; |
|
6 |
|
|
7 | 3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
8 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
9 | 5 |
import eu.dnetlib.oai.conf.OAISetsCounter; |
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 | 7 |
|
11 | 8 |
public class CountSetsAction extends AbstractOAIStoreAction { |
12 | 9 |
|
... | ... | |
29 | 26 |
|
30 | 27 |
private void executeForAll(final String storeId, final BlackboardServerHandler handler, final BlackboardJob job, final String dbName) { |
31 | 28 |
|
32 |
this.setsCounter.updateCounts(storeId, dbName, new Callable<Object>() { |
|
33 |
|
|
34 |
@Override |
|
35 |
public Object call() { |
|
36 |
handler.done(job); |
|
37 |
return null; |
|
38 |
} |
|
39 |
}, new Callable<Object>() { |
|
40 |
|
|
41 |
@Override |
|
42 |
public Object call() { |
|
43 |
handler.failed(job, new Exception("Error during OAI sets count on db " + dbName)); |
|
44 |
return null; |
|
45 |
} |
|
29 |
this.setsCounter.updateCounts(storeId, dbName, () -> { |
|
30 |
handler.done(job); |
|
31 |
return null; |
|
32 |
}, () -> { |
|
33 |
handler.failed(job, new Exception("Error during OAI sets count on db " + dbName)); |
|
34 |
return null; |
|
46 | 35 |
}); |
47 | 36 |
} |
48 | 37 |
|
49 | 38 |
private void executeForConfiguredSetsOnly(final String storeId, final BlackboardServerHandler handler, final BlackboardJob job, final String dbName) { |
50 |
this.setsCounter.updateConfigurationCounts(storeId, dbName, new Callable<Object>() { |
|
51 |
|
|
52 |
@Override |
|
53 |
public Object call() { |
|
54 |
handler.done(job); |
|
55 |
return null; |
|
56 |
} |
|
57 |
}, new Callable<Object>() { |
|
58 |
|
|
59 |
@Override |
|
60 |
public Object call() { |
|
61 |
handler.failed(job, new Exception("Error during OAI sets count on db " + dbName)); |
|
62 |
return null; |
|
63 |
} |
|
39 |
this.setsCounter.updateConfigurationCounts(storeId, dbName, () -> { |
|
40 |
handler.done(job); |
|
41 |
return null; |
|
42 |
}, () -> { |
|
43 |
handler.failed(job, new Exception("Error during OAI sets count on db " + dbName)); |
|
44 |
return null; |
|
64 | 45 |
}); |
65 | 46 |
} |
66 | 47 |
|
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/SyncAction.java | ||
---|---|---|
8 | 8 |
import eu.dnetlib.oai.sync.OAIStoreSynchronizer; |
9 | 9 |
import eu.dnetlib.rmi.common.ResultSet; |
10 | 10 |
import eu.dnetlib.rmi.provision.MDFInfo; |
11 |
import eu.dnetlib.utils.MetadataReference; |
|
12 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
11 | 13 |
import org.apache.commons.logging.Log; |
12 | 14 |
import org.apache.commons.logging.LogFactory; |
13 | 15 |
import org.dom4j.io.SAXReader; |
... | ... | |
28 | 30 |
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception { |
29 | 31 |
String epr = job.getParameters().get("oai_syncEpr"); |
30 | 32 |
String recordSource = job.getParameters().get("oai_recordSource"); |
31 |
String formatName = job.getParameters().get("oai_formatName"); |
|
32 |
String formatLayout = job.getParameters().get("oai_formatLayout"); |
|
33 |
String formatInterpretation = job.getParameters().get("oai_formatInterpretation"); |
|
34 | 33 |
boolean alwaysNewRecord = Boolean.valueOf(job.getParameters().get("oai_alwaysNewRecord")); |
35 | 34 |
final String dbName = job.getParameters().get("oai_dbName"); |
36 |
MDFInfo mdf = new MDFInfo("", "", "", formatName, formatLayout, formatInterpretation, "", true); |
|
37 | 35 |
|
38 |
ResultSet<?> resutlSet = ResultSet.fromJson(epr); |
|
39 |
log.info("Syncronizing content for oai on db " + dbName + "for metadata format: " + mdf); |
|
40 |
Iterable<String> records = resultSetClient.iter(resutlSet, String.class); |
|
36 |
final String collectionName = job.getParameters().get("oai_collectionName"); |
|
37 |
final MetadataReference mdRef = MetadataReferenceFactory.decode(collectionName, MDREF_SEPARATOR); |
|
38 |
|
|
39 |
final ResultSet<?> rs = ResultSet.fromJson(epr); |
|
40 |
log.info("Syncronizing content for oai on db " + dbName + "for metadata format: " + mdRef); |
|
41 |
Iterable<String> records = resultSetClient.iter(rs, String.class); |
|
41 | 42 |
// in case of DMF there is no "hat element" after oai:metadata: we must add it or the OAI-PMH export will only contain the first |
42 | 43 |
// element inside oai:metadata. |
43 |
if (formatName.equalsIgnoreCase("DMF")) {
|
|
44 |
if (mdRef.getFormat().equalsIgnoreCase("DMF")) {
|
|
44 | 45 |
records = addDMFBlock(records); |
45 | 46 |
} |
46 |
this.synchronizer.synchronize(records, mdf, recordSource, dbName, alwaysNewRecord, () -> { |
|
47 |
this.synchronizer.synchronize(records, mdRef, recordSource, dbName, alwaysNewRecord, () -> {
|
|
47 | 48 |
handler.done(job); |
48 | 49 |
return null; |
49 | 50 |
}, () -> { |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/utils/ServiceTools.java | ||
---|---|---|
10 | 10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
11 | 11 |
import eu.dnetlib.rmi.enabling.*; |
12 | 12 |
import eu.dnetlib.rmi.provision.IndexServiceException; |
13 |
import eu.dnetlib.utils.MetadataReference; |
|
14 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
13 | 15 |
import org.apache.commons.lang3.StringUtils; |
14 | 16 |
import org.apache.commons.logging.Log; |
15 | 17 |
import org.apache.commons.logging.LogFactory; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/OAIStoreServiceImpl.java | ||
---|---|---|
13 | 13 |
import eu.dnetlib.rmi.common.ResultSet; |
14 | 14 |
import eu.dnetlib.rmi.provision.MDFInfo; |
15 | 15 |
import eu.dnetlib.rmi.provision.OAIStoreService; |
16 |
import eu.dnetlib.utils.MetadataReference; |
|
16 | 17 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 18 |
import org.springframework.beans.factory.annotation.Required; |
18 | 19 |
|
... | ... | |
35 | 36 |
private ResultSetClient resultSetClient; |
36 | 37 |
|
37 | 38 |
@Override |
38 |
public void feed(final ResultSet<String> recordsEpr, final MDFInfo mdfInfo, final String dbName) {
|
|
39 |
public void feed(final ResultSet<String> recordsEpr, final MetadataReference mdfInfo, final String dbName) {
|
|
39 | 40 |
this.feed(recordsEpr, mdfInfo, "", dbName); |
40 | 41 |
} |
41 | 42 |
|
42 | 43 |
@Override |
43 |
public void feed(final ResultSet<String> recordsEpr, final MDFInfo mdfInfo, final String recordSource, final String dbName) {
|
|
44 |
public void feed(final ResultSet<String> recordsEpr, final MetadataReference mdfInfo, final String recordSource, final String dbName) {
|
|
44 | 45 |
final Iterable<String> iter = this.resultSetClient.iter(recordsEpr, String.class); |
45 | 46 |
this.synchronizer.synchronize(iter, mdfInfo, recordSource, dbName, false, null, null); |
46 | 47 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/utils/MDFormatReader.java | ||
---|---|---|
10 | 10 |
import com.mycila.xmltool.XMLDoc; |
11 | 11 |
import com.mycila.xmltool.XMLTag; |
12 | 12 |
import eu.dnetlib.clients.index.client.IndexClientException; |
13 |
import eu.dnetlib.utils.MetadataReference; |
|
14 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
13 | 15 |
import org.dom4j.Document; |
14 | 16 |
import org.dom4j.DocumentException; |
15 | 17 |
import org.dom4j.io.SAXReader; |
16 | 18 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 19 |
import org.xml.sax.InputSource; |
18 | 20 |
|
19 |
; |
|
20 |
|
|
21 | 21 |
public class MDFormatReader { |
22 | 22 |
|
23 | 23 |
@Autowired |
24 | 24 |
private ServiceTools serviceTools; |
25 | 25 |
@Autowired |
26 |
private MetadataReferenceFactory mdFactory; |
|
27 | 26 |
|
28 | 27 |
public List<MetadataReference> listMDRefs() throws IndexClientException { |
29 | 28 |
return serviceTools.listMDRefs(); |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/query/BrowseAliases.java | ||
---|---|---|
9 | 9 |
import eu.dnetlib.clients.index.client.IndexClientException; |
10 | 10 |
import eu.dnetlib.clients.index.utils.IndexFieldUtility; |
11 | 11 |
import eu.dnetlib.clients.index.utils.MDFormatReader; |
12 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
12 |
import eu.dnetlib.utils.MetadataReference; |
|
13 | 13 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
14 | 14 |
import org.apache.commons.logging.Log; |
15 | 15 |
import org.apache.commons.logging.LogFactory; |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/query/IndexQueryFactory.java | ||
---|---|---|
9 | 9 |
import eu.dnetlib.clients.index.client.AbstractIndexClient; |
10 | 10 |
import eu.dnetlib.clients.index.client.IndexClientException; |
11 | 11 |
import eu.dnetlib.clients.index.query.Pruner.Result; |
12 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
12 |
import eu.dnetlib.utils.MetadataReference; |
|
13 | 13 |
import eu.dnetlib.index.cql.CqlTranslator; |
14 | 14 |
import eu.dnetlib.index.cql.TranslatedQuery; |
15 | 15 |
import org.springframework.beans.factory.annotation.Autowired; |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/query/Weights.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import eu.dnetlib.clients.index.client.IndexClientException; |
7 | 7 |
import eu.dnetlib.clients.index.utils.MDFormatReader; |
8 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
8 |
import eu.dnetlib.utils.MetadataReference; |
|
9 | 9 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
10 | 10 |
import org.apache.commons.logging.Log; |
11 | 11 |
import org.apache.commons.logging.LogFactory; |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/query/QueryResponseFactory.java | ||
---|---|---|
3 | 3 |
import java.util.function.Function; |
4 | 4 |
|
5 | 5 |
import eu.dnetlib.clients.index.client.IndexClientException; |
6 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
6 |
import eu.dnetlib.utils.MetadataReference; |
|
7 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
8 | 8 |
import org.springframework.beans.factory.annotation.Required; |
9 | 9 |
|
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/clients/index/client/AbstractIndexClient.java | ||
---|---|---|
3 | 3 |
import java.util.Map; |
4 | 4 |
|
5 | 5 |
import eu.dnetlib.clients.index.query.IndexQueryFactory; |
6 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
6 |
import eu.dnetlib.utils.MetadataReference; |
|
7 | 7 |
import eu.dnetlib.index.cql.CqlValueTransformerMap; |
8 | 8 |
|
9 | 9 |
public abstract class AbstractIndexClient implements IndexClient { |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/rmi/provision/OAIStoreService.java | ||
---|---|---|
6 | 6 |
|
7 | 7 |
import eu.dnetlib.rmi.common.BaseService; |
8 | 8 |
import eu.dnetlib.rmi.common.ResultSet; |
9 |
import eu.dnetlib.utils.MetadataReference; |
|
9 | 10 |
|
10 | 11 |
@WebService(targetNamespace = "http://services.dnetlib.eu/") |
11 | 12 |
public interface OAIStoreService extends BaseService { |
12 | 13 |
|
13 | 14 |
@WebMethod |
14 | 15 |
void feed(@WebParam(name = "recordsEpr") final ResultSet<String> recordsEpr, |
15 |
@WebParam(name = "mdformat") final MDFInfo mdfInfo,
|
|
16 |
@WebParam(name = "mdformat") final MetadataReference mdfInfo,
|
|
16 | 17 |
@WebParam(name = "dbName") final String dbName); |
17 | 18 |
|
18 | 19 |
@WebMethod(operationName = "feedWithSource") |
19 | 20 |
void feed(@WebParam(name = "recordsEpr") final ResultSet<String> recordsEpr, |
20 |
@WebParam(name = "mdformat") final MDFInfo mdfInfo,
|
|
21 |
@WebParam(name = "mdformat") final MetadataReference mdfInfo,
|
|
21 | 22 |
@WebParam(name = "recordSource") final String recordSource, |
22 | 23 |
@WebParam(name = "dbName") final String dbName); |
23 | 24 |
|
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/rmi/provision/OAIStoreActions.java | ||
---|---|---|
1 |
package eu.dnetlib.rmi.provision; |
|
2 |
|
|
3 |
public enum OAIStoreActions { |
|
4 |
SYNC, COUNT_SETS, REFRESH_CONFIG, ENSURE_INDEXES, CREATE_STORE, CREATE_OAI_INDEX, DROP_STORE |
|
5 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/rmi/manager/MSRORuntimeException.java | ||
---|---|---|
1 |
package eu.dnetlib.rmi.manager; |
|
2 |
|
|
3 |
public class MSRORuntimeException extends RuntimeException { |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
*/ |
|
8 |
private static final long serialVersionUID = 6126457312212409217L; |
|
9 |
|
|
10 |
public MSRORuntimeException(final String string) { |
|
11 |
super(string); |
|
12 |
} |
|
13 |
|
|
14 |
public MSRORuntimeException(final String string, final Throwable exception) { |
|
15 |
super(string, exception); |
|
16 |
} |
|
17 |
|
|
18 |
public MSRORuntimeException(final Throwable exception) { |
|
19 |
super(exception); |
|
20 |
} |
|
21 |
} |
modules/dnet-core-components/trunk/src/main/java/eu/dnetlib/data/collector/plugins/datasets/DatasetsIterator.java | ||
---|---|---|
4 | 4 |
import java.io.InputStream; |
5 | 5 |
import java.util.Iterator; |
6 | 6 |
|
7 |
import com.google.common.xml.XmlEscapers; |
|
7 | 8 |
import com.google.gson.Gson; |
8 | 9 |
import com.google.gson.GsonBuilder; |
9 | 10 |
import org.apache.commons.io.IOUtils; |
... | ... | |
74 | 75 |
|
75 | 76 |
if (info != null) { |
76 | 77 |
this.setJournalId(info.getJournalId()); |
78 |
//TODO check deprecation |
|
77 | 79 |
this.setJournalName(StringEscapeUtils.escapeXml(info.getJournalName())); |
78 | 80 |
this.setJournalISSN(info.getJournalISSN()); |
79 | 81 |
this.setOpenaireDatasource(info.getDatasourceId()); |
modules/dnet-core-components/trunk/src/main/resources/eu/dnetlib/index/utils/applicationContext-utils.xml | ||
---|---|---|
12 | 12 |
depends-on="uniqueServiceLocator"/> |
13 | 13 |
|
14 | 14 |
<bean id="mdFactory" |
15 |
class="eu.dnetlib.clients.index.utils.MetadataReferenceFactory" depends-on="uniqueServiceLocator"/> |
|
16 |
</beans> |
|
15 |
class="eu.dnetlib.utils.MetadataReferenceFactory" depends-on="uniqueServiceLocator"/> |
|
16 |
</beans> |
modules/dnet-core-components/trunk/src/main/resources/eu/dnetlib/index/query/applicationContext-index-query.xml | ||
---|---|---|
16 | 16 |
|
17 | 17 |
<bean id="mdFormatReader" class="eu.dnetlib.clients.index.utils.MDFormatReader"/> |
18 | 18 |
|
19 |
<bean id="metadataReferenceFactory" class="eu.dnetlib.clients.index.utils.MetadataReferenceFactory"/>
|
|
19 |
<bean id="metadataReferenceFactory" class="eu.dnetlib.utils.MetadataReferenceFactory"/> |
|
20 | 20 |
|
21 | 21 |
|
22 |
</beans> |
|
22 |
</beans> |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/solr/SolrIndexServerDAO.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import eu.dnetlib.clients.index.model.Any.ValueType; |
9 | 9 |
import eu.dnetlib.clients.index.query.IndexQueryFactory; |
10 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import eu.dnetlib.index.AbstractBackendDescriptor; |
12 | 12 |
import eu.dnetlib.index.IndexCollection; |
13 | 13 |
import eu.dnetlib.index.IndexServerDAO; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/solr/feed/SolrDocumentMapperFactory.java | ||
---|---|---|
7 | 7 |
import eu.dnetlib.clients.index.model.Any.ValueType; |
8 | 8 |
import eu.dnetlib.clients.index.model.document.IndexDocument; |
9 | 9 |
import eu.dnetlib.clients.index.model.document.Status; |
10 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import eu.dnetlib.index.feed.DocumentMapperFactory; |
12 | 12 |
import eu.dnetlib.index.solr.model.SolrIndexDocument; |
13 | 13 |
import org.springframework.beans.factory.annotation.Required; |
... | ... | |
45 | 45 |
final String dsId, |
46 | 46 |
final String version, |
47 | 47 |
final boolean emptyResult) { |
48 |
if (emptyResult == false) return getRecordMapper(schema, dsId, version);
|
|
48 |
if (!emptyResult) return getRecordMapper(schema, dsId, version);
|
|
49 | 49 |
else { |
50 | 50 |
return doc -> { |
51 | 51 |
SolrIndexDocument indexDocument = new SolrIndexDocument(schema, dsId); |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/solr/client/SolrIndexClient.java | ||
---|---|---|
19 | 19 |
import eu.dnetlib.clients.index.query.QueryLanguage; |
20 | 20 |
import eu.dnetlib.clients.index.query.QueryResponseFactory; |
21 | 21 |
import eu.dnetlib.clients.index.query.QueryResponseParser; |
22 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
22 |
import eu.dnetlib.utils.MetadataReference; |
|
23 | 23 |
import eu.dnetlib.index.cql.CqlValueTransformerMap; |
24 | 24 |
import eu.dnetlib.index.query.SolrIndexQuery; |
25 | 25 |
import eu.dnetlib.index.query.SolrIndexQueryFactory; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/IndexServerDAO.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import eu.dnetlib.clients.index.model.Any.ValueType; |
9 | 9 |
import eu.dnetlib.clients.index.query.IndexQueryFactory; |
10 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import eu.dnetlib.index.cql.CqlValueTransformerMap; |
12 | 12 |
import eu.dnetlib.index.feed.DocumentMapperFactory; |
13 | 13 |
import eu.dnetlib.rmi.provision.IndexServiceException; |
... | ... | |
55 | 55 |
*/ |
56 | 56 |
Map<String, ValueType> getSchema(final MetadataReference mdRef) throws IndexServiceException; |
57 | 57 |
|
58 |
; |
|
59 |
|
|
60 | 58 |
/** |
61 | 59 |
* Gets the cql value transformer map. |
62 | 60 |
* |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/feed/DocumentMapperFactory.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import eu.dnetlib.clients.index.model.Any.ValueType; |
7 | 7 |
import eu.dnetlib.clients.index.model.document.IndexDocument; |
8 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
8 |
import eu.dnetlib.utils.MetadataReference; |
|
9 | 9 |
|
10 | 10 |
/** |
11 | 11 |
* A factory for creating DocumentMapper objects. |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/query/SolrIndexQueryResponseFactory.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.clients.index.query.IndexQueryResponse; |
5 | 5 |
import eu.dnetlib.clients.index.query.QueryResponseFactory; |
6 | 6 |
import eu.dnetlib.clients.index.query.QueryResponseParser; |
7 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
7 |
import eu.dnetlib.utils.MetadataReference; |
|
8 | 8 |
import org.apache.solr.client.solrj.response.QueryResponse; |
9 | 9 |
|
10 | 10 |
/** |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/actors/IndexFeedActorImpl.java | ||
---|---|---|
7 | 7 |
|
8 | 8 |
import eu.dnetlib.clients.index.model.document.IndexDocument; |
9 | 9 |
import eu.dnetlib.clients.index.utils.IndexFieldUtility; |
10 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
10 |
import eu.dnetlib.utils.MetadataReference; |
|
11 | 11 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
12 | 12 |
import eu.dnetlib.enabling.tools.DnetStreamSupport; |
13 | 13 |
import eu.dnetlib.index.IndexCollection; |
... | ... | |
136 | 136 |
* |
137 | 137 |
* @param indexCollection the server dao |
138 | 138 |
* @param dsId the ds id |
139 |
* @return the time elapsed to complete the operation. |
|
140 | 139 |
* @throws IndexServiceException the index service exception |
141 | 140 |
*/ |
142 | 141 |
public void cleanMarkedDocuments(final IndexCollection indexCollection, final String dsId) throws IndexServiceException { |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/action/DeleteByQueryAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.action; |
2 | 2 |
|
3 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
3 |
import eu.dnetlib.utils.MetadataReference; |
|
4 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
5 | 5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction; |
6 | 6 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/action/DeleteIndexAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.action; |
2 | 2 |
|
3 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
3 |
import eu.dnetlib.utils.MetadataReference; |
|
4 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
5 | 5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction; |
6 | 6 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/action/AbstractIndexAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.index.action; |
2 | 2 |
|
3 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
3 |
import eu.dnetlib.utils.MetadataReference; |
|
4 | 4 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
5 | 5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
6 | 6 |
import eu.dnetlib.index.feed.FeedMode; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/index/MdFormatNotificationHandler.java | ||
---|---|---|
5 | 5 |
import java.util.concurrent.Executor; |
6 | 6 |
import java.util.concurrent.Executors; |
7 | 7 |
|
8 |
import eu.dnetlib.clients.index.utils.MetadataReference;
|
|
9 |
import eu.dnetlib.clients.index.utils.MetadataReferenceFactory;
|
|
8 |
import eu.dnetlib.utils.MetadataReference; |
|
9 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
10 | 10 |
import eu.dnetlib.clients.index.utils.ServiceTools; |
11 | 11 |
import eu.dnetlib.enabling.actions.AbstractSubscriptionAction; |
12 | 12 |
import org.apache.commons.logging.Log; |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/CreateOAIIndexAction.java | ||
---|---|---|
17 | 17 |
|
18 | 18 |
@Override |
19 | 19 |
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception { |
20 |
final String storeId = job.getParameters().get("collection");
|
|
20 |
final String storeId = job.getParameters().get("oai_collectionName");
|
|
21 | 21 |
final String dbName = job.getParameters().get("oai_dbName"); |
22 | 22 |
// Examples: field1,field2 -- one compound index on the given two fields |
23 | 23 |
// field1,field2;field3,field4 -- two compound indices: one on field1 and field2, the other on field3 and field4 |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/AbstractOAIStoreAction.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.oai.actions; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction; |
4 |
import eu.dnetlib.rmi.provision.OAIStoreActions; |
|
4 | 5 |
|
5 | 6 |
public abstract class AbstractOAIStoreAction implements BlackboardServerAction<OAIStoreActions> { |
6 | 7 |
|
8 |
protected final static String MDREF_SEPARATOR = "-"; |
|
9 |
|
|
7 | 10 |
} |
modules/dnet-data-provision-services/trunk/src/main/java/eu/dnetlib/oai/actions/CreateStoreAction.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
5 | 5 |
import eu.dnetlib.oai.mongo.MongoPublisherStore; |
6 | 6 |
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO; |
7 |
import eu.dnetlib.rmi.provision.MDFInfo; |
|
8 |
import eu.dnetlib.utils.MetadataReference; |
|
9 |
import eu.dnetlib.utils.MetadataReferenceFactory; |
|
7 | 10 |
import org.apache.commons.logging.Log; |
8 | 11 |
import org.apache.commons.logging.LogFactory; |
9 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
17 | 20 |
|
18 | 21 |
@Override |
19 | 22 |
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception { |
20 |
final String mdformat = job.getParameters().get("format"); |
|
21 |
final String layout = job.getParameters().get("layout"); |
|
22 |
final String interp = job.getParameters().get("interpretation"); |
|
23 | 23 |
final String dbName = job.getParameters().get("oai_dbName"); |
24 |
if (this.mongoPublisherStoreDAO.getStore(mdformat, interp, layout, dbName) == null) { |
|
25 |
final MongoPublisherStore store = this.mongoPublisherStoreDAO.createStore(mdformat, interp, layout, dbName); |
|
24 |
|
|
25 |
final String collectionName = job.getParameters().get("oai_collectionName"); |
|
26 |
final MetadataReference mdRef = MetadataReferenceFactory.decode(collectionName, MDREF_SEPARATOR); |
|
27 |
|
|
28 |
if (this.mongoPublisherStoreDAO.getStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName) == null) { |
|
29 |
final MongoPublisherStore store = this.mongoPublisherStoreDAO.createStore(mdRef.getFormat(), mdRef.getInterpretation(), mdRef.getLayout(), dbName); |
|
26 | 30 |
log.info("Created store with id: " + store.getId() + "on db " + dbName); |
27 | 31 |
} else { |
28 |
log.info("Store already exists for format=" + mdformat + " layout=" + layout + " interpretation=" + interp + " on db " + dbName);
|
|
32 |
log.info("Store already exist: " + collectionName + " on db " + dbName);
|
|
29 | 33 |
} |
30 | 34 |
handler.done(job); |
31 | 35 |
} |
modules/dnet-data-provision-services/trunk/src/main/resources/eu/dnetlib/oai/store/applicationContext-dnet-oai-store-service.xml | ||
---|---|---|
25 | 25 |
<bean id="oaiStoreBlackboardExecutor" |
26 | 26 |
class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor" |
27 | 27 |
p:blackboardHandler-ref="blackboardHandler" |
28 |
p:actionType="eu.dnetlib.oai.actions.OAIStoreActions"
|
|
28 |
p:actionType="eu.dnetlib.rmi.provision.OAIStoreActions"
|
|
29 | 29 |
p:incomplete="false"> |
30 | 30 |
<property name="actionMap"> |
31 | 31 |
<map> |
... | ... | |
60 | 60 |
|
61 | 61 |
<bean id="oaiSetsCounter" class="eu.dnetlib.oai.conf.OAISetsCounter"/> |
62 | 62 |
|
63 |
</beans> |
|
63 |
</beans> |
Also available in: Unified diff
moved MetadataReference class in common package, it will be used by both index service and oai store service