Source:
<code>public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { Collection c = obj.getOwningCollection(); if (c != null) { item.setOwningCollection(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting owning collection for item" + item.getHandle(), e); } try { Collection c = obj.getTemplateItemOf(); if (c != null) { item.setTemplateItemOf(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting template item of for item " + item.getHandle(), e); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); List<Relationship> relationships = new LinkedList<>(); try { <START> relationships = relationshipService.findByItem(new Context(), obj); <END> } catch (SQLException e) { log.error(e, e); } List<RelationshipRest> relationshipRestList = new LinkedList<>(); for (Relationship relationship : relationships) { RelationshipRest relationshipRest = relationshipConverter.fromModel(relationship); relationshipRestList.add(relationshipRest); } item.setRelationships(relationshipRestList); List<MetadataValue> fullList = new LinkedList<>(); fullList = itemService.getMetadata(obj, Item.ANY, Item.ANY, Item.ANY, Item.ANY, true); item.setMetadata(metadataConverter.convert(fullList)); return item; }</code><technical_language>need create a new context</technical_language>

Target:
public ItemRest fromModel(org.dspace.content.Item obj) { ItemRest item = super.fromModel(obj); item.setInArchive(obj.isArchived()); item.setDiscoverable(obj.isDiscoverable()); item.setWithdrawn(obj.isWithdrawn()); item.setLastModified(obj.getLastModified()); try { Collection c = obj.getOwningCollection(); if (c != null) { item.setOwningCollection(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting owning collection for item" + item.getHandle(), e); } try { Collection c = obj.getTemplateItemOf(); if (c != null) { item.setTemplateItemOf(collectionConverter.fromModel(c)); } } catch (Exception e) { log.error("Error setting template item of for item " + item.getHandle(), e); } List<BitstreamRest> bitstreams = new ArrayList<BitstreamRest>(); for (Bundle bun : obj.getBundles()) { for (Bitstream bit : bun.getBitstreams()) { BitstreamRest bitrest = bitstreamConverter.fromModel(bit); bitstreams.add(bitrest); } } item.setBitstreams(bitstreams); List<Relationship> relationships = new LinkedList<>(); try { Context context; Request currentRequest = requestService.getCurrentRequest(); if (currentRequest != null) { HttpServletRequest request = currentRequest.getHttpServletRequest(); context = ContextUtil.obtainContext(request); } else { context = new Context(); } relationships = relationshipService.findByItem(context, obj); } catch (SQLException e) { log.error("Error retrieving relationships for item " + item.getHandle(), e); } List<RelationshipRest> relationshipRestList = new LinkedList<>(); for (Relationship relationship : relationships) { RelationshipRest relationshipRest = relationshipConverter.fromModel(relationship); relationshipRestList.add(relationshipRest); } item.setRelationships(relationshipRestList); List<MetadataValue> fullList = new LinkedList<>(); fullList = itemService.getMetadata(obj, Item.ANY, Item.ANY, Item.ANY, Item.ANY, true); item.setMetadata(metadataConverter.convert(fullList)); return item; }