use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method getCorrespondencePartInternalTemplate.
// Create a suggested CorrespondencePartInternal (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartintern
@ApiOperation(value = "Suggests the contents of a new CorrespondencePartInternal object", notes = "Returns a pre-filled CorrespondencePartInternal object" + " with values relevant for the logged-in user", response = CorrespondencePartInternalHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartInternalHateoas.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(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_INTERNAL })
public ResponseEntity<String> getCorrespondencePartInternalTemplate(HttpServletRequest request) throws NikitaException {
CorrespondencePartInternal suggestedCorrespondencePart = new CorrespondencePartInternal();
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);
// The reason this is not implemented is that we are missing AdministrativeUnit and multiple users
CorrespondencePartInternalHateoas correspondencePartHateoas = new CorrespondencePartInternalHateoas(suggestedCorrespondencePart);
correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("");
}
use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartTypeController method createCorrespondencePartType.
// API - All POST Requests (CRUD - CREATE)
// Creates a new korrespondanseparttype
// POST [contextPath][api]/metadata/korrespondanseparttype/ny-korrespondanseparttype
@ApiOperation(value = "Persists a new CorrespondencePartType object", notes = "Returns the newly" + " created CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.class), @ApiResponse(code = 201, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartType.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = CORRESPONDENCE_PART_TYPE + SLASH + NEW_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> createCorrespondencePartType(HttpServletRequest request, @RequestBody CorrespondencePartType correspondencePartType) throws NikitaException {
correspondencePartTypeService.createNewCorrespondencePartType(correspondencePartType);
MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartTypeController method findAll.
// API - All GET Requests (CRUD - READ)
// Retrieves all correspondencePartType
// GET [contextPath][api]/metadata/korrespondanseparttype/
@ApiOperation(value = "Retrieves all CorrespondencePartType ", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType codes found", response = CorrespondencePartType.class), @ApiResponse(code = 404, message = "No CorrespondencePartType found"), @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(method = RequestMethod.GET, value = CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(correspondencePartTypeService.findAllAsList()), CORRESPONDENCE_PART_TYPE);
metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartTypeController method findBySystemIdOrderBySystemId.
// Retrieves a given correspondencePartType identified by a systemId
// GET [contextPath][api]/metadata/korrespondanseparttype/{systemId}
@ApiOperation(value = "Gets correspondencePartType identified by its systemId", notes = "Returns the requested " + " correspondencePartType object", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.class), @ApiResponse(code = 201, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartType.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(value = CORRESPONDENCE_PART_TYPE + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemIdOrderBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
CorrespondencePartType correspondencePartType = correspondencePartTypeService.findBySystemIdOrderBySystemId(systemId);
MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.metadata.CorrespondencePartType in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartTypeService method getCorrespondencePartTypeOrThrow.
/**
* Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
* If you call this, be aware that you will only ever get a valid CorrespondencePartType back. If there is no valid
* CorrespondencePartType, an exception is thrown
*
* @param correspondencePartTypeCode
* @return
*/
protected CorrespondencePartType getCorrespondencePartTypeOrThrow(@NotNull String correspondencePartTypeCode) {
CorrespondencePartType correspondencePartType = correspondencePartTypeRepository.findByCode(correspondencePartTypeCode);
if (correspondencePartType == null) {
String info = INFO_CANNOT_FIND_OBJECT + " correspondencePartType, using kode " + correspondencePartTypeCode;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return correspondencePartType;
}
Aggregations