use of nikita.common.model.noark5.v4.File 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.common.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method updateFile.
// API - All PUT Requests (CRUD - UPDATE)
// Update a File with given values
// PUT [contextPath][api]/arkivstruktur/mappe/{systemId}
@ApiOperation(value = "Updates a File identified by a given systemId", notes = "Returns the newly updated file", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FileHateoas.class), @ApiResponse(code = 201, message = "File " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FileHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type File"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FileHateoas> updateFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of file to update", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "File", value = "Incoming file object", required = true) @RequestBody File file) throws NikitaException {
validateForUpdate(file);
File updatedFile = fileService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), file);
FileHateoas fileHateoas = new FileHateoas(updatedFile);
fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedFile));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedFile.getVersion().toString()).body(fileHateoas);
}
use of nikita.common.model.noark5.v4.File 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.common.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class SeriesHateoasController method createCaseFileAssociatedWithSeries.
// Create a new casefile
// POST [contextPath][api]/arkivstruktur/arkivdel/{systemId}/ny-saksmappe/
// This currently is not supported in the standard, but probably will be later
@ApiOperation(value = "Persists a CaseFile object associated with the given Series systemId", notes = "Returns " + "the newly created caseFile object after it was associated with a Series object and persisted to " + "the database", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CaseFileHateoas.class), @ApiResponse(code = 201, message = "File " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CaseFileHateoas.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_PARENT_DOES_NOT_EXIST + " of type CaseFile"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CASE_FILE, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<CaseFileHateoas> createCaseFileAssociatedWithSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of series to associate the caseFile with", required = true) @PathVariable String systemID, @ApiParam(name = "caseFile", value = "Incoming caseFile object", required = true) @RequestBody CaseFile caseFile) throws NikitaException {
validateForCreate(caseFile);
CaseFile createdCaseFile = seriesService.createCaseFileAssociatedWithSeries(systemID, caseFile);
CaseFileHateoas caseFileHateoas = new CaseFileHateoas(createdCaseFile);
caseFileHateoasHandler.addLinks(caseFileHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdCaseFile));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdCaseFile.getVersion().toString()).body(caseFileHateoas);
}
use of nikita.common.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.
the class SeriesHateoasController method createDefaultFile.
// Create a File object with default values
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/ny-mappe/
@ApiOperation(value = "Create a File with default values", response = File.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File returned", response = File.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 + NEW_FILE, method = RequestMethod.GET)
public ResponseEntity<FileHateoas> createDefaultFile(HttpServletRequest request, final HttpServletResponse response) {
File defaultFile = new File();
defaultFile = setFileDefaults(defaultFile);
FileHateoas fileHateoas = new FileHateoas(defaultFile);
fileHateoasHandler.addLinksOnNew(fileHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fileHateoas);
}
Aggregations