Project

General

Profile

« Previous | Next » 

Revision 41466

implemented Drop content action

View differences:

FeedObjectStoreAction.java
1 1
package eu.dnetlib.data.objectstore.modular;
2 2

  
3
import org.springframework.beans.factory.annotation.Required;
4

  
3
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
5 4
import eu.dnetlib.data.objectstore.rmi.Protocols;
6 5
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
7
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
8 6
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
7
import org.springframework.beans.factory.annotation.Required;
9 8

  
10 9

  
11 10
/**
12 11
 * The Class FeedObjectStoreAction to execute the blacboard action of type FEED.
13 12
 */
14
public class FeedObjectStoreAction extends AbstractObjectStoreAction implements
15
		BlackboardServerAction<ObjectStoreActions> {
13
public class FeedObjectStoreAction extends AbstractObjectStoreAction {
16 14

  
17 15
	/** The profile creator. */
18 16
	private ObjectStoreProfileCreator profileCreator;
......
20 18
	/** The store feeder. */
21 19
	private ModularObjectStoreFeeder storeFeeder;
22 20

  
23
	/* (non-Javadoc)
24
	 * @see eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler, eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
25
	 */
26 21
	@Override
27
	public void execute(BlackboardServerHandler handler, BlackboardJob job)
28
			throws Exception {
22
	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws ObjectStoreServiceException {
23
		try {
24
			final String objStoreID = job.getParameters().get("obsID");
25
			final String objID = job.getParameters().get("objID");
26
			final String URI = job.getParameters().get("URI");
27
			final String eprRs = job.getParameters().get("epr");
28
			final String protocolString = job.getParameters().get("protocol");
29 29

  
30
		final String objStoreID = job.getParameters().get("obsID");
31
		final String objID = job.getParameters().get("objID");
32
		final String URI = job.getParameters().get("URI");
33
		final String eprRs = job.getParameters().get("epr");
34
		final String protocolString = job.getParameters().get("protocol");
30
			final Protocols protocol;
31
			if (protocolString == null)
32
				protocol = Protocols.None;
33
			else
34
				protocol = Protocols.valueOf(job.getParameters().get("protocol"));
35
			final String mime = job.getParameters().get("mime");
36
			final String login = job.getParameters().get("login");
37
			final String password = job.getParameters().get("password");
35 38

  
36
		final Protocols protocol;
37
		if (protocolString == null)
38
			protocol = Protocols.None;
39
		else
40
			protocol = Protocols.valueOf(job.getParameters().get("protocol"));
41
		final String mime = job.getParameters().get("mime");
42
		final String login = job.getParameters().get("login");
43
		final String password = job.getParameters().get("password");
44

  
45
		if (URI != null && URI.length() > 0) {
46
			storeFeeder.feedObject(objStoreID, objID, URI, protocol, login,
47
					password, mime);
48
		} else if (eprRs != null && eprRs.length() > 0) {
49
			storeFeeder
50
					.feed(objStoreID, eprRs, protocol, login, password, mime);
39
			if (URI != null && URI.length() > 0) {
40
				storeFeeder.feedObject(objStoreID, objID, URI, protocol, login,
41
						password, mime);
42
			} else if (eprRs != null && eprRs.length() > 0) {
43
				storeFeeder
44
						.feed(objStoreID, eprRs, protocol, login, password, mime);
45
			}
46
			completeWithSuccess(handler, job);
47
		} catch (Exception e) {
48
			completeWithFail(handler, job, e);
51 49
		}
50
	}
52 51

  
53
		handler.done(job);
54 52

  
55
	}
56 53

  
57 54
	/**
58 55
	 * Gets the profile creator.

Also available in: Unified diff