use of nikita.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject recordHateoas, JsonGenerator jgen) throws IOException {
Record record = (Record) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, record);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, record);
if (record.getArchivedDate() != null) {
jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(record.getArchivedDate()));
}
if (record.getArchivedBy() != null) {
jgen.writeStringField(RECORD_ARCHIVED_BY, record.getArchivedBy());
}
CommonUtils.Hateoas.Serialize.printDisposal(jgen, record);
CommonUtils.Hateoas.Serialize.printScreening(jgen, record);
CommonUtils.Hateoas.Serialize.printClassified(jgen, record);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, recordHateoas.getLinks(record));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionHateoasController method deleteDocumentDescriptionBySystemId.
// Delete a DocumentDescription identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentDescription entity identified by systemID", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", response = RecordHateoas.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<RecordHateoas> deleteDocumentDescriptionBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentDescription to delete", required = true) @PathVariable("systemID") final String systemID) {
DocumentDescription documentDescription = documentDescriptionService.findBySystemIdOrderBySystemId(systemID);
List<Record> record = new ArrayList<>();
record.addAll(documentDescription.getReferenceRecord());
documentDescriptionService.deleteEntity(systemID);
RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) record);
recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentDescription));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
use of nikita.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectHateoasController method deleteDocumentObjectBySystemId.
// Delete a DocumentObject identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single DocumentObject entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteDocumentObjectBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the documentObject to delete", required = true) @PathVariable("systemID") final String systemID) {
DocumentObject documentObject = documentObjectService.findBySystemIdOrderBySystemId(systemID);
NoarkEntity parentEntity = documentObject.chooseParent();
documentObjectService.deleteEntity(systemID);
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof DocumentDescription) {
hateoasNoarkObject = new DocumentDescriptionHateoas(parentEntity);
documentDescriptionHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof Record) {
hateoasNoarkObject = new RecordHateoas(parentEntity);
recordHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else {
throw new NikitaException("Internal error. Could process" + request.getRequestURI());
}
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, documentObject));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
use of nikita.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasController method findOneRecordbySystemId.
// API - All GET Requests (CRUD - READ)
// Retrieve a Record identified by a systemId
// GET [contextPath][api]/arkivstruktur/registrering/{systemId}
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieves a single Record entity given a systemId", response = Record.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record returned", response = Record.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findOneRecordbySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to retrieve", required = true) @PathVariable("systemID") final String systemID) {
Record record = recordService.findBySystemIdOrderBySystemId(systemID);
RecordHateoas recordHateoas = new RecordHateoas(record);
recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(record.getVersion().toString()).body(recordHateoas);
}
use of nikita.model.noark5.v4.hateoas.RecordHateoas in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasController method findAllRecord.
// Retrieve all Records
// GET [contextPath][api]/arkivstruktur/registrering
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieves multiple Record entities limited by ownership rights", notes = "The field skip tells how many Record rows of the result set to ignore (starting at 0), " + "while top tells how many rows after skip to return. Note if the value of top is greater than " + "system value nikita-noark5-core.pagination.maxPageSize, then " + "nikita-noark5-core.pagination.maxPageSize is used.", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RecordHateoas found", response = RecordHateoas.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)
public ResponseEntity<RecordHateoas> findAllRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
RecordHateoas recordHateoas = new RecordHateoas((ArrayList<INikitaEntity>) (ArrayList) recordService.findRecordByOwnerPaginated(top, skip));
recordHateoasHandler.addLinks(recordHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
Aggregations