Search in sources :

Example 21 with Series

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

the class FondsHateoasController method createSeriesAssociatedWithFonds.

// Create a Series and associate it with the Fonds identified by systemId
// POST [contextPath][api]/arkivstruktur/arkiv/{systemId}/ny-arkivdel
@ApiOperation(value = "Persists a Series object associated with the given Fonds" + " systemId", notes = "Returns the newly created Series object after it was " + "associated with a Fonds object and persisted to the " + "database", response = SeriesHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesHateoas.class), @ApiResponse(code = 201, message = "Series" + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesHateoas.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 " + "Series"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@RequestMapping(method = RequestMethod.POST, value = FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_SERIES, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<SeriesHateoas> createSeriesAssociatedWithFonds(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of fonds to associate the series with.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "series", value = "Incoming series object", required = true) @RequestBody Series series) throws NikitaException {
    validateForCreate(series);
    SeriesHateoas seriesHateoas = fondsService.createSeriesAssociatedWithFonds(systemID, series);
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(seriesHateoas.getEntityVersion().toString()).body(seriesHateoas);
}
Also used : SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 22 with Series

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

the class SeriesHateoasController method findAllCaseFileAssociatedWithCaseFile.

// Retrieve all CaseFiles associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/saksmappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of CaseFiles associated with a Series", notes = "The field skip" + "tells how many CaseFile rows of the result set to ignore (starting at 0), while  top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = CaseFileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CaseFile list found", response = CaseFileHateoas.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 + CASE_FILE, method = RequestMethod.GET)
public ResponseEntity<CaseFileHateoas> findAllCaseFileAssociatedWithCaseFile(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    seriesService.findAllCaseFileBySeries(systemID);
    CaseFileHateoas caseFileHateoas = new CaseFileHateoas((List<INikitaEntity>) (List) seriesService.findAllCaseFileBySeries(systemID));
    caseFileHateoasHandler.addLinksOnRead(caseFileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(caseFileHateoas);
}
Also used : CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted)

Example 23 with Series

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

the class SeriesHateoasController method findAllFileAssociatedWithSeries.

// Retrieve all Files associated with a Series (paginated)
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/
// GET [contextPath][api]/arkivstruktur/arkivdel/{systemId}/mappe/?top=5&skip=1
@ApiOperation(value = "Retrieves a list of Files associated with a Series", notes = "The field skip" + "tells how many File rows of the result set to ignore (starting at 0), while  top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File list found", response = FileHateoas.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 + FILE, method = RequestMethod.GET)
public ResponseEntity<FileHateoas> findAllFileAssociatedWithSeries(HttpServletRequest request, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip, @ApiParam(name = "systemID", value = "systemID of the series to retrieve", required = true) @PathVariable("systemID") final String systemID) {
    Series series = seriesService.findBySystemId(systemID);
    if (series == null) {
        throw new NoarkEntityNotFoundException("Could not find series object with systemID " + systemID);
    }
    FileHateoas fileHateoas = new FileHateoas((List<INikitaEntity>) (List) series.getReferenceFile());
    fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fileHateoas);
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException) List(java.util.List) CaseFileHateoas(nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas) Counted(com.codahale.metrics.annotation.Counted)

Example 24 with Series

use of nikita.common.model.noark5.v4.Series 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);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Series(nikita.common.model.noark5.v4.Series) NoarkEntity(nikita.common.model.noark5.v4.NoarkEntity) ClassHateoas(nikita.common.model.noark5.v4.hateoas.ClassHateoas) CaseFile(nikita.common.model.noark5.v4.casehandling.CaseFile) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(nikita.webapp.security.Authorisation) SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas) Class(nikita.common.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 25 with Series

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

the class FileDeserializer method deserialize.

@Override
public File deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    File file = new File();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(file, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseDocumentMedium(file, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseStorageLocation(file, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseKeyword(file, objectNode);
    // Deserialize fileId
    JsonNode currentNode = objectNode.get(FILE_ID);
    if (null != currentNode) {
        file.setFileId(currentNode.textValue());
        objectNode.remove(FILE_ID);
    }
    // Deserialize officialTitle
    currentNode = objectNode.get(FILE_PUBLIC_TITLE);
    if (null != currentNode) {
        file.setOfficialTitle(currentNode.textValue());
        objectNode.remove(FILE_PUBLIC_TITLE);
    }
    // TODO: FIX THIS CommonCommonUtils.Hateoas.Deserialize.deserialiseCrossReference(file, objectNode);
    CommonUtils.Hateoas.Deserialize.deserialiseComments(file, objectNode);
    file.setReferenceDisposal(CommonUtils.Hateoas.Deserialize.deserialiseDisposal(objectNode));
    file.setReferenceScreening(CommonUtils.Hateoas.Deserialize.deserialiseScreening(objectNode));
    file.setReferenceClassified(CommonUtils.Hateoas.Deserialize.deserialiseClassified(objectNode));
    // Deserialize referenceSeries
    currentNode = objectNode.get(REFERENCE_SERIES);
    if (null != currentNode) {
        Series series = new Series();
        String systemID = currentNode.textValue();
        if (systemID != null) {
            series.setSystemId(systemID);
        }
        file.setReferenceSeries(series);
        objectNode.remove(REFERENCE_SERIES);
    }
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        throw new NikitaMalformedInputDataException("The mappe you tried to create is malformed. The " + "following fields are not recognised as mappe fields  [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
    }
    return file;
}
Also used : Series(nikita.model.noark5.v4.Series) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode) File(nikita.model.noark5.v4.File) NikitaMalformedInputDataException(nikita.util.exceptions.NikitaMalformedInputDataException)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)29 Series (nikita.model.noark5.v4.Series)20 ApiOperation (io.swagger.annotations.ApiOperation)18 ApiResponses (io.swagger.annotations.ApiResponses)18 Timed (com.codahale.metrics.annotation.Timed)16 Authorisation (nikita.webapp.security.Authorisation)13 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)13 Series (nikita.common.model.noark5.v4.Series)11 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)11 CaseFile (nikita.model.noark5.v4.casehandling.CaseFile)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)6 Fonds (nikita.model.noark5.v4.Fonds)6 NoarkEntityEditWhenClosedException (nikita.util.exceptions.NoarkEntityEditWhenClosedException)6 List (java.util.List)5 SeriesHateoas (nikita.common.model.noark5.v4.hateoas.SeriesHateoas)5 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 SeriesHateoas (nikita.model.noark5.v4.hateoas.SeriesHateoas)5