Search in sources :

Example 6 with AfterNoarkEntityCreatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityCreatedEvent in project nikita-noark5-core by HiOA-ABI.

the class FondsCreatorHateoasController method createFondsCreator.

// API - All POST Requests (CRUD - CREATE)
// Create a new FondsCreator
// POST [contextPath][api]/arkivstruktur/ny-arkivskaper
@ApiOperation(value = "Persists a FondsCreator object", notes = "Returns the newly" + " created FondsCreator object after it is persisted to the database", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsCreatorHateoas.class), @ApiResponse(code = 201, message = "FondsCreator " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsCreatorHateoas.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 FondsCreator"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = { RequestMethod.POST }, value = NEW_FONDS_CREATOR, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsCreatorHateoas> createFondsCreator(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "FondsCreator", value = "Incoming FondsCreator object", required = true) @RequestBody FondsCreator fondsCreator) throws NikitaException {
    fondsCreatorService.createNewFondsCreator(fondsCreator);
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(fondsCreator);
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, fondsCreator));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsCreator.getVersion().toString()).body(fondsCreatorHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 7 with AfterNoarkEntityCreatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityCreatedEvent 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
@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, 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);
}
Also used : ClassHateoas(nikita.common.model.noark5.v4.hateoas.ClassHateoas) AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) Class(nikita.common.model.noark5.v4.Class) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 8 with AfterNoarkEntityCreatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityCreatedEvent 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 9 with AfterNoarkEntityCreatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityCreatedEvent in project nikita-noark5-core by HiOA-ABI.

the class FondsService method createSeriesAssociatedWithFonds.

/**
 * Persists a new Series object to the database. Some values are set in
 * the incoming payload (e.g. title) and some are set by the core. owner,
 * createdBy, createdDate are automatically set by the core.
 * <p>
 * First we try to locate the fonds to associate the Series with. If the
 * fonds does not exist a NoarkEntityNotFoundException exception is
 * thrown. Then we check that the fonds does not have children fonds. If it
 * does an NoarkInvalidStructureException exception is thrown. After that
 * we check that the Fonds object is not already closed.
 *
 * @param fondsSystemId The systemId of the fonds object to associate a
 *                      Series with
 * @param series        The incoming Series object
 * @return the newly persisted series object wrapped as a SeriesHateoas
 * object
 */
@Override
public SeriesHateoas createSeriesAssociatedWithFonds(@NotNull String fondsSystemId, @NotNull Series series) {
    Fonds fonds = getFondsOrThrow(fondsSystemId);
    checkFondsNotClosed(fonds);
    checkFondsDoesNotContainSubFonds(fonds);
    series.setReferenceFonds(fonds);
    SeriesHateoas seriesHateoas = new SeriesHateoas(seriesService.save(series));
    seriesHateoasHandler.addLinks(seriesHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, fonds));
    return seriesHateoas;
}
Also used : AfterNoarkEntityCreatedEvent(nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) Authorisation(nikita.webapp.security.Authorisation) SeriesHateoas(nikita.common.model.noark5.v4.hateoas.SeriesHateoas) Fonds(nikita.common.model.noark5.v4.Fonds)

Example 10 with AfterNoarkEntityCreatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityCreatedEvent in project nikita-noark5-core by HiOA-ABI.

the class RecordHateoasController method createDocumentDescriptionAssociatedWithRecord.

// API - All POST Requests (CRUD - CREATE)
// Create a new DocumentDescription and associate it with the given Record
// POST [contextPath][api]/arkivstruktur/registrering/{systemId}/ny-dokumentobjekt
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-dokumentobjekt/
@ApiOperation(value = "Persists a DocumentDescription object associated with the given Record systemId", notes = "Returns the newly created DocumentDescription object after it was associated with a " + "Record object and persisted to the database", response = DocumentDescriptionHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "DocumentDescription " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = DocumentDescriptionHateoas.class), @ApiResponse(code = 201, message = "DocumentDescription " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = DocumentDescriptionHateoas.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 DocumentDescription"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_DOCUMENT_DESCRIPTION, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<DocumentDescriptionHateoas> createDocumentDescriptionAssociatedWithRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of record to associate the documentDescription with.", required = true) @PathVariable String systemID, @ApiParam(name = "documentDescription", value = "Incoming documentDescription object", required = true) @RequestBody DocumentDescription documentDescription) throws NikitaException {
    DocumentDescription createdDocumentDescription = recordService.createDocumentDescriptionAssociatedWithRecord(systemID, documentDescription);
    DocumentDescriptionHateoas documentDescriptionHateoas = new DocumentDescriptionHateoas(createdDocumentDescription);
    documentDescriptionHateoasHandler.addLinks(documentDescriptionHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdDocumentDescription));
    return ResponseEntity.status(HttpStatus.CREATED).eTag(createdDocumentDescription.getVersion().toString()).body(documentDescriptionHateoas);
}
Also used : DocumentDescription(nikita.common.model.noark5.v4.DocumentDescription) 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)

Aggregations

Authorisation (nikita.webapp.security.Authorisation)13 AfterNoarkEntityCreatedEvent (nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)13 Counted (com.codahale.metrics.annotation.Counted)11 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Class (nikita.common.model.noark5.v4.Class)2 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)2 ClassHateoas (nikita.common.model.noark5.v4.hateoas.ClassHateoas)2 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)2 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)1 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)1 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)1 Fonds (nikita.common.model.noark5.v4.Fonds)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 ClassificationSystemHateoas (nikita.common.model.noark5.v4.hateoas.ClassificationSystemHateoas)1 DocumentObjectHateoas (nikita.common.model.noark5.v4.hateoas.DocumentObjectHateoas)1 FondsCreatorHateoas (nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas)1 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)1 SeriesHateoas (nikita.common.model.noark5.v4.hateoas.SeriesHateoas)1 RegistryEntryHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.RegistryEntryHateoas)1