use of org.orcid.jaxb.model.record_rc4.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordService method getRecordOrThrow.
// All HELPER operations
/**
* 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 Record back. If there is no valid
* Record, an exception is thrown
*
* @param systemID
* @return
*/
protected Record getRecordOrThrow(@NotNull String systemID) {
Record record = recordRepository.findBySystemIdOrderBySystemId(systemID);
if (record == null) {
String info = INFO_CANNOT_FIND_OBJECT + " Record, using systemId " + systemID;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
}
return record;
}
use of org.orcid.jaxb.model.record_rc4.Record 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 org.orcid.jaxb.model.record_rc4.Record in project nikita-noark5-core by HiOA-ABI.
the class RecordHateoasController method findAllDocumentDescriptionAssociatedWithRecord.
// Retrieve all DocumentDescriptions associated with a Record identified by systemId
// GET [contextPath][api]/arkivstruktur/resgistrering/{systemId}/dokumentbeskrivelse
@ApiOperation(value = "Retrieves a lit of DocumentDescriptions associated with a Record", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription returned", response = DocumentDescriptionHateoas.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 + SLASH + DOCUMENT_DESCRIPTION, method = RequestMethod.GET)
public ResponseEntity<DocumentDescriptionHateoas> findAllDocumentDescriptionAssociatedWithRecord(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) {
Record record = recordService.findBySystemIdOrderBySystemId(systemID);
if (record == null) {
throw new NoarkEntityNotFoundException("Could not find File object with systemID " + systemID);
}
DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(new ArrayList<>(record.getReferenceDocumentDescription()));
documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(documentDescriptionHateoas);
}
use of org.orcid.jaxb.model.record_rc4.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 org.orcid.jaxb.model.record_rc4.Record in project nikita-noark5-core by HiOA-ABI.
the class FileService method createRecordAssociatedWithFile.
@Override
public Record createRecordAssociatedWithFile(String fileSystemId, Record record) {
Record persistedRecord = null;
File file = fileRepository.findBySystemIdOrderBySystemId(fileSystemId);
if (file == null) {
String info = INFO_CANNOT_FIND_OBJECT + " File, using fileSystemId " + fileSystemId;
logger.info(info);
throw new NoarkEntityNotFoundException(info);
} else {
record.setReferenceFile(file);
persistedRecord = recordService.save(record);
}
return persistedRecord;
}
Aggregations