Search in sources :

Example 16 with CorrespondencePartType

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

the class RegistryEntryHateoasController method getCorrespondencePartInternalTemplate.

// Create a suggested CorrespondencePartInternal (like a template) object with default values (nothing persisted)
// GET [contextPath][api]/casehandling/journalpost/{systemId}/ny-korrespondansepartintern
@ApiOperation(value = "Suggests the contents of a new CorrespondencePartInternal object", notes = "Returns a pre-filled CorrespondencePartInternal object" + " with values relevant for the logged-in user", response = CorrespondencePartInternalHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePart " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartInternalHateoas.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(method = RequestMethod.GET, value = { SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_CORRESPONDENCE_PART_INTERNAL })
public ResponseEntity<String> getCorrespondencePartInternalTemplate(HttpServletRequest request) throws NikitaException {
    CorrespondencePartInternal suggestedCorrespondencePart = new CorrespondencePartInternal();
    CorrespondencePartType correspondencePartType = correspondencePartTypeService.findByCode(CORRESPONDENCE_PART_CODE_EA);
    if (correspondencePartType == null) {
        throw new NikitaException("Internal error, metadata missing. [" + CORRESPONDENCE_PART_CODE_EA + "] returns no value");
    }
    suggestedCorrespondencePart.setCorrespondencePartType(correspondencePartType);
    // The reason this is not implemented is that we are missing AdministrativeUnit and multiple users
    CorrespondencePartInternalHateoas correspondencePartHateoas = new CorrespondencePartInternalHateoas(suggestedCorrespondencePart);
    correspondencePartHateoasHandler.addLinksOnTemplate(correspondencePartHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("");
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with CorrespondencePartType

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

the class CorrespondencePartTypeController method createCorrespondencePartType.

// API - All POST Requests (CRUD - CREATE)
// Creates a new korrespondanseparttype
// POST [contextPath][api]/metadata/korrespondanseparttype/ny-korrespondanseparttype
@ApiOperation(value = "Persists a new CorrespondencePartType object", notes = "Returns the newly" + " created CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.class), @ApiResponse(code = 201, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = CorrespondencePartType.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), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@RequestMapping(method = RequestMethod.POST, value = CORRESPONDENCE_PART_TYPE + SLASH + NEW_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> createCorrespondencePartType(HttpServletRequest request, @RequestBody CorrespondencePartType correspondencePartType) throws NikitaException {
    correspondencePartTypeService.createNewCorrespondencePartType(correspondencePartType);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 18 with CorrespondencePartType

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

the class CorrespondencePartTypeController method getCorrespondencePartTypeTemplate.

// Create a suggested correspondencePartType(like a template) with default values (nothing persisted)
// GET [contextPath][api]/metadata/ny-korrespondanseparttype
@ApiOperation(value = "Creates a suggested CorrespondencePartType", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType codes found", response = CorrespondencePartType.class), @ApiResponse(code = 404, message = "No CorrespondencePartType found"), @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(method = RequestMethod.GET, value = NEW_CORRESPONDENCE_PART_TYPE)
public ResponseEntity<MetadataHateoas> getCorrespondencePartTypeTemplate(HttpServletRequest request) {
    CorrespondencePartType correspondencePartType = new CorrespondencePartType();
    correspondencePartType.setCode(TEMPLATE_FONDS_STATUS_CODE);
    correspondencePartType.setDescription(TEMPLATE_FONDS_STATUS_DESCRIPTION);
    MetadataHateoas metadataHateoas = new MetadataHateoas(correspondencePartType);
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 19 with CorrespondencePartType

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

the class CorrespondencePartTypeController method updateCorrespondencePartTypeUnit.

// API - All PUT Requests (CRUD - UPDATE)
// Update a korrespondanseparttype
// PUT [contextPath][api]/metatdata/korrespondanseparttype/
@ApiOperation(value = "Updates a CorrespondencePartType object", notes = "Returns the newly" + " updated CorrespondencePartType object after it is persisted to the database", response = CorrespondencePartType.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "CorrespondencePartType " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = CorrespondencePartType.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
@RequestMapping(method = RequestMethod.PUT, value = CORRESPONDENCE_PART_TYPE + UNIT + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS)
public ResponseEntity<MetadataHateoas> updateCorrespondencePartTypeUnit(@RequestBody CorrespondencePartType correspondencePartType, HttpServletRequest request) throws NikitaException {
    CorrespondencePartType updatedCorrespondencePartType = correspondencePartTypeService.update(correspondencePartType);
    MetadataHateoas metadataHateoas = new MetadataHateoas(updatedCorrespondencePartType);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(correspondencePartType.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) CorrespondencePartType(nikita.common.model.noark5.v4.metadata.CorrespondencePartType) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)16 ApiOperation (io.swagger.annotations.ApiOperation)16 ApiResponses (io.swagger.annotations.ApiResponses)16 Timed (com.codahale.metrics.annotation.Timed)8 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)8 Authorisation (nikita.webapp.security.Authorisation)7 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)6 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)5 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)5 NikitaException (nikita.common.util.exceptions.NikitaException)3 NikitaException (nikita.util.exceptions.NikitaException)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Record (nikita.common.model.noark5.v4.Record)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)1 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1