use of nikita.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class DocumentDescriptionHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkEntity, HateoasNoarkObject documentDescriptionHateoas, JsonGenerator jgen) throws IOException {
DocumentDescription documentDescription = (DocumentDescription) noarkEntity;
jgen.writeStartObject();
// handle DocumentDescription properties
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentDescription);
if (documentDescription.getDocumentType() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_DOCUMENT_TYPE, documentDescription.getDocumentType());
}
if (documentDescription.getDocumentStatus() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_STATUS, documentDescription.getDocumentStatus());
}
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, documentDescription);
if (documentDescription.getDocumentNumber() != null) {
jgen.writeNumberField(DOCUMENT_DESCRIPTION_DOCUMENT_NUMBER, documentDescription.getDocumentNumber().intValue());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentDescription);
if (documentDescription.getAssociationDate() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATION_DATE, Serialize.formatDate(documentDescription.getAssociationDate()));
}
if (documentDescription.getAssociatedWithRecordAs() != null) {
jgen.writeStringField(DOCUMENT_DESCRIPTION_ASSOCIATED_WITH_RECORD_AS, documentDescription.getAssociatedWithRecordAs());
}
CommonUtils.Hateoas.Serialize.printComment(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposal(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDisposalUndertaken(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printDeletion(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printScreening(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printClassified(jgen, documentDescription);
if (documentDescription.getStorageLocation() != null) {
jgen.writeStringField(STORAGE_LOCATION, documentDescription.getStorageLocation());
}
CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentDescription);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentDescriptionHateoas.getLinks(documentDescription));
jgen.writeEndObject();
}
use of nikita.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordHateoasController 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
@Timed
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> 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) {
BasicRecord basicRecord = basicRecordService.findBySystemIdOrderBySystemId(systemID);
NoarkEntity parentEntity = basicRecord.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof File) {
hateoasNoarkObject = new FileHateoas(parentEntity);
fileHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else {
throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
}
basicRecordService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, basicRecord));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
use of nikita.model.noark5.v4.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class ClassHateoasController method deleteClassBySystemId.
// Delete a Class identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single Class 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> deleteClassBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the class to delete", required = true) @PathVariable("systemID") final String systemID) {
Class klass = classService.findBySystemIdOrderBySystemId(systemID);
NoarkEntity parentEntity = klass.chooseParent();
classService.deleteEntity(systemID);
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof ClassificationSystem) {
hateoasNoarkObject = new ClassificationSystemHateoas(parentEntity);
classificationSystemHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else {
throw new NikitaException("Internal error. Could process" + request.getRequestURI());
}
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, klass));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
use of nikita.model.noark5.v4.NoarkEntity 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.NoarkEntity in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method deleteFileBySystemId.
// Delete a File identified by systemID
// DELETE [contextPath][api]/arkivstruktur/mappe/{systemId}/
@ApiOperation(value = "Deletes a single File entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or File) 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> deleteFileBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to delete", required = true) @PathVariable("systemID") final String systemID) {
File file = fileService.findBySystemIdOrderBySystemId(systemID);
NoarkEntity parentEntity = file.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof File) {
hateoasNoarkObject = new FileHateoas(parentEntity);
fileHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else {
throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
}
fileService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, file));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Aggregations