org.glassfish.jaxb
diff --git a/src/main/java/org/dspace/ctask/replicate/AbstractPackagerTask.java b/src/main/java/org/dspace/ctask/replicate/AbstractPackagerTask.java
index b453bed..9aae8e4 100644
--- a/src/main/java/org/dspace/ctask/replicate/AbstractPackagerTask.java
+++ b/src/main/java/org/dspace/ctask/replicate/AbstractPackagerTask.java
@@ -25,6 +25,8 @@
* @see org.dspace.content.packager.PackageIngester
*/
public abstract class AbstractPackagerTask extends AbstractCurationTask {
+ private static final Logger log = LogManager.getLogger();
+
// Name of recursive mode option configurable in curation task configuration file
private final String recursiveMode = "recursiveMode";
@@ -34,8 +36,6 @@ public abstract class AbstractPackagerTask extends AbstractCurationTask {
// Name of useCollectionTemplate option configurable in curation task configuration file
private final String useCollectionTemplate = "useCollectionTemplate";
- private static Logger log = LogManager.getLogger();
-
/**
* Loads pre-configured PackageParameters settings from a given Module
* configuration file (specified by 'moduleName').
@@ -47,7 +47,7 @@ public abstract class AbstractPackagerTask extends AbstractCurationTask {
*
* Valid 'options' include all packager options supported by the
* Packager class, e.g. AIP packagers minimally support these options:
- * https://wiki.lyrasis.org/display/DSDOC6x/AIP+Backup+and+Restore#AIPBackupandRestore-AdditionalPackagerOptions
+ * https://wiki.lyrasis.org/display/DSDOC9x/AIP+Backup+and+Restore#AIPBackupandRestore-AdditionalPackagerOptions
*
* Please note that different Packager classes will support different options.
* You should determine which options are valid for your Packager class
@@ -100,7 +100,7 @@ protected PackageParameters loadPackagerParameters(String moduleName) {
pkgParams.addProperty(option, value);
}
- log.debug("Set package parameter property <" + option + "> to value <" + value + ">");
+ log.debug("Set package parameter property <{}> to value <{}>", option, value);
}
}
diff --git a/src/main/java/org/dspace/ctask/replicate/BagItReplaceWithAIP.java b/src/main/java/org/dspace/ctask/replicate/BagItReplaceWithAIP.java
index d0d75d0..45dd6e1 100644
--- a/src/main/java/org/dspace/ctask/replicate/BagItReplaceWithAIP.java
+++ b/src/main/java/org/dspace/ctask/replicate/BagItReplaceWithAIP.java
@@ -40,17 +40,16 @@
*/
@Mutative
public class BagItReplaceWithAIP extends AbstractCurationTask {
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
private String archFmt;
// Group where all AIPs are stored
private String storeGroupName;
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
- private SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
-
@Override
public void init(Curator curator, String taskId) throws IOException {
super.init(curator, taskId);
diff --git a/src/main/java/org/dspace/ctask/replicate/BagItReplicateConsumer.java b/src/main/java/org/dspace/ctask/replicate/BagItReplicateConsumer.java
index d501a5d..c7e0f10 100644
--- a/src/main/java/org/dspace/ctask/replicate/BagItReplicateConsumer.java
+++ b/src/main/java/org/dspace/ctask/replicate/BagItReplicateConsumer.java
@@ -62,13 +62,13 @@
* @author richardrodgers
*/
public class BagItReplicateConsumer implements Consumer {
- private Logger log = LogManager.getLogger();
+ private final Logger log = LogManager.getLogger();
- private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
- private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
+ private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private ReplicaManager repMan = null;
private TaskQueue taskQueue = null;
diff --git a/src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java b/src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java
index 483e0d5..d12cf9e 100644
--- a/src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java
+++ b/src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java
@@ -57,8 +57,13 @@
@Distributive
@Mutative
public class BagItRestoreFromAIP extends AbstractCurationTask {
+ private static final Logger log = LogManager.getLogger();
+
+ private final EmbargoService embargoService = EmbargoServiceFactory.getInstance().getEmbargoService();
+ private final WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
+ private final InstallItemService installItemService = ContentServiceFactory.getInstance().getInstallItemService();
+ private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
- private static Logger log = LogManager.getLogger();
private String archFmt;
// Group where all AIPs are stored
@@ -67,11 +72,6 @@ public class BagItRestoreFromAIP extends AbstractCurationTask {
// Group where object deletion catalog/records are stored
private String deleteGroupName;
- private EmbargoService embargoService = EmbargoServiceFactory.getInstance().getEmbargoService();
- private WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
- private InstallItemService installItemService = ContentServiceFactory.getInstance().getInstallItemService();
- private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
-
@Override
public void init(Curator curator, String taskId) throws IOException {
super.init(curator, taskId);
@@ -224,10 +224,10 @@ private void recoverItem(Context ctx, File archive, String objId, Properties pro
packer.unpack(archive);
// Install item
Item item = installItemService.restoreItem(ctx, wi, objId);
- String colls = props.getProperty(OTHER_IDS);
- if (colls != null) {
+ String collections = props.getProperty(OTHER_IDS);
+ if (collections != null) {
// reset linked collections
- for (String link : colls.split(",")) {
+ for (String link : collections.split(",")) {
Collection linkC = (Collection) handleService.resolveToObject(ctx, link);
collectionService.addItem(ctx, linkC, item);
}
@@ -251,17 +251,21 @@ private void recoverItem(Context ctx, File archive, String objId, Properties pro
* @throws IOException if IO error
*/
private void recoverCollection(Context ctx, File archive, String collId, String commId) throws IOException {
- Collection coll = null;
try {
if (commId != null) {
- Community pcomm = (Community) handleService.resolveToObject(ctx, commId);
- coll = collectionService.create(ctx, pcomm, collId);
+ Community parentCommunity = (Community) handleService.resolveToObject(ctx, commId);
+ Collection collection = collectionService.create(ctx, parentCommunity, collId);
+
+ if (collection != null) {
+ // update with AIP data
+ Packer packer = PackerFactory.instance(ctx, collection);
+ packer.unpack(archive);
+ } else {
+ log.error("Unable to restore collection {} because it could not be found.", collId);
+ }
} else {
- log.error("Collection '" + collId + "' lacks parent community");
+ log.error("Collection '{}' lacks parent community", collId);
}
- // update with AIP data
- Packer packer = PackerFactory.instance(ctx, coll);
- packer.unpack(archive);
} catch (AuthorizeException | SQLException authE) {
throw new IOException(authE);
}
@@ -277,16 +281,17 @@ private void recoverCollection(Context ctx, File archive, String collId, String
*/
private void recoverCommunity(Context ctx, File archive, String commId, String parentId) throws IOException {
// if not top-level, have parent create it
- Community comm = null;
+ Community community = null;
try {
if (parentId != null) {
- Community pcomm = (Community) handleService.resolveToObject(ctx, parentId);
- comm = communityService.createSubcommunity(ctx, pcomm, commId);
+ Community parentCommunity = (Community) handleService.resolveToObject(ctx, parentId);
+ community = communityService.createSubcommunity(ctx, parentCommunity, commId);
} else {
- comm = communityService.create(null, ctx, commId);
+ community = communityService.create(null, ctx, commId);
}
+
// update with AIP data
- Packer packer = PackerFactory.instance(ctx, comm);
+ Packer packer = PackerFactory.instance(ctx, community);
packer.unpack(archive);
} catch (AuthorizeException | SQLException authE) {
throw new IOException(authE);
diff --git a/src/main/java/org/dspace/ctask/replicate/METSReplicateConsumer.java b/src/main/java/org/dspace/ctask/replicate/METSReplicateConsumer.java
index b5dc518..ec8ac5d 100644
--- a/src/main/java/org/dspace/ctask/replicate/METSReplicateConsumer.java
+++ b/src/main/java/org/dspace/ctask/replicate/METSReplicateConsumer.java
@@ -82,14 +82,14 @@
* @author richardrodgers
*/
public class METSReplicateConsumer implements Consumer {
- private Logger log = LogManager.getLogger();
-
- private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
- private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
- private SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final Logger log = LogManager.getLogger();
+
+ private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
+ private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
+ private final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private ReplicaManager repMan = null;
private TaskQueue taskQueue = null;
diff --git a/src/main/java/org/dspace/ctask/replicate/METSRestoreFromAIP.java b/src/main/java/org/dspace/ctask/replicate/METSRestoreFromAIP.java
index 4433156..deb69bb 100644
--- a/src/main/java/org/dspace/ctask/replicate/METSRestoreFromAIP.java
+++ b/src/main/java/org/dspace/ctask/replicate/METSRestoreFromAIP.java
@@ -33,7 +33,7 @@
@Distributive
@Mutative
public class METSRestoreFromAIP extends AbstractPackagerTask {
- private Logger log = LogManager.getLogger();
+ private final Logger log = LogManager.getLogger();
private String archFmt;
diff --git a/src/main/java/org/dspace/ctask/replicate/MoveToTrashSingleAIP.java b/src/main/java/org/dspace/ctask/replicate/MoveToTrashSingleAIP.java
index e7a9912..86ea1c4 100644
--- a/src/main/java/org/dspace/ctask/replicate/MoveToTrashSingleAIP.java
+++ b/src/main/java/org/dspace/ctask/replicate/MoveToTrashSingleAIP.java
@@ -21,7 +21,7 @@
/**
* MoveToTrashSingleAIP task moves a single AIP from one group (folder) in external
- * storage to another group (folder). Currently it always moves content
+ * storage to another group (folder). Currently, it always moves content
* from the 'group.aip.name' store to the 'group.delete.name' store, essentially
* moving the content into a "trash" folder.
*
@@ -37,8 +37,6 @@
*/
@Distributive
public class MoveToTrashSingleAIP extends AbstractCurationTask {
- private static Logger log = LogManager.getLogger();
-
// Source and destination group where AIP will be moved to
private String srcGroupName;
private String destGroupName;
diff --git a/src/main/java/org/dspace/ctask/replicate/RemoveAIP.java b/src/main/java/org/dspace/ctask/replicate/RemoveAIP.java
index 9a37b54..bd6c3f9 100644
--- a/src/main/java/org/dspace/ctask/replicate/RemoveAIP.java
+++ b/src/main/java/org/dspace/ctask/replicate/RemoveAIP.java
@@ -41,6 +41,9 @@
public class RemoveAIP extends AbstractCurationTask {
private static final Logger log = LogManager.getLogger();
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+
private String archFmt;
// Group where all AIPs are stored
@@ -49,9 +52,6 @@ public class RemoveAIP extends AbstractCurationTask {
// Group where object deletion catalog/records are stored
private String deleteGroupName;
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
-
@Override
public void init(Curator curator, String taskId) throws IOException {
super.init(curator, taskId);
diff --git a/src/main/java/org/dspace/ctask/replicate/ReplicaManager.java b/src/main/java/org/dspace/ctask/replicate/ReplicaManager.java
index a44115b..6b5a3f5 100644
--- a/src/main/java/org/dspace/ctask/replicate/ReplicaManager.java
+++ b/src/main/java/org/dspace/ctask/replicate/ReplicaManager.java
@@ -40,11 +40,11 @@
* @author richardrodgers
*/
public class ReplicaManager {
- private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
- private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
- private HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
+ private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
+ private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
+ private final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
- private Logger log = LogManager.getLogger();
+ private final Logger log = LogManager.getLogger();
// singleton instance
private static ReplicaManager instance = null;
// the replica provider
diff --git a/src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java b/src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java
index 8db5c88..69e021c 100644
--- a/src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java
+++ b/src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java
@@ -42,13 +42,12 @@
*/
@Distributive
public class RemoveManifest extends AbstractCurationTask {
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
// Group where all Manifests are stored
private String manifestGroupName;
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
-
@Override
public void init(Curator curator, String taskId) throws IOException {
super.init(curator, taskId);
@@ -98,9 +97,9 @@ private void remove(Context context, ReplicaManager repMan, DSpaceObject dso) th
repMan.removeObject(manifestGroupName, objId);
report("Removing manifest for: " + objId);
if (dso instanceof Collection) {
- Collection coll = (Collection)dso;
+ Collection collection = (Collection)dso;
try {
- Iterator- iter = itemService.findByCollection(context, coll);
+ Iterator
- iter = itemService.findByCollection(context, collection);
while (iter.hasNext()) {
remove(context, repMan, iter.next());
}
@@ -108,17 +107,17 @@ private void remove(Context context, ReplicaManager repMan, DSpaceObject dso) th
throw new IOException(sqlE);
}
} else if (dso instanceof Community) {
- Community comm = (Community)dso;
- for (Community subcomm : comm.getSubcommunities()) {
- remove(context, repMan, subcomm);
+ Community community = (Community)dso;
+ for (Community subCommunity : community.getSubcommunities()) {
+ remove(context, repMan, subCommunity);
}
- for (Collection coll : comm.getCollections()) {
+ for (Collection coll : community.getCollections()) {
remove(context, repMan, coll);
}
} else if (dso instanceof Site) {
List topCommunities = communityService.findAllTop(context);
- for (Community subcomm : topCommunities) {
- remove(context, repMan, subcomm);
+ for (Community subCommunity : topCommunities) {
+ remove(context, repMan, subCommunity);
}
}
}
diff --git a/src/main/java/org/dspace/ctask/replicate/checkm/TransmitManifest.java b/src/main/java/org/dspace/ctask/replicate/checkm/TransmitManifest.java
index 8e66148..baa50f9 100644
--- a/src/main/java/org/dspace/ctask/replicate/checkm/TransmitManifest.java
+++ b/src/main/java/org/dspace/ctask/replicate/checkm/TransmitManifest.java
@@ -50,6 +50,10 @@
*/
@Distributive
public class TransmitManifest extends AbstractCurationTask {
+ private static final Logger log = LogManager.getLogger();
+
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
// Version of CDL Checkm spec that this manifest conforms to
private static final String CKM_VSN = "0.7";
@@ -62,11 +66,6 @@ public class TransmitManifest extends AbstractCurationTask {
// Group where all Manifests will be stored
private String manifestGroupName;
- private static Logger log = LogManager.getLogger();
-
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
-
@Override
public void init(Curator curator, String taskId) throws IOException {
super.init(curator, taskId);
diff --git a/src/main/java/org/dspace/ctask/replicate/store/LocalObjectStore.java b/src/main/java/org/dspace/ctask/replicate/store/LocalObjectStore.java
index e01b1b3..a7ba001 100644
--- a/src/main/java/org/dspace/ctask/replicate/store/LocalObjectStore.java
+++ b/src/main/java/org/dspace/ctask/replicate/store/LocalObjectStore.java
@@ -103,12 +103,18 @@ public long transferObject(String group, File file) throws IOException {
File archDir = new File(storeDir, group);
if (!archDir.isDirectory()) {
- archDir.mkdirs();
+ boolean successful = archDir.mkdirs();
+ if (!successful) {
+ log.warn("Cannot create directory: '{}'.", archDir);
+ }
}
File archFile = new File(archDir, file.getName());
if (archFile.exists()) {
- archFile.delete();
+ boolean successful = archFile.delete();
+ if (!successful) {
+ log.warn("Cannot delete archive file: '{}'.", archFile);
+ }
}
if (!file.renameTo(archFile)) {
diff --git a/src/main/java/org/dspace/pack/bagit/BagItAipReader.java b/src/main/java/org/dspace/pack/bagit/BagItAipReader.java
index 3824e75..f46b3cf 100644
--- a/src/main/java/org/dspace/pack/bagit/BagItAipReader.java
+++ b/src/main/java/org/dspace/pack/bagit/BagItAipReader.java
@@ -58,7 +58,6 @@
* @since 2020-03-19
*/
public class BagItAipReader {
-
private final Logger logger = LoggerFactory.getLogger(BagItAipReader.class);
private final String dataDirectory = "data";
diff --git a/src/main/java/org/dspace/pack/bagit/BagItPolicyUtil.java b/src/main/java/org/dspace/pack/bagit/BagItPolicyUtil.java
index 1660602..473090b 100644
--- a/src/main/java/org/dspace/pack/bagit/BagItPolicyUtil.java
+++ b/src/main/java/org/dspace/pack/bagit/BagItPolicyUtil.java
@@ -9,11 +9,10 @@
import java.io.IOException;
import java.sql.SQLException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import com.google.common.collect.BiMap;
@@ -63,7 +62,6 @@ private BagItPolicyUtil() {}
public static Policies getPolicy(final Context context, final DSpaceObject dso) throws IOException {
final Policies policies = new Policies();
final BiMap actions = actionMapper().inverse();
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (ResourcePolicy resourcePolicy : dso.getResourcePolicies()) {
final Policy policy = new Policy();
@@ -72,13 +70,13 @@ public static Policies getPolicy(final Context context, final DSpaceObject dso)
policy.setName(resourcePolicy.getRpName());
policy.setDescription(resourcePolicy.getRpDescription());
- final Date endDate = resourcePolicy.getEndDate();
- final Date startDate = resourcePolicy.getStartDate();
+ final LocalDate endDate = resourcePolicy.getEndDate();
+ final LocalDate startDate = resourcePolicy.getStartDate();
if (startDate != null) {
- policy.setStartDate(dateFormat.format(startDate));
+ policy.setStartDate(startDate.toString());
}
if (endDate != null) {
- policy.setEndDate(dateFormat.format(endDate));
+ policy.setEndDate(endDate.toString());
}
// attributes for determining if adding policies on a group + what type of group or policies for a user
@@ -128,7 +126,8 @@ public static Policies getPolicy(final Context context, final DSpaceObject dso)
*/
public static void registerPolicies(final Context context, final DSpaceObject dSpaceObject, final Policies policies)
throws SQLException, AuthorizeException, PackageException {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
final GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
final EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
final AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
@@ -193,9 +192,9 @@ public static void registerPolicies(final Context context, final DSpaceObject dS
final String rpStartDate = policy.getStartDate();
if (rpStartDate != null) {
try {
- final Date date = dateFormat.parse(rpStartDate);
+ final LocalDate date = LocalDate.parse(rpStartDate, dateFormat);
resourcePolicy.setStartDate(date);
- } catch (ParseException ignored) {
+ } catch (DateTimeParseException ignored) {
logger.warn("Failed to parse rp-start-date. The date needs to be in the format 'yyyy-MM-dd'.");
}
}
@@ -203,9 +202,9 @@ public static void registerPolicies(final Context context, final DSpaceObject dS
final String rpEndDate = policy.getEndDate();
if (rpEndDate != null) {
try {
- final Date date = dateFormat.parse(rpEndDate);
+ final LocalDate date = LocalDate.parse(rpEndDate, dateFormat);
resourcePolicy.setEndDate(date);
- } catch (ParseException ignored) {
+ } catch (DateTimeParseException ignored) {
logger.warn("Failed to parse rp-end-date. The date needs to be in the format 'yyyy-MM-dd'.");
}
}
diff --git a/src/main/java/org/dspace/pack/bagit/CatalogPacker.java b/src/main/java/org/dspace/pack/bagit/CatalogPacker.java
index aef4a86..332f215 100644
--- a/src/main/java/org/dspace/pack/bagit/CatalogPacker.java
+++ b/src/main/java/org/dspace/pack/bagit/CatalogPacker.java
@@ -40,14 +40,14 @@
* @author richardrodgers
*/
public class CatalogPacker implements Packer {
- private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
+ private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
private final Context context;
private final String objectId;
private String ownerId = null;
private List members = null;
// Package compression format (e.g. zip or tgz) - Catalog packer uses same as AIPs
- private String archFmt = configurationService.getProperty("replicate.packer.archfmt");
+ private final String archFmt = configurationService.getProperty("replicate.packer.archfmt");
public CatalogPacker(Context context, String objectId) {
this.context = context;
diff --git a/src/main/java/org/dspace/pack/bagit/CollectionPacker.java b/src/main/java/org/dspace/pack/bagit/CollectionPacker.java
index 985fbb0..b318a5e 100644
--- a/src/main/java/org/dspace/pack/bagit/CollectionPacker.java
+++ b/src/main/java/org/dspace/pack/bagit/CollectionPacker.java
@@ -54,8 +54,8 @@
* @author richardrodgers
*/
public class CollectionPacker implements Packer {
- private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
// NB - these values must remain synchronized with DB schema
// they represent the persistent object state
diff --git a/src/main/java/org/dspace/pack/bagit/CommunityPacker.java b/src/main/java/org/dspace/pack/bagit/CommunityPacker.java
index 5f1db86..511b00b 100644
--- a/src/main/java/org/dspace/pack/bagit/CommunityPacker.java
+++ b/src/main/java/org/dspace/pack/bagit/CommunityPacker.java
@@ -50,7 +50,7 @@
* @author richardrodgers
*/
public class CommunityPacker implements Packer {
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
// NB - these values must remain synchronized with DB schema -
// they represent the persistent object state
diff --git a/src/main/java/org/dspace/pack/bagit/ItemPacker.java b/src/main/java/org/dspace/pack/bagit/ItemPacker.java
index 7e8cfa4..30328c3 100644
--- a/src/main/java/org/dspace/pack/bagit/ItemPacker.java
+++ b/src/main/java/org/dspace/pack/bagit/ItemPacker.java
@@ -51,9 +51,9 @@
* @author richardrodgers
*/
public class ItemPacker implements Packer {
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
- private BundleService bundleService = ContentServiceFactory.getInstance().getBundleService();
- private BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final BundleService bundleService = ContentServiceFactory.getInstance().getBundleService();
+ private final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
// XML constants
private static final String NAME = "name";
@@ -67,7 +67,7 @@ public class ItemPacker implements Packer {
private String archFmt = null;
private List filterBundles = new ArrayList<>();
private boolean exclude = true;
- private List refFilters = new ArrayList<>();
+ private final List refFilters = new ArrayList<>();
public ItemPacker(Context context, Item item, String archFmt) {
this.context = context;
diff --git a/src/main/java/org/dspace/pack/bagit/SitePacker.java b/src/main/java/org/dspace/pack/bagit/SitePacker.java
index 04e22b7..b58a393 100644
--- a/src/main/java/org/dspace/pack/bagit/SitePacker.java
+++ b/src/main/java/org/dspace/pack/bagit/SitePacker.java
@@ -47,7 +47,6 @@
* @author mikejritter
*/
public class SitePacker implements Packer {
-
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
diff --git a/src/main/java/org/dspace/pack/mets/METSPacker.java b/src/main/java/org/dspace/pack/mets/METSPacker.java
index 82f3a8e..5c870cb 100644
--- a/src/main/java/org/dspace/pack/mets/METSPacker.java
+++ b/src/main/java/org/dspace/pack/mets/METSPacker.java
@@ -46,9 +46,9 @@
* @author richardrodgers
*/
public class METSPacker implements Packer {
- private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
- private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
- private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
+ private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
+ private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
+ private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private final Logger log = LogManager.getLogger();
diff --git a/src/test/java/org/dspace/TestConfigurationService.java b/src/test/java/org/dspace/TestConfigurationService.java
index 68b3ee3..b7c2cf3 100644
--- a/src/test/java/org/dspace/TestConfigurationService.java
+++ b/src/test/java/org/dspace/TestConfigurationService.java
@@ -12,6 +12,8 @@
import java.util.Properties;
import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.HierarchicalConfiguration;
+import org.apache.commons.configuration2.tree.ImmutableNode;
import org.dspace.services.ConfigurationService;
/**
@@ -118,6 +120,16 @@ public Configuration getConfiguration() {
throw new UnsupportedOperationException();
}
+ @Override
+ public HierarchicalConfiguration getHierarchicalConfiguration() {
+ throw new UnsupportedOperationException();
+ };
+
+ @Override
+ public List> getChildren(String name) {
+ throw new UnsupportedOperationException();
+ };
+
@Override
public boolean hasProperty(String name) {
return properties.containsKey(name);
diff --git a/src/test/java/org/dspace/TestEPersonServiceFactory.java b/src/test/java/org/dspace/TestEPersonServiceFactory.java
index 399e766..8875dfe 100644
--- a/src/test/java/org/dspace/TestEPersonServiceFactory.java
+++ b/src/test/java/org/dspace/TestEPersonServiceFactory.java
@@ -13,6 +13,7 @@
import org.dspace.eperson.service.AccountService;
import org.dspace.eperson.service.EPersonService;
import org.dspace.eperson.service.GroupService;
+import org.dspace.eperson.service.RegistrationDataMetadataService;
import org.dspace.eperson.service.RegistrationDataService;
import org.dspace.eperson.service.SubscribeService;
@@ -41,6 +42,11 @@ public RegistrationDataService getRegistrationDataService() {
throw new UnsupportedOperationException();
}
+ @Override
+ public RegistrationDataMetadataService getRegistrationDAtaDataMetadataService() {
+ throw new UnsupportedOperationException();
+ };
+
@Override
public AccountService getAccountService() {
throw new UnsupportedOperationException();
diff --git a/src/test/java/org/dspace/TestServiceManager.java b/src/test/java/org/dspace/TestServiceManager.java
index 2d6d044..8691731 100644
--- a/src/test/java/org/dspace/TestServiceManager.java
+++ b/src/test/java/org/dspace/TestServiceManager.java
@@ -22,7 +22,7 @@
*/
public class TestServiceManager implements ServiceManager {
- private Map serviceNameMap = new HashMap<>();
+ private final Map serviceNameMap = new HashMap<>();
@Override
public ConfigurableApplicationContext getApplicationContext() {
diff --git a/src/test/java/org/dspace/pack/bagit/BagItPolicyUtilTest.java b/src/test/java/org/dspace/pack/bagit/BagItPolicyUtilTest.java
index d6c30aa..f828012 100644
--- a/src/test/java/org/dspace/pack/bagit/BagItPolicyUtilTest.java
+++ b/src/test/java/org/dspace/pack/bagit/BagItPolicyUtilTest.java
@@ -22,11 +22,10 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.SQLException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
-import java.util.Date;
import java.util.List;
import org.dspace.authorize.ResourcePolicy;
@@ -73,14 +72,14 @@ public void setup() throws SQLException {
@Test
public void getPolicyForAdmin() throws Exception {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- // Setup group
+ // Set up the Group
final Group adminGroup = mock(Group.class);
when(adminGroup.getName()).thenReturn(Group.ADMIN);
- // set up an admin ResourcePolicy for the Community
- final Date groupDate = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
+ // Set up an admin ResourcePolicy for the Community
+ final LocalDate groupDate = Instant.now().minus(1, ChronoUnit.DAYS)
+ .atZone(ZoneId.systemDefault())
+ .toLocalDate();
final ResourcePolicy adminGroupPolicy = initReloadable(ResourcePolicy.class);
adminGroupPolicy.setGroup(adminGroup);
adminGroupPolicy.setRpType(TYPE_CUSTOM);
@@ -102,7 +101,7 @@ public void getPolicyForAdmin() throws Exception {
assertThat(child.getAction()).isEqualTo("READ");
assertThat(child.getType()).isEqualTo(TYPE_CUSTOM);
assertThat(child.getGroup()).isEqualTo(Group.ADMIN);
- assertThat(child.getStartDate()).isEqualTo(dateFormat.format(groupDate));
+ assertThat(child.getStartDate()).isEqualTo(groupDate.toString());
assertThat(child.getName()).isNull();
assertThat(child.getEndDate()).isNull();
@@ -114,14 +113,14 @@ public void getPolicyForAdmin() throws Exception {
@Test
public void getPolicyForAnonymous() throws Exception {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- // setup the Group
+ // Set up the Group
final Group anonGroup = mock(Group.class);
when(anonGroup.getName()).thenReturn(Group.ANONYMOUS);
// set up the ResourcePolicy
- final Date groupDate = Date.from(Instant.now().minus(1, ChronoUnit.DAYS));
+ final LocalDate groupDate = Instant.now().minus(1, ChronoUnit.DAYS)
+ .atZone(ZoneId.systemDefault())
+ .toLocalDate();
final ResourcePolicy anonGroupPolicy = initReloadable(ResourcePolicy.class);
anonGroupPolicy.setGroup(anonGroup);
anonGroupPolicy.setRpType(TYPE_CUSTOM);
@@ -142,7 +141,7 @@ public void getPolicyForAnonymous() throws Exception {
assertThat(child.getAction()).isEqualTo("READ");
assertThat(child.getType()).isEqualTo(TYPE_CUSTOM);
assertThat(child.getGroup()).isEqualTo(Group.ANONYMOUS);
- assertThat(child.getEndDate()).isEqualTo(dateFormat.format(groupDate));
+ assertThat(child.getEndDate()).isEqualTo(groupDate.toString());
assertThat(child.getName()).isNull();
assertThat(child.getEperson()).isNull();
@@ -154,15 +153,15 @@ public void getPolicyForAnonymous() throws Exception {
@Test
public void getPolicyForEPerson() throws Exception {
- final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- // setup the EPerson
+ // Set up the EPerson
final String epersonEmail = "bagit-policy-util-test";
final EPerson ePerson = mock(EPerson.class);
when(ePerson.getEmail()).thenReturn(epersonEmail);
// Create the ePerson policy
- final Date ePersonDate = Date.from(Instant.now().plus(1, ChronoUnit.DAYS));
+ final LocalDate ePersonDate = Instant.now().plus(1, ChronoUnit.DAYS)
+ .atZone(ZoneId.systemDefault())
+ .toLocalDate();
final ResourcePolicy ePersonPolicy = initReloadable(ResourcePolicy.class);
ePersonPolicy.setEPerson(ePerson);
ePersonPolicy.setRpType(TYPE_CUSTOM);
@@ -183,7 +182,7 @@ public void getPolicyForEPerson() throws Exception {
assertThat(child.getAction()).isEqualTo("READ");
assertThat(child.getType()).isEqualTo(TYPE_CUSTOM);
assertThat(child.getEperson()).isEqualTo(epersonEmail);
- assertThat(child.getStartDate()).isEqualTo(dateFormat.format(ePersonDate));
+ assertThat(child.getStartDate()).isEqualTo(ePersonDate.toString());
assertThat(child.getName()).isNull();
assertThat(child.getGroup()).isNull();
@@ -195,7 +194,7 @@ public void getPolicyForEPerson() throws Exception {
@Test
public void registerPolicies() throws Exception {
- // Read an aip in order to load a policy.xml
+ // Read an AIP in order to load a policy.xml
final URL resources = BagItPolicyUtilTest.class.getClassLoader().getResource("");
assertThat(resources).isNotNull();