77 */
88package org .dspace .pack ;
99
10+ import org .apache .logging .log4j .LogManager ;
11+ import org .apache .logging .log4j .Logger ;
1012import org .dspace .content .Collection ;
1113import org .dspace .content .Community ;
1214import org .dspace .content .DSpaceObject ;
3032 * @author richardrodgers
3133 */
3234public 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