Compare commits
47 Commits
stable-acs
...
v2.0.2-acs
Author | SHA1 | Date | |
---|---|---|---|
f709d8dad8 | |||
f8ee4f79f2 | |||
4563273606 | |||
6ad9c87d13 | |||
2fb0003f70 | |||
c800a492d6 | |||
8e53e44356 | |||
af33dc3730 | |||
1f6838ece7 | |||
038237e2aa | |||
407197d3e9 | |||
29a13ac7b2 | |||
50c6cf6199 | |||
2d05a1a7d0 | |||
f8967b535e | |||
a70dfe2d60 | |||
e9adb1bf2f | |||
898cb702e9 | |||
8fcaed758d | |||
920aeb4ec4 | |||
a015ed5101 | |||
4ddb9aafd4 | |||
7b0963617e | |||
52010dc76e | |||
cac4c90781 | |||
117efaeedd | |||
b3275519ff | |||
3093d2bdc4 | |||
068aff951e | |||
76ac68d0e4 | |||
9e0499b243 | |||
eb0ab01355 | |||
105868b5df | |||
0e8d522769 | |||
7185dd225e | |||
1e4f420f47 | |||
64330e3ca4 | |||
8e538cfec5 | |||
d0c1e92bce | |||
c879fa41b7 | |||
10b8a4c982 | |||
7dd7cc0fd4 | |||
e9ea115849 | |||
5741c77a45 | |||
3bbda05066 | |||
cf1da9b6f1 | |||
1f48c3196f |
36
pom.xml
36
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.0.2-acs60</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 v6.0.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>6.0.0-ea</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>
|
||||||
@@ -145,6 +145,36 @@
|
|||||||
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-core.yaml</inputSpec>
|
<inputSpec>${project.build.directory}/dependency/definitions/alfresco-core.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>
|
||||||
|
@@ -14,14 +14,28 @@
|
|||||||
*/
|
*/
|
||||||
package com.inteligr8.alfresco.acs;
|
package com.inteligr8.alfresco.acs;
|
||||||
|
|
||||||
|
import com.inteligr8.alfresco.acs.api.ActivitiesApi;
|
||||||
|
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.CommentsApi;
|
||||||
|
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.FavoritesApi;
|
||||||
|
import com.inteligr8.alfresco.acs.api.GroupsApi;
|
||||||
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.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.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
|
||||||
@@ -33,26 +47,74 @@ public interface AcsPublicRestApi {
|
|||||||
|
|
||||||
<T> T getApi(Class<T> apiClass);
|
<T> T getApi(Class<T> apiClass);
|
||||||
|
|
||||||
|
default ActivitiesApi getActivitiesApi() {
|
||||||
|
return this.getApi(ActivitiesApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
default AuditApi getAuditApi() {
|
||||||
|
return this.getApi(AuditApi.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 DiscoveryApi getDiscoveryApi() {
|
||||||
|
return this.getApi(DiscoveryApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
default DownloadsApi getDownloadsApi() {
|
||||||
|
return this.getApi(DownloadsApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default FavoritesApi getFavoritesApi() {
|
default FavoritesApi getFavoritesApi() {
|
||||||
return this.getApi(FavoritesApi.class);
|
return this.getApi(FavoritesApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default GroupsApi getGroupsApi() {
|
||||||
|
return this.getApi(GroupsApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
default NetworksApi getNetworksApi() {
|
default NetworksApi getNetworksApi() {
|
||||||
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 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);
|
||||||
}
|
}
|
||||||
@@ -61,6 +123,14 @@ public interface AcsPublicRestApi {
|
|||||||
return this.getApi(TagsApi.class);
|
return this.getApi(TagsApi.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,116 @@
|
|||||||
|
/*
|
||||||
|
* 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.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) {
|
||||||
|
Map<String, ?> props = (Map<String, ?>)nodeBody.getProperties();
|
||||||
|
for (Entry<String, ?> 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,113 @@
|
|||||||
|
/*
|
||||||
|
* 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.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) {
|
||||||
|
Map<String, ?> props = (Map<String, ?>)nodeBody.getProperties();
|
||||||
|
for (Entry<String, ?> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user