use of nikita.model.noark5.v4.DocumentDescription 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);
}
use of nikita.model.noark5.v4.DocumentDescription 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
@Timed
@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.findBySystemIdOrderBySystemId(systemID);
/* NoarkEntity parentEntity = record.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 no.arkivlab.hioa.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.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class AdministrativeUnitController method updateAdministrativeUnit.
// API - All PUT Requests (CRUD - UPDATE)
// Update a administrativtenhet
// PUT [contextPath][api]/metatdata/administrativtenhet/{systemID}
@ApiOperation(value = "Updates a AdministrativeUnit object", notes = "Returns the newly" + " updated AdministrativeUnit object after it is persisted to the database", response = AdministrativeUnit.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "AdministrativeUnit " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = AdministrativeUnit.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.PUT, value = ADMINISTRATIVE_UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS)
public ResponseEntity<AdministrativeUnitHateoas> updateAdministrativeUnit(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of documentDescription to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "administrativeUnit", value = "Incoming administrativeUnit object", required = true) @RequestBody AdministrativeUnit administrativeUnit) throws NikitaException {
AdministrativeUnit newAdministrativeUnit = administrativeUnitService.update(systemID, parseETAG(request.getHeader(ETAG)), administrativeUnit);
AdministrativeUnitHateoas adminHateoas = new AdministrativeUnitHateoas(administrativeUnit);
administrativeUnitHateoasHandler.addLinks(adminHateoas, request, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(adminHateoas);
}
use of nikita.model.noark5.v4.DocumentDescription 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
@Timed
@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.findBySystemIdOrderBySystemId(systemID);
NoarkEntity parentEntity = caseFile.chooseParent();
HateoasNoarkObject hateoasNoarkObject;
if (parentEntity instanceof Series) {
hateoasNoarkObject = new SeriesHateoas(parentEntity);
seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
} else // TODO: Can a casefile have a Class as parent???
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());
}
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.model.noark5.v4.DocumentDescription in project nikita-noark5-core by HiOA-ABI.
the class RegistryEntryHateoasController method deleteRecordBySystemId.
// Delete a Record identified by systemID
// DELETE [contextPath][api]/casehandling/journalpost/{systemId}/
@ApiOperation(value = "Deletes a single RegistryEntry entity identified by systemID", response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = String.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<String> deleteRecordBySystemId(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
RegistryEntry registryEntry = registryEntryService.findBySystemIdOrderBySystemId(systemID);
registryEntryService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, registryEntry));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(CommonUtils.WebUtils.getSuccessStatusStringForDelete());
}
Aggregations