Skip to content

Commit 11226f4

Browse files
committed
Reordered datastreams added to new FOXML documents for ingest so that the DATA_FILE will come after other uploaded datastreams. Added more breakpoints in ingest jobs to allow pausing to interrupt
1 parent 4d6d23e commit 11226f4

File tree

4 files changed

+42
-35
lines changed

4 files changed

+42
-35
lines changed

deposit/src/main/java/edu/unc/lib/deposit/fcrepo3/IngestDeposit.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
import edu.unc.lib.deposit.work.AbstractDepositJob;
3131
import edu.unc.lib.deposit.work.DepositGraphUtils;
32-
import edu.unc.lib.deposit.work.JobInterruptedException;
3332
import edu.unc.lib.dl.acl.util.AccessGroupSet;
3433
import edu.unc.lib.dl.acl.util.GroupsThreadStore;
3534
import edu.unc.lib.dl.fedora.AccessClient;
@@ -50,7 +49,6 @@
5049
import edu.unc.lib.dl.util.PremisEventLogger;
5150
import edu.unc.lib.dl.util.PremisEventLogger.Type;
5251
import edu.unc.lib.dl.util.RedisWorkerConstants.DepositField;
53-
import edu.unc.lib.dl.util.RedisWorkerConstants.DepositState;
5452
import edu.unc.lib.dl.xml.FOXMLJDOMUtil;
5553

