Skip to content

Commit 066f297

Browse files
committed
set variables to final where applicable
1 parent 6140c49 commit 066f297

19 files changed

Lines changed: 80 additions & 86 deletions

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* @see org.dspace.content.packager.PackageIngester
2626
*/
2727
public abstract class AbstractPackagerTask extends AbstractCurationTask {
28+
private static final Logger log = LogManager.getLogger();
29+
2830
// Name of recursive mode option configurable in curation task configuration file
2931
private final String recursiveMode = "recursiveMode";
3032

@@ -34,8 +36,6 @@ public abstract class AbstractPackagerTask extends AbstractCurationTask {
3436
// Name of useCollectionTemplate option configurable in curation task configuration file
3537
private final String useCollectionTemplate = "useCollectionTemplate";
3638

37-
private static Logger log = LogManager.getLogger();
38-
3939
/**
4040
* Loads pre-configured PackageParameters settings from a given Module
4141
* configuration file (specified by 'moduleName').
@@ -47,7 +47,7 @@ public abstract class AbstractPackagerTask extends AbstractCurationTask {
4747
* <p>
4848
* Valid 'options' include all packager options supported by the
4949
* Packager class, e.g. AIP packagers minimally support these options:
50-
* https://wiki.lyrasis.org/display/DSDOC6x/AIP+Backup+and+Restore#AIPBackupandRestore-AdditionalPackagerOptions
50+
* https://wiki.lyrasis.org/display/DSDOC9x/AIP+Backup+and+Restore#AIPBackupandRestore-AdditionalPackagerOptions
5151
* <p>
5252
* Please note that different Packager classes will support different options.
5353
* You should determine which options are valid for your Packager class
@@ -100,7 +100,7 @@ protected PackageParameters loadPackagerParameters(String moduleName) {
100100
pkgParams.addProperty(option, value);
101101
}
102102

103-
log.debug("Set package parameter property <" + option + "> to value <" + value + ">");
103+
log.debug("Set package parameter property <{}> to value <{}>", option, value);
104104
}
105105
}
106106

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@
4040
*/
4141
@Mutative
4242
public class BagItReplaceWithAIP extends AbstractCurationTask {
43+
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
44+
private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
45+
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
46+
private final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
4347

4448
private String archFmt;
4549

4650
// Group where all AIPs are stored
4751
private String storeGroupName;
4852

49-
private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
50-
private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
51-
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
52-
private SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
53-
5453
@Override
5554
public void init(Curator curator, String taskId) throws IOException {
5655
super.init(curator, taskId);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@
6262
* @author richardrodgers
6363
*/
6464
public class BagItReplicateConsumer implements Consumer {
65-
private Logger log = LogManager.getLogger();
65+
private final Logger log = LogManager.getLogger();
6666

67-
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
68-
private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
69-
private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
70-
private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
71-
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
67+
private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
68+
private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
69+
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
70+
private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
71+
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
7272

7373
private ReplicaManager repMan = null;
7474
private TaskQueue taskQueue = null;

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@
5757
@Distributive
5858
@Mutative
5959
public 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);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@
8282
* @author richardrodgers
8383
*/
8484
public class METSReplicateConsumer implements Consumer {
85-
private Logger log = LogManager.getLogger();
86-
87-
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
88-
private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
89-
private SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
90-
private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
91-
private CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
92-
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
85+
private final Logger log = LogManager.getLogger();
86+
87+
private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
88+
private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
89+
private final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
90+
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
91+
private final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
92+
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
9393

9494
private ReplicaManager repMan = null;
9595
private TaskQueue taskQueue = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@Distributive
3434
@Mutative
3535
public class METSRestoreFromAIP extends AbstractPackagerTask {
36-
private Logger log = LogManager.getLogger();
36+
private final Logger log = LogManager.getLogger();
3737

3838
private String archFmt;
3939

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
/**
2323
* MoveToTrashSingleAIP task moves a single AIP from one group (folder) in external
24-
* storage to another group (folder). Currently it always moves content
24+
* storage to another group (folder). Currently, it always moves content
2525
* from the 'group.aip.name' store to the 'group.delete.name' store, essentially
2626
* moving the content into a "trash" folder.
2727
* <P>
@@ -37,8 +37,6 @@
3737
*/
3838
@Distributive
3939
public class MoveToTrashSingleAIP extends AbstractCurationTask {
40-
private static Logger log = LogManager.getLogger();
41-
4240
// Source and destination group where AIP will be moved to
4341
private String srcGroupName;
4442
private String destGroupName;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
public class RemoveAIP extends AbstractCurationTask {
4242
private static final Logger log = LogManager.getLogger();
4343

44+
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
45+
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
46+
4447
private String archFmt;
4548

4649
// Group where all AIPs are stored
@@ -49,9 +52,6 @@ public class RemoveAIP extends AbstractCurationTask {
4952
// Group where object deletion catalog/records are stored
5053
private String deleteGroupName;
5154

52-
private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
53-
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
54-
5555
@Override
5656
public void init(Curator curator, String taskId) throws IOException {
5757
super.init(curator, taskId);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
* @author richardrodgers
4141
*/
4242
public class ReplicaManager {
43-
private ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
44-
private PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
45-
private HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
43+
private final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
44+
private final PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
45+
private final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
4646

47-
private Logger log = LogManager.getLogger();
47+
private final Logger log = LogManager.getLogger();
4848
// singleton instance
4949
private static ReplicaManager instance = null;
5050
// the replica provider

src/main/java/org/dspace/ctask/replicate/checkm/RemoveManifest.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@
4242
*/
4343
@Distributive
4444
public class RemoveManifest extends AbstractCurationTask {
45+
private final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
46+
private final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
4547

4648
// Group where all Manifests are stored
4749
private String manifestGroupName;
4850

49-
private CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
50-
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
51-
5251
@Override
5352
public void init(Curator curator, String taskId) throws IOException {
5453
super.init(curator, taskId);
@@ -98,27 +97,27 @@ private void remove(Context context, ReplicaManager repMan, DSpaceObject dso) th
9897
repMan.removeObject(manifestGroupName, objId);
9998
report("Removing manifest for: " + objId);
10099
if (dso instanceof Collection) {
101-
Collection coll = (Collection)dso;
100+
Collection collection = (Collection)dso;
102101
try {
103-
Iterator<Item> iter = itemService.findByCollection(context, coll);
102+
Iterator<Item> iter = itemService.findByCollection(context, collection);
104103
while (iter.hasNext()) {
105104
remove(context, repMan, iter.next());
106105
}
107106
} catch (SQLException sqlE) {
108107
throw new IOException(sqlE);
109108
}
110109
} else if (dso instanceof Community) {
111-
Community comm = (Community)dso;
112-
for (Community subcomm : comm.getSubcommunities()) {
113-
remove(context, repMan, subcomm);
110+
Community community = (Community)dso;
111+
for (Community subCommunity : community.getSubcommunities()) {
112+
remove(context, repMan, subCommunity);
114113
}
115-
for (Collection coll : comm.getCollections()) {
114+
for (Collection coll : community.getCollections()) {
116115
remove(context, repMan, coll);
117116
}
118117
} else if (dso instanceof Site) {
119118
List<Community> topCommunities = communityService.findAllTop(context);
120-
for (Community subcomm : topCommunities) {
121-
remove(context, repMan, subcomm);
119+
for (Community subCommunity : topCommunities) {
120+
remove(context, repMan, subCommunity);
122121
}
123122
}
124123
}

0 commit comments

Comments
 (0)