Merge branch 'develop-acs6' into stable-acs6
This commit is contained in:
commit
2105748896
118
pom.xml
118
pom.xml
@ -17,6 +17,7 @@
|
||||
<acs.baseUrl>http://localhost:8080/api-explorer</acs.baseUrl>
|
||||
<acs.platform.tag>acs6</acs.platform.tag>
|
||||
<swagger.basePackage>com.inteligr8.alfresco.acs</swagger.basePackage>
|
||||
<it.directory>src/test/none</it.directory>
|
||||
|
||||
<junit.version>5.7.2</junit.version>
|
||||
<spring.version>5.2.14.RELEASE</spring.version>
|
||||
@ -124,6 +125,21 @@
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>add-services</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>add-test-resource</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${it.directory}</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -142,6 +158,12 @@
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*Jersey*</exclude>
|
||||
<exclude>**/*Cxf*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
@ -153,6 +175,12 @@
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*Jersey*</exclude>
|
||||
<exclude>**/*Cxf*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
@ -171,6 +199,96 @@
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>it-jersey</id>
|
||||
<properties>
|
||||
<it.directory>src/test/jersey</it.directory>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Jersey*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*IT.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Jersey*IT.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>it-cxf</id>
|
||||
<properties>
|
||||
<it.directory>src/test/cxf</it.directory>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Cxf*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*IT.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Cxf*IT.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<!-- Implement when descriptor is available -->
|
||||
<profile>
|
||||
<id>swagger-codegen</id>
|
||||
|
@ -1,5 +1,21 @@
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.AssociationBody;
|
||||
import com.inteligr8.alfresco.acs.model.AssociationEntry;
|
||||
import com.inteligr8.alfresco.acs.model.ChildAssociationBody;
|
||||
@ -13,14 +29,11 @@ import com.inteligr8.alfresco.acs.model.NodeBodyMove;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyUpdate;
|
||||
import com.inteligr8.alfresco.acs.model.NodeChildAssociationPaging;
|
||||
import com.inteligr8.alfresco.acs.model.NodeEntry;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.ws.rs.*;
|
||||
|
||||
/**
|
||||
* Alfresco Content Services REST API
|
||||
|
@ -7,9 +7,8 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Error;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartCxf;
|
||||
import com.inteligr8.alfresco.acs.model.NodeEntry;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@ -40,7 +39,7 @@ public interface NodesCxfApi {
|
||||
@ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
|
||||
public NodeEntry createNode(
|
||||
@PathParam("nodeId") String nodeId,
|
||||
MultipartBody body);
|
||||
NodeBodyCreateMultipartCxf body);
|
||||
/*
|
||||
* This better impl doesn't work
|
||||
*
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
@ -10,11 +7,8 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Error;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartJersey;
|
||||
import com.inteligr8.alfresco.acs.model.NodeEntry;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@ -45,13 +39,6 @@ public interface NodesJerseyApi {
|
||||
@ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
|
||||
public NodeEntry createNode(
|
||||
@PathParam("nodeId") String nodeId,
|
||||
NodeBodyCreate nodeBodyCreate,
|
||||
@FormDataParam("autoRename") Boolean autoRename,
|
||||
@FormDataParam("majorVersion") Boolean majorVersion,
|
||||
@FormDataParam("versioningEnabled") Boolean versioningEnabled,
|
||||
@FormDataParam("include") List<String> include,
|
||||
@FormDataParam("fields") List<String> fields,
|
||||
@FormDataParam("filedata") InputStream filedataStream,
|
||||
@FormDataParam("filedata") FormDataContentDisposition filedataDisposition);
|
||||
NodeBodyCreateMultipartJersey file);
|
||||
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.inteligr8.alfresco.acs.model;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class NodeBodyCreateFile extends NodeBodyCreate {
|
||||
|
||||
@ApiModelProperty
|
||||
private File filedata;
|
||||
|
||||
@JsonProperty
|
||||
public File getFiledata() {
|
||||
return this.filedata;
|
||||
}
|
||||
|
||||
public void setFiledata(File filedata) {
|
||||
this.filedata = filedata;
|
||||
}
|
||||
|
||||
public NodeBodyCreateFile filedata(File filedata) {
|
||||
this.filedata = filedata;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +1,29 @@
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
package com.inteligr8.alfresco.acs.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition;
|
||||
import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
|
||||
public class NodeBodyCreateMultipart extends MultipartBody {
|
||||
public class NodeBodyCreateMultipartCxf extends MultipartBody {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NodeBodyCreateMultipartCxf.class);
|
||||
private static final ObjectMapper om = new ObjectMapper();
|
||||
|
||||
public static NodeBodyCreateMultipart from(
|
||||
public static NodeBodyCreateMultipartCxf from(
|
||||
NodeBodyCreate nodeBody, String filename, InputStream istream,
|
||||
Boolean autoRename, Boolean majorVersion, Boolean versioningEnabled) throws IOException {
|
||||
List<Attachment> atts = new LinkedList<>();
|
||||
@ -34,14 +35,14 @@ public class NodeBodyCreateMultipart extends MultipartBody {
|
||||
if (versioningEnabled != null)
|
||||
atts.add(toAttachment("versioningEnabled", String.valueOf(versioningEnabled)));
|
||||
atts.add(toAttachment(filename, istream));
|
||||
return new NodeBodyCreateMultipart(atts, true);
|
||||
return new NodeBodyCreateMultipartCxf(atts, true);
|
||||
}
|
||||
|
||||
public NodeBodyCreateMultipart(List<Attachment> atts) throws IOException {
|
||||
public NodeBodyCreateMultipartCxf(List<Attachment> atts) throws IOException {
|
||||
super(atts);
|
||||
}
|
||||
|
||||
public NodeBodyCreateMultipart(List<Attachment> atts, boolean outbound) throws IOException {
|
||||
public NodeBodyCreateMultipartCxf(List<Attachment> atts, boolean outbound) throws IOException {
|
||||
super(atts, outbound);
|
||||
}
|
||||
|
||||
@ -63,37 +64,35 @@ public class NodeBodyCreateMultipart extends MultipartBody {
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Attachment> toAttachments(NodeBodyCreate nodeBody) throws IOException {
|
||||
List<Attachment> atts = new LinkedList<>();
|
||||
atts.add(toAttachment("name", nodeBody.getName()));
|
||||
atts.add(toAttachment("nodeType", nodeBody.getNodeType()));
|
||||
if (nodeBody.getAspectNames() != null)
|
||||
atts.add(toAttachment("aspectNames", nodeBody.getAspectNames()));
|
||||
if (nodeBody.getProperties() != null)
|
||||
atts.add(toAttachment("properties", (Map<String, Object>)nodeBody.getProperties()));
|
||||
if (nodeBody.getAspectNames() != null && !nodeBody.getAspectNames().isEmpty())
|
||||
logger.warn("The ACS Public REST API does not support the explicit inclusion of aspects while creating content");
|
||||
if (nodeBody.getProperties() != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> props = (Map<String, Object>)nodeBody.getProperties();
|
||||
for (Entry<String, Object> prop : props.entrySet()) {
|
||||
if (prop.getValue() != null) {
|
||||
// FIXME convert dates as ACS would expect them to be formatted
|
||||
atts.add(toAttachment(prop.getKey(), prop.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return atts;
|
||||
}
|
||||
|
||||
private static Attachment toAttachment(String name, String value) {
|
||||
return new Attachment(name, new ByteArrayInputStream(value.getBytes()), new ContentDisposition("form-data; name=\"" + name + "\""));
|
||||
}
|
||||
|
||||
private static Attachment toAttachment(String name, Collection<String> c) throws JsonProcessingException {
|
||||
return toJsonAttachment(name, c);
|
||||
}
|
||||
|
||||
private static Attachment toAttachment(String name, Map<String, Object> map) throws JsonProcessingException {
|
||||
return toJsonAttachment(name, map);
|
||||
}
|
||||
|
||||
private static Attachment toJsonAttachment(String name, Object obj) throws JsonProcessingException {
|
||||
String json = om.writeValueAsString(obj);
|
||||
return new Attachment(name, new ByteArrayInputStream(json.getBytes()), new ContentDisposition("form-data; name=\"" + name + "\""));
|
||||
}
|
||||
|
||||
private static Attachment toAttachment(String filename, InputStream istream) {
|
||||
return new Attachment("filedata", istream, new ContentDisposition("form-data; name=\"filedata\"; filename=\"" + filename + "\""));
|
||||
if (filename == null) {
|
||||
return new Attachment("filedata", istream, new ContentDisposition("form-data; name=\"filedata\""));
|
||||
} else {
|
||||
return new Attachment("filedata", istream, new ContentDisposition("form-data; name=\"filedata\"; filename=\"" + filename + "\""));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.inteligr8.alfresco.acs.model;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.BodyPart;
|
||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class NodeBodyCreateMultipartJersey extends FormDataMultiPart {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NodeBodyCreateMultipartJersey.class);
|
||||
private static final ObjectMapper om = new ObjectMapper();
|
||||
|
||||
public static NodeBodyCreateMultipartJersey from(
|
||||
NodeBodyCreate nodeBody, String filename, InputStream istream,
|
||||
Boolean autoRename, Boolean majorVersion, Boolean versioningEnabled) throws IOException, ParseException {
|
||||
NodeBodyCreateMultipartJersey multipart = new NodeBodyCreateMultipartJersey();
|
||||
multipart.field("autoRename", String.valueOf(autoRename))
|
||||
.field("majorVersion", String.valueOf(majorVersion))
|
||||
.field("versioningEnabled", String.valueOf(versioningEnabled))
|
||||
.bodyPart(toBodyPart(filename, istream))
|
||||
.getBodyParts().addAll(toFields(nodeBody));
|
||||
return multipart;
|
||||
}
|
||||
|
||||
private NodeBodyCreateMultipartJersey() throws IOException {
|
||||
}
|
||||
|
||||
public NodeBodyCreate getBody() throws IOException {
|
||||
BodyPart bodyPart = this.getField("");
|
||||
if (bodyPart == null)
|
||||
throw new IllegalStateException();
|
||||
if (!MediaType.APPLICATION_JSON_TYPE.equals(bodyPart.getMediaType()))
|
||||
throw new IllegalStateException();
|
||||
|
||||
InputStream istream = bodyPart.getEntityAs(InputStream.class);
|
||||
try {
|
||||
return om.readValue(istream, NodeBodyCreate.class);
|
||||
} finally {
|
||||
istream.close();
|
||||
}
|
||||
}
|
||||
|
||||
public FormDataBodyPart getFiledataAttachment() {
|
||||
return this.getField("filedata");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static List<FormDataBodyPart> toFields(NodeBodyCreate nodeBody) throws IOException {
|
||||
List<FormDataBodyPart> fields = new LinkedList<>();
|
||||
fields.add(new FormDataBodyPart("name", nodeBody.getName()));
|
||||
fields.add(new FormDataBodyPart("nodeType", nodeBody.getNodeType()));
|
||||
if (nodeBody.getAspectNames() != null && !nodeBody.getAspectNames().isEmpty())
|
||||
logger.warn("The ACS Public REST API does not support the explicit inclusion of aspects while creating content");
|
||||
if (nodeBody.getProperties() != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> props = (Map<String, Object>)nodeBody.getProperties();
|
||||
for (Entry<String, Object> prop : props.entrySet()) {
|
||||
if (prop.getValue() != null) {
|
||||
// FIXME convert dates as ACS would expect them to be formatted
|
||||
fields.add(new FormDataBodyPart(prop.getKey(), prop.getValue().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
private static BodyPart toBodyPart(String filename, InputStream istream) throws ParseException {
|
||||
if (filename == null) {
|
||||
return new FormDataBodyPart()
|
||||
.contentDisposition(new FormDataContentDisposition("form-data; name=\"filedata\""))
|
||||
.entity(istream);
|
||||
} else {
|
||||
return new FormDataBodyPart()
|
||||
.contentDisposition(new FormDataContentDisposition("form-data; name=\"filedata\"; filename=\"" + filename + "\""))
|
||||
.entity(istream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl
|
@ -1,21 +1,10 @@
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.NodeBodyCreateMultipart;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
import com.inteligr8.alfresco.acs.model.RequestQuery;
|
||||
import com.inteligr8.alfresco.acs.model.RequestQuery.LanguageEnum;
|
||||
import com.inteligr8.alfresco.acs.model.ResultNode;
|
||||
import com.inteligr8.alfresco.acs.model.ResultSetPaging;
|
||||
import com.inteligr8.alfresco.acs.model.SearchRequest;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@ -36,25 +25,4 @@ public class ConnectionCxfClientIT extends ConnectionClientIT {
|
||||
return this.client.getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uploadFile() throws IOException {
|
||||
RequestQuery query = new RequestQuery();
|
||||
query.setLanguage(LanguageEnum.AFTS);
|
||||
query.setQuery("=@cm:name:'Shared'");
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.setQuery(query);
|
||||
|
||||
ResultSetPaging paging = this.client.getSearchApi().search(searchRequest);
|
||||
ResultNode folderNode = paging.getList().getEntries().iterator().next().getEntry();
|
||||
String folderNodeId = folderNode.getId();
|
||||
|
||||
NodeBodyCreate nodeBody = new NodeBodyCreate().nodeType("cm:content").name("TestFolder");
|
||||
|
||||
ByteArrayInputStream istream = new ByteArrayInputStream("This is a test".getBytes());
|
||||
NodeBodyCreateMultipart body = NodeBodyCreateMultipart.from(nodeBody, "test.txt", istream, true, null, null);
|
||||
|
||||
this.client.getNodesExtApi().createNode(folderNodeId, body);
|
||||
}
|
||||
|
||||
}
|
||||
|
57
src/test/java/com/inteligr8/alfresco/acs/CxfUploadIT.java
Normal file
57
src/test/java/com/inteligr8/alfresco/acs/CxfUploadIT.java
Normal file
@ -0,0 +1,57 @@
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Node;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartCxf;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@SpringJUnitConfig(classes = {AcsClientConfiguration.class, AcsPublicRestApiCxfImpl.class, AcsClientCxfImpl.class})
|
||||
public class CxfUploadIT extends UploadIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("acs.api.cxf")
|
||||
private AcsPublicRestApiCxfImpl client;
|
||||
|
||||
@Override
|
||||
public AcsPublicRestApi getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.client.getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void uploadFile() throws IOException {
|
||||
String folderNodeId = this.getSharedFolder();
|
||||
|
||||
NodeBodyCreate nodeBody = new NodeBodyCreate().nodeType("trx:transferReport").name("test-name1.txt")
|
||||
.properties(Collections.singletonMap("cm:author", "Brian"));
|
||||
|
||||
ByteArrayInputStream istream = new ByteArrayInputStream("This is a test".getBytes());
|
||||
NodeBodyCreateMultipartCxf body = NodeBodyCreateMultipartCxf.from(nodeBody, "test-name2.txt", istream, true, null, null);
|
||||
|
||||
Node newNode = this.client.getNodesExtApi().createNode(folderNodeId, body).getEntry();
|
||||
Assertions.assertNotNull(newNode);
|
||||
Assertions.assertNotNull(newNode.getId());
|
||||
Assertions.assertEquals(folderNodeId, newNode.getParentId());
|
||||
Assertions.assertEquals(nodeBody.getNodeType(), newNode.getNodeType());
|
||||
Assertions.assertTrue(newNode.getName().startsWith("test-name1"));
|
||||
}
|
||||
|
||||
}
|
58
src/test/java/com/inteligr8/alfresco/acs/JerseyUploadIT.java
Normal file
58
src/test/java/com/inteligr8/alfresco/acs/JerseyUploadIT.java
Normal file
@ -0,0 +1,58 @@
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Node;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartJersey;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@SpringJUnitConfig(classes = {AcsClientConfiguration.class, AcsPublicRestApiJerseyImpl.class, AcsClientJerseyImpl.class})
|
||||
public class JerseyUploadIT extends UploadIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("acs.api.jersey")
|
||||
private AcsPublicRestApiJerseyImpl client;
|
||||
|
||||
@Override
|
||||
public AcsPublicRestApi getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.client.getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void uploadFile() throws IOException, ParseException {
|
||||
String folderNodeId = this.getSharedFolder();
|
||||
|
||||
NodeBodyCreate nodeBody = new NodeBodyCreate().nodeType("trx:transferReport").name("test-name1.txt")
|
||||
.properties(Collections.singletonMap("cm:author", "Brian"));
|
||||
|
||||
ByteArrayInputStream istream = new ByteArrayInputStream("This is a test".getBytes());
|
||||
NodeBodyCreateMultipartJersey body = NodeBodyCreateMultipartJersey.from(nodeBody, "test-name2.txt", istream, true, null, null);
|
||||
|
||||
Node newNode = this.client.getNodesExtApi().createNode(folderNodeId, body).getEntry();
|
||||
Assertions.assertNotNull(newNode);
|
||||
Assertions.assertNotNull(newNode.getId());
|
||||
Assertions.assertEquals(folderNodeId, newNode.getParentId());
|
||||
Assertions.assertEquals(nodeBody.getNodeType(), newNode.getNodeType());
|
||||
Assertions.assertTrue(newNode.getName().startsWith("test-name1"));
|
||||
}
|
||||
|
||||
}
|
26
src/test/java/com/inteligr8/alfresco/acs/UploadIT.java
Normal file
26
src/test/java/com/inteligr8/alfresco/acs/UploadIT.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.RequestQuery;
|
||||
import com.inteligr8.alfresco.acs.model.RequestQuery.LanguageEnum;
|
||||
import com.inteligr8.alfresco.acs.model.ResultNode;
|
||||
import com.inteligr8.alfresco.acs.model.ResultSetPaging;
|
||||
import com.inteligr8.alfresco.acs.model.SearchRequest;
|
||||
|
||||
public abstract class UploadIT extends ConditionalIT {
|
||||
|
||||
public abstract AcsPublicRestApi getClient();
|
||||
|
||||
public String getSharedFolder() {
|
||||
RequestQuery query = new RequestQuery();
|
||||
query.setLanguage(LanguageEnum.AFTS);
|
||||
query.setQuery("=@cm:name:'Shared'");
|
||||
|
||||
SearchRequest searchRequest = new SearchRequest();
|
||||
searchRequest.setQuery(query);
|
||||
|
||||
ResultSetPaging paging = this.getClient().getSearchApi().search(searchRequest);
|
||||
ResultNode folderNode = paging.getList().getEntries().iterator().next().getEntry();
|
||||
return folderNode.getId();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
org.glassfish.jersey.client.JerseyClientBuilder
|
Loading…
x
Reference in New Issue
Block a user