mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +00:00
Repaired finally statements and community.
Repaired all finally statements. It was rewrited from context.abort to if condition with check if context is valid. In community was changed back name of subcommunities.
This commit is contained in:
@@ -120,8 +120,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return bitstream;
|
||||
}
|
||||
@@ -181,8 +185,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return policies.toArray(new ResourcePolicy[0]);
|
||||
}
|
||||
@@ -261,8 +269,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return bitstreams.toArray(new Bitstream[0]);
|
||||
}
|
||||
@@ -339,8 +351,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -419,8 +435,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
return Response.status(Status.OK).build();
|
||||
}
|
||||
|
||||
@@ -547,8 +567,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Bitstream metadata(id=" + bitstreamId + ") were successfully updated.");
|
||||
return Response.ok().build();
|
||||
@@ -634,8 +658,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Bitstream(id=" + bitstreamId + ") data was successfully updated.");
|
||||
return Response.ok().build();
|
||||
@@ -709,8 +737,12 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Bitstream(id=" + bitstreamId + ") was successfully deleted.");
|
||||
return Response.ok().build();
|
||||
@@ -783,8 +815,13 @@ public class BitstreamResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return Response.status(Status.OK).build();
|
||||
}
|
||||
|
||||
|
@@ -116,8 +116,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.trace("Collection(id=" + collectionId + ") has been successfully read.");
|
||||
return collection;
|
||||
@@ -204,8 +208,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.trace("All collections were successfully read.");
|
||||
return collections.toArray(new org.dspace.rest.common.Collection[0]);
|
||||
@@ -292,8 +300,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.trace("All items in collection(id=" + collectionId + ") were successfully read.");
|
||||
return null;
|
||||
@@ -398,8 +410,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Item successfully created in collection(id=" + collectionId + "). Item handle=" + returnItem.getHandle());
|
||||
return returnItem;
|
||||
@@ -472,8 +488,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Collection(id=" + collectionId + ") successfully updated.");
|
||||
return Response.ok().build();
|
||||
@@ -542,8 +562,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Collection(id=" + collectionId + ") was successfully deleted.");
|
||||
return Response.ok().build();
|
||||
@@ -648,8 +672,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Item(id=" + itemId + ") in collection(id=" + collectionId + ") was successfully deleted.");
|
||||
return Response.ok().build();
|
||||
@@ -712,8 +740,12 @@ public class CollectionsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (collection == null)
|
||||
{
|
||||
|
@@ -104,8 +104,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.trace("Community(id=" + communityId + ") was successfully read.");
|
||||
return community;
|
||||
@@ -186,8 +191,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -270,8 +280,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -358,8 +373,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -447,8 +467,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -524,8 +549,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Community at top level has been successfully created. Handle:" + retCommunity.getHandle());
|
||||
return retCommunity;
|
||||
@@ -605,8 +635,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Collection was successfully added into community(id=" + communityId + "). Collection handle="
|
||||
+ retCollection.getHandle());
|
||||
@@ -685,8 +720,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Subcommunity was successfully added in community(id=" + communityId + ").");
|
||||
return retCommunity;
|
||||
@@ -757,8 +797,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Community(id=" + communityId + ") has been successfully updated.");
|
||||
return Response.ok().build();
|
||||
@@ -822,8 +867,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Community(id=" + communityId + ") was successfully deleted.");
|
||||
return Response.status(Response.Status.OK).build();
|
||||
@@ -927,8 +977,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Collection(id=" + collectionId + ") in community(id=" + communityId + ") was successfully deleted.");
|
||||
return Response.status(Response.Status.OK).build();
|
||||
@@ -1032,8 +1087,13 @@ public class CommunitiesResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.info("Subcommunity(id=" + subcommunityId + ") from community(id=" + parentCommunityId + ") was successfully deleted.");
|
||||
return Response.status(Response.Status.OK).build();
|
||||
|
@@ -121,8 +121,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -202,8 +206,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -261,8 +269,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -334,8 +346,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -409,8 +425,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Metadata to item(id=" + itemId + ") were successfully added.");
|
||||
return Response.status(Status.OK).build();
|
||||
@@ -580,8 +600,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Bitstream(id=" + bitstream.getId() + ") was successfully added into item(id=" + itemId + ").");
|
||||
return bitstream;
|
||||
@@ -666,8 +690,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Metadata of item(id=" + itemId + ") were successfully updated.");
|
||||
return Response.status(Status.OK).build();
|
||||
@@ -735,8 +763,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Item(id=" + itemId + ") was successfully deleted.");
|
||||
return Response.status(Status.OK).build();
|
||||
@@ -813,8 +845,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Item(id=" + itemId + ") metadata were successfully deleted.");
|
||||
return Response.status(Status.OK).build();
|
||||
@@ -909,8 +945,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
log.info("Bitstream(id=" + bitstreamId + ") from item(id=" + itemId + ") was successfuly deleted .");
|
||||
return Response.status(Status.OK).build();
|
||||
@@ -1031,8 +1071,12 @@ public class ItemsResource extends Resource
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
if (items.size() == 0)
|
||||
{
|
||||
|
@@ -77,11 +77,14 @@ public class Resource
|
||||
}
|
||||
|
||||
return context;
|
||||
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
throw new ContextException("Could not create context, SQLException. Message: " + e, e);
|
||||
}
|
||||
}
|
||||
@@ -129,12 +132,12 @@ public class Resource
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
processException("Could not write usageEvent, SQLException. Message: " + e, context);
|
||||
processException("Could not write usageEvent, SQLException. Message: " + e, null); // Write statistic should not abort context.
|
||||
|
||||
}
|
||||
catch (ContextException e)
|
||||
{
|
||||
processException("Could not write usageEvent, ContextException. Message: " + e.getMessage(), context);
|
||||
processException("Could not write usageEvent, ContextException. Message: " + e.getMessage(), null); // Write statistic should not abort context.
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -95,8 +95,12 @@ public class TokenHolder
|
||||
}
|
||||
finally
|
||||
{
|
||||
if((context != null) && (context.isValid()))
|
||||
{
|
||||
log.error("Something get wrong. Aborting context in finally statement.");
|
||||
context.abort();
|
||||
}
|
||||
}
|
||||
|
||||
return token;
|
||||
}
|
||||
|
@@ -39,8 +39,8 @@ public class Community extends DSpaceObject{
|
||||
private Integer countItems;
|
||||
|
||||
// Renamed because of xml annotation exception with this attribute and getSubCommunities.
|
||||
@XmlElement(name = "subcommunities2", required = true)
|
||||
private List<Community> subCommunities2 = new ArrayList<Community>();
|
||||
@XmlElement(name = "subcommunities", required = true)
|
||||
private List<Community> subcommunities = new ArrayList<Community>();
|
||||
|
||||
private List<Collection> collections = new ArrayList<Collection>();
|
||||
|
||||
@@ -88,10 +88,10 @@ public class Community extends DSpaceObject{
|
||||
|
||||
if(expandFields.contains("subCommunities") || expandFields.contains("all")) {
|
||||
org.dspace.content.Community[] communityArray = community.getSubcommunities();
|
||||
subCommunities2 = new ArrayList<Community>();
|
||||
subcommunities = new ArrayList<Community>();
|
||||
for(org.dspace.content.Community subCommunity : communityArray) {
|
||||
if(AuthorizeManager.authorizeActionBoolean(context, subCommunity, org.dspace.core.Constants.READ)) {
|
||||
subCommunities2.add(new Community(subCommunity, null, context));
|
||||
subcommunities.add(new Community(subCommunity, null, context));
|
||||
} else {
|
||||
log.info("Omitted restricted subCommunity: " + subCommunity.getID() + " _ " + subCommunity.getName());
|
||||
}
|
||||
@@ -173,12 +173,12 @@ public class Community extends DSpaceObject{
|
||||
return logo;
|
||||
}
|
||||
|
||||
public List<Community> getSubCommunities() {
|
||||
return subCommunities2;
|
||||
public List<Community> getSubcommunities() {
|
||||
return subcommunities;
|
||||
}
|
||||
|
||||
public void setSubCommunities(List<Community> subCommunities) {
|
||||
this.subCommunities2 = subCommunities;
|
||||
public void setSubcommunities(List<Community> subcommunities) {
|
||||
this.subcommunities = subcommunities;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user