use of nikita.common.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasController method deleteSeriesBySystemId.
// Delete a FondsCreator identified by systemID
// DELETE [contextPath][api]/arkivstruktur/arkivskaper/{systemId}/
@ApiOperation(value = "Deletes a single FondsCreator entity identified by systemID", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", response = FondsHateoas.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 + FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteSeriesBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the fondsCreator to delete", required = true) @PathVariable("systemID") final String seriesSystemId) {
FondsCreator fondsCreator = fondsCreatorService.findBySystemId(seriesSystemId);
fondsCreatorService.deleteEntity(seriesSystemId);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, fondsCreator));
/* List<Fonds> fonds = new List<>();
fonds.addAll(fondsCreator.getReferenceFonds());
FondsHateoas fondsHateoas = new FondsHateoas((List<INikitaEntity>) (List)fonds);
fondsHateoasHandler.addLinks(fondsHateoas, new Authorisation());
*/
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("{\"status\" : \"Success\"}");
}
use of nikita.common.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.
the class FondsHateoasController method createFondsAssociatedWithFonds.
// Create a sub-fonds and associate it with the Fonds identified by systemId
// POST [contextPath][api]/arkivstruktur/arkiv/{systemId}/ny-underarkiv
@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
@RequestMapping(method = RequestMethod.POST, value = FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS + SLASH + NEW_SUB_FONDS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsHateoas> createFondsAssociatedWithFonds(HttpServletRequest request, @ApiParam(name = "systemID", value = "systemId of parent fonds to associate the fonds " + "with.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
validateForCreate(fonds);
FondsHateoas fondsHateoas = fondsService.createFondsAssociatedWithFonds(systemID, fonds);
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(fonds.getVersion().toString()).body(fondsHateoas);
}
use of nikita.common.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.
the class FondsHateoasSerializer method serializeNoarkEntity.
@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject fondsHateoas, JsonGenerator jgen) throws IOException {
Fonds fonds = (Fonds) noarkSystemIdEntity;
jgen.writeStartObject();
CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printTitleAndDescription(jgen, fonds);
if (fonds.getFondsStatus() != null) {
jgen.writeStringField(FONDS_STATUS, fonds.getFondsStatus());
}
CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, fonds);
CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, fonds);
CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printFinaliseEntity(jgen, fonds);
CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, fondsHateoas.getLinks(fonds));
jgen.writeEndObject();
}
use of nikita.common.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.
the class FondsCreatorHateoasController method deleteSeriesBySystemId.
// Delete a FondsCreator identified by systemID
// DELETE [contextPath][api]/arkivstruktur/arkivskaper/{systemId}/
@ApiOperation(value = "Deletes a single FondsCreator entity identified by systemID", response = FondsHateoas.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent Fonds returned", response = FondsHateoas.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
@Timed
@RequestMapping(value = SLASH + FONDS_CREATOR + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<String> deleteSeriesBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the fondsCreator to delete", required = true) @PathVariable("systemID") final String seriesSystemId) {
FondsCreator fondsCreator = fondsCreatorService.findBySystemIdOrderBySystemId(seriesSystemId);
fondsCreatorService.deleteEntity(seriesSystemId);
applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, fondsCreator));
/* List<Fonds> fonds = new ArrayList<>();
fonds.addAll(fondsCreator.getReferenceFonds());
FondsHateoas fondsHateoas = new FondsHateoas((List<INikitaEntity>) (List)fonds);
fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
*/
return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body("{\"status\" : \"Success\"}");
}
use of nikita.common.model.noark5.v4.hateoas.FondsHateoas in project nikita-noark5-core by HiOA-ABI.
the class FondsHateoasController method updateFonds.
// API - All PUT Requests (CRUD - UPDATE)
// Update a Fonds
// PUT [contextPath][api]/arkivstruktur/arkiv
@ApiOperation(value = "Updates a Fonds object", notes = "Returns the newly" + " update 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.PUT, value = FONDS + SLASH + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, consumes = { NOARK5_V4_CONTENT_TYPE_JSON })
public ResponseEntity<FondsHateoas> updateFonds(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemId of fonds to update.", required = true) @PathVariable("systemID") String systemID, @ApiParam(name = "fonds", value = "Incoming fonds object", required = true) @RequestBody Fonds fonds) throws NikitaException {
validateForUpdate(fonds);
Fonds updatedFonds = fondsService.handleUpdate(systemID, parseETAG(request.getHeader(ETAG)), fonds);
FondsHateoas fondsHateoas = new FondsHateoas(updatedFonds);
fondsHateoasHandler.addLinks(fondsHateoas, request, new Authorisation());
applicationEventPublisher.publishEvent(new AfterNoarkEntityUpdatedEvent(this, updatedFonds));
return ResponseEntity.status(HttpStatus.CREATED).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).eTag(updatedFonds.getVersion().toString()).body(fondsHateoas);
}
Aggregations