Search in sources :

Example 1 with Contents

use of com.opentext.ia.sdk.dto.Contents in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class PropertiesBasedApplicationConfigurer method ensureContents.

private void ensureContents(LinkContainer state, String configurationName, String format) throws IOException {
    Contents contents = restClient.follow(state, LINK_CONTENTS, Contents.class);
    if (contents.hasItems()) {
        return;
    }
    String content = configured(configurationName);
    try (InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
        perform(() -> restClient.post(state.getUri(LINK_CONTENTS), null, new TextPart("content", MediaTypes.HAL, "{ \"format\": \"" + format + "\" }"), new BinaryPart("file", stream, configurationName)));
    }
}
Also used : BinaryPart(com.opentext.ia.sdk.support.http.BinaryPart) Contents(com.opentext.ia.sdk.dto.Contents) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) TextPart(com.opentext.ia.sdk.support.http.TextPart)

Aggregations

Contents (com.opentext.ia.sdk.dto.Contents)1 BinaryPart (com.opentext.ia.sdk.support.http.BinaryPart)1 TextPart (com.opentext.ia.sdk.support.http.TextPart)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1