5654
/**
@@ -247,11 +245,7 @@ public void runJob() {
247245
statusFactory.incrIngestedObjects(getDepositUUID(), 1);
248246

249247
// Verify that the job has not been interrupted before continuing
250-
DepositState state = statusFactory.getState(getDepositUUID());
251-
if (!DepositState.running.equals(state)) {
252-
throw new JobInterruptedException("State for job " + getDepositUUID()
253-
+ " is no longer running, interrupting");
254-
}
248+
verifyRunning();
255249
}
256250
} catch (DepositException e) {
257251
failJob(e, Type.INGESTION, "Ingest of object {0} failed", ingestPid);
@@ -261,6 +255,7 @@ public void runJob() {
261255
// listen to Fedora JMS to see when all objects are ingested
262256
try {
263257
while (ingestsAwaitingConfirmation.size() > 0) {
258+
verifyRunning();
264259
Thread.sleep(COMPLETE_CHECK_DELAY);
265260
}
266261

deposit/src/main/java/edu/unc/lib/deposit/fcrepo3/MakeFOXML.java

+28-28
Original file line numberDiff line numberDiff line change
@@ -159,29 +159,6 @@ public void runJob() {
159159

160160
// TODO translate default web object, already copied, check it
161161

162-
// add DATA_FILE
163-
Property fileLocation = dprop(m, DepositRelationship.stagingLocation);
164-
if(o.hasProperty(fileLocation)) {
165-
addDatastream(m, o, foxml);
166-
167-
// add sourceData and defaultWebData properties
168-
Resource dataFileResource = m.createResource(new DatastreamPID(p.getPid() + "/DATA_FILE")
169-
.getDatastreamURI());
170-
relsExt.add(o, cdrprop(m, CDRProperty.sourceData), dataFileResource);
171-
relsExt.add(o, cdrprop(m, CDRProperty.defaultWebData), dataFileResource);
172-
}
173-
174-
// add any other datastreams
175-
Property hasDatastream = dprop(m, DepositRelationship.hasDatastream);
176-
if (o.hasProperty(hasDatastream)) {
177-
StmtIterator dsIt = o.listProperties(hasDatastream);
178-
179-
while (dsIt.hasNext()) {
180-
Statement dsStmt = dsIt.next();
181-
addDatastream(m, dsStmt.getResource(), foxml);
182-
}
183-
}
184-
185162
// Add in invalid term triples
186163
Property invalidTermProp = cdrprop(m, CDRProperty.invalidTerm);
187164
if (o.hasProperty(invalidTermProp)) {
@@ -198,9 +175,6 @@ public void runJob() {
198175
relsExt.add(o, publishedProperty, "no");
199176
}
200177

201-
// add RELS-EXT
202-
saveRELSEXTtoFOXMl(relsExt, foxml);
203-
204178
// add MD_EVENTS
205179
addEventsDS(p, foxml);
206180

@@ -233,6 +207,32 @@ public void runJob() {
233207
foxml.getRootElement().addContent(el);
234208
}
235209

210+
// Adding other datastreams before DATA_FILE to avoid temporary files being deleted before ingesting
211+
Property hasDatastream = dprop(m, DepositRelationship.hasDatastream);
212+
if (o.hasProperty(hasDatastream)) {
213+
StmtIterator dsIt = o.listProperties(hasDatastream);
214+
215+
while (dsIt.hasNext()) {
216+
Statement dsStmt = dsIt.next();
217+
addDatastream(m, dsStmt.getResource(), foxml);
218+
}
219+
}
220+
221+
// add DATA_FILE
222+
Property fileLocation = dprop(m, DepositRelationship.stagingLocation);
223+
if (o.hasProperty(fileLocation)) {
224+
addDatastream(m, o, foxml);
225+
226+
// add sourceData and defaultWebData properties
227+
Resource dataFileResource = m.createResource(new DatastreamPID(p.getPid() + "/DATA_FILE")
228+
.getDatastreamURI());
229+
relsExt.add(o, cdrprop(m, CDRProperty.sourceData), dataFileResource);
230+
relsExt.add(o, cdrprop(m, CDRProperty.defaultWebData), dataFileResource);
231+
}
232+
233+
// add RELS-EXT
234+
saveRELSEXTtoFOXMl(relsExt, foxml);
235+
236236
writeFOXML(p, foxml);
237237
addClicks(1);
238238
}
@@ -303,12 +303,12 @@ private void writeFOXML(PID p, Document foxml) {
303303
private void addEventsDS(PID p, Document foxml) {
304304
// Add locator datastream for events, referencing the events file identified by p
305305
File events = getEventsFile(p);
306-
306+
307307
// Use a path relative to the deposit directory
308308
Path absolute = Paths.get(events.getAbsolutePath());
309309
Path base = Paths.get(getDepositDirectory().getAbsolutePath());
310310
Path relative = base.relativize(absolute);
311-
311+
312312
Element el = FOXMLJDOMUtil.makeLocatorDatastream(Datastream.MD_EVENTS.getName(), "M", relative.toString(),
313313
"text/xml", "URL", Datastream.MD_EVENTS.getLabel(), false, null);
314314
foxml.getRootElement().addContent(el);

deposit/src/main/java/edu/unc/lib/deposit/validate/VirusScanJob.java

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public void runJob() {
9292
int scannedObjects = 0;
9393

9494
for (Entry<PID, String> href : hrefs.entrySet()) {
95+
verifyRunning();
96+
9597
URI manifestURI;
9698
URI storageURI = null;
9799
try {

deposit/src/main/java/edu/unc/lib/deposit/work/AbstractDepositJob.java

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import edu.unc.lib.dl.util.JobStatusFactory;
3434
import edu.unc.lib.dl.util.PremisEventLogger;
3535
import edu.unc.lib.dl.util.PremisEventLogger.Type;
36+
import edu.unc.lib.dl.util.RedisWorkerConstants.DepositState;
3637
import edu.unc.lib.dl.xml.JDOMNamespaceUtil;
3738

3839
/**
@@ -225,6 +226,15 @@ public void failJob(Throwable throwable, Type type, String messageformat,
225226
appendDepositEvent(getDepositPID(), event);
226227
throw new JobFailedException(message, throwable);
227228
}
229+
230+
protected void verifyRunning() {
231+
DepositState state = getDepositStatusFactory().getState(getDepositUUID());
232+
233+
if (!DepositState.running.equals(state)) {
234+
throw new JobInterruptedException("State for job " + getDepositUUID()
235+
+ " is no longer running, interrupting");
236+
}
237+
}
228238

229239
/**
230240
* Returns the PREMIS events file for the given PID

0 commit comments

Comments
 (0)