Skip to content

Commit 7a78cfe

Browse files
authored
Updates for compatibility with DSpace 8.4 (DSpace#88)
* updated dependencies * fixed spelling * logging fixes * reflect changes to EPerson class in DSpace * combined exceptions * combined exceptions * combined exceptions * improved error handling when creating ObjectStore; other fixes * improved error handling when creating ObjectStore; other fixes * fixed typo * fixed typo * fixed bug due to the dereference() method getting removed from the AbstractCurationTask class * improved logging; lint fixes; corrected typos * accidentally commented out code for testing * typo * improved logging * replace joda.time classes with java.time equivalents * fixed checkstyle violations * roll back bagit support version
1 parent 0e9a8f6 commit 7a78cfe

24 files changed

Lines changed: 226 additions & 159 deletions

pom.xml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<description>Replication Task Suite: A DSpace add-on providing Curation Tasks that perform replication
88
(backup and restore) of DSpace content to other locations or services.</description>
99
<url>https://wiki.lyrasis.org/display/DSPACE/ReplicationTaskSuite</url>
10-
<version>8.2-SNAPSHOT</version>
10+
<version>8.4-SNAPSHOT</version>
1111

1212
<organization>
1313
<name>LYRASIS</name>
@@ -16,13 +16,13 @@
1616

1717
<properties>
1818
<!-- DSpace Version Information (supported version of DSpace is 8.1 or above) -->
19-
<dspace.version>[8.1,8.20)</dspace.version>
19+
<dspace.version>[8.4,8.20)</dspace.version>
2020
<!-- DuraCloud Version Information (supported version of DuraCloud) -->
2121
<duracloud.version>8.1.0</duracloud.version>
2222
<!-- DuraSpace BagIt Support Library -->
2323
<bagit-support.version>1.1.0</bagit-support.version>
24-
<jaxb-api.version>4.0.2</jaxb-api.version>
25-
<jaxb-runtime.version>4.0.5</jaxb-runtime.version>
24+
<jaxb-api.version>4.0.5</jaxb-api.version>
25+
<jaxb-runtime.version>4.0.9</jaxb-runtime.version>
2626
<!-- Replication Task Suite requires Java 17 because DSpace 8 requires it -->
2727
<java.version>17</java.version>
2828
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -37,7 +37,7 @@
3737
<plugin>
3838
<groupId>org.apache.maven.plugins</groupId>
3939
<artifactId>maven-enforcer-plugin</artifactId>
40-
<version>3.5.0</version>
40+
<version>3.6.3</version>
4141
<executions>
4242
<execution>
4343
<id>enforce-java</id>
@@ -88,7 +88,7 @@
8888
<plugin>
8989
<groupId>org.apache.maven.plugins</groupId>
9090
<artifactId>maven-compiler-plugin</artifactId>
91-
<version>3.14.0</version>
91+
<version>3.15.0</version>
9292
<configuration>
9393
<release>${java.version}</release>
9494
</configuration>
@@ -97,7 +97,7 @@
9797
<plugin>
9898
<groupId>org.apache.maven.plugins</groupId>
9999
<artifactId>maven-jar-plugin</artifactId>
100-
<version>3.4.2</version>
100+
<version>3.5.0</version>
101101
<configuration>
102102
<archive>
103103
<manifest>
@@ -115,12 +115,12 @@
115115
<plugin>
116116
<groupId>org.apache.maven.plugins</groupId>
117117
<artifactId>maven-dependency-plugin</artifactId>
118-
<version>3.8.1</version>
118+
<version>3.11.0</version>
119119
</plugin>
120120
<plugin>
121121
<groupId>org.apache.maven.plugins</groupId>
122122
<artifactId>maven-resources-plugin</artifactId>
123-
<version>3.3.1</version>
123+
<version>3.5.0</version>
124124
</plugin>
125125
<!-- Used to validate all code style rules in source code via the Checkstyle config in checkstyle.xml -->
126126
<!-- Can be skipped by passing -Dcheckstyle.skip=true to Maven. -->
@@ -156,7 +156,7 @@
156156
<dependency>
157157
<groupId>com.puppycrawl.tools</groupId>
158158
<artifactId>checkstyle</artifactId>
159-
<version>8.45.1</version>
159+
<version>9.3</version>
160160
</dependency>
161161
</dependencies>
162162
</plugin>
@@ -170,7 +170,7 @@
170170
<plugin>
171171
<groupId>org.apache.maven.plugins</groupId>
172172
<artifactId>maven-javadoc-plugin</artifactId>
173-
<version>3.11.2</version>
173+
<version>3.12.0</version>
174174
<configuration>
175175
<!-- Never fail a build based on Javadoc errors -->
176176
<failOnError>false</failOnError>
@@ -180,13 +180,13 @@
180180
<plugin>
181181
<groupId>org.apache.maven.plugins</groupId>
182182
<artifactId>maven-source-plugin</artifactId>
183-
<version>3.3.1</version>
183+
<version>3.4.0</version>
184184
</plugin>
185185
<!-- Used to sign new releases via GPG (see release profile). -->
186186
<plugin>
187187
<groupId>org.apache.maven.plugins</groupId>
188188
<artifactId>maven-gpg-plugin</artifactId>
189-
<version>3.2.7</version>
189+
<version>3.2.8</version>
190190
</plugin>
191191
</plugins>
192192
</pluginManagement>
@@ -195,7 +195,7 @@
195195
<!-- Specify our settings for new releases via 'mvn release:*' -->
196196
<groupId>org.apache.maven.plugins</groupId>
197197
<artifactId>maven-release-plugin</artifactId>
198-
<version>3.1.1</version>
198+
<version>3.3.1</version>
199199
<configuration>
200200
<!-- During release:prepare and release:perform, pass the "release" property to enable the
201201
"release" profile (and enable/disable other profiles based on whether they need releasing) -->
@@ -353,7 +353,7 @@
353353
<dependency>
354354
<groupId>org.assertj</groupId>
355355
<artifactId>assertj-core</artifactId>
356-
<version>3.26.3</version>
356+
<version>3.27.7</version>
357357
<scope>test</scope>
358358
</dependency>
359359
<dependency>
@@ -373,6 +373,10 @@
373373
<artifactId>bagit-support</artifactId>
374374
<version>${bagit-support.version}</version>
375375
<exclusions>
376+
<exclusion>
377+
<groupId>org.apache.commons</groupId>
378+
<artifactId>commons-compress</artifactId>
379+
</exclusion>
376380
<exclusion>
377381
<groupId>org.apache.tika</groupId>
378382
<artifactId>tika-core</artifactId>
@@ -386,12 +390,12 @@
386390
<dependency>
387391
<groupId>org.apache.logging.log4j</groupId>
388392
<artifactId>log4j-api</artifactId>
389-
<version>2.24.3</version>
393+
<version>2.26.0</version>
390394
</dependency>
391395
<dependency>
392396
<groupId>org.apache.logging.log4j</groupId>
393397
<artifactId>log4j-core</artifactId>
394-
<version>2.24.3</version>
398+
<version>2.26.0</version>
395399
<scope>test</scope>
396400
</dependency>
397401

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
* @author richardrodgers
6363
*/
6464
public class BagItReplicateConsumer implements Consumer {
65-
6665
private Logger log = LogManager.getLogger();
6766

6867
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
@@ -153,7 +152,7 @@ public void consume(Context ctx, Event event) throws Exception {
153152
int evType = event.getEventType();
154153
int subjType = event.getSubjectType();
155154

156-
// This is the Handle of the object on which an event occured
155+
// This is the Handle of the object on which an event occurred
157156
String id = event.getDetail();
158157

159158
// System.out.println("got event type: " + evType + " for subject type: " + subjType);
@@ -175,10 +174,9 @@ public void consume(Context ctx, Event event) throws Exception {
175174
case MODIFY_METADATA: // MODIFY_METADATA = just modify an object's metadata
176175
// If subject of event is null, this means the object was likely deleted
177176
if (event.getSubject(ctx) == null) {
178-
log.warn(event.getEventTypeAsString() + " event, could not get object for "
179-
+ event.getSubjectTypeAsString() + " id="
180-
+ String.valueOf(event.getSubjectID())
181-
+ ", perhaps it has been deleted.");
177+
log.warn("{} event, could not get object for {} id={}, perhaps it has been deleted.",
178+
event.getEventTypeAsString(), event.getSubjectTypeAsString(),
179+
String.valueOf(event.getSubjectID()));
182180
break;
183181
}
184182

@@ -243,7 +241,7 @@ public void end(Context ctx) throws Exception {
243241
taskPMap.clear();
244242
}
245243

246-
// if there any uncommitted deletions, record them now
244+
// if there are any uncommitted deletions, record them now
247245
if (delObjId != null) {
248246
if (delTasks != null) {
249247
entrySet.add(new TaskQueueEntry(name, stamp, delTasks, delObjId));
@@ -362,7 +360,7 @@ private void processDelete(Context context) throws IOException {
362360
String catID = repMan.deletionCatalogId(delObjId, null);
363361
File packDir = repMan.stage(context, deleteGroupName, catID);
364362
File archive = packer.pack(packDir);
365-
// System.out.println("delcat about to transfer");
363+
// System.out.println("deleted catalog about to transfer");
366364
repMan.transferObject(deleteGroupName, archive);
367365
}
368366
} catch (AuthorizeException | SQLException e) {
@@ -394,7 +392,7 @@ private boolean loadIdFilter(String filterName) {
394392
}
395393
return true;
396394
} catch (IOException ioE) {
397-
// log.error("Unable to read filter file '" + filterName + "'");
395+
// log.error("Unable to read filter file '{}'", filterName);
398396
idFilter = null;
399397
} finally {
400398
if (reader != null) {

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/CompareWithAIP.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.util.Iterator;
1515
import java.util.List;
1616

17+
import org.apache.logging.log4j.LogManager;
18+
import org.apache.logging.log4j.Logger;
1719
import org.dspace.authorize.AuthorizeException;
1820
import org.dspace.content.Collection;
1921
import org.dspace.content.Community;
@@ -51,6 +53,8 @@
5153
*/
5254
@Suspendable(invoked = Curator.Invoked.INTERACTIVE)
5355
public class CompareWithAIP extends AbstractCurationTask {
56+
private final Logger log = LogManager.getLogger();
57+
5458
private String archFmt;
5559
private int status = Curator.CURATE_UNSET;
5660
private String result = null;
@@ -87,8 +91,12 @@ public int perform(DSpaceObject dso) throws IOException {
8791
File packDir = repMan.stage(context, storeGroupName, id);
8892
File archive = packer.pack(packDir);
8993
String chkSum = Utils.checksum(archive, "MD5");
94+
9095
// remove local archive file -- it's no longer needed
91-
archive.delete();
96+
boolean successful = archive.delete();
97+
if (!successful) {
98+
log.warn("Failed to delete archive {}", archive.getAbsolutePath());
99+
}
92100

93101
// compare with replica
94102
String repChkSum = repMan.objectAttribute(storeGroupName, objId, "checksum");
@@ -110,10 +118,8 @@ public int perform(DSpaceObject dso) throws IOException {
110118

111119
setResult(result);
112120
return status;
113-
} catch (AuthorizeException authE) {
121+
} catch (AuthorizeException | SQLException authE) {
114122
throw new IOException(authE);
115-
} catch (SQLException sqlE) {
116-
throw new IOException(sqlE);
117123
}
118124
}
119125

@@ -135,25 +141,25 @@ private void auditExtent(Context context, ReplicaManager repMan, DSpaceObject ds
135141

136142
// If container is a Collection, make sure all Items have AIPs in remote storage
137143
if (Constants.COLLECTION == type) {
138-
Collection coll = (Collection)dso;
139-
Iterator<Item> iter = itemService.findByCollection(context, coll);
144+
Collection collection = (Collection)dso;
145+
Iterator<Item> iter = itemService.findByCollection(context, collection);
140146
while (iter.hasNext()) {
141147
checkReplica(context, repMan, iter.next());
142148
}
143149
} else if (Constants.COMMUNITY == type) {
144-
// If Community, make sure all Sub-Communities/Collections have AIPs in remote storage
145-
Community comm = (Community)dso;
146-
for (Community subcomm : comm.getSubcommunities()) {
147-
checkReplica(context, repMan, subcomm);
150+
// If it is a Community, make sure all Sub-Communities/Collections have AIPs in remote storage
151+
Community community = (Community)dso;
152+
for (Community subCommunity : community.getSubcommunities()) {
153+
checkReplica(context, repMan, subCommunity);
148154
}
149-
for (Collection coll : comm.getCollections()) {
150-
checkReplica(context, repMan, coll);
155+
for (Collection collection : community.getCollections()) {
156+
checkReplica(context, repMan, collection);
151157
}
152158
} else if (Constants.SITE == type) {
153-
// If Site, check to see all Top-Level Communities have an AIP in remote storage
154-
List<Community> topComm = communityService.findAllTop(context);
155-
for (Community comm : topComm) {
156-
checkReplica(context, repMan, comm);
159+
// If it is a Site, check to see all Top-Level Communities have an AIP in remote storage
160+
List<Community> topCommunities = communityService.findAllTop(context);
161+
for (Community topCommunity : topCommunities) {
162+
checkReplica(context, repMan, topCommunity);
157163
}
158164
}
159165
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public int perform(DSpaceObject dso) throws IOException {
6363
}
6464
}
6565

66-
6766
/**
6867
* Perform the 'Fetch AIP' task
6968
* @param ctx DSpace Context

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import java.util.List;
1414
import java.util.Set;
1515

16-
import org.apache.logging.log4j.LogManager;
17-
import org.apache.logging.log4j.Logger;
1816
import org.dspace.curate.FileTaskQueue;
1917
import org.dspace.curate.TaskQueueEntry;
2018

@@ -41,8 +39,6 @@
4139
* @author Tim Donohue
4240
*/
4341
public class FilteredFileTaskQueue extends FileTaskQueue {
44-
private static Logger log = LogManager.getLogger();
45-
4642
/**
4743
* Returns the set of UNIQUE task entries from the named queue. Any duplicate
4844
* task entries in the queue are ignored. The operation locks

0 commit comments

Comments
 (0)