Source:
public SimpleObject update(String uuid, SimpleObject postBody, RequestContext context) throws ResponseException { Object manualEntryEnabled = (postBody.get("manualEntryEnabled")); Object automaticGenerationEnabled = postBody.get("automaticGenerationEnabled"); Object sourceUuid = postBody.get("source"); Object locationUuid = postBody.get("location"); manualEntryEnabled = (manualEntryEnabled != null) && (StringUtils.isNotBlank(manualEntryEnabled.toString())) ? manualEntryEnabled : null; automaticGenerationEnabled = ((automaticGenerationEnabled != null) && (StringUtils.isNotBlank(automaticGenerationEnabled.toString()))) ? automaticGenerationEnabled : null; IdentifierSource identifierSource = ((sourceUuid != null) && (StringUtils.isNotBlank(sourceUuid.toString())) && (identifierSourceService.getIdentifierSourceByUuid(sourceUuid.toString()) != null)) ? identifierSourceService.getIdentifierSourceByUuid(sourceUuid.toString()) : null; Location location = ((locationUuid != null) && (StringUtils.isNotBlank(locationUuid.toString())) && (Context.getLocationService().getLocationByUuid(locationUuid.toString()) != null)) ? Context.getLocationService().getLocationByUuid(locationUuid.toString()) : null; AutoGenerationOption autoGenerationOption = identifierSourceService.getAutoGenerationOption(Integer.parseInt(uuid)); if (manualEntryEnabled != null) { autoGenerationOption.setManualEntryEnabled(Boolean.parseBoolean(manualEntryEnabled.toString())); } if (automaticGenerationEnabled != null) { autoGenerationOption.setAutomaticGenerationEnabled(Boolean.parseBoolean(automaticGenerationEnabled.toString())); } if (identifierSource != null) { autoGenerationOption.setSource(identifierSource); } if (location != null) { autoGenerationOption.setLocation(location); } if (location == null && identifierSource == null && automaticGenerationEnabled == null && manualEntryEnabled == null) { throw new ResourceDoesNotSupportOperationException( "updating an autoGenerationOption with missing parameters is not supported"); } return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.REF); }

Target:
public SimpleObject update(String uuid, SimpleObject postBody, RequestContext context) throws ResponseException { int id = 0; try { id = Integer.parseInt(uuid); } catch (NumberFormatException e) { throw new ValidationException("The uuid is either missing or not an integer"); } AutoGenerationOption autoGenerationOption = Context.getService(IdentifierSourceService.class) .getAutoGenerationOption(id); if (autoGenerationOption == null) { throw new ObjectNotFoundException(); } Object manualEntryEnabled = postBody.get("manualEntryEnabled"); Object automaticGenerationEnabled = postBody.get("automaticGenerationEnabled"); Object sourceUuid = postBody.get("source"); Object locationUuid = postBody.get("location"); IdentifierSource identifierSource = null; if (sourceUuid != null && StringUtils.isNotBlank(sourceUuid.toString())) { identifierSource = Context.getService(IdentifierSourceService.class) .getIdentifierSourceByUuid(sourceUuid.toString()); } Location location = null; if (locationUuid != null && StringUtils.isNotBlank(locationUuid.toString())) { location = Context.getLocationService().getLocationByUuid(locationUuid.toString()); } if (location == null && identifierSource == null && automaticGenerationEnabled == null && manualEntryEnabled == null) { throw new ResourceDoesNotSupportOperationException( "You must provide at least a location, or a source, or an automaticGenerationEnabled, or a manualEntryEnabled parameter to update an autoGenerationOption"); } if (manualEntryEnabled != null) { autoGenerationOption.setManualEntryEnabled(this.parseBoolean(manualEntryEnabled)); } if (automaticGenerationEnabled != null) { autoGenerationOption.setAutomaticGenerationEnabled(this.parseBoolean(automaticGenerationEnabled)); } if (identifierSource != null) { autoGenerationOption.setSource(identifierSource); } if (location != null) { autoGenerationOption.setLocation(location); } return (SimpleObject) ConversionUtil.convertToRepresentation(save(autoGenerationOption), Representation.REF); }