5757@ Distributive
5858@ Mutative
5959public class BagItRestoreFromAIP extends AbstractCurationTask {
60+ private static final Logger log = LogManager .getLogger ();
61+
62+ private final EmbargoService embargoService = EmbargoServiceFactory .getInstance ().getEmbargoService ();
63+ private final WorkspaceItemService workspaceItemService = ContentServiceFactory .getInstance ().getWorkspaceItemService ();
64+ private final InstallItemService installItemService = ContentServiceFactory .getInstance ().getInstallItemService ();
65+ private final CollectionService collectionService = ContentServiceFactory .getInstance ().getCollectionService ();
6066
61- private static Logger log = LogManager .getLogger ();
6267 private String archFmt ;
6368
6469 // Group where all AIPs are stored
@@ -67,11 +72,6 @@ public class BagItRestoreFromAIP extends AbstractCurationTask {
6772 // Group where object deletion catalog/records are stored
6873 private String deleteGroupName ;
6974
70- private EmbargoService embargoService = EmbargoServiceFactory .getInstance ().getEmbargoService ();
71- private WorkspaceItemService workspaceItemService = ContentServiceFactory .getInstance ().getWorkspaceItemService ();
72- private InstallItemService installItemService = ContentServiceFactory .getInstance ().getInstallItemService ();
73- private CollectionService collectionService = ContentServiceFactory .getInstance ().getCollectionService ();
74-
7575 @ Override
7676 public void init (Curator curator , String taskId ) throws IOException {
7777 super .init (curator , taskId );
@@ -224,10 +224,10 @@ private void recoverItem(Context ctx, File archive, String objId, Properties pro
224224 packer .unpack (archive );
225225 // Install item
226226 Item item = installItemService .restoreItem (ctx , wi , objId );
227- String colls = props .getProperty (OTHER_IDS );
228- if (colls != null ) {
227+ String collections = props .getProperty (OTHER_IDS );
228+ if (collections != null ) {
229229 // reset linked collections
230- for (String link : colls .split ("," )) {
230+ for (String link : collections .split ("," )) {
231231 Collection linkC = (Collection ) handleService .resolveToObject (ctx , link );
232232 collectionService .addItem (ctx , linkC , item );
233233 }
@@ -251,17 +251,17 @@ private void recoverItem(Context ctx, File archive, String objId, Properties pro
251251 * @throws IOException if IO error
252252 */
253253 private void recoverCollection (Context ctx , File archive , String collId , String commId ) throws IOException {
254- Collection coll = null ;
255254 try {
256255 if (commId != null ) {
257- Community pcomm = (Community ) handleService .resolveToObject (ctx , commId );
258- coll = collectionService .create (ctx , pcomm , collId );
256+ Community parentCommunity = (Community ) handleService .resolveToObject (ctx , commId );
257+ Collection collection = collectionService .create (ctx , parentCommunity , collId );
258+
259+ // update with AIP data
260+ Packer packer = PackerFactory .instance (ctx , collection );
261+ packer .unpack (archive );
259262 } else {
260- log .error ("Collection '" + collId + " ' lacks parent community" );
263+ log .error ("Collection '{} ' lacks parent community" , collId );
261264 }
262- // update with AIP data
263- Packer packer = PackerFactory .instance (ctx , coll );
264- packer .unpack (archive );
265265 } catch (AuthorizeException | SQLException authE ) {
266266 throw new IOException (authE );
267267 }
@@ -277,16 +277,17 @@ private void recoverCollection(Context ctx, File archive, String collId, String
277277 */
278278 private void recoverCommunity (Context ctx , File archive , String commId , String parentId ) throws IOException {
279279 // if not top-level, have parent create it
280- Community comm = null ;
280+ Community community = null ;
281281 try {
282282 if (parentId != null ) {
283- Community pcomm = (Community ) handleService .resolveToObject (ctx , parentId );
284- comm = communityService .createSubcommunity (ctx , pcomm , commId );
283+ Community parentCommunity = (Community ) handleService .resolveToObject (ctx , parentId );
284+ community = communityService .createSubcommunity (ctx , parentCommunity , commId );
285285 } else {
286- comm = communityService .create (null , ctx , commId );
286+ community = communityService .create (null , ctx , commId );
287287 }
288+
288289 // update with AIP data
289- Packer packer = PackerFactory .instance (ctx , comm );
290+ Packer packer = PackerFactory .instance (ctx , community );
290291 packer .unpack (archive );
291292 } catch (AuthorizeException | SQLException authE ) {
292293 throw new IOException (authE );
0 commit comments