Search in sources :

Example 21 with AfterNoarkEntityUpdatedEvent

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

the class PostalCodeService method handleUpdate.

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

Example 22 with AfterNoarkEntityUpdatedEvent

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

the class RegistryEntryStatusService method handleUpdate.

/**
 * Update a RegistryEntryStatus identified by its systemId
 * <p>
 * Copy the values you are allowed to change, code and description
 *
 * @param RegistryEntryStatus
 * @return the updated RegistryEntryStatus
 */
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, RegistryEntryStatus RegistryEntryStatus) {
    RegistryEntryStatus existingRegistryEntryStatus = getRegistryEntryStatusOrThrow(systemId);
    // Copy all the values you are allowed to copy ....
    if (null != existingRegistryEntryStatus.getCode()) {
        existingRegistryEntryStatus.setCode(existingRegistryEntryStatus.getCode());
    }
    if (null != existingRegistryEntryStatus.getDescription()) {
        existingRegistryEntryStatus.setDescription(existingRegistryEntryStatus.getDescription());
    }
    // Note this can potentially result in a NoarkConcurrencyException
    // exception
    existingRegistryEntryStatus.setVersion(version);
    MetadataHateoas RegistryEntryStatusHateoas = new MetadataHateoas(RegistryEntryStatusRepository.save(existingRegistryEntryStatus));
    metadataHateoasHandler.addLinks(RegistryEntryStatusHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingRegistryEntryStatus));
    return RegistryEntryStatusHateoas;
}
Also used : Authorisation(nikita.webapp.security.Authorisation) RegistryEntryStatus(nikita.common.model.noark5.v4.metadata.RegistryEntryStatus) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)

Example 23 with AfterNoarkEntityUpdatedEvent

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

the class RegistryEntryTypeService method handleUpdate.

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

Example 24 with AfterNoarkEntityUpdatedEvent

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

the class ClassHateoasController method updateClass.

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

Example 25 with AfterNoarkEntityUpdatedEvent

use of nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent 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

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