Search in sources :

Example 16 with AfterNoarkEntityUpdatedEvent

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

the class SeriesHateoasController method updateSeries.

// Update an identified Series
// PUT [contextPath][api]/arkivstruktur/arkivdel/{systemId}
@ApiOperation(value = "Updates a Series object", notes = "Returns the newly" + " update Series object after it is persisted to the database", response = SeriesHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Series " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = SeriesHateoas.class), @ApiResponse(code = 201, message = "Series " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = SeriesHateoas.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<SeriesHateoas> updateSeries(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of fonds to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "series", value = "Incoming series object", required = true) @RequestBody Series series) throws NikitaException {
    validateForUpdate(series);
    Series updatedSeries = seriesService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), series);
    SeriesHateoas seriesHateoas = new SeriesHateoas(updatedSeries);
    seriesHateoasHandler.addLinks(seriesHateoas, new Authorisation());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedSeries));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedSeries.getVersion().toString()).body(seriesHateoas);
}
Also used : Authorisation(nikita.webapp.security.Authorisation) AfterNoarkEntityUpdatedEvent(nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent) Counted(com.codahale.metrics.annotation.Counted)

Example 17 with AfterNoarkEntityUpdatedEvent

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

the class CountryService method handleUpdate.

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

Example 18 with AfterNoarkEntityUpdatedEvent

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

the class DocumentTypeService method handleUpdate.

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

Example 19 with AfterNoarkEntityUpdatedEvent

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

the class ElectronicSignatureSecurityLevelService method handleUpdate.

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

Example 20 with AfterNoarkEntityUpdatedEvent

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

the class FileTypeService method handleUpdate.

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

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