1
|
package eu.dnetlib.oai.actions;
|
2
|
|
3
|
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
|
import eu.dnetlib.rmi.provision.MDFInfo;
|
8
|
import eu.dnetlib.utils.MetadataReference;
|
9
|
import eu.dnetlib.utils.MetadataReferenceFactory;
|
10
|
import org.apache.commons.logging.Log;
|
11
|
import org.apache.commons.logging.LogFactory;
|
12
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
|
14
|
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
|
@Autowired
|
19
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
20
|
|
21
|
@Override
|
22
|
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
|
23
|
final String dbName = job.getParameters().get("oai_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);
|
30
|
log.info("Created store with id: " + store.getId() + "on db " + dbName);
|
31
|
} else {
|
32
|
log.info("Store already exist: " + collectionName + " on db " + dbName);
|
33
|
}
|
34
|
handler.done(job);
|
35
|
}
|
36
|
|
37
|
}
|