Search in sources :

Example 51 with HateoasNoarkObject

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

the class CorrespondencePartPersonHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartPerson correspondencePart = (CorrespondencePartPerson) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartPerson(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartPerson(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartPerson)

Example 52 with HateoasNoarkObject

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

the class CorrespondencePartUnitHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject correspondencePartHateoas, JsonGenerator jgen) throws IOException {
    CorrespondencePartUnit correspondencePart = (CorrespondencePartUnit) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printCorrespondencePartUnit(jgen, correspondencePart);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, correspondencePartHateoas.getLinks(correspondencePart));
    jgen.writeEndObject();
}
Also used : CorrespondencePartUnit(nikita.model.noark5.v4.casehandling.secondary.CorrespondencePartUnit)

Example 53 with HateoasNoarkObject

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

the class MetadataHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject metadataHateoas, JsonGenerator jgen) throws IOException {
    if (!(noarkSystemIdEntity instanceof nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)) {
        throw new NikitaException("Internal error when serialising " + noarkSystemIdEntity + " Not castable to nikita.model.noark5.v4.interfaces.entities.IMetadataEntity");
    }
    IMetadataEntity metadataEntity = (IMetadataEntity) noarkSystemIdEntity;
    jgen.writeStartObject();
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, metadataEntity);
    if (metadataEntity.getCode() != null) {
        jgen.writeStringField(CODE, metadataEntity.getCode());
    }
    if (metadataEntity.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, metadataEntity.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, metadataHateoas.getLinks(metadataEntity));
    jgen.writeEndObject();
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) IMetadataEntity(nikita.model.noark5.v4.interfaces.entities.IMetadataEntity)

Example 54 with HateoasNoarkObject

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

the class HateoasHandler method addLinksOnNew.

@Override
public void addLinksOnNew(IHateoasNoarkObject hateoasNoarkObject, HttpServletRequest request, IAuthorisation authorisation) {
    setParameters(request);
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addEntityLinksOnNew(entity, hateoasNoarkObject);
    }
}
Also used : INikitaEntity(nikita.model.noark5.v4.interfaces.entities.INikitaEntity)

Example 55 with HateoasNoarkObject

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

the class BasicRecordHateoasController method deleteRecordBySystemId.

// Delete a Record identified by systemID
// DELETE [contextPath][api]/arkivstruktur/registrering/{systemId}/
@ApiOperation(value = "Deletes a single Record entity identified by systemID", response = HateoasNoarkObject.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Parent entity (DocumentDescription or Record) returned", response = HateoasNoarkObject.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 + LEFT_PARENTHESIS + SYSTEM_ID + RIGHT_PARENTHESIS, method = RequestMethod.DELETE)
public ResponseEntity<HateoasNoarkObject> deleteRecordBySystemId(final UriComponentsBuilder uriBuilder, HttpServletRequest request, final HttpServletResponse response, @ApiParam(name = "systemID", value = "systemID of the record to delete", required = true) @PathVariable("systemID") final String systemID) {
    BasicRecord basicRecord = basicRecordService.findBySystemIdOrderBySystemId(systemID);
    NoarkEntity parentEntity = basicRecord.chooseParent();
    HateoasNoarkObject hateoasNoarkObject;
    if (parentEntity instanceof Series) {
        hateoasNoarkObject = new SeriesHateoas(parentEntity);
        seriesHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof File) {
        hateoasNoarkObject = new FileHateoas(parentEntity);
        fileHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else if (parentEntity instanceof Class) {
        hateoasNoarkObject = new ClassHateoas(parentEntity);
        classHateoasHandler.addLinks(hateoasNoarkObject, request, new Authorisation());
    } else {
        throw new NikitaException("Internal error. Could not process" + request.getRequestURI());
    }
    basicRecordService.deleteEntity(systemID);
    applicationEventPublisher.publishEvent(new AfterNoarkEntityDeletedEvent(this, basicRecord));
    return ResponseEntity.status(HttpStatus.OK).allow(CommonUtils.WebUtils.getMethodsForRequestOrThrow(request.getServletPath())).body(hateoasNoarkObject);
}
Also used : NikitaException(nikita.util.exceptions.NikitaException) Authorisation(no.arkivlab.hioa.nikita.webapp.security.Authorisation) Class(nikita.model.noark5.v4.Class) AfterNoarkEntityDeletedEvent(no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent) 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)12 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Timed (com.codahale.metrics.annotation.Timed)6 NikitaException (nikita.common.util.exceptions.NikitaException)6 NikitaException (nikita.util.exceptions.NikitaException)6 AfterNoarkEntityDeletedEvent (nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)6 AfterNoarkEntityDeletedEvent (no.arkivlab.hioa.nikita.webapp.web.events.AfterNoarkEntityDeletedEvent)6 Class (nikita.common.model.noark5.v4.Class)5 HateoasNoarkObject (nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject)5 INikitaEntity (nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity)5 Class (nikita.model.noark5.v4.Class)5 Authorisation (nikita.webapp.security.Authorisation)5 Authorisation (no.arkivlab.hioa.nikita.webapp.security.Authorisation)5 INikitaEntity (nikita.model.noark5.v4.interfaces.entities.INikitaEntity)4 NoarkEntity (nikita.common.model.noark5.v4.NoarkEntity)3 Record (nikita.common.model.noark5.v4.Record)3 NoarkEntity (nikita.model.noark5.v4.NoarkEntity)3 Record (nikita.model.noark5.v4.Record)3 HateoasNoarkObject (nikita.model.noark5.v4.hateoas.HateoasNoarkObject)3