1
|
package eu.dnetlib.data.oai.store.actions;
|
2
|
|
3
|
import javax.annotation.Resource;
|
4
|
|
5
|
import eu.dnetlib.data.information.oai.publisher.OaiPublisherException;
|
6
|
import eu.dnetlib.data.information.oai.utils.OAIParameterNames;
|
7
|
import eu.dnetlib.data.oai.store.mongo.MongoPublisherStore;
|
8
|
import eu.dnetlib.data.oai.store.mongo.MongoPublisherStoreDAO;
|
9
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
10
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
|
11
|
import org.apache.commons.logging.Log;
|
12
|
import org.apache.commons.logging.LogFactory;
|
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
|
@Resource
|
19
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
20
|
|
21
|
@Override
|
22
|
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
|
23
|
String mdformat = job.getParameters().get(OAIParameterNames.OAI_FORMAT_NAME);
|
24
|
String layout = job.getParameters().get(OAIParameterNames.OAI_FORMAT_LAYOUT);
|
25
|
String interp = job.getParameters().get(OAIParameterNames.OAI_FORMAT_INTERPRETATION);
|
26
|
String dbName = job.getParameters().get(OAIParameterNames.OAI_DB);
|
27
|
String collection = job.getParameters().get(OAIParameterNames.OAI_COLLECTON);
|
28
|
if (this.mongoPublisherStoreDAO.getStore(mdformat, interp, layout, dbName) == null) {
|
29
|
MongoPublisherStore store = this.mongoPublisherStoreDAO.createStore(mdformat, interp, layout, dbName);
|
30
|
if(store == null){
|
31
|
log.error("Could not create MongoPublisherStore");
|
32
|
handler.failed(job, new OaiPublisherException(String.format("Cannot create OAI store for %s, %s, %s on db %s", mdformat, interp, layout, dbName)));
|
33
|
}
|
34
|
log.info("Created store with id: " + store.getId() + "on db " + dbName+": \n"+store.toString());
|
35
|
} else {
|
36
|
log.info("Store "+collection+" already exists on db " + dbName);
|
37
|
}
|
38
|
handler.done(job);
|
39
|
}
|
40
|
|
41
|
}
|