Skip to content

Commit 02b76c7

Browse files
committed
improved logging
1 parent b6313ff commit 02b76c7

3 files changed

Lines changed: 25 additions & 14 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ private ReplicaManager() throws IOException {
8181
Path repPath = Path.of(repDir);
8282
try {
8383
Files.createDirectories(repPath);
84-
System.out.println("Successfully created replicate directory: " + repPath);
84+
log.debug("Successfully created replicate.store.dir directory: {}", repPath);
8585
} catch (IOException e) {
86-
System.err.println("Failed to create replicate.store.dir: " + e.getMessage());
86+
log.debug("Failed to create replicate.store.dir directory: {}", e.getMessage());
8787
throw e;
8888
}
8989

src/main/java/org/dspace/ctask/replicate/store/LocalObjectStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void init() throws IOException {
5252
Path storePath = Path.of(storeDir);
5353
try {
5454
Files.createDirectories(storePath);
55-
log.info("Successfully created replicate store directory: {}", storePath);
55+
log.info("Successfully created object store directory: {}", storePath);
5656
} catch (IOException e) {
5757
log.warn("Failed to create replicate.store.dir: {}", e.getMessage());
5858
throw e;

src/main/java/org/dspace/pack/PackerFactory.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
package org.dspace.pack;
99

10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
1012
import org.dspace.content.Collection;
1113
import org.dspace.content.Community;
1214
import org.dspace.content.DSpaceObject;
@@ -30,6 +32,8 @@
3032
* @author richardrodgers
3133
*/
3234
public class PackerFactory {
35+
private static final Logger log = LogManager.getLogger(PackerFactory.class);
36+
3337
// basic bag property names - some optional
3438
public static final String OBJFILE = "object.properties";
3539
public static final String BAG_TYPE = "bagType";
@@ -63,6 +67,7 @@ public static Packer instance(Context context, DSpaceObject dso) {
6367
Packer packer = null;
6468
int type = dso.getType();
6569
if ("mets".equals(packType)) {
70+
log.info("Creating Packer for METS package type.");
6671
if (metsPacker == null) {
6772
metsPacker = new METSPacker(context, dso, archFmt);
6873
} else {
@@ -73,20 +78,26 @@ public static Packer instance(Context context, DSpaceObject dso) {
7378
if (cfgFilter != null) {
7479
packer.setContentFilter(cfgFilter);
7580
}
76-
} else if (Constants.ITEM == type) {
77-
packer = new ItemPacker(context, (Item)dso, archFmt);
78-
if (cfgFilter != null) {
79-
packer.setContentFilter(cfgFilter);
81+
} else if ("bagit".equals(packType)) {
82+
log.info("Creating Packer for BagIt package type.");
83+
if (Constants.ITEM == type) {
84+
packer = new ItemPacker(context, (Item)dso, archFmt);
85+
if (cfgFilter != null) {
86+
packer.setContentFilter(cfgFilter);
87+
}
88+
} else if (Constants.COLLECTION == type) {
89+
packer = new CollectionPacker(context, (Collection)dso, archFmt);
90+
} else if (Constants.COMMUNITY == type) {
91+
packer = new CommunityPacker(context, (Community)dso, archFmt);
92+
} else if (Constants.SITE == type) {
93+
packer = new SitePacker(context, (Site)dso, archFmt);
94+
} else {
95+
throw new RuntimeException("No BagIt packer for object type.");
8096
}
81-
} else if (Constants.COLLECTION == type) {
82-
packer = new CollectionPacker(context, (Collection)dso, archFmt);
83-
} else if (Constants.COMMUNITY == type) {
84-
packer = new CommunityPacker(context, (Community)dso, archFmt);
85-
} else if (Constants.SITE == type) {
86-
packer = new SitePacker(context, (Site)dso, archFmt);
8797
} else {
88-
throw new RuntimeException("No packer for object type.");
98+
throw new RuntimeException("Invalid packer package type. Check 'replicate.packer.pkgtype' in replicate.cfg.");
8999
}
100+
90101
return packer;
91102
}
92103
}

0 commit comments

Comments
 (0)