Search in sources :

Example 1 with ClassificationSystemHateoas

use of nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas in project nikita-noark5-core by HiOA-ABI.

the class ClassificationSystemHateoasController method findOne.

// API - All GET Requests (CRUD - READ)
@RequestMapping(value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<ClassificationSystemHateoas> findOne(HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of classificationSystem to retrieve.", required = true) @PathVariable("systemID") final String classificationSystemId) {
    ClassificationSystem classificationSystem = classificationSystemService.findBySystemIdOrderBySystemId(classificationSystemId);
    if (classificationSystem == null) {
        throw new NoarkEntityNotFoundException(classificationSystemId);
    }
    ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(classificationSystem);
    classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(classificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
Also used : ClassificationSystem(nikita.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.util.exceptions.NoarkEntityNotFoundException)

Example 2 with ClassificationSystemHateoas

use of nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas in project nikita-noark5-core by HiOA-ABI.

the class ClassificationSystemHateoasController method findAllClassificationSystem.

@ApiOperation(value = "Retrieves multiple ClassificationSystem entities limited by ownership rights", notes = "The field skip" + "tells how many ClassificationSystem 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 = ClassificationSystemHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "ClassificationSystem list found", response = ClassificationSystemHateoas.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 = CLASSIFICATION_SYSTEM, method = RequestMethod.GET)
public ResponseEntity<ClassificationSystemHateoas> findAllClassificationSystem(HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
    ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas((List<INikitaEntity>) (List) classificationSystemService.findClassificationSystemByOwnerPaginated(top, skip));
    classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(classificationSystemHateoas);
}
Also used : ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with ClassificationSystemHateoas

use of nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas in project nikita-noark5-core by HiOA-ABI.

the class ClassHateoasController method deleteClassBySystemId.

// Delete a Class identified by systemID
// DELETE [contextPath][api]/arkivstruktur/dokumentobjekt/{systemId}/
@ApiOperation(value = "Deletes a single Class 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<HateoasNoarkObject> deleteClassBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the class to delete", required = true) @PathVariable("systemID") final String systemID) {
    Class klass = classService.findBySystemId(systemID);
    NoarkEntity parentEntity = klass.chooseParent();
    classService.deleteEntity(systemID);
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else if (parentEntity instanceof ClassificationSystem) {
        hateoasNoarkObject = new ClassificationSystemHateoas(parentEntity);
        classificationSystemHateoasHandler.addLinks(hateoasNoarkObject, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could process" + request.getRequestURI());
    }
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, klass));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.common.util.exceptions.NikitaException) ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) NoarkEntity(nikita.common.model.noark5.v4.NoarkEntity) ClassHateoas(nikita.common.model.noark5.v4.hateoas.ClassHateoas) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject) Authorisation(nikita.webapp.security.Authorisation) 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 4 with ClassificationSystemHateoas

use of nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas in project nikita-noark5-core by HiOA-ABI.

the class ClassificationSystemHateoasController method findOne.

// API - All GET Requests (CRUD - READ)
@RequestMapping(value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<ClassificationSystemHateoas> findOne(HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemId", value = "systemId of classificationSystem to retrieve.", required = true) @PathVariable("systemID") final String classificationSystemId) {
    ClassificationSystem classificationSystem = classificationSystemService.findBySystemId(classificationSystemId);
    if (classificationSystem == null) {
        throw new NoarkEntityNotFoundException(classificationSystemId);
    }
    ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(classificationSystem);
    classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(classificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) Authorisation(nikita.webapp.security.Authorisation) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 5 with ClassificationSystemHateoas

use of nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas in project nikita-noark5-core by HiOA-ABI.

the class ClassificationSystemHateoasController method updateClassificationSystem.

// API - All PUT Requests (CRUD - UPDATE)
// Update a ClassificationSystem
// PUT [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemID}
@ApiOperation(value = "Updates a ClassificationSystem object", notes = "Returns the newly" + " update ClassificationSystem object after it is persisted to the database", response = ClassificationSystemHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "ClassificationSystem " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = ClassificationSystemHateoas.class), @ApiResponse(code = 201, message = "ClassificationSystem " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = ClassificationSystemHateoas.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 ClassificationSystem"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.PUT, value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<ClassificationSystemHateoas> updateClassificationSystem(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of classificationSystem to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "classificationSystem", value = "Incoming classificationSystem object", required = true) @RequestBody ClassificationSystem classificationSystem) throws NikitaException {
    validateForUpdate(classificationSystem);
    ClassificationSystem updatedClassificationSystem = classificationSystemService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), classificationSystem);
    ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(updatedClassificationSystem);
    classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedClassificationSystem));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedClassificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) Authorisation(nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)8 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiResponses (io.swagger.annotations.ApiResponses)8 ClassificationSystemHateoas (nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 ClassificationSystemHateoas (nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 Authorisation (nikita.webapp.security.Authorisation)5 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)5 Timed (com.codahale.metrics.annotation.Timed)4 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)4 ClassificationSystem (nikita.model.noark5.v4.ClassificationSystem)4 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Class (nikita.common.model.noark5.v4.Class)1 NoarkEntity (nikita.common.model.noark5.v4.NoarkEntity)1 ClassHateoas (nikita.common.model.noark5.v4.hateoas.ClassHateoas)1 HateoasNoarkObject (nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject)1 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)1 NikitaException (nikita.common.util.exceptions.NikitaException)1 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)1 Class (nikita.model.noark5.v4.Class)1