use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject basicRecordHateoas, JsonGenerator jgen) throws IOException {
BasicRecord basicRecord = (BasicRecord) noarkSystemIdEntity;
jgen.writeStartObject();
// handle the record properties first
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, basicRecord);
if (basicRecord.getArchivedDate() != null) {
jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(basicRecord.getArchivedDate()));
}
if (basicRecord.getArchivedBy() != null) {
jgen.writeStringField(RECORD_ARCHIVED_BY, basicRecord.getArchivedBy());
}
CommonUtils.Hateoas.Serialize.printDisposal(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printScreening(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printClassified(jgen, basicRecord);
// handle general basicRecord properties
if (basicRecord.getTitle() != null) {
jgen.writeStringField(TITLE, basicRecord.getTitle());
}
if (basicRecord.getOfficialTitle() != null) {
jgen.writeStringField(FILE_PUBLIC_TITLE, basicRecord.getOfficialTitle());
}
if (basicRecord.getDescription() != null) {
jgen.writeStringField(DESCRIPTION, basicRecord.getDescription());
}
CommonUtils.Hateoas.Serialize.printKeyword(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printComment(jgen, basicRecord);
// TODO: FIX THIS CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, basicRecord);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, basicRecordHateoas.getLinks(basicRecord));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.Record 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.Record in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method findAllRecordsAssociatedWithFile.
// API - All GET Requests (CRUD - READ)
// Retrieve all Records associated with File identified by systemId
// GET [contextPath][api]/arkivstruktur/mappe/{systemId}/registrering
// REL http://rel.kxml.no/noark5/v4/api/arkivstruktur/registrering/
@ApiOperation(value = "Retrieve all Record associated with a File identified by systemId", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record 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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + REGISTRATION, method = RequestMethod.GET)
public ResponseEntity<RecordHateoas> findAllRecordsAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve associated Record", required = true) @PathVariable("systemID") final String systemID) {
File file = fileService.findBySystemId(systemID);
if (file == null) {
throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
}
RecordHateoas recordHateoas = new RecordHateoas((List<INikitaEntity>) (List) file.getReferenceRecord());
recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(recordHateoas);
}
use of nikita.model.noark5.v4.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasController method deleteRecordBySystemId.
// Delete a Record identified by systemID
// DELETE [contextPath][api]/arkivstruktur/registrering/{systemId}/
@ApiOperation(value = "Deletes a single Record 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
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteRecordBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
Record record = recordService.findBySystemId(systemID);
/* NoarkEntity parentEntity = record.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
}
else if (parentEntity instanceof File) {
hateoasNoarkObject = new FileHateoas(parentEntity);
fileHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
}
else if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
}
else {
throw new nikita.webapp.util.exceptions.NikitaException("Internal error. Could not process"
+ request.getRequestURI());
} */
recordService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, record));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("{\"status\": \"deleted\"}");
}
use of nikita.model.noark5.v4.Record 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
@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.findBySystemId(systemID);
RecordHateoas recordHateoas = new RecordHateoas(record);
recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(record.getVersion().toString()).body(recordHateoas);
}
Aggregations