mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #1220 from bram-atmire/DS-2936-master
DS-2936 REST-API /handle endpoint broken
This commit is contained in:
@@ -40,13 +40,14 @@ public class HandleResource extends Resource {
|
||||
protected AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
|
||||
private static Logger log = Logger.getLogger(HandleResource.class);
|
||||
private static org.dspace.core.Context context;
|
||||
|
||||
@GET
|
||||
@Path("/{prefix}/{suffix}")
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public org.dspace.rest.common.DSpaceObject getObject(@PathParam("prefix") String prefix, @PathParam("suffix") String suffix, @QueryParam("expand") String expand, @javax.ws.rs.core.Context HttpHeaders headers) {
|
||||
DSpaceObject dSpaceObject = new DSpaceObject();
|
||||
org.dspace.core.Context context = null;
|
||||
|
||||
try {
|
||||
context = createContext(getUser(headers));
|
||||
|
||||
@@ -62,20 +63,23 @@ public class HandleResource extends Resource {
|
||||
switch(dso.getType()) {
|
||||
case Constants.COMMUNITY:
|
||||
dSpaceObject = new Community((org.dspace.content.Community) dso, expand, context);
|
||||
return dSpaceObject;
|
||||
break;
|
||||
case Constants.COLLECTION:
|
||||
dSpaceObject = new Collection((org.dspace.content.Collection) dso, expand, context, null, null);
|
||||
return dSpaceObject;
|
||||
break;
|
||||
case Constants.ITEM:
|
||||
dSpaceObject = new Item((org.dspace.content.Item) dso, expand, context);
|
||||
return dSpaceObject;
|
||||
break;
|
||||
default:
|
||||
dSpaceObject = new DSpaceObject(dso);
|
||||
return dSpaceObject;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
context.complete();
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||
@@ -88,7 +92,7 @@ public class HandleResource extends Resource {
|
||||
processFinally(context);
|
||||
}
|
||||
|
||||
//Not sure where I was missing a return..
|
||||
return dSpaceObject;
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user