mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Make context's static, and autoCommit for remainders
This commit is contained in:
@@ -55,7 +55,6 @@ public class BitstreamResource {
|
||||
log.error(e.getMessage());
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GET
|
||||
|
@@ -44,7 +44,11 @@ public class CollectionsResource {
|
||||
public String listHTML() {
|
||||
StringBuilder everything = new StringBuilder();
|
||||
try {
|
||||
org.dspace.core.Context context = new org.dspace.core.Context();
|
||||
if(context == null || !context.isValid() ) {
|
||||
context = new org.dspace.core.Context();
|
||||
//Failed SQL is ignored as a failed SQL statement, prevent: current transaction is aborted, commands ignored until end of transaction block
|
||||
context.getDBConnection().setAutoCommit(true);
|
||||
}
|
||||
|
||||
org.dspace.content.Collection[] collections = org.dspace.content.Collection.findAll(context);
|
||||
for(org.dspace.content.Collection collection : collections) {
|
||||
@@ -52,12 +56,12 @@ public class CollectionsResource {
|
||||
everything.append("<li><a href='" + servletContext.getContextPath() + "/collections/" + collection.getID() + "'>" + collection.getID() + " - " + collection.getName() + "</a></li>\n");
|
||||
}
|
||||
|
||||
return "<html><title>Hello!</title><body>Collections<br/><ul>" + everything.toString() + "</ul>.</body></html> ";
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage());
|
||||
return "ERROR: " + e.getMessage();
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return "<html><title>Hello!</title><body>Collections<br/><ul>" + everything.toString() + "</ul>.</body></html> ";
|
||||
}
|
||||
|
||||
@GET
|
||||
|
@@ -28,7 +28,7 @@ http://localhost:8080/<webapp>/communities
|
||||
public class CommunitiesResource {
|
||||
private static Logger log = Logger.getLogger(CommunitiesResource.class);
|
||||
|
||||
private static Context context;
|
||||
private static org.dspace.core.Context context;
|
||||
|
||||
/*
|
||||
The "GET" annotation indicates this method will respond to HTTP Get requests.
|
||||
@@ -41,18 +41,19 @@ public class CommunitiesResource {
|
||||
try {
|
||||
if(context == null || !context.isValid() ) {
|
||||
context = new Context();
|
||||
//Failed SQL is ignored as a failed SQL statement, prevent: current transaction is aborted, commands ignored until end of transaction block
|
||||
context.getDBConnection().setAutoCommit(true);
|
||||
}
|
||||
org.dspace.content.Community[] communities = org.dspace.content.Community.findAllTop(context);
|
||||
for(org.dspace.content.Community community : communities) {
|
||||
everything.append(community.getName() + "<br/>\n");
|
||||
}
|
||||
return "<html><title>Hello!</title><body>Communities:<br/>" + everything.toString() + ".</body></html> ";
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage());
|
||||
return "ERROR: " + e.getMessage();
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
return "<html><title>Hello!</title><body>Communities:<br/>" + everything.toString() + ".</body></html> ";
|
||||
}
|
||||
|
||||
//TODO Respond to html for communities/:id
|
||||
@@ -83,7 +84,7 @@ public class CommunitiesResource {
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
} //finally?
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -106,6 +107,6 @@ public class CommunitiesResource {
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
} //finally?
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ public class ItemsResource {
|
||||
Logger log = Logger.getLogger(ItemsResource.class);
|
||||
//ItemList - Not Implemented
|
||||
|
||||
Context context;
|
||||
private static org.dspace.core.Context context;
|
||||
|
||||
@GET
|
||||
@Path("/{item_id}")
|
||||
|
Reference in New Issue
Block a user