Compare commits
5 Commits
develop-ac
...
develop-ac
Author | SHA1 | Date | |
---|---|---|---|
224a40c1eb | |||
4587c4d05a | |||
6ad9c87d13 | |||
8e53e44356 | |||
407197d3e9 |
52
pom.xml
52
pom.xml
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>acs-public-rest-api</artifactId>
|
<artifactId>acs-public-rest-api</artifactId>
|
||||||
<version>2.1-SNAPSHOT-acs51</version>
|
<version>2.1-SNAPSHOT-acs52</version>
|
||||||
|
|
||||||
<name>Alfresco Content Services ReST API for Java</name>
|
<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 v5.2.x JAX-RS REST API clients</description>
|
||||||
<url>https://bitbucket.org/inteligr8/acs-public-rest-api</url>
|
<url>https://bitbucket.org/inteligr8/acs-public-rest-api</url>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
<swagger.basePackage>com.inteligr8.alfresco.acs</swagger.basePackage>
|
<swagger.basePackage>com.inteligr8.alfresco.acs</swagger.basePackage>
|
||||||
|
|
||||||
<alfresco.platform.version>5.1.0</alfresco.platform.version>
|
<alfresco.platform.version>5.2.0</alfresco.platform.version>
|
||||||
|
|
||||||
<jersey.version>2.39.1</jersey.version>
|
<jersey.version>2.39.1</jersey.version>
|
||||||
<cxf.version>3.5.6</cxf.version>
|
<cxf.version>3.5.6</cxf.version>
|
||||||
@@ -164,6 +164,36 @@
|
|||||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-workflow.yaml</inputSpec>
|
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-workflow.yaml</inputSpec>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<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-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>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -190,6 +220,10 @@
|
|||||||
<pattern>import org\.apache\.cxf\.jaxrs\.ext\.multipart\.\*;.*</pattern>
|
<pattern>import org\.apache\.cxf\.jaxrs\.ext\.multipart\.\*;.*</pattern>
|
||||||
<replacement></replacement>
|
<replacement></replacement>
|
||||||
</regex>
|
</regex>
|
||||||
|
<regex>
|
||||||
|
<pattern>public NodeEntry createNode\(@Multipart.*</pattern>
|
||||||
|
<previousPattern>/\*\*</previousPattern>
|
||||||
|
</regex>
|
||||||
<regex>
|
<regex>
|
||||||
<pattern>(\* Alfresco Core REST API[^@]*)@Path\("/"\)</pattern>
|
<pattern>(\* Alfresco Core REST API[^@]*)@Path\("/"\)</pattern>
|
||||||
<replacement>$1@Path("/api/-default-/public/alfresco/versions/1")</replacement>
|
<replacement>$1@Path("/api/-default-/public/alfresco/versions/1")</replacement>
|
||||||
@@ -198,6 +232,18 @@
|
|||||||
<pattern>(\* Alfresco Workflow REST API[^@]*)@Path\("/"\)</pattern>
|
<pattern>(\* Alfresco Workflow REST API[^@]*)@Path\("/"\)</pattern>
|
||||||
<replacement>$1@Path("/api/-default-/public/workflow/versions/1")</replacement>
|
<replacement>$1@Path("/api/-default-/public/workflow/versions/1")</replacement>
|
||||||
</regex>
|
</regex>
|
||||||
|
<regex>
|
||||||
|
<pattern>(\* Alfresco Authentication REST API[^@]*)@Path\("/"\)</pattern>
|
||||||
|
<replacement>$1@Path("/api/-default-/public/authentication/versions/1")</replacement>
|
||||||
|
</regex>
|
||||||
|
<regex>
|
||||||
|
<pattern>(\* Alfresco Discovery REST API[^@]*)@Path\("/"\)</pattern>
|
||||||
|
<replacement>$1@Path("/api")</replacement>
|
||||||
|
</regex>
|
||||||
|
<regex>
|
||||||
|
<pattern>(\* Alfresco Search REST API[^@]*)@Path\("/"\)</pattern>
|
||||||
|
<replacement>$1@Path("/api/-default-/public/search/versions/1")</replacement>
|
||||||
|
</regex>
|
||||||
</regexes>
|
</regexes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
@@ -14,18 +14,29 @@
|
|||||||
*/
|
*/
|
||||||
package com.inteligr8.alfresco.acs;
|
package com.inteligr8.alfresco.acs;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.acs.api.ActivitiesApi;
|
||||||
|
import com.inteligr8.alfresco.acs.api.AuthenticationApi;
|
||||||
import com.inteligr8.alfresco.acs.api.CommentsApi;
|
import com.inteligr8.alfresco.acs.api.CommentsApi;
|
||||||
import com.inteligr8.alfresco.acs.api.DeploymentsApi;
|
import com.inteligr8.alfresco.acs.api.DeploymentsApi;
|
||||||
|
import com.inteligr8.alfresco.acs.api.DiscoveryApi;
|
||||||
import com.inteligr8.alfresco.acs.api.FavoritesApi;
|
import com.inteligr8.alfresco.acs.api.FavoritesApi;
|
||||||
import com.inteligr8.alfresco.acs.api.NetworksApi;
|
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.PeopleApi;
|
||||||
|
import com.inteligr8.alfresco.acs.api.PreferencesApi;
|
||||||
import com.inteligr8.alfresco.acs.api.ProcessDefinitionsApi;
|
import com.inteligr8.alfresco.acs.api.ProcessDefinitionsApi;
|
||||||
import com.inteligr8.alfresco.acs.api.ProcessesApi;
|
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.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.SitesApi;
|
||||||
import com.inteligr8.alfresco.acs.api.TagsApi;
|
import com.inteligr8.alfresco.acs.api.TagsApi;
|
||||||
import com.inteligr8.alfresco.acs.api.TasksApi;
|
import com.inteligr8.alfresco.acs.api.TasksApi;
|
||||||
|
import com.inteligr8.alfresco.acs.api.TrashcanApi;
|
||||||
import com.inteligr8.alfresco.acs.api.V0Api;
|
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
|
* This interface consolidates the JAX-RS APIs available in the ACS Public
|
||||||
@@ -37,12 +48,24 @@ public interface AcsPublicRestApi {
|
|||||||
|
|
||||||
<T> T getApi(Class<T> apiClass);
|
<T> T getApi(Class<T> apiClass);
|
||||||
|
|
||||||
|
default ActivitiesApi getActivitiesApi() {
|
||||||
|
return this.getApi(ActivitiesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
default AuthenticationApi getAuthenticationApi() {
|
||||||
|
return this.getApi(AuthenticationApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default CommentsApi getCommentsApi() {
|
default CommentsApi getCommentsApi() {
|
||||||
return this.getApi(CommentsApi.class);
|
return this.getApi(CommentsApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default DeploymentsApi getDeploymentsApi() {
|
||||||
|
return this.getApi(DeploymentsApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default DeploymentsApi getDeploymentsApi() {
|
default DiscoveryApi getDiscoveryApi() {
|
||||||
return this.getApi(DeploymentsApi.class);
|
return this.getApi(DiscoveryApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
default FavoritesApi getFavoritesApi() {
|
default FavoritesApi getFavoritesApi() {
|
||||||
@@ -53,10 +76,18 @@ public interface AcsPublicRestApi {
|
|||||||
return this.getApi(NetworksApi.class);
|
return this.getApi(NetworksApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default NodesApi getNodesApi() {
|
||||||
|
return this.getApi(NodesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default PeopleApi getPeopleApi() {
|
default PeopleApi getPeopleApi() {
|
||||||
return this.getApi(PeopleApi.class);
|
return this.getApi(PeopleApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PreferencesApi getPreferencesApi() {
|
||||||
|
return this.getApi(PreferencesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default ProcessDefinitionsApi getProcessDefinitionApi() {
|
default ProcessDefinitionsApi getProcessDefinitionApi() {
|
||||||
return this.getApi(ProcessDefinitionsApi.class);
|
return this.getApi(ProcessDefinitionsApi.class);
|
||||||
}
|
}
|
||||||
@@ -65,10 +96,26 @@ public interface AcsPublicRestApi {
|
|||||||
return this.getApi(ProcessesApi.class);
|
return this.getApi(ProcessesApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default QueriesApi getQueriesApi() {
|
||||||
|
return this.getApi(QueriesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default RatingsApi getRatingsApi() {
|
default RatingsApi getRatingsApi() {
|
||||||
return this.getApi(RatingsApi.class);
|
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() {
|
default SitesApi getSitesApi() {
|
||||||
return this.getApi(SitesApi.class);
|
return this.getApi(SitesApi.class);
|
||||||
}
|
}
|
||||||
@@ -81,6 +128,14 @@ public interface AcsPublicRestApi {
|
|||||||
return this.getApi(TasksApi.class);
|
return this.getApi(TasksApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default TrashcanApi getTrashcanApi() {
|
||||||
|
return this.getApi(TrashcanApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
default VersionsApi getVersionsApi() {
|
||||||
|
return this.getApi(VersionsApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default V0Api getV0Api() {
|
default V0Api getV0Api() {
|
||||||
return this.getApi(V0Api.class);
|
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 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.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 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.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);
|
||||||
|
|
||||||
|
}
|
@@ -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 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user