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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations