@@ -159,29 +159,6 @@ public void runJob() {
159
159
160
160
// TODO translate default web object, already copied, check it
161
161
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
-
185
162
// Add in invalid term triples
186
163
Property invalidTermProp = cdrprop (m , CDRProperty .invalidTerm );
187
164
if (o .hasProperty (invalidTermProp )) {
@@ -198,9 +175,6 @@ public void runJob() {
198
175
relsExt .add (o , publishedProperty , "no" );
199
176
}
200
177
201
- // add RELS-EXT
202
- saveRELSEXTtoFOXMl (relsExt , foxml );
203
-
204
178
// add MD_EVENTS
205
179
addEventsDS (p , foxml );
206
180
@@ -233,6 +207,32 @@ public void runJob() {
233
207
foxml .getRootElement ().addContent (el );
234
208
}
235
209
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
+
236
236
writeFOXML (p , foxml );
237
237
addClicks (1 );
238
238
}
@@ -303,12 +303,12 @@ private void writeFOXML(PID p, Document foxml) {
303
303
private void addEventsDS (PID p , Document foxml ) {
304
304
// Add locator datastream for events, referencing the events file identified by p
305
305
File events = getEventsFile (p );
306
-
306
+
307
307
// Use a path relative to the deposit directory
308
308
Path absolute = Paths .get (events .getAbsolutePath ());
309
309
Path base = Paths .get (getDepositDirectory ().getAbsolutePath ());
310
310
Path relative = base .relativize (absolute );
311
-
311
+
312
312
Element el = FOXMLJDOMUtil .makeLocatorDatastream (Datastream .MD_EVENTS .getName (), "M" , relative .toString (),
313
313
"text/xml" , "URL" , Datastream .MD_EVENTS .getLabel (), false , null );
314
314
foxml .getRootElement ().addContent (el );
0 commit comments