]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
64db074a942cb5c3fb24e1de4c70bbc1deb1249a
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.batch.nuxeo;
2
3 import java.util.Arrays;
4 import org.collectionspace.services.batch.AbstractBatchInvocable;
5 import org.collectionspace.services.common.api.Tools;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8
9 public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
10
11     final String CLASSNAME = this.getClass().getSimpleName();
12     final Logger logger = LoggerFactory.getLogger(UpdateObjectLocationBatchJob.class);
13
14     // Initialization tasks
15     public UpdateObjectLocationBatchJob() {
16         setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE));
17     }
18
19     /**
20      * The main work logic of the batch job. Will be called after setContext.
21      */
22     @Override
23     public void run() {
24
25         setCompletionStatus(STATUS_MIN_PROGRESS);
26         try {
27             // FIXME: Placeholder during early development
28             if (logger.isInfoEnabled()) {
29                 logger.info("Invoking " + CLASSNAME + " ...");
30                 logger.info("Invocation context is: " + getInvocationContext().getMode());
31             }
32             if (!requestedInvocationModeIsSupported()) {
33                 setInvocationModeNotSupportedResult();
34             }
35             String csid;
36             if (requestIsForInvocationModeSingle()) {
37                 csid = getInvocationContext().getSingleCSID();
38                 if (Tools.isBlank(csid)) {
39                     throw new Exception("Could not find required CSID value in the context for this batch job.");
40                 }
41                 logger.info("CSID value is: " + csid);
42             }
43             String docType = getInvocationContext().getDocType();
44         } catch (Exception e) {
45             String errMsg = "Error encountered in " + CLASSNAME + ": " + e.getLocalizedMessage();
46             setErrorResult(errMsg);
47         }
48         setCompletionStatus(STATUS_COMPLETE);
49     }
50 }