Search in sources :

Example 56 with File

use of nikita.common.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.

the class SeriesHateoasController method createFileAssociatedWithSeries.

// API - All POST Requests (CRUD - CREATE)
// Create a new file
// POST [contextPath][api]/arkivstruktur/arkivdel/ny-mappe/
@ApiOperation(value = "Persists a File object associated with the given Series systemId", notes = "Returns the " + "newly created file object after it was associated with a Series object and persisted to the database", 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(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_FILE, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FileHateoas> createFileAssociatedWithSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of series to associate the caseFile with", required = true) @PathVariable String systemID, @ApiParam(name = "File", value = "Incoming file object", required = true) @RequestBody File file) throws NikitaException {
    validateForCreate(file);
    File createdFile = seriesService.createFileAssociatedWithSeries(systemID, file);
    FileHateoas fileHateoas = new FileHateoas(createdFile);
    fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdFile));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFile.getVersion().toString()).body(fileHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) Counted(com.codahale.metrics.annotation.Counted)

Example 57 with File

use of nikita.common.model.noark5.v4.File in project nikita-noark5-core by HiOA-ABI.

the class CaseFileHateoasController method createRegistryEntryAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
// Create a RegistryEntry entity
// POST [contextPath][api]/casehandling/{systemId}/ny-journalpost
@ApiOperation(value = "Persists a RegistryEntry object associated with the given Series systemId", notes = "Returns the newly created record object after it was associated with a File object and " + "persisted to the database", response = RegistryEntryHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "RegistryEntry " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RegistryEntryHateoas.class), @ApiResponse(code = 201, message = "RegistryEntry " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RegistryEntryHateoas.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 RegistryEntry"), @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_REGISTRY_ENTRY, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RegistryEntryHateoas> createRegistryEntryAssociatedWithFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "RegistryEntry", value = "Incoming registryEntry object", required = true) @RequestBody RegistryEntry registryEntry) throws NikitaException {
    RegistryEntry createdRegistryEntry = caseFileService.createRegistryEntryAssociatedWithCaseFile(systemID, registryEntry);
    RegistryEntryHateoas registryEntryHateoas = new RegistryEntryHateoas(createdRegistryEntry);
    registryEntryHateoasHandler.addLinks(registryEntryHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRegistryEntry));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRegistryEntry.getVersion().toString()).body(registryEntryHateoas);
}
Also used : RegistryEntryHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas) AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) RegistryEntry(nikita.common.model.noark5.v4.casehandling.RegistryEntry) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)31 ApiOperation (io.swagger.annotations.ApiOperation)23 ApiResponses (io.swagger.annotations.ApiResponses)23 Timed (com.codahale.metrics.annotation.Timed)15 File (nikita.model.noark5.v4.File)14 Authorisation (nikita.webapp.security.Authorisation)14 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)13 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)13 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)10 File (nikita.common.model.noark5.v4.File)8 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)8 CaseFileHateoas (nikita.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)8 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)7 List (java.util.List)5 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4