Skip to content

Commit 7718a33

Browse files
committed
fixed bug due to the dereference() method getting removed from the AbstractCurationTask class
1 parent 0134b77 commit 7718a33

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ public int perform(Context ctx, String id) throws IOException {
179179
private void recover(Context ctx, ReplicaManager repMan, String id) throws IOException {
180180
final String objId = repMan.storageId(ctx, id, archFmt);
181181
final File archive = repMan.fetchObject(ctx, storeGroupName, objId);
182-
final DSpaceObject dso = dereference(ctx, id);
182+
DSpaceObject dso;
183+
try {
184+
dso = dspaceObjectUtils.findDSpaceObject(ctx,id);
185+
} catch (SQLException sqlE) {
186+
throw new IOException(sqlE.getMessage(), sqlE);
187+
}
183188
if (archive != null && dso == null) {
184189
final BagItAipReader reader = new BagItAipReader(archive.toPath());
185190
final Properties props = reader.readProperties();
@@ -197,7 +202,7 @@ private void recover(Context ctx, ReplicaManager repMan, String id) throws IOExc
197202
// discard bag when done
198203
reader.clean();
199204
} else if (dso != null) {
200-
log.warn("Unable to restore object for " + id + ". Object already exists!");
205+
log.warn("Unable to restore object for {}. Object already exists!", id);
201206
}
202207
}
203208

@@ -232,10 +237,8 @@ private void recoverItem(Context ctx, File archive, String objId, Properties pro
232237
itemService.withdraw(ctx, item);
233238
}
234239
embargoService.setEmbargo(ctx, item);
235-
} catch (AuthorizeException authE) {
240+
} catch (AuthorizeException | SQLException authE) {
236241
throw new IOException(authE);
237-
} catch (SQLException sqlE) {
238-
throw new IOException(sqlE);
239242
}
240243
}
241244

@@ -259,10 +262,8 @@ private void recoverCollection(Context ctx, File archive, String collId, String
259262
// update with AIP data
260263
Packer packer = PackerFactory.instance(ctx, coll);
261264
packer.unpack(archive);
262-
} catch (AuthorizeException authE) {
265+
} catch (AuthorizeException | SQLException authE) {
263266
throw new IOException(authE);
264-
} catch (SQLException sqlE) {
265-
throw new IOException(sqlE);
266267
}
267268
}
268269

@@ -287,10 +288,8 @@ private void recoverCommunity(Context ctx, File archive, String commId, String p
287288
// update with AIP data
288289
Packer packer = PackerFactory.instance(ctx, comm);
289290
packer.unpack(archive);
290-
} catch (AuthorizeException authE) {
291+
} catch (AuthorizeException | SQLException authE) {
291292
throw new IOException(authE);
292-
} catch (SQLException sqlE) {
293-
throw new IOException(sqlE);
294293
}
295294
}
296295

src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,16 @@ private void remove(Context context, ReplicaManager repMan, DSpaceObject dso) th
138138
*/
139139
@Override
140140
public int perform(Context ctx, String id) throws IOException {
141-
DSpaceObject dso = dereference(ctx, id);
142-
if (dso != null) {
143-
return perform(dso);
141+
DSpaceObject dso;
142+
try {
143+
dso = dspaceObjectUtils.findDSpaceObject(ctx,id);
144+
if (dso != null) {
145+
return perform(dso);
146+
}
147+
} catch (SQLException sqlE) {
148+
throw new IOException(sqlE.getMessage(), sqlE);
144149
}
150+
145151
ReplicaManager repMan = ReplicaManager.instance();
146152
deleteManifest(ctx, repMan, repMan.storageId(ctx, id, TransmitManifest.MANIFEST_EXTENSION));
147153
setResult("Manifest for '" + id + "' has been removed");

0 commit comments

Comments
 (0)