Compare commits
30 Commits
stable-acs
...
develop-ac
Author | SHA1 | Date | |
---|---|---|---|
27f2c2677c | |||
783d93dfe2 | |||
14853ca9ca | |||
91f215ec1d | |||
c637298e3b | |||
224a40c1eb | |||
3718b3afb1 | |||
b06c7a5b6e | |||
6becd9fbcd | |||
573804252b | |||
151366e787 | |||
af23be4e64 | |||
b420e53a58 | |||
4587c4d05a | |||
457bdec3ec | |||
afa78f27d5 | |||
11f1b54dc2 | |||
0f32bb67c0 | |||
4563273606 | |||
6ad9c87d13 | |||
39bdc3ab0d | |||
89515eb147 | |||
12b4544f81 | |||
c800a492d6 | |||
8e53e44356 | |||
e80401167a | |||
2d05f7a2a5 | |||
ca54c5f893 | |||
1f6838ece7 | |||
407197d3e9 |
99
pom.xml
99
pom.xml
@ -5,10 +5,10 @@
|
||||
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>acs-public-rest-api</artifactId>
|
||||
<version>2.1-SNAPSHOT-acs51</version>
|
||||
<version>3.0-SNAPSHOT-acs7</version>
|
||||
|
||||
<name>Alfresco Content Services ReST API for Java</name>
|
||||
<description>A library for building ACS v5.1.x JAX-RS REST API clients</description>
|
||||
<description>A library for building ACS v7.x JAX-RS REST API clients</description>
|
||||
<url>https://bitbucket.org/inteligr8/acs-public-rest-api</url>
|
||||
|
||||
<licenses>
|
||||
@ -38,17 +38,17 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
|
||||
|
||||
<swagger.basePackage>com.inteligr8.alfresco.acs</swagger.basePackage>
|
||||
|
||||
<alfresco.platform.version>5.1.0</alfresco.platform.version>
|
||||
<alfresco.platform.version>7.3.0</alfresco.platform.version>
|
||||
|
||||
<jersey.version>2.39.1</jersey.version>
|
||||
<cxf.version>3.5.6</cxf.version>
|
||||
<jackson.version>2.15.1</jackson.version>
|
||||
<jersey.version>3.1.8</jersey.version>
|
||||
<cxf.version>4.0.2</cxf.version>
|
||||
<jackson.version>2.17.2</jackson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -63,9 +63,9 @@
|
||||
<version>2.2.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>2.0.1.Final</version>
|
||||
<groupId>jakarta.activation</groupId>
|
||||
<artifactId>jakarta.activation-api</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -75,7 +75,12 @@
|
||||
<dependency>
|
||||
<groupId>jakarta.ws.rs</groupId>
|
||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||
<version>2.1.6</version>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
@ -131,9 +136,12 @@
|
||||
<plugin>
|
||||
<groupId>io.swagger.codegen.v3</groupId>
|
||||
<artifactId>swagger-codegen-maven-plugin</artifactId>
|
||||
<version>3.0.45</version>
|
||||
<version>3.0.61</version>
|
||||
<configuration>
|
||||
<language>jaxrs-cxf-client</language>
|
||||
<configOptions>
|
||||
<jakarta>true</jakarta>
|
||||
</configOptions>
|
||||
<output>${basedir}</output>
|
||||
<apiPackage>${swagger.basePackage}.api</apiPackage>
|
||||
<modelPackage>${swagger.basePackage}.model</modelPackage>
|
||||
@ -144,6 +152,17 @@
|
||||
<generateModelDocumentation>false</generateModelDocumentation>
|
||||
</configuration>
|
||||
<executions>
|
||||
<!-- search before core, as ContentInfo is incorrect in search -->
|
||||
<execution>
|
||||
<id>swagger-search-codegen</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-search.yaml</inputSpec>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>swagger-core-codegen</id>
|
||||
<phase>generate-sources</phase>
|
||||
@ -164,6 +183,36 @@
|
||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-workflow.yaml</inputSpec>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>swagger-auth-codegen</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-auth.yaml</inputSpec>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>swagger-discovery-codegen</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-discovery.yaml</inputSpec>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>swagger-model-codegen</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-model.yaml</inputSpec>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -191,13 +240,33 @@
|
||||
<replacement></replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\* Alfresco Core REST API[^@]*)@Path\("/"\)</pattern>
|
||||
<pattern>public NodeEntry createNode\(@Multipart.*</pattern>
|
||||
<previousPattern>/\*\*</previousPattern>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\*\*Core API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api/-default-/public/alfresco/versions/1")</replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\* Alfresco Workflow REST API[^@]*)@Path\("/"\)</pattern>
|
||||
<pattern>(\*\*Workflow API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api/-default-/public/workflow/versions/1")</replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\*\*Authentication API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api/-default-/public/authentication/versions/1")</replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\*\*Discovery API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api")</replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\*\*Search API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api/-default-/public/search/versions/1")</replacement>
|
||||
</regex>
|
||||
<regex>
|
||||
<pattern>(\*\*Model API\*\*[^@]*)@Path\("/"\)</pattern>
|
||||
<replacement>$1@Path("/api/-default-/public/alfresco/versions/1")</replacement>
|
||||
</regex>
|
||||
</regexes>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -14,18 +14,36 @@
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.ActionsApi;
|
||||
import com.inteligr8.alfresco.acs.api.ActivitiesApi;
|
||||
import com.inteligr8.alfresco.acs.api.AspectsApi;
|
||||
import com.inteligr8.alfresco.acs.api.AuditApi;
|
||||
import com.inteligr8.alfresco.acs.api.AuthenticationApi;
|
||||
import com.inteligr8.alfresco.acs.api.CommentsApi;
|
||||
import com.inteligr8.alfresco.acs.api.DeploymentsApi;
|
||||
import com.inteligr8.alfresco.acs.api.DiscoveryApi;
|
||||
import com.inteligr8.alfresco.acs.api.DownloadsApi;
|
||||
import com.inteligr8.alfresco.acs.api.FavoritesApi;
|
||||
import com.inteligr8.alfresco.acs.api.GroupsApi;
|
||||
import com.inteligr8.alfresco.acs.api.NetworksApi;
|
||||
import com.inteligr8.alfresco.acs.api.NodesApi;
|
||||
import com.inteligr8.alfresco.acs.api.PeopleApi;
|
||||
import com.inteligr8.alfresco.acs.api.PreferencesApi;
|
||||
import com.inteligr8.alfresco.acs.api.ProbesApi;
|
||||
import com.inteligr8.alfresco.acs.api.ProcessDefinitionsApi;
|
||||
import com.inteligr8.alfresco.acs.api.ProcessesApi;
|
||||
import com.inteligr8.alfresco.acs.api.QueriesApi;
|
||||
import com.inteligr8.alfresco.acs.api.RatingsApi;
|
||||
import com.inteligr8.alfresco.acs.api.RenditionsApi;
|
||||
import com.inteligr8.alfresco.acs.api.SearchApi;
|
||||
import com.inteligr8.alfresco.acs.api.SharedLinksApi;
|
||||
import com.inteligr8.alfresco.acs.api.SitesApi;
|
||||
import com.inteligr8.alfresco.acs.api.TagsApi;
|
||||
import com.inteligr8.alfresco.acs.api.TasksApi;
|
||||
import com.inteligr8.alfresco.acs.api.TrashcanApi;
|
||||
import com.inteligr8.alfresco.acs.api.TypesApi;
|
||||
import com.inteligr8.alfresco.acs.api.V0Api;
|
||||
import com.inteligr8.alfresco.acs.api.VersionsApi;
|
||||
|
||||
/**
|
||||
* This interface consolidates the JAX-RS APIs available in the ACS Public
|
||||
@ -37,26 +55,66 @@ public interface AcsPublicRestApi {
|
||||
|
||||
<T> T getApi(Class<T> apiClass);
|
||||
|
||||
default ActionsApi getActionsApi() {
|
||||
return this.getApi(ActionsApi.class);
|
||||
}
|
||||
|
||||
default ActivitiesApi getActivitiesApi() {
|
||||
return this.getApi(ActivitiesApi.class);
|
||||
}
|
||||
|
||||
default AspectsApi getAspectsApi() {
|
||||
return this.getApi(AspectsApi.class);
|
||||
}
|
||||
|
||||
default AuditApi getAuditApi() {
|
||||
return this.getApi(AuditApi.class);
|
||||
}
|
||||
|
||||
default AuthenticationApi getAuthenticationApi() {
|
||||
return this.getApi(AuthenticationApi.class);
|
||||
}
|
||||
|
||||
default CommentsApi getCommentsApi() {
|
||||
return this.getApi(CommentsApi.class);
|
||||
}
|
||||
|
||||
default DeploymentsApi getDeploymentsApi() {
|
||||
return this.getApi(DeploymentsApi.class);
|
||||
default DeploymentsApi getDeploymentsApi() {
|
||||
return this.getApi(DeploymentsApi.class);
|
||||
}
|
||||
|
||||
default DiscoveryApi getDiscoveryApi() {
|
||||
return this.getApi(DiscoveryApi.class);
|
||||
}
|
||||
|
||||
default DownloadsApi getDownloadsApi() {
|
||||
return this.getApi(DownloadsApi.class);
|
||||
}
|
||||
|
||||
default FavoritesApi getFavoritesApi() {
|
||||
return this.getApi(FavoritesApi.class);
|
||||
}
|
||||
|
||||
default GroupsApi getGroupsApi() {
|
||||
return this.getApi(GroupsApi.class);
|
||||
}
|
||||
|
||||
default NetworksApi getNetworksApi() {
|
||||
return this.getApi(NetworksApi.class);
|
||||
}
|
||||
|
||||
default NodesApi getNodesApi() {
|
||||
return this.getApi(NodesApi.class);
|
||||
}
|
||||
|
||||
default PeopleApi getPeopleApi() {
|
||||
return this.getApi(PeopleApi.class);
|
||||
}
|
||||
|
||||
default PreferencesApi getPreferencesApi() {
|
||||
return this.getApi(PreferencesApi.class);
|
||||
}
|
||||
|
||||
default ProcessDefinitionsApi getProcessDefinitionApi() {
|
||||
return this.getApi(ProcessDefinitionsApi.class);
|
||||
}
|
||||
@ -65,10 +123,30 @@ public interface AcsPublicRestApi {
|
||||
return this.getApi(ProcessesApi.class);
|
||||
}
|
||||
|
||||
default ProbesApi getProbesApi() {
|
||||
return this.getApi(ProbesApi.class);
|
||||
}
|
||||
|
||||
default QueriesApi getQueriesApi() {
|
||||
return this.getApi(QueriesApi.class);
|
||||
}
|
||||
|
||||
default RatingsApi getRatingsApi() {
|
||||
return this.getApi(RatingsApi.class);
|
||||
}
|
||||
|
||||
default RenditionsApi getRenditionsApi() {
|
||||
return this.getApi(RenditionsApi.class);
|
||||
}
|
||||
|
||||
default SearchApi getSearchApi() {
|
||||
return this.getApi(SearchApi.class);
|
||||
}
|
||||
|
||||
default SharedLinksApi getSharedLinksApi() {
|
||||
return this.getApi(SharedLinksApi.class);
|
||||
}
|
||||
|
||||
default SitesApi getSitesApi() {
|
||||
return this.getApi(SitesApi.class);
|
||||
}
|
||||
@ -81,6 +159,18 @@ public interface AcsPublicRestApi {
|
||||
return this.getApi(TasksApi.class);
|
||||
}
|
||||
|
||||
default TrashcanApi getTrashcanApi() {
|
||||
return this.getApi(TrashcanApi.class);
|
||||
}
|
||||
|
||||
default TypesApi getTypesApi() {
|
||||
return this.getApi(TypesApi.class);
|
||||
}
|
||||
|
||||
default VersionsApi getVersionsApi() {
|
||||
return this.getApi(VersionsApi.class);
|
||||
}
|
||||
|
||||
default V0Api getV0Api() {
|
||||
return this.getApi(V0Api.class);
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.NodesCxfApi;
|
||||
|
||||
/**
|
||||
* This interface appends Apache CXF implementation specific methods to the
|
||||
* JAX-RS API of the ACS Public ReST API. This is due to a lack of multi-part
|
||||
* in the JAX-RS specification.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
public interface AcsPublicRestCxfApi extends AcsPublicRestApi {
|
||||
|
||||
default NodesCxfApi getNodesExtApi() {
|
||||
return this.getApi(NodesCxfApi.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs;
|
||||
|
||||
import com.inteligr8.alfresco.acs.api.NodesJerseyApi;
|
||||
|
||||
/**
|
||||
* This interface appends Jersey implementation specific methods to the
|
||||
* JAX-RS API of the ACS Public ReST API. This is due to a lack of multi-part
|
||||
* in the JAX-RS specification.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
public interface AcsPublicRestJerseyApi extends AcsPublicRestApi {
|
||||
|
||||
default NodesJerseyApi getNodesExtApi() {
|
||||
return this.getApi(NodesJerseyApi.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
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;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
@Path("/api/-default-/public/alfresco/versions/1")
|
||||
@Api(value = "/api/-default-/public/alfresco/versions/1", description = "")
|
||||
public interface NodesCxfApi {
|
||||
|
||||
@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,
|
||||
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);
|
||||
*/
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.Error;
|
||||
import com.inteligr8.alfresco.acs.model.NodeBodyCreateMultipartJersey;
|
||||
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;
|
||||
|
||||
@Path("/api/-default-/public/alfresco/versions/1")
|
||||
@Api(value = "/api/-default-/public/alfresco/versions/1", description = "")
|
||||
public interface NodesJerseyApi {
|
||||
|
||||
@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,
|
||||
NodeBodyCreateMultipartJersey file);
|
||||
|
||||
}
|
@ -16,11 +16,11 @@ package com.inteligr8.alfresco.acs.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
|
||||
import com.inteligr8.alfresco.acs.model.v0.AssociationInfo;
|
||||
import com.inteligr8.alfresco.acs.model.v0.ClassInfo;
|
||||
|
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 jakarta.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;
|
||||
|
||||
/**
|
||||
* A CXF utility implementation of the CXF MultipartBody.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
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, ?> props = (Map<String, ?>)nodeBody.getProperties();
|
||||
for (Entry<String, ?> prop : props.entrySet()) {
|
||||
if (prop.getValue() instanceof Collection<?>) {
|
||||
for (Object value : (Collection<?>)prop.getValue())
|
||||
if (value != null)
|
||||
atts.add(toAttachment(prop.getKey(), value.toString()));
|
||||
} else if (prop.getValue() instanceof Object[]) {
|
||||
for (Object value : (Object[])prop.getValue())
|
||||
if (value != null)
|
||||
atts.add(toAttachment(prop.getKey(), value.toString()));
|
||||
} else 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,123 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.inteligr8.alfresco.acs.model;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import jakarta.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;
|
||||
|
||||
/**
|
||||
* A Jersey utility implementation of the Jersey FormDataMultiPart.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
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, ?> props = (Map<String, ?>)nodeBody.getProperties();
|
||||
for (Entry<String, ?> prop : props.entrySet()) {
|
||||
if (prop.getValue() instanceof Collection<?>) {
|
||||
for (Object value : (Collection<?>)prop.getValue())
|
||||
if (value != null)
|
||||
fields.add(new FormDataBodyPart(prop.getKey(), value.toString()));
|
||||
} else if (prop.getValue() instanceof Object[]) {
|
||||
for (Object value : (Object[])prop.getValue())
|
||||
if (value != null)
|
||||
fields.add(new FormDataBodyPart(prop.getKey(), value.toString()));
|
||||
} else 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user