Source:
public Response createOrUpdateItems(@ApiParam(value = "array of item data", required = true) GroupItemDTO[] items) { if (items == null) { return Response.status(Status.BAD_REQUEST).build(); } List<GroupItemDTO> wrongTypes = new ArrayList<>(); List<ActiveItem> activeItems = new ArrayList<>(); for (GroupItemDTO item : items) { ActiveItem newItem = createActiveItem(item); if (newItem == null) { wrongTypes.add(item); } else { activeItems.add(newItem); } } List<ActiveItem> createdItems = new ArrayList<>(); List<ActiveItem> updatedItems = new ArrayList<>(); List<ActiveItem> failedItems = new ArrayList<>(); for (ActiveItem activeItem : activeItems) { String itemName = activeItem.getName(); if (getItem(itemName) == null) { managedItemProvider.add(activeItem); createdItems.add(activeItem); } else if (managedItemProvider.get(itemName) != null) { managedItemProvider.update(activeItem); updatedItems.add(activeItem); } else { logger.warn("Cannot update existing item '{}', because is not managed.", itemName); failedItems.add(activeItem); } } List<JsonObject> responseList = new ArrayList<>(); for (GroupItemDTO item : wrongTypes) { responseList.add(buildStatusObject(item.name, "error", "Received HTTP PUT request at '" + uriInfo.getPath() + "' with an invalid item type '" + item.type + "'.")); } for (ActiveItem item : failedItems) { responseList.add(buildStatusObject(item.getName(), "error", "Cannot update non-managed Item")); } for (ActiveItem item : createdItems) { responseList.add(buildStatusObject(item.getName(), "created", null)); } for (ActiveItem item : updatedItems) { responseList.add(buildStatusObject(item.getName(), "updated", null)); } return JSONResponse.createResponse(Status.OK, responseList, null); }

Target:
public Response createOrUpdateItems(@ApiParam(value = "array of item data", required = true) GroupItemDTO[] items) { if (items == null) { return Response.status(Status.BAD_REQUEST).build(); } List<GroupItemDTO> wrongTypes = new ArrayList<>(); List<ActiveItem> activeItems = new ArrayList<>(); for (GroupItemDTO item : items) { ActiveItem newItem = createActiveItem(item); if (newItem == null) { wrongTypes.add(item); } else { activeItems.add(newItem); } } List<ActiveItem> createdItems = new ArrayList<>(); List<ActiveItem> updatedItems = new ArrayList<>(); List<ActiveItem> failedItems = new ArrayList<>(); for (ActiveItem activeItem : activeItems) { String itemName = activeItem.getName(); if (getItem(itemName) == null) { managedItemProvider.add(activeItem); createdItems.add(activeItem); } else if (managedItemProvider.get(itemName) != null) { managedItemProvider.update(activeItem); updatedItems.add(activeItem); } else { logger.warn("Cannot update existing item '{}', because it is not managed.", itemName); failedItems.add(activeItem); } } List<JsonObject> responseList = new ArrayList<>(); for (GroupItemDTO item : wrongTypes) { responseList.add(buildStatusObject(item.name, "error", "Received HTTP PUT request at '" + uriInfo.getPath() + "' with an invalid item type '" + item.type + "'.")); } for (ActiveItem item : failedItems) { responseList.add(buildStatusObject(item.getName(), "error", "Cannot update non-managed item")); } for (ActiveItem item : createdItems) { responseList.add(buildStatusObject(item.getName(), "created", null)); } for (ActiveItem item : updatedItems) { responseList.add(buildStatusObject(item.getName(), "updated", null)); } return JSONResponse.createResponse(Status.OK, responseList, null); }