use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method updateCorrespondencePartUnit.
// Update a CorrespondencePartUnit with given values
// PUT [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Updates a CorrespondencePartUnit identified by a given systemId", notes = "Returns the newly updated correspondencePartUnit", response = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 201, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type CorrespondencePartUnit"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CorrespondencePartUnitHateoas> updateCorrespondencePartUnit(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of correspondencePartUnit to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CorrespondencePartUnit", value = "Incoming correspondencePartUnit object", required = true) @RequestBody CorrespondencePartUnit correspondencePartUnit) throws NikitaException {
validateForUpdate(correspondencePartUnit);
CorrespondencePartUnit updatedCorrespondencePartUnit = correspondencePartService.updateCorrespondencePartUnit(systemID, parseETAG(request.getHeader(ETAG)), correspondencePartUnit);
CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(updatedCorrespondencePartUnit);
correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCorrespondencePartUnit));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCorrespondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method findOneCorrespondencePartUnitBySystemId.
// Get a CorrespondencePartPerson identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartUnit entity given a systemId", response = CorrespondencePartUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit returned", response = CorrespondencePartUnit.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartUnitHateoas> findOneCorrespondencePartUnitBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartUnit to retrieve", required = true) @PathVariable("systemID") final String correspondencePartUnitSystemId) {
CorrespondencePartUnit correspondencePartUnit = (CorrespondencePartUnit) correspondencePartService.findBySystemId(correspondencePartUnitSystemId);
CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(correspondencePartUnit);
correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method getCorrespondencePartUnitTemplate.
// Create a suggested CorrespondencePartUnit (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartenhet
@ApiOperation(value = "Suggests the contents of a new CorrespondencePart object", notes = "Returns a pre-filled CorrespondencePart object" + " with values relevant for the logged-in user", response = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_UNIT })
public ResponseEntity<CorrespondencePartUnitHateoas> getCorrespondencePartUnitTemplate(HttpServletRequest request) throws NikitaException {
CorrespondencePartUnit suggestedCorrespondencePart = new CorrespondencePartUnit();
CorrespondencePartType correspondencePartType = correspondencePartTypeService.findByCode(CORRESPONDENCE_PART_CODE_EA);
if (correspondencePartType == null) {
throw new NikitaException("Internal error, metadata missing. [" + CORRESPONDENCE_PART_CODE_EA + "] returns no value");
}
suggestedCorrespondencePart.setCorrespondencePartType(correspondencePartType);
PostalAddress postalAddress = new PostalAddress();
postalAddress.setAddressType(POSTAL_ADDRESS);
postalAddress.setAddressLine1("ADRL1: 744 Evergreen Terrace");
postalAddress.setAddressLine2("ADRL2: 744 Evergreen Terrace");
postalAddress.setAddressLine3("ADRL3: 744 Evergreen Terrace");
postalAddress.setCountryCode("US");
postalAddress.setPostalNumber(new PostalNumber("12345"));
postalAddress.setPostalTown("Springfield");
suggestedCorrespondencePart.setPostalAddress(postalAddress);
BusinessAddress businessAddress = new BusinessAddress();
businessAddress.setAddressType(BUSINESS_ADDRESS);
businessAddress.setAddressLine1("ADRL1: 745 Evergreen Terrace");
businessAddress.setAddressLine2("ADRL2: 745 Evergreen Terrace");
businessAddress.setAddressLine3("ADRL3: 745 Evergreen Terrace");
businessAddress.setCountryCode("US");
businessAddress.setPostalNumber(new PostalNumber("12345"));
businessAddress.setPostalTown("Springfield");
suggestedCorrespondencePart.setBusinessAddress(businessAddress);
suggestedCorrespondencePart.setContactPerson("Frank Contact Person Grimes");
ContactInformation contactInformation = new ContactInformation();
contactInformation.setEmailAddress("nikita@example.com");
contactInformation.setMobileTelephoneNumber("123456789");
contactInformation.setTelephoneNumber("987654321");
suggestedCorrespondencePart.setContactInformation(contactInformation);
suggestedCorrespondencePart.setName("Frank Grimes");
CorrespondencePartUnitHateoas correspondencePartHateoas = new CorrespondencePartUnitHateoas(suggestedCorrespondencePart);
correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(correspondencePartHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method updateCorrespondencePartUnit.
// Update a CorrespondencePartUnit with given values
// PUT [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Updates a CorrespondencePartUnit identified by a given systemId", notes = "Returns the newly updated correspondencePartUnit", response = CorrespondencePartUnitHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 201, message = "CorrespondencePartUnit " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartUnitHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type CorrespondencePartUnit"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CorrespondencePartUnitHateoas> updateCorrespondencePartUnit(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of correspondencePartUnit to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "CorrespondencePartUnit", value = "Incoming correspondencePartUnit object", required = true) @RequestBody CorrespondencePartUnit correspondencePartUnit) throws NikitaException {
validateForUpdate(correspondencePartUnit);
CorrespondencePartUnit updatedCorrespondencePartUnit = correspondencePartService.updateCorrespondencePartUnit(systemID, parseETAG(request.getHeader(ETAG)), correspondencePartUnit);
CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(updatedCorrespondencePartUnit);
correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedCorrespondencePartUnit));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedCorrespondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
use of nikita.model.noark5.v4.hateoas.casehandling.CorrespondencePartUnitHateoas in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartHateoasController method findOneCorrespondencePartUnitBySystemId.
// Get a CorrespondencePartPerson identified by systemID
// GET [contextPath][api]/casehandling/korrespondansepartenhet/{systemId}
@ApiOperation(value = "Retrieves a single CorrespondencePartUnit entity given a systemId", response = CorrespondencePartUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartUnit returned", response = CorrespondencePartUnit.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<CorrespondencePartUnitHateoas> findOneCorrespondencePartUnitBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the correspondencePartUnit to retrieve", required = true) @PathVariable("systemID") final String correspondencePartUnitSystemId) {
CorrespondencePartUnit correspondencePartUnit = (CorrespondencePartUnit) correspondencePartService.findBySystemIdOrderBySystemId(correspondencePartUnitSystemId);
CorrespondencePartUnitHateoas correspondencePartUnitHateoas = new CorrespondencePartUnitHateoas(correspondencePartUnit);
correspondencePartHateoasHandler.addLinks(correspondencePartUnitHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartUnit.getVersion().toString()).body(correspondencePartUnitHateoas);
}
Aggregations