mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +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();
|
protected AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||||
|
|
||||||
private static Logger log = Logger.getLogger(HandleResource.class);
|
private static Logger log = Logger.getLogger(HandleResource.class);
|
||||||
private static org.dspace.core.Context context;
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/{prefix}/{suffix}")
|
@Path("/{prefix}/{suffix}")
|
||||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@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) {
|
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();
|
DSpaceObject dSpaceObject = new DSpaceObject();
|
||||||
|
org.dspace.core.Context context = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context = createContext(getUser(headers));
|
context = createContext(getUser(headers));
|
||||||
|
|
||||||
@@ -62,20 +63,23 @@ public class HandleResource extends Resource {
|
|||||||
switch(dso.getType()) {
|
switch(dso.getType()) {
|
||||||
case Constants.COMMUNITY:
|
case Constants.COMMUNITY:
|
||||||
dSpaceObject = new Community((org.dspace.content.Community) dso, expand, context);
|
dSpaceObject = new Community((org.dspace.content.Community) dso, expand, context);
|
||||||
return dSpaceObject;
|
break;
|
||||||
case Constants.COLLECTION:
|
case Constants.COLLECTION:
|
||||||
dSpaceObject = new Collection((org.dspace.content.Collection) dso, expand, context, null, null);
|
dSpaceObject = new Collection((org.dspace.content.Collection) dso, expand, context, null, null);
|
||||||
return dSpaceObject;
|
break;
|
||||||
case Constants.ITEM:
|
case Constants.ITEM:
|
||||||
dSpaceObject = new Item((org.dspace.content.Item) dso, expand, context);
|
dSpaceObject = new Item((org.dspace.content.Item) dso, expand, context);
|
||||||
return dSpaceObject;
|
break;
|
||||||
default:
|
default:
|
||||||
dSpaceObject = new DSpaceObject(dso);
|
dSpaceObject = new DSpaceObject(dso);
|
||||||
return dSpaceObject;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.complete();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
|
||||||
@@ -88,7 +92,7 @@ public class HandleResource extends Resource {
|
|||||||
processFinally(context);
|
processFinally(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not sure where I was missing a return..
|
|
||||||
return dSpaceObject;
|
return dSpaceObject;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user