Search in sources :

Example 51 with HateoasNoarkObject

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

the class HateoasHandler method addLinks.

@Override
public void addLinks(IHateoasNoarkObject hateoasNoarkObject, IAuthorisation authorisation) {
    this.authorisation = authorisation;
    Iterable<INikitaEntity> entities = hateoasNoarkObject.getList();
    for (INikitaEntity entity : entities) {
        addSelfLink(entity, hateoasNoarkObject);
        addEntityLinks(entity, hateoasNoarkObject);
    }
    // { "entity": [], "_links": [] }
    if (!hateoasNoarkObject.isSingleEntity()) {
        String url = this.contextPath;
        Link selfLink = new Link(url, getRelSelfLink(), false);
        hateoasNoarkObject.addSelfLink(selfLink);
    }
}
Also used : INikitaEntity(nikita.common.model.noark5.v4.interfaces.entities.INikitaEntity) Link(nikita.common.model.noark5.v4.hateoas.Link)

Example 52 with HateoasNoarkObject

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

the class HateoasHandler method addSelfLink.

@Override
public void addSelfLink(INikitaEntity entity, IHateoasNoarkObject hateoasNoarkObject) {
    String systemId = entity.getSystemId();
    hateoasNoarkObject.addLink(entity, new Link(contextPath + HATEOAS_API_PATH + SLASH + entity.getFunctionalTypeName() + SLASH + entity.getBaseTypeName() + SLASH + systemId + SLASH, getRelSelfLink(), false));
}
Also used : Link(nikita.common.model.noark5.v4.hateoas.Link)

Example 53 with HateoasNoarkObject

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

the class HateoasDeserializer method deserialize.

@Override
public HateoasNoarkObject deserialize(JsonParser jsonParser, DeserializationContext dc) throws IOException {
    StringBuilder errors = new StringBuilder();
    NoarkGeneralEntity entity = new NoarkGeneralEntity();
    ObjectNode objectNode = mapper.readTree(jsonParser);
    // Deserialise general properties
    CommonUtils.Hateoas.Deserialize.deserialiseNoarkEntity(entity, objectNode, errors);
    // If there are additional throw a malformed input exception
    if (objectNode.size() != 0) {
        errors.append("The arkiv you tried to create is malformed. The " + "following fields are not recognised as arkiv fields [" + CommonUtils.Hateoas.Deserialize.checkNodeObjectEmpty(objectNode) + "]. ");
    }
    // if (0 < errors.length())
    // throw new NikitaMalformedInputDataException(errors.toString());
    HateoasNoarkObject hateoasNoarkObject = new HateoasNoarkObject(entity);
    return hateoasNoarkObject;
}
Also used : NoarkGeneralEntity(nikita.common.model.noark5.v4.NoarkGeneralEntity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) HateoasNoarkObject(nikita.common.model.noark5.v4.hateoas.HateoasNoarkObject)

Example 54 with HateoasNoarkObject

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

the class BasicRecordHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject basicRecordHateoas, JsonGenerator jgen) throws IOException {
    BasicRecord basicRecord = (BasicRecord) noarkSystemIdEntity;
    jgen.writeStartObject();
    // handle the record properties first
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, basicRecord);
    if (basicRecord.getArchivedDate() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_DATE, Serialize.formatDateTime(basicRecord.getArchivedDate()));
    }
    if (basicRecord.getArchivedBy() != null) {
        jgen.writeStringField(RECORD_ARCHIVED_BY, basicRecord.getArchivedBy());
    }
    CommonUtils.Hateoas.Serialize.printDisposal(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printScreening(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printClassified(jgen, basicRecord);
    // handle general basicRecord properties
    if (basicRecord.getTitle() != null) {
        jgen.writeStringField(TITLE, basicRecord.getTitle());
    }
    if (basicRecord.getOfficialTitle() != null) {
        jgen.writeStringField(FILE_PUBLIC_TITLE, basicRecord.getOfficialTitle());
    }
    if (basicRecord.getDescription() != null) {
        jgen.writeStringField(DESCRIPTION, basicRecord.getDescription());
    }
    CommonUtils.Hateoas.Serialize.printKeyword(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printDocumentMedium(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printStorageLocation(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printComment(jgen, basicRecord);
    // TODO: FIX THIS CommonCommonUtils.Hateoas.Serialize.printCrossReference(jgen, basicRecord);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, basicRecordHateoas.getLinks(basicRecord));
    jgen.writeEndObject();
}
Also used : BasicRecord(nikita.common.model.noark5.v4.BasicRecord)

Example 55 with HateoasNoarkObject

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

the class DocumentObjectHateoasSerializer method serializeNoarkEntity.

@Override
public void serializeNoarkEntity(INikitaEntity noarkSystemIdEntity, HateoasNoarkObject documentObjectHateoas, JsonGenerator jgen) throws IOException {
    DocumentObject documentObject = (DocumentObject) noarkSystemIdEntity;
    jgen.writeStartObject();
    // handle DocumentObject properties
    CommonUtils.Hateoas.Serialize.printSystemIdEntity(jgen, documentObject);
    if (documentObject.getVersionNumber() != null) {
        jgen.writeNumberField(DOCUMENT_OBJECT_VERSION_NUMBER, documentObject.getVersionNumber().intValue());
    }
    if (documentObject.getVariantFormat() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_VARIANT_FORMAT, documentObject.getVariantFormat());
    }
    if (documentObject.getFormat() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FORMAT, documentObject.getFormat());
    }
    if (documentObject.getFormatDetails() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FORMAT_DETAILS, documentObject.getFormatDetails());
    }
    CommonUtils.Hateoas.Serialize.printCreateEntity(jgen, documentObject);
    if (documentObject.getReferenceDocumentFile() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_REFERENCE_DOCUMENT_FILE, documentObject.getReferenceDocumentFile());
    }
    if (documentObject.getChecksum() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM, documentObject.getChecksum());
    }
    if (documentObject.getChecksumAlgorithm() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_CHECKSUM_ALGORITHM, documentObject.getChecksumAlgorithm());
    }
    if (documentObject.getFileSize() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FILE_SIZE, Long.toString(documentObject.getFileSize()));
    }
    if (documentObject.getOriginalFilename() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_FILE_NAME, documentObject.getOriginalFilename());
    }
    if (documentObject.getMimeType() != null) {
        jgen.writeStringField(DOCUMENT_OBJECT_MIME_TYPE, documentObject.getMimeType());
    }
    CommonUtils.Hateoas.Serialize.printElectronicSignature(jgen, documentObject);
    CommonUtils.Hateoas.Serialize.printConversion(jgen, documentObject);
    CommonUtils.Hateoas.Serialize.printHateoasLinks(jgen, documentObjectHateoas.getLinks(documentObject));
    jgen.writeEndObject();
}
Also used : DocumentObject(nikita.common.model.noark5.v4.DocumentObject)

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