Search in sources :

Example 11 with AfterNoarkEntityUpdatedEvent

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

the class CaseStatusService method handleUpdate.

/**
 * Update a CaseStatus identified by its systemId
 * <p>
 * Copy the values you are allowed to change, code and description
 *
 * @param systemId   The systemId of the caseStatus object you wish to
 *                   update
 * @param caseStatus The updated caseStatus object. Note the values
 *                   you are allowed to change are copied from this
 *                   object. This object is not persisted.
 * @return the updated caseStatus
 */
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, CaseStatus caseStatus) {
    CaseStatus existingCaseStatus = getCaseStatusOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != existingCaseStatus.getCode()) {
        existingCaseStatus.setCode(existingCaseStatus.getCode());
    }
    if (null != existingCaseStatus.getDescription()) {
        existingCaseStatus.setDescription(existingCaseStatus.getDescription());
    }
    // Note this can potentially result in a NoarkConcurrencyException
    // exception
    existingCaseStatus.setVersion(version);
    MetadataHateoas caseStatusHateoas = new MetadataHateoas(caseStatusRepository.save(existingCaseStatus));
    metadataHateoasHandler.addLinks(caseStatusHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCaseStatus));
    return caseStatusHateoas;
}
Also used : CaseStatus(nikita.common.model.noark5.v4.metadata.CaseStatus) Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)

Example 12 with AfterNoarkEntityUpdatedEvent

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

the class CommentTypeService method handleUpdate.

/**
 * Update a CommentType identified by its systemId
 * <p>
 * Copy the values you are allowed to change, code and description
 *
 * @param systemId    The systemId of the commentType object you wish to
 *                    update
 * @param commentType The updated commentType object. Note the values
 *                    you are allowed to change are copied from this
 *                    object. This object is not persisted.
 * @return the updated commentType
 */
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, CommentType commentType) {
    CommentType existingCommentType = getCommentTypeOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != existingCommentType.getCode()) {
        existingCommentType.setCode(existingCommentType.getCode());
    }
    if (null != existingCommentType.getDescription()) {
        existingCommentType.setDescription(existingCommentType.getDescription());
    }
    // Note this can potentially result in a NoarkConcurrencyException
    // exception
    existingCommentType.setVersion(version);
    MetadataHateoas commentTypeHateoas = new MetadataHateoas(commentTypeRepository.save(existingCommentType));
    metadataHateoasHandler.addLinks(commentTypeHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingCommentType));
    return commentTypeHateoas;
}
Also used : CommentType(nikita.common.model.noark5.v4.metadata.CommentType) Authorisation(nikita.webapp.security.Authorisation) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)

Example 13 with AfterNoarkEntityUpdatedEvent

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

the class DocumentObjectHateoasController method updateDocumentObject.

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

Example 14 with AfterNoarkEntityUpdatedEvent

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

the class FondsCreatorHateoasController method updateFondsCreator.

// API - All PUT Requests (CRUD - UPDATE)
// Updates a FondsCreator identified by a systemId
// PUT [contextPath][api]/arkivstruktur/arkivskaper/{systemId}
@ApiOperation(value = "Updates a FondsCreator identified by a systemId with new values", response = FondsCreator.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator updated", response = FondsCreator.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 = FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.PUT, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsCreatorHateoas> updateFondsCreator(HttpServletRequest request, @ApiParam(name = "fondsCreator", value = "Incoming fondsCreator object", required = true) @RequestBody FondsCreator fondsCreator, @ApiParam(name = "systemId", value = "systemId of FondsCreator to retrieve.", required = true) @PathVariable("systemID") final String systemID) {
    FondsCreator createdFonds = fondsCreatorService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), fondsCreator);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, createdFonds));
    FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas(createdFonds);
    fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFonds.getVersion().toString()).body(fondsCreatorHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) FondsCreatorHateoas(nikita.common.model.noark5.v4.hateoas.FondsCreatorHateoas) FondsCreator(nikita.common.model.noark5.v4.FondsCreator) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 15 with AfterNoarkEntityUpdatedEvent

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

the class RecordHateoasController method updateRecord.

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

Aggregations

Authorisation (nikita.webapp.security.Authorisation)34 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)34 MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)17 Counted (com.codahale.metrics.annotation.Counted)15 ApiOperation (io.swagger.annotations.ApiOperation)14 ApiResponses (io.swagger.annotations.ApiResponses)14 FondsHateoas (nikita.common.model.noark5.v4.hateoas.FondsHateoas)3 Fonds (nikita.common.model.noark5.v4.Fonds)2 CaseFileHateoas (nikita.common.model.noark5.v4.hateoas.casehandling.CaseFileHateoas)2 Class (nikita.common.model.noark5.v4.Class)1 ClassificationSystem (nikita.common.model.noark5.v4.ClassificationSystem)1 DocumentDescription (nikita.common.model.noark5.v4.DocumentDescription)1 DocumentObject (nikita.common.model.noark5.v4.DocumentObject)1 FondsCreator (nikita.common.model.noark5.v4.FondsCreator)1 Record (nikita.common.model.noark5.v4.Record)1 CaseFile (nikita.common.model.noark5.v4.casehandling.CaseFile)1 RegistryEntry (nikita.common.model.noark5.v4.casehandling.RegistryEntry)1 CorrespondencePartInternal (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartInternal)1 CorrespondencePartPerson (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)1 CorrespondencePartUnit (nikita.common.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)1