[DS-2701-rest-api-fixes] Small bugfixes concerning comparing of objects, missing update call & ConcurrentModificationException

This commit is contained in:
KevinVdV
2015-09-18 12:28:09 +02:00
parent 79f882da11
commit 8c0062354e
3 changed files with 11 additions and 6 deletions

View File

@@ -687,7 +687,7 @@ public class BitstreamResource extends Resource
request, context); request, context);
org.dspace.authorize.ResourcePolicy resourcePolicy = resourcePolicyService.find(context, policyId); org.dspace.authorize.ResourcePolicy resourcePolicy = resourcePolicyService.find(context, policyId);
if(resourcePolicy.getdSpaceObject().getID() == dspaceBitstream.getID() && authorizeService.authorizeActionBoolean(context, dspaceBitstream, org.dspace.core.Constants.REMOVE)) { if(resourcePolicy.getdSpaceObject().getID().equals(dspaceBitstream.getID()) && authorizeService.authorizeActionBoolean(context, dspaceBitstream, org.dspace.core.Constants.REMOVE)) {
try { try {
resourcePolicyService.delete(context, resourcePolicy); resourcePolicyService.delete(context, resourcePolicy);

View File

@@ -499,7 +499,7 @@ public class ItemsResource extends Resource
// Remove default bitstream policies // Remove default bitstream policies
List<org.dspace.authorize.ResourcePolicy> policiesToRemove = new ArrayList<org.dspace.authorize.ResourcePolicy>(); List<org.dspace.authorize.ResourcePolicy> policiesToRemove = new ArrayList<org.dspace.authorize.ResourcePolicy>();
for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies) { for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies) {
if (policy.getdSpaceObject().getID() == dspaceBitstream.getID()) if (policy.getdSpaceObject().getID().equals(dspaceBitstream.getID()))
{ {
policiesToRemove.add(policy); policiesToRemove.add(policy);
} }
@@ -631,6 +631,8 @@ public class ItemsResource extends Resource
itemService.addMetadata(context, dspaceItem, data[0], data[1], data[2], entry.getLanguage(), entry.getValue()); itemService.addMetadata(context, dspaceItem, data[0], data[1], data[2], entry.getLanguage(), entry.getValue());
} }
} }
//Update the item to ensure that all the events get fired.
itemService.update(context, dspaceItem);
context.complete(); context.complete();
@@ -643,8 +645,10 @@ public class ItemsResource extends Resource
{ {
processException( processException(
"Could not update metadata in item(id=" + itemId + "), ContextException. Message: " + e.getMessage(), context); "Could not update metadata in item(id=" + itemId + "), ContextException. Message: " + e.getMessage(), context);
} } catch (AuthorizeException e) {
finally processException(
"Could not update metadata in item(id=" + itemId + "), AuthorizeException. Message: " + e.getMessage(), context);
} finally
{ {
processFinally(context); processFinally(context);
} }
@@ -857,8 +861,9 @@ public class ItemsResource extends Resource
while (bundleBitstreamIterator.hasNext()) while (bundleBitstreamIterator.hasNext())
{ {
BundleBitstream bundleBitstream = bundleBitstreamIterator.next(); BundleBitstream bundleBitstream = bundleBitstreamIterator.next();
if (bundleBitstream.getBitstream().getID() == bitstream.getID()) if (bundleBitstream.getBitstream().getID().equals(bitstream.getID()))
{ {
bundleBitstreamIterator.remove();
bundleService.removeBitstream(context, bundle, bitstream); bundleService.removeBitstream(context, bundle, bitstream);
} }
} }

View File

@@ -94,7 +94,7 @@ public class Bitstream extends DSpaceObject {
for (BundleBitstream bundleBitstream : bundleBitstreams) { for (BundleBitstream bundleBitstream : bundleBitstreams) {
List<org.dspace.authorize.ResourcePolicy> bitstreamsPolicies = bundleService.getBitstreamPolicies(context, bundleBitstream.getBundle()); List<org.dspace.authorize.ResourcePolicy> bitstreamsPolicies = bundleService.getBitstreamPolicies(context, bundleBitstream.getBundle());
for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies) { for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies) {
if(policy.getdSpaceObject() == bitstream) { if(policy.getdSpaceObject().equals(bitstream)) {
tempPolicies.add(new ResourcePolicy(policy)); tempPolicies.add(new ResourcePolicy(policy));
} }
} }