use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.
the class CommentTypeService method handleUpdate.
/**
* Update a CommentType identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the commentType object you wish to
* update
* @param commentType The updated commentType object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated commentType
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, CommentType commentType) {
CommentType existingCommentType = getCommentTypeOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingCommentType.getCode()) {
existingCommentType.setCode(existingCommentType.getCode());
}
if (null != existingCommentType.getDescription()) {
existingCommentType.setDescription(existingCommentType.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingCommentType.setVersion(version);
MetadataHateoas commentTypeHateoas = new MetadataHateoas(commentTypeRepository.save(existingCommentType));
metadataHateoasHandler.addLinks(commentTypeHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCommentType));
return commentTypeHateoas;
}
use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.
the class MetadataHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject metadataHateoas, JsonGenerator jgen) throws IOException {
if (!(noarkSystemIdEntity instanceof IMetadataEntity)) {
throw new NikitaException("Internal error when serialising " + noarkSystemIdEntity + " Not castable to nikita.common.model.noark5.v4.interfaces.entities.IMetadataEntity");
}
IMetadataEntity metadataEntity = (IMetadataEntity) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, metadataEntity);
if (metadataEntity.getCode() != null) {
jgen.writeStringField(CODE, metadataEntity.getCode());
}
if (metadataEntity.getDescription() != null) {
jgen.writeStringField(DESCRIPTION, metadataEntity.getDescription());
}
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, metadataHateoas.getLinks(metadataEntity));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.
the class CorrespondencePartTypeController method findBySystemId.
// 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
@RequestMapping(value = CORRESPONDENCE_PART_TYPE + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<MetadataHateoas> findBySystemId(@PathVariable("systemID") final String systemId, HttpServletRequest request) {
CorrespondencePartType correspondencePartType = correspondencePartTypeService.findBySystemId(systemId);
MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
metadataHateoasHandler.addLinks(metadataHateoas, 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.hateoas.metadata.MetadataHateoas 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
@RequestMapping(method = RequestMethod.GET, value = CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) correspondencePartTypeService.findAll(), CORRESPONDENCE_PART_TYPE);
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.
the class DocumentMediumController method findAll.
// API - All GET Requests (CRUD - READ)
// Retrieves all documentMedium
// GET [contextPath][api]/metadata/dokumentmedium/
@ApiOperation(value = "Retrieves all DocumentMedium ", response = DocumentMedium.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentMedium codes found", response = DocumentMedium.class), @ApiResponse(code = 404, message = "No DocumentMedium 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
@RequestMapping(method = RequestMethod.GET, value = DOCUMENT_MEDIUM)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
// ArrayList <DocumentMedium> documentMediumList = (ArrayList<DocumentMedium>) documentMediumService.findAll2();
MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) documentMediumService.findAll(), DOCUMENT_MEDIUM);
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Aggregations