Search in sources :

Example 26 with ClassificationSystem

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

the class ClassificationSystemHateoasController method createClassificationSystemAssociatedWithFile.

// API - All POST Requests (CRUD - CREATE)
@ApiOperation(value = "Persists a ClassificationSystem object", notes = "Returns the newly created " + "classificationSystem object after it was 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.POST, value = NEW_CLASSIFICATION_SYSTEM, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<ClassificationSystemHateoas> createClassificationSystemAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "classificationSystem", value = "Incoming classificationSystem object", required = true) @RequestBody ClassificationSystem classificationSystem) throws NikitaException {
    ClassificationSystem createdClassificationSystem = classificationSystemService.createNewClassificationSystem(classificationSystem);
    ClassificationSystemHateoas classificationSystemHateoas = new ClassificationSystemHateoas(createdClassificationSystem);
    classificationSystemHateoasHandler.addLinks(classificationSystemHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdClassificationSystem));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdClassificationSystem.getVersion().toString()).body(classificationSystemHateoas);
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) ClassificationSystemHateoas(nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas) AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with ClassificationSystem

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

the class ClassificationSystemService method getClassificationSystemOrThrow.

// All HELPER operations
/**
 * Internal helper method. Rather than having a find and try catch in multiple methods, we have it here once.
 * If you call this, be aware that you will only ever get a valid ClassificationSystem back. If there is no valid
 * ClassificationSystem, an exception is thrown
 *
 * @param classificationSystemSystemId
 * @return
 */
protected ClassificationSystem getClassificationSystemOrThrow(@NotNull String classificationSystemSystemId) {
    ClassificationSystem classificationSystem = classificationSystemRepository.findBySystemId(classificationSystemSystemId);
    if (classificationSystem == null) {
        String info = INFO_CANNOT_FIND_OBJECT + " ClassificationSystem, using systemId " + classificationSystemSystemId;
        logger.info(info);
        throw new NoarkEntityNotFoundException(info);
    }
    return classificationSystem;
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem) NoarkEntityNotFoundException(nikita.common.util.exceptions.NoarkEntityNotFoundException)

Example 28 with ClassificationSystem

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

the class ClassificationSystemService method deleteEntity.

// All DELETE operations
@Override
public void deleteEntity(@NotNull String classificationSystemSystemId) {
    ClassificationSystem classificationSystem = getClassificationSystemOrThrow(classificationSystemSystemId);
    classificationSystemRepository.delete(classificationSystem);
}
Also used : ClassificationSystem(nikita.common.model.noark5.v4.ClassificationSystem)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)14 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)11 ClassificationSystem (nikita.model.noark5.v4.ClassificationSystem)11 Timed (com.codahale.metrics.annotation.Timed)7 Authorisation (nikita.webapp.security.Authorisation)7 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)7 ClassificationSystemHateoas (nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 ClassificationSystemHateoas (nikita.model.noark5.v4.hateoas.ClassificationSystemHateoas)5 Class (nikita.common.model.noark5.v4.Class)4 Class (nikita.model.noark5.v4.Class)4 ClassHateoas (nikita.common.model.noark5.v4.hateoas.ClassHateoas)3 NoarkEntityNotFoundException (nikita.common.util.exceptions.NoarkEntityNotFoundException)3 ClassHateoas (nikita.model.noark5.v4.hateoas.ClassHateoas)3 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)3 AfterNoarkEntityCreatedEvent (nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)3 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2