Search in sources :

Example 11 with FondsHateoas

use of nikita.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsHateoasController method createFonds.

// API - All POST Requests (CRUD - CREATE)
// Create a Fonds
// POST [contextPath][api]/arkivstruktur/arkiv
@ApiOperation(value = "Persists a Fonds object", notes = "Returns the newly" + " created Fonds object after it is persisted to the database", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.class), @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsHateoas.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 Fonds"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = NEW_FONDS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsHateoas> createFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
    validateForCreate(fonds);
    Fonds createdFonds = fondsService.createNewFonds(fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(createdFonds);
    fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
    response.setHeader(ETAG, fonds.getVersion().toString());
    applicationEventPublisher.publishEvent(new AfterNoarkEntityCreatedEvent(this, createdFonds));
    return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(createdFonds.getVersion().toString()).body(fondsHateoas);
}
Also used : AfterNoarkEntityCreatedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent) FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Fonds(nikita.model.noark5.v4.Fonds) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with FondsHateoas

use of nikita.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsImportController method createFonds.

// API - All POST Requests (CRUD - CREATE)
@ApiOperation(value = "Persists a Fonds object", notes = "Returns the newly" + " created Fonds object after it is persisted to the database", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.class), @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsHateoas.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 Fonds"), @ApiResponse(code = 409, message = API_MESSAGE_CONFLICT), @ApiResponse(code = 500, message = API_MESSAGE_INTERNAL_SERVER_ERROR) })
@Counted
@Timed
@RequestMapping(method = RequestMethod.POST, value = NEW_FONDS)
public ResponseEntity<FondsHateoas> createFonds(@ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
    Fonds createdFonds = fondsImportService.createNewFonds(fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(createdFonds);
    return new ResponseEntity<>(fondsHateoas, HttpStatus.CREATED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Fonds(nikita.model.noark5.v4.Fonds) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with FondsHateoas

use of nikita.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.

the class FondsImportController method createFondsAssociatedWithFonds.

// TODO: Doublecheck this logic
@ApiOperation(value = "Persists a child Fonds object", notes = "Returns the newly" + " created child Fonds object after it is persisted to the database", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fonds " + API_MESSAGE_OBJECT_ALREADY_PERSISTED, response = FondsHateoas.class), @ApiResponse(code = 201, message = "Fonds " + API_MESSAGE_OBJECT_SUCCESSFULLY_CREATED, response = FondsHateoas.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 Fonds"), @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 + SLASH + LEFT_PARENTHESIS + "fondsSystemId" + RIGHT_PARENTHESIS + SLASH + NEW_FONDS)
public ResponseEntity<FondsHateoas> createFondsAssociatedWithFonds(@ApiParam(name = "parentFondsSystemId", value = "systemId of parent fonds to associate the fonds with.", required = true) @PathVariable String parentFondsSystemId, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
    Fonds createdFonds = fondsImportService.createFondsAssociatedWithFonds(parentFondsSystemId, fonds);
    FondsHateoas fondsHateoas = new FondsHateoas(createdFonds);
    return new ResponseEntity<>(fondsHateoas, HttpStatus.CREATED);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) FondsHateoas(nikita.model.noark5.v4.hateoas.FondsHateoas) Fonds(nikita.model.noark5.v4.Fonds) Counted(com.codahale.metrics.annotation.Counted) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Counted (com.codahale.metrics.annotation.Counted)10 Timed (com.codahale.metrics.annotation.Timed)10 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 Fonds (nikita.model.noark5.v4.Fonds)10 FondsHateoas (nikita.model.noark5.v4.hateoas.FondsHateoas)10 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)8 ArrayList (java.util.ArrayList)2 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)2 AfterNoarkEntityCreatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityCreatedEvent)2 AfterNoarkEntityUpdatedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityUpdatedEvent)2 ResponseEntity (org.springframework.http.ResponseEntity)2 FondsCreator (nikita.model.noark5.v4.FondsCreator)1 NoarkEntityNotFoundException (nikita.util.exceptions.NoarkEntityNotFoundException)1 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)1 Session (org.hibernate.Session)1 FullTextSession (org.hibernate.search.FullTextSession)1 QueryDescriptor (org.hibernate.search.query.engine.spi.QueryDescriptor)1