Added method for proccessing finally statements.

Resource.writeStats should not throw exception, because it is not
important to abort method by writings statistic. But must abort own
context.
Added method for processing all finally statements.
Moved return to end of methods.
Repaired some bugs.
This commit is contained in:
ctu-developers
2014-10-13 11:39:09 +02:00
parent 57e72004be
commit 29b1d28566
6 changed files with 115 additions and 271 deletions

View File

@@ -116,11 +116,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.trace("Collection(id=" + collectionId + ") has been successfully read.");
@@ -208,11 +204,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.trace("All collections were successfully read.");
@@ -261,6 +253,7 @@ public class CollectionsResource extends Resource
log.info("Reading collection(id=" + collectionId + ") items.");
org.dspace.core.Context context = null;
List<Item> items = null;
try
{
@@ -270,7 +263,7 @@ public class CollectionsResource extends Resource
writeStats(dspaceCollection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor,
headers, request);
List<Item> items = new ArrayList<Item>();
items = new ArrayList<Item>();
org.dspace.content.ItemIterator dspaceItems = dspaceCollection.getItems();
for (int i = 0; (dspaceItems.hasNext()) && (i < (limit + offset)); i++)
{
@@ -287,8 +280,6 @@ public class CollectionsResource extends Resource
}
context.complete();
return items.toArray(new Item[0]);
}
catch (SQLException e)
{
@@ -300,15 +291,11 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.trace("All items in collection(id=" + collectionId + ") were successfully read.");
return null;
return items.toArray(new Item[0]);
}
/**
@@ -410,11 +397,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.info("Item successfully created in collection(id=" + collectionId + "). Item handle=" + returnItem.getHandle());
@@ -488,11 +471,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.info("Collection(id=" + collectionId + ") successfully updated.");
@@ -562,11 +541,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.info("Collection(id=" + collectionId + ") was successfully deleted.");
@@ -672,11 +647,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
log.info("Item(id=" + itemId + ") in collection(id=" + collectionId + ") was successfully deleted.");
@@ -740,11 +711,7 @@ public class CollectionsResource extends Resource
}
finally
{
if((context != null) && (context.isValid()))
{
log.error("Something get wrong. Aborting context in finally statement.");
context.abort();
}
processFinally(context);
}
if (collection == null)