1 |
42181
|
sandro.lab
|
package eu.dnetlib.oai.actions;
|
2 |
|
|
|
3 |
42184
|
michele.ar
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
4 |
|
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
|
5 |
|
|
import eu.dnetlib.oai.mongo.MongoPublisherStore;
|
6 |
|
|
import eu.dnetlib.oai.mongo.MongoPublisherStoreDAO;
|
7 |
43245
|
claudio.at
|
import eu.dnetlib.rmi.provision.MDFInfo;
|
8 |
|
|
import eu.dnetlib.utils.MetadataReference;
|
9 |
|
|
import eu.dnetlib.utils.MetadataReferenceFactory;
|
10 |
42621
|
sandro.lab
|
import org.apache.commons.logging.Log;
|
11 |
|
|
import org.apache.commons.logging.LogFactory;
|
12 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
13 |
42184
|
michele.ar
|
|
14 |
42181
|
sandro.lab
|
public class CreateStoreAction extends AbstractOAIStoreAction {
|
15 |
|
|
|
16 |
|
|
private static final Log log = LogFactory.getLog(CreateStoreAction.class); // NOPMD by marko on 11/24/08 5:02 PM
|
17 |
|
|
|
18 |
42621
|
sandro.lab
|
@Autowired
|
19 |
42181
|
sandro.lab
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
20 |
|
|
|
21 |
|
|
@Override
|
22 |
|
|
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
|
23 |
42184
|
michele.ar
|
final String dbName = job.getParameters().get("oai_dbName");
|
24 |
43245
|
claudio.at
|
|
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);
|
30 |
42181
|
sandro.lab
|
log.info("Created store with id: " + store.getId() + "on db " + dbName);
|
31 |
|
|
} else {
|
32 |
43245
|
claudio.at
|
log.info("Store already exist: " + collectionName + " on db " + dbName);
|
33 |
42181
|
sandro.lab
|
}
|
34 |
|
|
handler.done(job);
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
}
|