#8783 checkstyle fixes

This commit is contained in:
Kim Shepherd
2023-05-12 18:03:02 +12:00
parent b69517da74
commit 6943399938

View File

@@ -7,12 +7,14 @@
*/ */
package org.dspace.content; package org.dspace.content;
import static org.dspace.core.Constants.*; import static org.dspace.core.Constants.ADD;
import static org.dspace.core.Constants.READ;
import static org.dspace.core.Constants.REMOVE;
import static org.dspace.core.Constants.WRITE;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@@ -74,14 +76,14 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if (bundle == null) { if (bundle == null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(LogHelper.getHeader(context, "find_bundle", log.debug(LogHelper.getHeader(context, "find_bundle",
"not_found,bundle_id=" + id)); "not_found,bundle_id=" + id));
} }
return null; return null;
} else { } else {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(LogHelper.getHeader(context, "find_bundle", log.debug(LogHelper.getHeader(context, "find_bundle",
"bundle_id=" + id)); "bundle_id=" + id));
} }
return bundle; return bundle;
@@ -106,7 +108,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
log.info(LogHelper.getHeader(context, "create_bundle", "bundle_id=" log.info(LogHelper.getHeader(context, "create_bundle", "bundle_id="
+ bundle.getID())); + bundle.getID()));
// if we ever use the identifier service for bundles, we should // if we ever use the identifier service for bundles, we should
// create the bundle before we create the Event and should add all // create the bundle before we create the Event and should add all
@@ -132,12 +134,12 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override @Override
public void addBitstream(Context context, Bundle bundle, Bitstream bitstream) public void addBitstream(Context context, Bundle bundle, Bitstream bitstream)
throws SQLException, AuthorizeException { throws SQLException, AuthorizeException {
// Check authorisation // Check authorisation
authorizeService.authorizeAction(context, bundle, Constants.ADD); authorizeService.authorizeAction(context, bundle, Constants.ADD);
log.info(LogHelper.getHeader(context, "add_bitstream", "bundle_id=" log.info(LogHelper.getHeader(context, "add_bitstream", "bundle_id="
+ bundle.getID() + ",bitstream_id=" + bitstream.getID())); + bundle.getID() + ",bitstream_id=" + bitstream.getID()));
// First check that the bitstream isn't already in the list // First check that the bitstream isn't already in the list
List<Bitstream> bitstreams = bundle.getBitstreams(); List<Bitstream> bitstreams = bundle.getBitstreams();
@@ -167,8 +169,8 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
context.addEvent(new Event(Event.ADD, Constants.BUNDLE, bundle.getID(), context.addEvent(new Event(Event.ADD, Constants.BUNDLE, bundle.getID(),
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()), Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
getIdentifiers(context, bundle))); getIdentifiers(context, bundle)));
// copy authorization policies from bundle to bitstream // copy authorization policies from bundle to bitstream
// FIXME: multiple inclusion is affected by this... // FIXME: multiple inclusion is affected by this...
@@ -211,17 +213,17 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override @Override
public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream) public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream)
throws AuthorizeException, SQLException, IOException { throws AuthorizeException, SQLException, IOException {
// Check authorisation // Check authorisation
authorizeService.authorizeAction(context, bundle, Constants.REMOVE); authorizeService.authorizeAction(context, bundle, Constants.REMOVE);
log.info(LogHelper.getHeader(context, "remove_bitstream", log.info(LogHelper.getHeader(context, "remove_bitstream",
"bundle_id=" + bundle.getID() + ",bitstream_id=" + bitstream.getID())); "bundle_id=" + bundle.getID() + ",bitstream_id=" + bitstream.getID()));
context.addEvent(new Event(Event.REMOVE, Constants.BUNDLE, bundle.getID(), context.addEvent(new Event(Event.REMOVE, Constants.BUNDLE, bundle.getID(),
Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()), Constants.BITSTREAM, bitstream.getID(), String.valueOf(bitstream.getSequenceID()),
getIdentifiers(context, bundle))); getIdentifiers(context, bundle)));
//Ensure that the last modified from the item is triggered ! //Ensure that the last modified from the item is triggered !
Item owningItem = (Item) getParentObject(context, bundle); Item owningItem = (Item) getParentObject(context, bundle);
@@ -254,9 +256,9 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override @Override
public void inheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection) public void inheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection)
throws SQLException, AuthorizeException { throws SQLException, AuthorizeException {
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, collection, List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, collection,
Constants.DEFAULT_BITSTREAM_READ); Constants.DEFAULT_BITSTREAM_READ);
// change the action to just READ // change the action to just READ
// just don't call update on the resourcepolicies!!! // just don't call update on the resourcepolicies!!!
@@ -264,7 +266,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if (!i.hasNext()) { if (!i.hasNext()) {
throw new java.sql.SQLException("Collection " + collection.getID() throw new java.sql.SQLException("Collection " + collection.getID()
+ " has no default bitstream READ policies"); + " has no default bitstream READ policies");
} }
List<ResourcePolicy> newPolicies = new ArrayList<ResourcePolicy>(); List<ResourcePolicy> newPolicies = new ArrayList<ResourcePolicy>();
@@ -279,7 +281,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override @Override
public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies) public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List<ResourcePolicy> newpolicies)
throws SQLException, AuthorizeException { throws SQLException, AuthorizeException {
List<Bitstream> bitstreams = bundle.getBitstreams(); List<Bitstream> bitstreams = bundle.getBitstreams();
if (CollectionUtils.isNotEmpty(bitstreams)) { if (CollectionUtils.isNotEmpty(bitstreams)) {
for (Bitstream bs : bitstreams) { for (Bitstream bs : bitstreams) {
@@ -401,16 +403,16 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if (bitstream == null) { if (bitstream == null) {
//This should never occur but just in case //This should never occur but just in case
log.warn(LogHelper.getHeader(context, "Invalid bitstream id while changing bitstream order", log.warn(LogHelper.getHeader(context, "Invalid bitstream id while changing bitstream order",
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId)); "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
continue; continue;
} }
// If we have a Bitstream not in the current list, log a warning & exit immediately // If we have a Bitstream not in the current list, log a warning & exit immediately
if (!currentBitstreams.contains(bitstream)) { if (!currentBitstreams.contains(bitstream)) {
log.warn(LogHelper.getHeader(context, log.warn(LogHelper.getHeader(context,
"Encountered a bitstream not in this bundle while changing bitstream " + "Encountered a bitstream not in this bundle while changing bitstream " +
"order. Bitstream order will not be changed.", "order. Bitstream order will not be changed.",
"Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId)); "Bundle: " + bundle.getID() + ", bitstream id: " + bitstreamId));
return; return;
} }
updatedBitstreams.add(bitstream); updatedBitstreams.add(bitstream);
@@ -419,9 +421,9 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
// If our lists are different sizes, exit immediately // If our lists are different sizes, exit immediately
if (updatedBitstreams.size() != currentBitstreams.size()) { if (updatedBitstreams.size() != currentBitstreams.size()) {
log.warn(LogHelper.getHeader(context, log.warn(LogHelper.getHeader(context,
"Size of old list and new list do not match. Bitstream order will not be " + "Size of old list and new list do not match. Bitstream order will not be " +
"changed.", "changed.",
"Bundle: " + bundle.getID())); "Bundle: " + bundle.getID()));
return; return;
} }
@@ -467,7 +469,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
} else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) { } else if (AuthorizeConfiguration.canCollectionAdminPerformBitstreamDeletion()) {
adminObject = collection; adminObject = collection;
} else if (AuthorizeConfiguration } else if (AuthorizeConfiguration
.canCommunityAdminPerformBitstreamDeletion()) { .canCommunityAdminPerformBitstreamDeletion()) {
adminObject = community; adminObject = community;
} }
break; break;
@@ -475,10 +477,10 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) { if (AuthorizeConfiguration.canItemAdminPerformBitstreamCreation()) {
adminObject = item; adminObject = item;
} else if (AuthorizeConfiguration } else if (AuthorizeConfiguration
.canCollectionAdminPerformBitstreamCreation()) { .canCollectionAdminPerformBitstreamCreation()) {
adminObject = collection; adminObject = collection;
} else if (AuthorizeConfiguration } else if (AuthorizeConfiguration
.canCommunityAdminPerformBitstreamCreation()) { .canCommunityAdminPerformBitstreamCreation()) {
adminObject = community; adminObject = community;
} }
break; break;
@@ -510,7 +512,7 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
// Check authorisation // Check authorisation
//AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE); //AuthorizeManager.authorizeAction(ourContext, this, Constants.WRITE);
log.info(LogHelper.getHeader(context, "update_bundle", "bundle_id=" log.info(LogHelper.getHeader(context, "update_bundle", "bundle_id="
+ bundle.getID())); + bundle.getID()));
super.update(context, bundle); super.update(context, bundle);
bundleDAO.save(context, bundle); bundleDAO.save(context, bundle);
@@ -518,10 +520,10 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
if (bundle.isModified() || bundle.isMetadataModified()) { if (bundle.isModified() || bundle.isMetadataModified()) {
if (bundle.isMetadataModified()) { if (bundle.isMetadataModified()) {
context.addEvent(new Event(Event.MODIFY_METADATA, bundle.getType(), bundle.getID(), bundle.getDetails(), context.addEvent(new Event(Event.MODIFY_METADATA, bundle.getType(), bundle.getID(), bundle.getDetails(),
getIdentifiers(context, bundle))); getIdentifiers(context, bundle)));
} }
context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, bundle.getID(), context.addEvent(new Event(Event.MODIFY, Constants.BUNDLE, bundle.getID(),
null, getIdentifiers(context, bundle))); null, getIdentifiers(context, bundle)));
bundle.clearModified(); bundle.clearModified();
bundle.clearDetails(); bundle.clearDetails();
} }
@@ -530,12 +532,12 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override @Override
public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException { public void delete(Context context, Bundle bundle) throws SQLException, AuthorizeException, IOException {
log.info(LogHelper.getHeader(context, "delete_bundle", "bundle_id=" log.info(LogHelper.getHeader(context, "delete_bundle", "bundle_id="
+ bundle.getID())); + bundle.getID()));
authorizeService.authorizeAction(context, bundle, Constants.DELETE); authorizeService.authorizeAction(context, bundle, Constants.DELETE);
context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(), context.addEvent(new Event(Event.DELETE, Constants.BUNDLE, bundle.getID(),
bundle.getName(), getIdentifiers(context, bundle))); bundle.getName(), getIdentifiers(context, bundle)));
// Remove bitstreams // Remove bitstreams
List<Bitstream> bitstreams = bundle.getBitstreams(); List<Bitstream> bitstreams = bundle.getBitstreams();