use of nikita.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassHateoasController method createClassAssociatedWithClassificationSystem.
// API - All POST Requests (CRUD - CREATE)
// POST [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemID}/ny-underklass
@ApiOperation(value = "Persists a Class object associated with the (other) given Class systemId", notes = "Returns the newly created class object after it was associated with a class" + "object and persisted to the database", response = ClassHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Class " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = Class.class), @ApiResponse(code = 201, message = "Class " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = Class.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 Class"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + "classificationSystemSystemId" + RIGHT_PARENTHESIS + SLASH + NEW_SUB_CLASS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<ClassHateoas> createClassAssociatedWithClassificationSystem(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "classificationSystemSystemId", value = "systemId of classificationSystem to associate the klass with.", required = true) @PathVariable String classSystemId, @ApiParam(name = "klass", value = "Incoming class object", required = true) @RequestBody Class klass) throws NikitaException {
Class createdClass = classService.createClassAssociatedWithClass(classSystemId, klass);
ClassHateoas classHateoas = new ClassHateoas(createdClass);
classHateoasHandler.addLinks(classHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdClass));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdClass.getVersion().toString()).body(classHateoas);
}
use of nikita.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemHateoasController method deleteClassificationSystemBySystemId.
// Delete a ClassificationSystem identified by systemID
// DELETE [contextPath][api]/arkivstruktur/klassifikasjonsystem/{systemId}/
@ApiOperation(value = "Deletes a single ClassificationSystem entity identified by systemID", response = FondsStructureDetails.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent ApplicationDetails returned", response = FondsStructureDetails.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
@Timed
@RequestMapping(value = SLASH + CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<FondsStructureDetails> deleteClassificationSystemBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the ClassificationSystem to delete", required = true) @PathVariable("systemID") final String systemID) {
ClassificationSystem classificationSystem = classificationSystemService.findBySystemIdOrderBySystemId(systemID);
classificationSystemService.deleteEntity(systemID);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, classificationSystem));
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(applicationService.getFondsStructureDetails());
}
use of nikita.model.noark5.v4.ClassificationSystem 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);
}
use of nikita.model.noark5.v4.ClassificationSystem in project nikita-noark5-core by HiOA-ABI.
the class ClassifiactionSystemDeserializer method deserialize.
@Override
public ClassificationSystem deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
ClassificationSystem classificationSystem = new ClassificationSystem();
ObjectNode objectNode = mapper.readTree(jsonParser);
// Deserialise general properties
CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(classificationSystem, objectNode);
// If there are additional throw a malformed input exception
if (objectNode.size() != 0) {
throw new NikitaMalformedInputDataException("The klassifikasjonssystem you tried to create is " + "malformed. The following fields are not recognised as klassifikasjonssystem fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]");
}
return classificationSystem;
}
use of nikita.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);
}
Aggregations