Source:
<code>public Response addDeviceOrganization(@Valid DeviceOrganizationMetadataHolder deviceOrganizationMetadataHolder) { if (deviceOrganizationMetadataHolder == null) { String errorMessage = "The payload of device metadata is empty."; return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); } DeviceOrganizationProviderService dops = new DeviceOrganizationProviderServiceImpl(); String tempId = deviceOrganizationMetadataHolder.getDeviceId(); String tempName = deviceOrganizationMetadataHolder.getDeviceName(); String tempParent = deviceOrganizationMetadataHolder.getParent(); int tempPingMins = deviceOrganizationMetadataHolder.getPingMins(); int tempState = deviceOrganizationMetadataHolder.getState(); int tempIsGateway = deviceOrganizationMetadataHolder.getIsGateway(); boolean result; try { <START> result = dops.addDeviceOrganization(tempId,tempName,tempParent,tempPingMins,tempState,tempIsGateway); <END> return Response.status(Response.Status.OK).entity(result).build(); } catch (DeviceOrganizationException e) { String msg = "Error occurred while enrolling the device with ID:" + tempId + " to Device Organization "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (InvalidConfigurationException e) { log.error("failed to add operation", e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } }</code><technical_language>Please check code formatting for classes</technical_language>

Target:
public Response addDeviceOrganization(@Valid DeviceOrganizationMetadataHolder deviceOrganizationMetadataHolder) { if (deviceOrganizationMetadataHolder == null) { String errorMessage = "The payload of device metadata is empty."; return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build(); } DeviceOrganizationProviderService dops = new DeviceOrganizationProviderServiceImpl(); String tempId = deviceOrganizationMetadataHolder.getDeviceId(); String tempName = deviceOrganizationMetadataHolder.getDeviceName(); String tempParent = deviceOrganizationMetadataHolder.getParent(); int tempPingMins = deviceOrganizationMetadataHolder.getPingMins(); int tempState = deviceOrganizationMetadataHolder.getState(); int tempIsGateway = deviceOrganizationMetadataHolder.getIsGateway(); boolean result; if (!"server".equals(tempId)) { try { result = dops.addDeviceOrganization(tempId, tempName, tempParent, tempPingMins, tempState, tempIsGateway); if (result) { String msg = "Device added successfully"; return Response.status(Response.Status.OK).entity(msg).build(); } else { String msg = "Unable to add device"; if (log.isDebugEnabled()) { log.debug(msg); } return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } catch (DeviceOrganizationException e) { String msg = "Error occurred while enrolling the device with ID:" + tempId + " to Device Organization "; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } catch (InvalidConfigurationException e) { log.error("failed to add operation", e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); } } else { String msg = "Cannot manually add server"; log.error(msg); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } }