Search in sources :

Example 76 with MetadataHateoas

use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsStatusController method createFondsStatus.

// API - All POST Requests (CRUD - CREATE)
// Creates a new arkivstatus
// POST [contextPath][api]/metadata/arkivstatus/ny-arkivstatus
@ApiOperation(value = "Persists a new FondsStatus object", notes = "Returns the newly" + " created FondsStatus object after it is persisted to the database", response = FondsStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsStatus " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsStatus.class), @ApiResponse(code = 201, message = "FondsStatus " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsStatus.class), @ApiResponse(code = 401, message = API_MESSAGE_UNAUTHENTICATED_USER), @ApiResponse(code = 403, message = API_MESSAGE_UNAUTHORISED_FOR_USER), @ApiResponse(code = 404, message = API_MESSAGE_MALFORMED_PAYLOAD), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR), @ApiResponse(code = 501, message = API_MESSAGE_NOT_IMPLEMENTED) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = FONDS_STATUS + SLASH + NEW_FONDS_STATUS)
public ResponseEntity<MetadataHateoas> createFondsStatus(HttpServletRequest request, @RequestBody FondsStatus fondsStatus) throws NikitaException {
    fondsStatusService.createNewFondsStatus(fondsStatus);
    MetadataHateoas metadataHateoas = new MetadataHateoas(fondsStatus);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fondsStatus.getVersion().toString()).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 77 with MetadataHateoas

use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsStatusController method findAll.

// API - All GET Requests (CRUD - READ)
// Retrieves all fondsStatus
// GET [contextPath][api]/metadata/arkivstatus/
@ApiOperation(value = "Retrieves all FondsStatus ", response = FondsStatus.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsStatus codes found", response = FondsStatus.class), @ApiResponse(code = 404, message = "No FondsStatus found"), @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(method = RequestMethod.GET, value = FONDS_STATUS)
public ResponseEntity<MetadataHateoas> findAll(HttpServletRequest request) {
    MetadataHateoas metadataHateoas = new MetadataHateoas(new ArrayList<>(fondsStatusService.findAllAsList()), FONDS_STATUS);
    metadataHateoasHandler.addLinks(metadataHateoas, request, new Authorisation());
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(metadataHateoas);
}
Also used : Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) MetadataHateoas(nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 78 with MetadataHateoas

use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas 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 79 with MetadataHateoas

use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class CountryService method findByCode.

/**
 * retrieve all Country that have a particular code.
 * <br>
 * Note, this will be replaced by OData search.
 *
 * @param code The code of the object you wish to retrieve
 * @return A list of Country objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByCode(String code) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) countryRepository.findByCode(code), COUNTRY);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Example 80 with MetadataHateoas

use of nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas in project nikita-noark5-core by HiOA-ABI.

the class CountryService method findByDescription.

/**
 * Retrieve all Country that have a given description.
 * <br>
 * Note, this will be replaced by OData search.
 *
 * @param description Description of object you wish to retrieve. The
 *                    whole text, this is an exact search.
 * @return A list of Country objects wrapped as a MetadataHateoas
 * object
 */
@Override
public MetadataHateoas findByDescription(String description) {
    MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) countryRepository.findByDescription(description), COUNTRY);
    metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
    return metadataHateoas;
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Authorisation(nikita.webapp.security.Authorisation) List(java.util.List) MetadataHateoas(nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)

Aggregations

MetadataHateoas (nikita.common.model.noark5.v4.hateoas.metadata.MetadataHateoas)126 Authorisation (nikita.webapp.security.Authorisation)121 List (java.util.List)54 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)54 Counted (com.codahale.metrics.annotation.Counted)39 ApiOperation (io.swagger.annotations.ApiOperation)39 ApiResponses (io.swagger.annotations.ApiResponses)39 AfterNoarkEntityUpdatedEvent (nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)17 Timed (com.codahale.metrics.annotation.Timed)15 MetadataHateoas (nikita.model.noark5.v4.hateoas.metadata.MetadataHateoas)15 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)12 DocumentMedium (nikita.model.noark5.v4.metadata.DocumentMedium)4 CorrespondencePartType (nikita.common.model.noark5.v4.metadata.CorrespondencePartType)3 DocumentMedium (nikita.common.model.noark5.v4.metadata.DocumentMedium)3 CorrespondencePartType (nikita.model.noark5.v4.metadata.CorrespondencePartType)3 FondsStatus (nikita.model.noark5.v4.metadata.FondsStatus)3 DocumentStatus (nikita.common.model.noark5.v4.metadata.DocumentStatus)2 FondsStatus (nikita.common.model.noark5.v4.metadata.FondsStatus)2 SeriesStatus (nikita.common.model.noark5.v4.metadata.SeriesStatus)2 IMetadataEntity (nikita.common.model.noark5.v4.interfaces.entities.IMetadataEntity)1