Source:
public org.dspace.rest.common.FilteredCollection getCollection(@PathParam("collection_id") String collection_id, @QueryParam("expand") String expand, @QueryParam("limit") @DefaultValue("1000") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @QueryParam("filters") @DefaultValue("is_item") String filters, @Context HttpHeaders headers, @Context HttpServletRequest request) { org.dspace.core.Context context = null; try { context = createContext(getUser(headers)); if (!ConfigurationManager.getBooleanProperty("rest", "rest-reporting-authenticate", false)) { context.turnOffAuthorisationSystem(); } org.dspace.content.Collection collection = collectionService.findByIdOrLegacyId(context, collection_id); if(authorizeService.authorizeActionBoolean(context, collection, org.dspace.core.Constants.READ)) { writeStats(collection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor, headers, request, context); return new org.dspace.rest.common.FilteredCollection(collection, filters, expand, context, limit, offset); } else { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } } catch (SQLException e) { log.error(e.getMessage()); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } catch (ContextException e) { log.error(String.format("Could not read collection %d. %s", collection_id, e.getMessage())); throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } finally { if(context != null) { try { context.complete(); } catch (SQLException e) { log.error(e.getMessage() + " occurred while trying to close"); } } } }

Target:
public org.dspace.rest.common.FilteredCollection getCollection(@PathParam("collection_id") String collection_id, @QueryParam("expand") String expand, @QueryParam("limit") @DefaultValue("1000") Integer limit, @QueryParam("offset") @DefaultValue("0") Integer offset, @QueryParam("userIP") String user_ip, @QueryParam("userAgent") String user_agent, @QueryParam("xforwarderfor") String xforwarderfor, @QueryParam("filters") @DefaultValue("is_item") String filters, @Context HttpHeaders headers, @Context HttpServletRequest request) { org.dspace.core.Context context = null; FilteredCollection retColl = new org.dspace.rest.common.FilteredCollection(); try { context = createContext(getUser(headers)); if (!ConfigurationManager.getBooleanProperty("rest", "rest-reporting-authenticate", false)) { context.turnOffAuthorisationSystem(); } org.dspace.content.Collection collection = collectionService.findByIdOrLegacyId(context, collection_id); if(authorizeService.authorizeActionBoolean(context, collection, org.dspace.core.Constants.READ)) { writeStats(collection, UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor, headers, request, context); retColl = new org.dspace.rest.common.FilteredCollection(collection, filters, expand, context, limit, offset); } else { throw new WebApplicationException(Response.Status.UNAUTHORIZED); } context.complete(); } catch (SQLException e) { processException(e.getMessage(), context); } catch (ContextException e) { processException(String.format("Could not read collection %d. %s", collection_id, e.getMessage()), context); } finally { processFinally(context); } return retColl; }