Source:
protected CollectionRest createAndReturn(Context context) throws AuthorizeException { HttpServletRequest req = getRequestService().getCurrentRequest().getHttpServletRequest(); ObjectMapper mapper = new ObjectMapper(); CollectionRest collectionRest; try { ServletInputStream input = req.getInputStream(); collectionRest = mapper.readValue(input, CollectionRest.class); } catch (IOException e1) { throw new UnprocessableEntityException("Error parsing request body: " + e1.toString()); } Collection collection; try { Community parent = null; if (StringUtils.isNotBlank(req.getParameter("parentCommunity"))) { UUID owningCommunityUuid = UUIDUtils.fromString(req.getParameter("parentCommunity")); if (owningCommunityUuid == null) { throw new BadRequestException("The given owningCommunityUuid was invalid: " + req.getParameter("parentCommunity")); } parent = communityService.find(context, owningCommunityUuid); if (parent == null) { throw new ResourceNotFoundException("Parent community for id: " + owningCommunityUuid + " not found"); } } collection = cs.create(context, parent); cs.update(context, collection); if (collectionRest.getMetadata() != null) { for (MetadataEntryRest mer : collectionRest.getMetadata()) { String[] metadatakey = mer.getKey().split("\\."); cs.addMetadata(context, collection, metadatakey[0], metadatakey[1], metadatakey.length == 3 ? metadatakey[2] : null, mer.getLanguage(), mer.getValue()); } } } catch (SQLException e) { throw new RuntimeException(e.getMessage(), e); } return converter.convert(collection); }

Target:
protected CollectionRest createAndReturn(Context context) throws AuthorizeException { HttpServletRequest req = getRequestService().getCurrentRequest().getHttpServletRequest(); ObjectMapper mapper = new ObjectMapper(); CollectionRest collectionRest; try { ServletInputStream input = req.getInputStream(); collectionRest = mapper.readValue(input, CollectionRest.class); } catch (IOException e1) { throw new UnprocessableEntityException("Error parsing request body: " + e1.toString()); } Collection collection; String parentCommunityString = req.getParameter("parent"); try { Community parent = null; if (StringUtils.isNotBlank(parentCommunityString)) { UUID parentCommunityUuid = UUIDUtils.fromString(parentCommunityString); if (parentCommunityUuid == null) { throw new BadRequestException("The given parent was invalid: " + parentCommunityString); } parent = communityService.find(context, parentCommunityUuid); if (parent == null) { throw new UnprocessableEntityException("Parent community for id: " + parentCommunityUuid + " not found"); } } else { throw new BadRequestException("The parent parameter cannot be left empty," + "collections require a parent community."); } collection = cs.create(context, parent); cs.update(context, collection); if (collectionRest.getMetadata() != null) { for (MetadataEntryRest mer : collectionRest.getMetadata()) { String[] metadatakey = mer.getKey().split("\\."); cs.addMetadata(context, collection, metadatakey[0], metadatakey[1], metadatakey.length == 3 ? metadatakey[2] : null, mer.getLanguage(), mer.getValue()); } } } catch (SQLException e) { throw new RuntimeException("Unable to create new Collection under parent Community " + parentCommunityString, e); } return converter.convert(collection); }