use of nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject 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
@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.findBySystemId(systemID);
NoarkEntity parentEntity = documentObject.chooseParent();
documentObjectService.deleteEntity(systemID);
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof DocumentDescription) {
hateoasNoarkObject = new DocumentDescriptionHateoas(parentEntity);
documentDescriptionHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else if (parentEntity instanceof Record) {
hateoasNoarkObject = new RecordHateoas(parentEntity);
recordHateoasHandler.addLinks(hateoasNoarkObject, 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.common.model.noark5.v4.hateoas.HateoasNoarkObject 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
@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.findBySystemId(systemID);
NoarkEntity parentEntity = file.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 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);
}
use of nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class CaseFileHateoasController method deleteCaseFileBySystemId.
// Delete a CaseFile identified by systemID
// DELETE [contextPath][api]/casehandling/saksmappe/{systemId}/
@ApiOperation(value = "Deletes a single CaseFile entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or CaseFile) 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<HateoasNoarkObject> deleteCaseFileBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the caseFile to delete", required = true) @PathVariable("systemID") final String systemID) {
CaseFile caseFile = caseFileService.findBySystemId(systemID);
NoarkEntity parentEntity = caseFile.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else // TODO: Can a casefile have a Class as parent???
if (parentEntity instanceof Class) {
hateoasNoarkObject = new ClassHateoas(parentEntity);
classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
} else {
throw new NikitaException("Internal error. Could not process " + request.getRequestURI());
}
caseFileService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, caseFile));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
use of nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class DocumentObjectHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject documentObjectHateoas, JsonGenerator jgen) throws IOException {
DocumentObject documentObject = (DocumentObject) noarkSystemIdEntity;
jgen.writeStartObject();
// handle DocumentObject properties
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentObject);
if (documentObject.getVersionNumber() != null) {
jgen.writeNumberField(DOCUMENT_OBJECT_VERSION_NUMBER, documentObject.getVersionNumber().intValue());
}
if (documentObject.getVariantFormat() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_VARIANT_FORMAT, documentObject.getVariantFormat());
}
if (documentObject.getFormat() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_FORMAT, documentObject.getFormat());
}
if (documentObject.getFormatDetails() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_FORMAT_DETAILS, documentObject.getFormatDetails());
}
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentObject);
if (documentObject.getReferenceDocumentFile() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_REFERENCE_DOCUMENT_FILE, documentObject.getReferenceDocumentFile());
}
if (documentObject.getChecksum() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM, documentObject.getChecksum());
}
if (documentObject.getChecksumAlgorithm() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM_ALGORITHM, documentObject.getChecksumAlgorithm());
}
if (documentObject.getFileSize() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_FILE_SIZE, Long.toString(documentObject.getFileSize()));
}
if (documentObject.getOriginalFilename() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_FILE_NAME, documentObject.getOriginalFilename());
}
if (documentObject.getMimeType() != null) {
jgen.writeStringField(DOCUMENT_OBJECT_MIME_TYPE, documentObject.getMimeType());
}
CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentObject);
CommonUtils.Hateoas.Serialize.printConversion(jgen, documentObject);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentObjectHateoas.getLinks(documentObject));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsCreatorHateoas, JsonGenerator jgen) throws IOException {
FondsCreator fondsCreator = (FondsCreator) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printFondsCreator(jgen, fondsCreator);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsCreatorHateoas.getLinks(fondsCreator));
jgen.writeEndObject();
}
Aggregations