Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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').
Expand All @@ -47,7 +47,7 @@ public abstract class AbstractPackagerTask extends AbstractCurationTask {
* <p>
* 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
* <p>
* Please note that different Packager classes will support different options.
* You should determine which options are valid for your Packager class
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
47 changes: 26 additions & 21 deletions src/main/java/org/dspace/ctask/replicate/BagItRestoreFromAIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <P>
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/dspace/ctask/replicate/RemoveAIP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/dspace/ctask/replicate/ReplicaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -98,27 +97,27 @@ 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<Item> iter = itemService.findByCollection(context, coll);
Iterator<Item> iter = itemService.findByCollection(context, collection);
while (iter.hasNext()) {
remove(context, repMan, iter.next());
}
} catch (SQLException sqlE) {
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<Community> topCommunities = communityService.findAllTop(context);
for (Community subcomm : topCommunities) {
remove(context, repMan, subcomm);
for (Community subCommunity : topCommunities) {
remove(context, repMan, subCommunity);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/dspace/pack/bagit/BagItAipReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
* @since 2020-03-19
*/
public class BagItAipReader {

private final Logger logger = LoggerFactory.getLogger(BagItAipReader.class);

private final String dataDirectory = "data";
Expand Down
Loading
Loading