use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method findAllFiles.
// Retrieves all files
// GET [contextPath][api]/arkivstruktur/mappe
@ApiOperation(value = "Retrieves multiple File entities limited by ownership rights", notes = "The field skip" + "tells how many File rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = FileHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File list found", response = FileHateoas.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(method = RequestMethod.GET)
public ResponseEntity<FileHateoas> findAllFiles(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
String ownedBy = SecurityContextHolder.getContext().getAuthentication().getName();
FileHateoas fileHateoas = new FileHateoas((List<INikitaEntity>) (List) fileService.findByOwnedBy(ownedBy));
fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fileHateoas);
}
use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method findOneFileBySystemId.
// Retrieve a file identified by a systemId
// GET [contextPath][api]/arkivstruktur/mappe/{systemId}
@ApiOperation(value = "Retrieves a single File entity given a systemId", response = File.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "File returned", response = File.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<FileHateoas> findOneFileBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the file to retrieve", required = true) @PathVariable("systemID") final String systemID) {
File file = fileService.findBySystemId(systemID);
// TODO: If null return not found exception
FileHateoas fileHateoas = new FileHateoas(file);
fileHateoasHandler.addLinks(fileHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(file.getVersion().toString()).body(fileHateoas);
}
use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method createRecordAssociatedWithFile.
// API - All POST Requests (CRUD - CREATE)
// Create a Record
// POST [contextPath][api]/arkivstruktur/mappe/{systemId}/ny-registrering
// REL http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-registrering/
@ApiOperation(value = "Persists a Record associated with the given Series systemId", notes = "Returns the newly created record after it was associated with a File and " + "persisted to the database", response = RecordHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Record " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = RecordHateoas.class), @ApiResponse(code = 201, message = "Record " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = RecordHateoas.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 Record"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@RequestMapping(method = RequestMethod.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_RECORD, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<RecordHateoas> createRecordAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "fileSystemId", value = "systemId of file to associate the record with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "Record", value = "Incoming record", required = true) @RequestBody Record record) throws NikitaException {
Record createdRecord = fileService.createRecordAssociatedWithFile(systemID, record);
RecordHateoas recordHateoas = new RecordHateoas(createdRecord);
recordHateoasHandler.addLinks(recordHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdRecord));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdRecord.getVersion().toString()).body(recordHateoas);
}
use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.
the class FileHateoasController method createBasicRecordAssociatedWithFile.
// Create a BasicRecord
// POST [contextPath][api]/arkivstruktur/mappe/{systemId}/ny-basisregistrering
// http://rel.kxml.no/noark5/v4/api/arkivstruktur/ny-basisregistrering/
@ApiOperation(value = "Persists a BasicRecord associated with the given Series systemId", notes = "Returns the newly created basicRecord after it was associated with a File and " + "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.POST, value = SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_BASIC_RECORD, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<BasicRecordHateoas> createBasicRecordAssociatedWithFile(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of file to associate the basicRecord with", required = true) @PathVariable("systemID") final String systemID, @ApiParam(name = "BasicRecord", value = "Incoming basicRecord", required = true) @RequestBody BasicRecord basicRecord) throws NikitaException {
BasicRecord createdBasicRecord = fileService.createBasicRecordAssociatedWithFile(systemID, basicRecord);
BasicRecordHateoas basicRecordHateoas = new BasicRecordHateoas(createdBasicRecord);
basicRecordHateoasHandler.addLinks(basicRecordHateoas, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdBasicRecord));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdBasicRecord.getVersion().toString()).body(basicRecordHateoas);
}
use of com.codahale.metrics.annotation.Counted in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasController method findAllFondsCreator.
// Get all FondsCreator
// GET [contextPath][api]/arkivstruktur/arkivskaper/
@ApiOperation(value = "Retrieves multiple FondsCreator entities limited by ownership rights", notes = "The field skip" + "tells how many FondsCreator rows of the result set to ignore (starting at 0), while top tells how many rows" + " after skip to return. Note if the value of top is greater than system value " + " nikita-noark5-core.pagination.maxPageSize, then nikita-noark5-core.pagination.maxPageSize is used. ", response = FondsCreatorHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "FondsCreator found", response = FondsCreatorHateoas.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(method = RequestMethod.GET, value = FONDS_CREATOR)
public ResponseEntity<FondsCreatorHateoas> findAllFondsCreator(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @RequestParam(name = "top", required = false) Integer top, @RequestParam(name = "skip", required = false) Integer skip) {
String ownedBy = SecurityContextHolder.getContext().getAuthentication().getName();
FondsCreatorHateoas fondsCreatorHateoas = new FondsCreatorHateoas((List<INikitaEntity>) (List) fondsCreatorService.findByOwnedBy(ownedBy));
fondsCreatorHateoasHandler.addLinks(fondsCreatorHateoas, new Authorisation());
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(fondsCreatorHateoas);
}
Aggregations