Compare commits
28 Commits
v1.1.1-v1-
...
v1.1.8-acs
Author | SHA1 | Date | |
---|---|---|---|
8565394007 | |||
0989b7891e | |||
2105748896 | |||
8ab396fc57 | |||
9a24fff0de | |||
436df2e4be | |||
dd43fcd0e1 | |||
4f2aab316d | |||
e971cfdaea | |||
ba3aaa97f3 | |||
b1f4399412 | |||
ac59ee7960 | |||
d0afee96da | |||
8f4370a55f | |||
de86a1e01e | |||
e610752bc1 | |||
e07a8f9c0e | |||
7f495b6c76 | |||
41c7bd062b | |||
5d7d2b68ec | |||
ac0622c1e4 | |||
1211f8ad5b | |||
8c2c394e9f | |||
61400ad8c7 | |||
6cc939addb | |||
147a9a4a3e | |||
9f4f0d1c9f | |||
7089fb2bc8 |
171
pom.xml
171
pom.xml
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>acs-public-rest-api</artifactId>
|
||||
<version>1.1.1-v1-acs6</version>
|
||||
<version>1.1.8</version>
|
||||
<name>Alfresco Content Services ReST API Client for Java</name>
|
||||
|
||||
<properties>
|
||||
@@ -15,7 +15,9 @@
|
||||
<!-- If you want to build for your specific version, point to your own
|
||||
installation -->
|
||||
<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>
|
||||
@@ -29,7 +31,7 @@
|
||||
<dependency>
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<artifactId>common-rest-api</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
@@ -96,6 +98,12 @@
|
||||
<version>4.5.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.16.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -117,8 +125,29 @@
|
||||
</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>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<classifier>${acs.platform.tag}</classifier>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
@@ -129,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>
|
||||
@@ -140,23 +175,120 @@
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/*Jersey*</exclude>
|
||||
<exclude>**/*Cxf*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.repaint.maven</groupId>
|
||||
<artifactId>tiles-maven-plugin</artifactId>
|
||||
<version>2.21</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<filtering>true</filtering>
|
||||
<tiles>
|
||||
<tile>com.inteligr8:maven-public-deploy-tile:[1.0.0,2.0.0)</tile>
|
||||
</tiles>
|
||||
</configuration>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<phase>package</phase>
|
||||
<goals><goal>jar</goal></goals>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</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>
|
||||
@@ -409,7 +541,7 @@
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>inteligr8-releases</id>
|
||||
<id>inteligr8-public</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
@@ -420,8 +552,19 @@
|
||||
<url>https://repository.mulesoft.org/releases</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>inteligr8-releases</id>
|
||||
<id>inteligr8-public</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>inteligr8-releases</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>inteligr8-snapshots</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
|
@@ -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,6 +7,14 @@ import org.springframework.context.annotation.Configuration;
|
||||
import com.inteligr8.rs.ClientCxfConfiguration;
|
||||
import com.inteligr8.rs.ClientJerseyConfiguration;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the
|
||||
* ClientConfiguration interface. You can use it outside of the Spring
|
||||
* context, but you will need the spring-context and spring-beans libraries in
|
||||
* your non-Spring application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
public class AcsClientConfiguration implements ClientCxfConfiguration, ClientJerseyConfiguration {
|
||||
@@ -20,8 +28,8 @@ public class AcsClientConfiguration implements ClientCxfConfiguration, ClientJer
|
||||
@Value("${content.service.security.basicAuth.password:admin}")
|
||||
private String basicAuthPassword;
|
||||
|
||||
@Value("${content.service.security.accessToken:#{null}}")
|
||||
private String accessToken;
|
||||
@Value("${content.service.security.bearerToken:#{null}}")
|
||||
private String bearerToken;
|
||||
|
||||
@Value("${content.service.security.oauth.tokenUrl:#{null}}")
|
||||
private String oAuthTokenUrl;
|
||||
@@ -49,57 +57,109 @@ public class AcsClientConfiguration implements ClientCxfConfiguration, ClientJer
|
||||
|
||||
@Value("${content.service.jersey.putBodyRequired:true}")
|
||||
private boolean putBodyRequired;
|
||||
|
||||
|
||||
public String getBaseUrl() {
|
||||
return this.baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public String getBasicAuthUsername() {
|
||||
return this.basicAuthUsername;
|
||||
}
|
||||
|
||||
public void setBasicAuthUsername(String basicAuthUsername) {
|
||||
this.basicAuthUsername = basicAuthUsername;
|
||||
}
|
||||
|
||||
public String getBasicAuthPassword() {
|
||||
return this.basicAuthPassword;
|
||||
}
|
||||
|
||||
public void setBasicAuthPassword(String basicAuthPassword) {
|
||||
this.basicAuthPassword = basicAuthPassword;
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
return this.accessToken;
|
||||
public String getBearerToken() {
|
||||
return this.bearerToken;
|
||||
}
|
||||
|
||||
public void setBearerToken(String bearerToken) {
|
||||
this.bearerToken = bearerToken;
|
||||
}
|
||||
|
||||
public String getOAuthTokenUrl() {
|
||||
return this.oAuthTokenUrl;
|
||||
}
|
||||
|
||||
public void setOAuthTokenUrl(String oAuthTokenUrl) {
|
||||
this.oAuthTokenUrl = oAuthTokenUrl;
|
||||
}
|
||||
|
||||
public String getOAuthClientId() {
|
||||
return this.oAuthClientId;
|
||||
}
|
||||
|
||||
public void setOAuthClientId(String oAuthClientId) {
|
||||
this.oAuthClientId = oAuthClientId;
|
||||
}
|
||||
|
||||
public String getOAuthClientSecret() {
|
||||
return this.oAuthClientSecret;
|
||||
}
|
||||
|
||||
public void setOAuthClientSecret(String oAuthClientSecret) {
|
||||
this.oAuthClientSecret = oAuthClientSecret;
|
||||
}
|
||||
|
||||
public String getOAuthAuthCode() {
|
||||
return this.oAuthAuthCode;
|
||||
}
|
||||
|
||||
public void setOAuthAuthCode(String oAuthAuthCode) {
|
||||
this.oAuthAuthCode = oAuthAuthCode;
|
||||
}
|
||||
|
||||
public String getOAuthAuthRedirectUri() {
|
||||
return this.oAuthAuthRedirectUri;
|
||||
}
|
||||
|
||||
public void setOAuthAuthRedirectUri(String oAuthAuthRedirectUri) {
|
||||
this.oAuthAuthRedirectUri = oAuthAuthRedirectUri;
|
||||
}
|
||||
|
||||
public String getOAuthUsername() {
|
||||
return this.oAuthUsername;
|
||||
}
|
||||
|
||||
public void setOAuthUsername(String oAuthUsername) {
|
||||
this.oAuthUsername = oAuthUsername;
|
||||
}
|
||||
|
||||
public String getOAuthPassword() {
|
||||
return this.oAuthPassword;
|
||||
}
|
||||
|
||||
public void setOAuthPassword(String oAuthPassword) {
|
||||
this.oAuthPassword = oAuthPassword;
|
||||
}
|
||||
|
||||
public boolean isDefaultBusEnabled() {
|
||||
return this.defaultBusEnabled;
|
||||
}
|
||||
|
||||
public void setDefaultBusEnabled(boolean defaultBusEnabled) {
|
||||
this.defaultBusEnabled = defaultBusEnabled;
|
||||
}
|
||||
|
||||
public boolean isPutBodyRequired() {
|
||||
return this.putBodyRequired;
|
||||
}
|
||||
|
||||
public void setPutBodyRequired(boolean putBodyRequired) {
|
||||
this.putBodyRequired = putBodyRequired;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,12 @@ import com.inteligr8.rs.ClientCxfConfiguration;
|
||||
import com.inteligr8.rs.ClientCxfImpl;
|
||||
|
||||
/**
|
||||
* Configured JAX-RS Client & WebTarget for ACS & CXF
|
||||
* This class provides a POJO & Spring-based implementation of the Apache
|
||||
* CXF client. You can use it outside of the Spring context, but you will need
|
||||
* the spring-context and spring-beans libraries in your non-Spring
|
||||
* application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("acs.client.cxf")
|
||||
@Lazy
|
||||
@@ -17,6 +22,20 @@ public class AcsClientCxfImpl extends ClientCxfImpl {
|
||||
@Autowired
|
||||
private AcsClientConfiguration config;
|
||||
|
||||
/**
|
||||
* This constructor is for Spring use.
|
||||
*/
|
||||
protected AcsClientCxfImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is for POJO use.
|
||||
* @param config
|
||||
*/
|
||||
public AcsClientCxfImpl(AcsClientConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientCxfConfiguration getConfig() {
|
||||
return this.config;
|
||||
|
@@ -8,7 +8,12 @@ import com.inteligr8.rs.ClientJerseyConfiguration;
|
||||
import com.inteligr8.rs.ClientJerseyImpl;
|
||||
|
||||
/**
|
||||
* Configured JAX-RS Client & WebTarget for ACS & Jersey
|
||||
* This class provides a POJO & Spring-based implementation of the Apache
|
||||
* CXF client. You can use it outside of the Spring context, but you will need
|
||||
* the spring-context and spring-beans libraries in your non-Spring
|
||||
* application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("acs.client.jersey")
|
||||
@Lazy
|
||||
@@ -17,6 +22,20 @@ public class AcsClientJerseyImpl extends ClientJerseyImpl {
|
||||
@Autowired
|
||||
private AcsClientConfiguration config;
|
||||
|
||||
/**
|
||||
* This constructor is for Spring use.
|
||||
*/
|
||||
protected AcsClientJerseyImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is for POJO use.
|
||||
* @param config
|
||||
*/
|
||||
public AcsClientJerseyImpl(AcsClientConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClientJerseyConfiguration getConfig() {
|
||||
return this.config;
|
||||
|
@@ -24,111 +24,220 @@ import com.inteligr8.alfresco.acs.api.TagsApi;
|
||||
import com.inteligr8.alfresco.acs.api.TrashcanApi;
|
||||
import com.inteligr8.alfresco.acs.api.V0Api;
|
||||
import com.inteligr8.alfresco.acs.api.VersionsApi;
|
||||
import com.inteligr8.rs.AuthorizationFilter;
|
||||
import com.inteligr8.rs.Client;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
/**
|
||||
* Alfresco Content Services Spring-ready API
|
||||
* This class serves as the base implementation for the JAX-RS API for the ACS
|
||||
* Public ReST API.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
public abstract class AcsPublicRestApi {
|
||||
|
||||
abstract ClientConfiguration getConfig();
|
||||
|
||||
protected abstract <T> T getApi(Class<T> apiClass);
|
||||
abstract Client getClient();
|
||||
|
||||
protected final <T> T getApi(Class<T> apiClass) {
|
||||
return this.getApi(null, apiClass);
|
||||
}
|
||||
|
||||
protected <T> T getApi(AuthorizationFilter authFilter, Class<T> apiClass) {
|
||||
return this.getClient().getApi(authFilter, apiClass);
|
||||
}
|
||||
|
||||
public ActionsApi getActionsApi() {
|
||||
return this.getApi(ActionsApi.class);
|
||||
}
|
||||
|
||||
public ActionsApi getActionsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, ActionsApi.class);
|
||||
}
|
||||
|
||||
public ActivitiesApi getActivitiesApi() {
|
||||
return this.getApi(ActivitiesApi.class);
|
||||
}
|
||||
|
||||
public ActivitiesApi getActivitiesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, ActivitiesApi.class);
|
||||
}
|
||||
|
||||
public AuditApi getAuditApi() {
|
||||
return this.getApi(AuditApi.class);
|
||||
}
|
||||
|
||||
public AuditApi getAuditApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, AuditApi.class);
|
||||
}
|
||||
|
||||
public AuthenticationApi getAuthenticationApi() {
|
||||
return this.getApi(AuthenticationApi.class);
|
||||
}
|
||||
|
||||
public AuthenticationApi getAuthenticationApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, AuthenticationApi.class);
|
||||
}
|
||||
|
||||
public CommentsApi getCommentsApi() {
|
||||
return this.getApi(CommentsApi.class);
|
||||
}
|
||||
|
||||
public CommentsApi getCommentsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, CommentsApi.class);
|
||||
}
|
||||
|
||||
public DiscoveryApi getDiscoveryApi() {
|
||||
return this.getApi(DiscoveryApi.class);
|
||||
}
|
||||
|
||||
public DiscoveryApi getDiscoveryApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, DiscoveryApi.class);
|
||||
}
|
||||
|
||||
public DownloadsApi getDownloadsApi() {
|
||||
return this.getApi(DownloadsApi.class);
|
||||
}
|
||||
|
||||
public DownloadsApi getDownloadsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, DownloadsApi.class);
|
||||
}
|
||||
|
||||
public FavoritesApi getFavoritesApi() {
|
||||
return this.getApi(FavoritesApi.class);
|
||||
}
|
||||
|
||||
public FavoritesApi getFavoritesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, FavoritesApi.class);
|
||||
}
|
||||
|
||||
public GroupsApi getGroupsApi() {
|
||||
return this.getApi(GroupsApi.class);
|
||||
}
|
||||
|
||||
public GroupsApi getGroupsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, GroupsApi.class);
|
||||
}
|
||||
|
||||
public NetworksApi getNetworksApi() {
|
||||
return this.getApi(NetworksApi.class);
|
||||
}
|
||||
|
||||
public NetworksApi getNetworksApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, NetworksApi.class);
|
||||
}
|
||||
|
||||
public NodesApi getNodesApi() {
|
||||
return this.getApi(NodesApi.class);
|
||||
}
|
||||
|
||||
public NodesApi getNodesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, NodesApi.class);
|
||||
}
|
||||
|
||||
public PeopleApi getPeopleApi() {
|
||||
return this.getApi(PeopleApi.class);
|
||||
}
|
||||
|
||||
public PeopleApi getPeopleApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, PeopleApi.class);
|
||||
}
|
||||
|
||||
public PreferencesApi getPreferencesApi() {
|
||||
return this.getApi(PreferencesApi.class);
|
||||
}
|
||||
|
||||
public PreferencesApi getPreferencesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, PreferencesApi.class);
|
||||
}
|
||||
|
||||
public ProbesApi getProbesApi() {
|
||||
return this.getApi(ProbesApi.class);
|
||||
}
|
||||
|
||||
public ProbesApi getProbesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, ProbesApi.class);
|
||||
}
|
||||
|
||||
public QueriesApi getQueriesApi() {
|
||||
return this.getApi(QueriesApi.class);
|
||||
}
|
||||
|
||||
public QueriesApi getQueriesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, QueriesApi.class);
|
||||
}
|
||||
|
||||
public RatingsApi getRatingsApi() {
|
||||
return this.getApi(RatingsApi.class);
|
||||
}
|
||||
|
||||
public RatingsApi getRatingsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, RatingsApi.class);
|
||||
}
|
||||
|
||||
public RenditionsApi getRenditionsApi() {
|
||||
return this.getApi(RenditionsApi.class);
|
||||
}
|
||||
|
||||
public RenditionsApi getRenditionsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, RenditionsApi.class);
|
||||
}
|
||||
|
||||
public SearchApi getSearchApi() {
|
||||
return this.getApi(SearchApi.class);
|
||||
}
|
||||
|
||||
public SearchApi getSearchApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, SearchApi.class);
|
||||
}
|
||||
|
||||
public SharedLinksApi getSharedLinksApi() {
|
||||
return this.getApi(SharedLinksApi.class);
|
||||
}
|
||||
|
||||
public SharedLinksApi getSharedLinksApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, SharedLinksApi.class);
|
||||
}
|
||||
|
||||
public SitesApi getSitesApi() {
|
||||
return this.getApi(SitesApi.class);
|
||||
}
|
||||
|
||||
public SitesApi getSitesApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, SitesApi.class);
|
||||
}
|
||||
|
||||
public TagsApi getTagsApi() {
|
||||
return this.getApi(TagsApi.class);
|
||||
}
|
||||
|
||||
public TagsApi getTagsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, TagsApi.class);
|
||||
}
|
||||
|
||||
public TrashcanApi getTrashcanApi() {
|
||||
return this.getApi(TrashcanApi.class);
|
||||
}
|
||||
|
||||
public TrashcanApi getTrashcanApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, TrashcanApi.class);
|
||||
}
|
||||
|
||||
public VersionsApi getVersionsApi() {
|
||||
return this.getApi(VersionsApi.class);
|
||||
}
|
||||
|
||||
public VersionsApi getVersionsApi(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, VersionsApi.class);
|
||||
}
|
||||
|
||||
public V0Api getV0Api() {
|
||||
return this.getApi(V0Api.class);
|
||||
}
|
||||
|
||||
public V0Api getV0Api(AuthorizationFilter authFilter) {
|
||||
return this.getApi(authFilter, V0Api.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,10 +5,15 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.NodesCxfApi;
|
||||
import com.inteligr8.rs.AuthorizationFilter;
|
||||
import com.inteligr8.rs.Client;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
/**
|
||||
* Alfresco Content Services Spring-ready API for CXF
|
||||
* This class provides the Apache CXF client to the JAX-RS API for the ACS
|
||||
* Public ReST API. It also provides extension API helpers.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("acs.api.cxf")
|
||||
@Lazy
|
||||
@@ -17,18 +22,35 @@ public class AcsPublicRestApiCxfImpl extends AcsPublicRestApi {
|
||||
@Autowired
|
||||
private AcsClientCxfImpl client;
|
||||
|
||||
/**
|
||||
* This constructor is for Spring use.
|
||||
*/
|
||||
protected AcsPublicRestApiCxfImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is for POJO use.
|
||||
*/
|
||||
public AcsPublicRestApiCxfImpl(AcsClientCxfImpl client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
ClientConfiguration getConfig() {
|
||||
return this.client.getConfig();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected <T> T getApi(Class<T> apiClass) {
|
||||
return this.client.getApi(apiClass);
|
||||
Client getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
public NodesCxfApi getNodesExtApi() {
|
||||
return this.client.getApi(NodesCxfApi.class);
|
||||
}
|
||||
|
||||
public NodesCxfApi getNodesExtApi(AuthorizationFilter authFilter) {
|
||||
return this.client.getApi(authFilter, NodesCxfApi.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,10 +5,15 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.NodesJerseyApi;
|
||||
import com.inteligr8.rs.AuthorizationFilter;
|
||||
import com.inteligr8.rs.Client;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
/**
|
||||
* Alfresco Content Services Spring-ready API for Jersey
|
||||
* This class provides the Jersey client to the JAX-RS API for the ACS Public
|
||||
* ReST API. It also provides extension API helpers.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("acs.api.jersey")
|
||||
@Lazy
|
||||
@@ -17,18 +22,35 @@ public class AcsPublicRestApiJerseyImpl extends AcsPublicRestApi {
|
||||
@Autowired
|
||||
private AcsClientJerseyImpl client;
|
||||
|
||||
/**
|
||||
* This constructor is for Spring use.
|
||||
*/
|
||||
protected AcsPublicRestApiJerseyImpl() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is for POJO use.
|
||||
*/
|
||||
public AcsPublicRestApiJerseyImpl(AcsClientJerseyImpl client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
ClientConfiguration getConfig() {
|
||||
return this.client.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T getApi(Class<T> apiClass) {
|
||||
return this.client.getApi(apiClass);
|
||||
Client getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
public NodesJerseyApi getNodesExtApi() {
|
||||
return this.client.getApi(NodesJerseyApi.class);
|
||||
}
|
||||
|
||||
public NodesJerseyApi getNodesExtApi(AuthorizationFilter authFilter) {
|
||||
return this.client.getApi(authFilter, NodesJerseyApi.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,18 +1,14 @@
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Error;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreate;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartCxf;
|
||||
import com.inteligr8.alfresco.acs.model.NodeEntry;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -26,10 +22,10 @@ public interface NodesCxfApi {
|
||||
|
||||
@POST
|
||||
@Path("/nodes/{nodeId}/children")
|
||||
@Consumes({ "application/json", "multipart/form-data" })
|
||||
@Produces({ "application/json" })
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@ApiOperation(value = "Create a node", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 201, message = "Successful response", response = NodeEntry.class),
|
||||
@ApiResponse(code = 400, message = "Invalid parameter: **nodeId** is not a valid format or **nodeBodyCreate** is invalid "),
|
||||
@ApiResponse(code = 401, message = "Authentication failed"),
|
||||
@@ -43,12 +39,35 @@ public interface NodesCxfApi {
|
||||
@ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
|
||||
public NodeEntry createNode(
|
||||
@PathParam("nodeId") String nodeId,
|
||||
NodeBodyCreate nodeBodyCreate,
|
||||
@QueryParam("autoRename") Boolean autoRename,
|
||||
@QueryParam("majorVersion") Boolean majorVersion,
|
||||
@QueryParam("versioningEnabled") Boolean versioningEnabled,
|
||||
@QueryParam("include") List<String> include,
|
||||
@QueryParam("fields") List<String> fields,
|
||||
List<Attachment> attachments);
|
||||
|
||||
NodeBodyCreateMultipartCxf body);
|
||||
/*
|
||||
* This better impl doesn't work
|
||||
*
|
||||
@POST
|
||||
@Path("/nodes/{nodeId}/children")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@ApiOperation(value = "Create a node", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 201, message = "Successful response", response = NodeEntry.class),
|
||||
@ApiResponse(code = 400, message = "Invalid parameter: **nodeId** is not a valid format or **nodeBodyCreate** is invalid "),
|
||||
@ApiResponse(code = 401, message = "Authentication failed"),
|
||||
@ApiResponse(code = 403, message = "Current user does not have permission to create children of **nodeId**"),
|
||||
@ApiResponse(code = 404, message = "**nodeId** or **renditionId** does not exist "),
|
||||
@ApiResponse(code = 409, message = "New name clashes with an existing node in the current parent folder"),
|
||||
@ApiResponse(code = 413, message = "Content exceeds individual file size limit configured for the network or system"),
|
||||
@ApiResponse(code = 415, message = "Content Type is not supported"),
|
||||
@ApiResponse(code = 422, message = "Model integrity exception including a file name containing invalid characters"),
|
||||
@ApiResponse(code = 507, message = "Content exceeds overall storage quota limit configured for the network or system"),
|
||||
@ApiResponse(code = 200, message = "Unexpected error", response = Error.class) })
|
||||
public NodeEntry createNode(
|
||||
@PathParam("nodeId") String nodeId,
|
||||
@Multipart("name") String name,
|
||||
@Multipart("nodeType") String nodeType,
|
||||
@Multipart("filedata") InputStream fileStream,
|
||||
@Multipart("filedata") ContentDisposition disposition,
|
||||
@Multipart(value = "autoRename", required = false) Boolean autoRename,
|
||||
@Multipart(value = "majorVersion", required = false) Boolean majorVersion,
|
||||
@Multipart(value = "versioningEnabled", required = false) Boolean versioningEnabled);
|
||||
*/
|
||||
}
|
||||
|
@@ -1,20 +1,14 @@
|
||||
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;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
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;
|
||||
@@ -28,8 +22,8 @@ public interface NodesJerseyApi {
|
||||
|
||||
@POST
|
||||
@Path("/nodes/{nodeId}/children")
|
||||
@Consumes({ "application/json", "multipart/form-data" })
|
||||
@Produces({ "application/json" })
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@ApiOperation(value = "Create a node", tags={ })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 201, message = "Successful response", response = NodeEntry.class),
|
||||
@@ -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,
|
||||
@QueryParam("autoRename") Boolean autoRename,
|
||||
@QueryParam("majorVersion") Boolean majorVersion,
|
||||
@QueryParam("versioningEnabled") Boolean versioningEnabled,
|
||||
@QueryParam("include") List<String> include,
|
||||
@QueryParam("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;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package com.inteligr8.alfresco.acs.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
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.databind.ObjectMapper;
|
||||
|
||||
public class NodeBodyCreateMultipartCxf extends MultipartBody {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NodeBodyCreateMultipartCxf.class);
|
||||
private static final ObjectMapper om = new ObjectMapper();
|
||||
|
||||
public static NodeBodyCreateMultipartCxf from(
|
||||
NodeBodyCreate nodeBody, String filename, InputStream istream,
|
||||
Boolean autoRename, Boolean majorVersion, Boolean versioningEnabled) throws IOException {
|
||||
List<Attachment> atts = new LinkedList<>();
|
||||
atts.addAll(toAttachments(nodeBody));
|
||||
if (autoRename != null)
|
||||
atts.add(toAttachment("autoRename", String.valueOf(autoRename)));
|
||||
if (majorVersion != null)
|
||||
atts.add(toAttachment("majorVersion", String.valueOf(majorVersion)));
|
||||
if (versioningEnabled != null)
|
||||
atts.add(toAttachment("versioningEnabled", String.valueOf(versioningEnabled)));
|
||||
atts.add(toAttachment(filename, istream));
|
||||
return new NodeBodyCreateMultipartCxf(atts, true);
|
||||
}
|
||||
|
||||
public NodeBodyCreateMultipartCxf(List<Attachment> atts) throws IOException {
|
||||
super(atts);
|
||||
}
|
||||
|
||||
public NodeBodyCreateMultipartCxf(List<Attachment> atts, boolean outbound) throws IOException {
|
||||
super(atts, outbound);
|
||||
}
|
||||
|
||||
public NodeBodyCreate getBody() throws IOException {
|
||||
if (!MediaType.APPLICATION_JSON_TYPE.equals(this.getRootAttachment().getContentType()))
|
||||
throw new IllegalStateException();
|
||||
|
||||
InputStream istream = this.getRootAttachment().getDataHandler().getInputStream();
|
||||
try {
|
||||
return om.readValue(istream, NodeBodyCreate.class);
|
||||
} finally {
|
||||
istream.close();
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment getFiledataAttachment() {
|
||||
return this.getAttachment("filedata");
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 && !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 filename, InputStream istream) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -13,7 +13,7 @@ public class ConstraintInfo {
|
||||
private String type;
|
||||
|
||||
@JsonProperty
|
||||
private List<Map<String, String>> parameters;
|
||||
private List<Map<String, Object>> parameters;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
@@ -23,11 +23,11 @@ public class ConstraintInfo {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<Map<String, String>> getParameters() {
|
||||
public List<Map<String, Object>> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(List<Map<String, String>> parameters) {
|
||||
public void setParameters(List<Map<String, Object>> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,7 @@ public class PropertyInfo extends NamedObject {
|
||||
private boolean indexed;
|
||||
|
||||
@JsonProperty
|
||||
private List<ConstraintInfo> contraints;
|
||||
private List<ConstraintInfo> constraints;
|
||||
|
||||
|
||||
|
||||
@@ -100,5 +100,13 @@ public class PropertyInfo extends NamedObject {
|
||||
public void setIndexed(boolean indexed) {
|
||||
this.indexed = indexed;
|
||||
}
|
||||
|
||||
public List<ConstraintInfo> getConstraints() {
|
||||
return constraints;
|
||||
}
|
||||
|
||||
public void setConstraints(List<ConstraintInfo> constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl
|
@@ -13,7 +13,7 @@ public class ConnectionCxfClientIT extends ConnectionClientIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("acs.api.cxf")
|
||||
private AcsPublicRestApi client;
|
||||
private AcsPublicRestApiCxfImpl client;
|
||||
|
||||
@Override
|
||||
public AcsPublicRestApi getClient() {
|
||||
|
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
|
19
src/test/resources/log4j2.properties
Normal file
19
src/test/resources/log4j2.properties
Normal file
@@ -0,0 +1,19 @@
|
||||
rootLogger.level=trace
|
||||
rootLogger.appenderRef.stdout.ref=STDOUT
|
||||
|
||||
logger.spring.name=org.springframework
|
||||
logger.spring.level=info
|
||||
|
||||
logger.common-rest-api.name=com.inteligr8.rs
|
||||
logger.common-rest-api.level=trace
|
||||
|
||||
logger.this.name=com.inteligr8.alfresco.acs
|
||||
logger.this.level=trace
|
||||
|
||||
logger.jaxrslog.name=jaxrs.request
|
||||
logger.jaxrslog.level=trace
|
||||
|
||||
appender.stdout.type=Console
|
||||
appender.stdout.name=STDOUT
|
||||
appender.stdout.layout.type=PatternLayout
|
||||
appender.stdout.layout.pattern=%C [%t] %m%n
|
53
src/test/vscode/createNode.http
Normal file
53
src/test/vscode/createNode.http
Normal file
@@ -0,0 +1,53 @@
|
||||
@baseUrl = http://localhost:8080/alfresco
|
||||
@username = admin
|
||||
@password = admin
|
||||
|
||||
### Find Folder
|
||||
# @name find
|
||||
POST {{baseUrl}}/api/-default-/public/search/versions/1/search HTTP/1.1
|
||||
Authorization: Basic {{username}}:{{password}}
|
||||
|
||||
{
|
||||
"query": {
|
||||
"language": "afts",
|
||||
"query": "=@cm:name:'Shared'"
|
||||
}
|
||||
}
|
||||
|
||||
@folderNodeId = {{find.response.body.list.entries[0].entry.id}}
|
||||
|
||||
### Upload File
|
||||
# @name upload
|
||||
POST {{baseUrl}}/api/-default-/public/alfresco/versions/1/nodes/{{folderNodeId}}/children?autoRename=true
|
||||
Authorization: Basic {{username}}:{{password}}
|
||||
Content-type: application/json
|
||||
|
||||
{
|
||||
"name": "TestFolder",
|
||||
"nodeType": "cm:content",
|
||||
"properties": null
|
||||
}
|
||||
|
||||
### Upload File
|
||||
# @name upload-form
|
||||
POST {{baseUrl}}/api/-default-/public/alfresco/versions/1/nodes/{{folderNodeId}}/children
|
||||
Authorization: Basic {{username}}:{{password}}
|
||||
Content-type: multipart/form-data; boundary=----Test
|
||||
|
||||
------Test
|
||||
Content-disposition: form-data; name="name"
|
||||
|
||||
TestFolder
|
||||
------Test
|
||||
Content-disposition: form-data; name="nodeType"
|
||||
|
||||
cm:content
|
||||
------Test
|
||||
Content-disposition: form-data; name="autoRename"
|
||||
|
||||
true
|
||||
------Test
|
||||
Content-disposition: form-data; name="filedata"; filename="test.txt"
|
||||
|
||||
This is a test
|
||||
------Test--
|
Reference in New Issue
Block a user