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.oai.utils.OAIParameterNames;
|
8
|
import eu.dnetlib.rmi.provision.OaiPublisherException;
|
9
|
import org.apache.commons.logging.Log;
|
10
|
import org.apache.commons.logging.LogFactory;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
|
13
|
public class CreateStoreAction extends AbstractOAIStoreAction {
|
14
|
|
15
|
private static final Log log = LogFactory.getLog(CreateStoreAction.class); // NOPMD by marko on 11/24/08 5:02 PM
|
16
|
|
17
|
@Autowired
|
18
|
private MongoPublisherStoreDAO mongoPublisherStoreDAO;
|
19
|
|
20
|
@Override
|
21
|
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
|
22
|
String mdformat = job.getParameters().get(OAIParameterNames.OAI_FORMAT_NAME);
|
23
|
String layout = job.getParameters().get(OAIParameterNames.OAI_FORMAT_LAYOUT);
|
24
|
String interp = job.getParameters().get(OAIParameterNames.OAI_FORMAT_INTERPRETATION);
|
25
|
String dbName = job.getParameters().get(OAIParameterNames.OAI_DB);
|
26
|
String collection = job.getParameters().get(OAIParameterNames.OAI_COLLECTON);
|
27
|
if (this.mongoPublisherStoreDAO.getStore(mdformat, interp, layout, dbName) == null) {
|
28
|
MongoPublisherStore store = this.mongoPublisherStoreDAO.createStore(mdformat, interp, layout, dbName);
|
29
|
if (store == null) {
|
30
|
log.error("Cannot create MongoPublisherStore");
|
31
|
handler.failed(job,
|
32
|
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
|
}
|