use of nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.
the class VariantFormatService method handleUpdate.
/**
* Update a VariantFormat identified by its systemId
* <p>
* Copy the values you are allowed to change, code and description
*
* @param systemId The systemId of the variantFormat object you wish to
* update
* @param variantFormat The updated variantFormat object. Note the values
* you are allowed to change are copied from this
* object. This object is not persisted.
* @return the updated variantFormat
*/
@Override
public MetadataHateoas handleUpdate(String systemId, Long version, VariantFormat variantFormat) {
VariantFormat existingVariantFormat = getVariantFormatOrThrow(systemId);
// Copy all the values you are allowed to copy ....
if (null != existingVariantFormat.getCode()) {
existingVariantFormat.setCode(existingVariantFormat.getCode());
}
if (null != existingVariantFormat.getDescription()) {
existingVariantFormat.setDescription(existingVariantFormat.getDescription());
}
// Note this can potentially result in a NoarkConcurrencyException
// exception
existingVariantFormat.setVersion(version);
MetadataHateoas variantFormatHateoas = new MetadataHateoas(variantFormatRepository.save(existingVariantFormat));
metadataHateoasHandler.addLinks(variantFormatHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, existingVariantFormat));
return variantFormatHateoas;
}
use of nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.
the class VariantFormatService method findByDescription.
/**
* Retrieve all VariantFormat 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 VariantFormat objects wrapped as a MetadataHateoas
* object
*/
@Override
public MetadataHateoas findByDescription(String description) {
MetadataHateoas metadataHateoas = new MetadataHateoas((List<INikitaEntity>) (List) variantFormatRepository.findByDescription(description), VARIANT_FORMAT);
metadataHateoasHandler.addLinks(metadataHateoas, new Authorisation());
return metadataHateoas;
}
use of nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordHateoasController method updateBasicRecord.
// API - All PUT Requests (CRUD - UPDATE)
// Update a BasicRecord
// PUT [contextPath][api]/arkivstruktur/basisregistrering/{systemID}
@ApiOperation(value = "Updates a BasicRecord object", notes = "Returns the newly" + " update BasicRecord object after it is persisted to the database", response = BasicRecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "BasicRecord " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = BasicRecordHateoas.class), @ApiResponse(code = 201, message = "BasicRecord " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = BasicRecordHateoas.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 BasicRecord"), @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<BasicRecordHateoas> updateBasicRecord(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of basicRecord to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "basicRecord", value = "Incoming basicRecord object", required = true) @RequestBody BasicRecord basicRecord) throws NikitaException {
validateForUpdate(basicRecord);
BasicRecord updatedBasicRecord = basicRecordService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), basicRecord);
BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(updatedBasicRecord);
basicRecordHateoasHandler.addLinks(basicRecordHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedBasicRecord));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
use of nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.
the class BasicRecordHateoasController method findOneBasicRecordBySystemId.
// API - All GET Requests (CRUD - READ)
@ApiOperation(value = "Retrieves a single BasicRecord entity given a systemId", response = BasicRecord.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "BasicRecord returned", response = BasicRecord.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 = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.GET)
public ResponseEntity<BasicRecordHateoas> findOneBasicRecordBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the basicRecord to retrieve", required = true) @PathVariable("systemID") final String basicRecordSystemId) {
BasicRecord createdBasicRecord = basicRecordService.findBySystemId(basicRecordSystemId);
BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(createdBasicRecord);
basicRecordHateoasHandler.addLinks(basicRecordHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
use of nikita.webapp.security.Authorisation in project nikita-noark5-core by HiOA-ABI.
the class ClassificationSystemHateoasController method createClassAssociatedWithClassificationSystem.
@ApiOperation(value = "Persists a Class object associated with the given ClassificationSystem systemId", notes = "Returns the newly created class object after it was associated with a classificationSystem " + "object and persisted to the database", response = ClassHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Class " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = Class.class), @ApiResponse(code = 201, message = "Class " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = Class.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.POST, value = CLASSIFICATION_SYSTEM + SLASH + LEFT_PARENTHESIS + "classificationSystemSystemId" + RIGHT_PARENTHESIS + SLASH + NEW_RECORD, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<ClassHateoas> createClassAssociatedWithClassificationSystem(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "classificationSystemSystemId", value = "systemId of classificationSystem to associate the klass with.", required = true) @PathVariable String classificationSystemSystemId, @ApiParam(name = "klass", value = "Incoming class object", required = true) @RequestBody Class klass) throws NikitaException {
Class createdClass = classificationSystemService.createClassAssociatedWithClassificationSystem(classificationSystemSystemId, klass);
ClassHateoas classHateoas = new ClassHateoas(createdClass);
classHateoasHandler.addLinks(classHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdClass));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdClass.getVersion().toString()).body(classHateoas);
}
Aggregations