diff --git a/.gitignore b/.gitignore
index 2af3a1c..33f9969 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,4 +2,6 @@
target/
bin/
.project
-.classpath
\ No newline at end of file
+.classpath
+.idea
+*.iml
\ No newline at end of file
diff --git a/README.md b/README.md
index 6c5e29b..7d20cc4 100644
--- a/README.md
+++ b/README.md
@@ -6,12 +6,18 @@ This library aims to provide some common interfaces / classes that could be used
```java
ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
+
+SimpleModule module = new SimpleModule();
+module.setDeserializerModifier(new RestAPIBeanDeserializerModifier());
+
ObjectMapper mapper = new ObjectMapper();
+mapper.registerModule(module);
mapper.setSerializationInclusion(Include.NON_EMPTY);
resteasyJacksonProvider.setMapper(mapper);
LocalResteasyProviderFactory resteasyProviderFactory = new LocalResteasyProviderFactory(new ResteasyProviderFactory());
resteasyProviderFactory.register(resteasyJacksonProvider);
+resteasyProviderFactory.register(new MultiValuedParamConverterProvider());
RegisterBuiltin.register(resteasyProviderFactory);
String alfrescoBaseUrl = "https://example.com/alfresco";
diff --git a/pom.xml b/pom.xml
index dc8077f..192a1e6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
de.acosix.alfresco.rest.client
de.acosix.alfresco.rest.client
- 0.1.0
+ 0.1.1
jar
Acosix Alfresco v1 ReST API Client
diff --git a/src/main/java/de/acosix/alfresco/rest/client/api/NodesV1.java b/src/main/java/de/acosix/alfresco/rest/client/api/NodesV1.java
index ba97cd0..54f86ea 100644
--- a/src/main/java/de/acosix/alfresco/rest/client/api/NodesV1.java
+++ b/src/main/java/de/acosix/alfresco/rest/client/api/NodesV1.java
@@ -86,7 +86,9 @@ public static enum IncludeOption
/**
* Include {@link NodeResponseEntity#getPermissions() permissions}
*/
- PERMISSIONS("permissions");
+ PERMISSIONS("permissions"),
+
+ PROPERTIES("properties");
private final String simpleName;
diff --git a/src/main/java/de/acosix/alfresco/rest/client/api/QueriesV1.java b/src/main/java/de/acosix/alfresco/rest/client/api/QueriesV1.java
new file mode 100644
index 0000000..4b51217
--- /dev/null
+++ b/src/main/java/de/acosix/alfresco/rest/client/api/QueriesV1.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2019 Acosix GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package de.acosix.alfresco.rest.client.api;
+
+import de.acosix.alfresco.rest.client.model.common.MultiValuedParam;
+import de.acosix.alfresco.rest.client.model.nodes.ChildNodeResponseEntity;
+import de.acosix.alfresco.rest.client.model.nodes.NodeResponseEntity;
+import de.acosix.alfresco.rest.client.model.nodes.PaginatedNodeChildrenList;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import java.util.List;
+
+/**
+ * Instances of this API provide operations to work with queries: nodes.
+ *
+ * @author Kanagat Nugusbayev
+ */
+@Path("/api/-default-/public/alfresco/versions/1/queries")
+public interface QueriesV1 {
+
+ /**
+ * Note: this endpoint is available in Alfresco 5.2 and newer versions.
+ *
+ * Gets a list of nodes that match the given search criteria.
+ *
+ * The search term is used to look for nodes that match against name, title, description, full text content or tags.
+ *
+ * The search term:
+ *
+ * - must contain a minimum of 3 alphanumeric characters
+ * - allows "quoted term"
+ * - can optionally use '*' for wildcard matching
+ * By default, file and folder types will be searched unless a specific type is provided as a query parameter.
+ *
+ * By default, the search will be across the repository unless a specific root node id is provided to start the search from.
+ *
+ * You can sort the result list using the orderBy parameter. You can specify one or more of the following fields in the orderBy parameter:
+ *
+ * - name
+ * - modifiedAt
+ * - createdAt
+ *
+ * @param term - The term to search for.
+ * @param rootNodeId - The id of the node to start the search from. Supports the aliases -my-, -root- and -shared-.
+ * @param skipCount - The number of entities that exist in the collection before those included in this list. If not supplied then the default value is 0.
+ * @param maxItems - The maximum number of items to return in the list. If not supplied then the default value is 100.
+ * @param nodeType - Restrict the returned results to only those of the given node type and its sub-types
+ * @param include - Returns additional information about the node. The following optional fields can be requested:
+ * allowableOperations
+ * aspectNames
+ * isLink
+ * isFavorite
+ * isLocked
+ * path
+ * properties
+ * @param orderBy - A string to control the order of the entities returned in a list. To sort the entities in a specific order,
+ * you can use the ASC and DESC keywords for any field.
+ * @param fields - A list of field names.
+ * @return the retrieved node in the detail requested
+ */
+ @GET
+ @Path("/nodes")
+ @Produces("application/json")
+ PaginatedNodeChildrenList queryNodes(@QueryParam("term") String term,
+ @QueryParam("rootNodeId") String rootNodeId,
+ @QueryParam("skipCount") Integer skipCount,
+ @QueryParam("maxItems") Integer maxItems,
+ @QueryParam("nodeType") String nodeType,
+ @QueryParam("include") MultiValuedParam include,
+ @QueryParam("orderBy") MultiValuedParam orderBy,
+ @QueryParam("fields") MultiValuedParam fields);
+
+}
diff --git a/src/test/java/de/acosix/alfresco/rest/client/api/integration/QueriesV1Tests.java b/src/test/java/de/acosix/alfresco/rest/client/api/integration/QueriesV1Tests.java
new file mode 100644
index 0000000..ab959e4
--- /dev/null
+++ b/src/test/java/de/acosix/alfresco/rest/client/api/integration/QueriesV1Tests.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2019 Acosix GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package de.acosix.alfresco.rest.client.api.integration;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import de.acosix.alfresco.rest.client.api.AuthenticationV1;
+import de.acosix.alfresco.rest.client.api.NodesV1;
+import de.acosix.alfresco.rest.client.api.QueriesV1;
+import de.acosix.alfresco.rest.client.jackson.RestAPIBeanDeserializerModifier;
+import de.acosix.alfresco.rest.client.model.authentication.TicketEntity;
+import de.acosix.alfresco.rest.client.model.authentication.TicketRequest;
+import de.acosix.alfresco.rest.client.model.common.MultiValuedParam;
+import de.acosix.alfresco.rest.client.model.nodes.NodeCreationRequestEntity;
+import de.acosix.alfresco.rest.client.model.nodes.NodeResponseEntity;
+import de.acosix.alfresco.rest.client.model.nodes.PaginatedNodeChildrenList;
+import de.acosix.alfresco.rest.client.resteasy.MultiValuedParamConverterProvider;
+import org.apache.commons.codec.binary.Base64;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
+import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
+import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
+import org.jboss.resteasy.client.jaxrs.internal.LocalResteasyProviderFactory;
+import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
+import org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.core.UriBuilder;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Nugusbayev Kanagat
+ */
+public class QueriesV1Tests {
+
+ private ResteasyWebTarget target;
+
+ private QueriesV1 queriesAPI;
+
+ private NodesV1 nodesAPI;
+
+ @Before
+ public void setup() {
+ final SimpleModule module = new SimpleModule();
+ module.setDeserializerModifier(new RestAPIBeanDeserializerModifier());
+
+ final ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
+ final ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_EMPTY);
+ mapper.registerModule(module);
+ resteasyJacksonProvider.setMapper(mapper);
+
+ final LocalResteasyProviderFactory resteasyProviderFactory = new LocalResteasyProviderFactory(new ResteasyProviderFactory());
+ resteasyProviderFactory.register(resteasyJacksonProvider);
+ resteasyProviderFactory.register(new MultiValuedParamConverterProvider());
+ // will cause a warning regarding Jackson provider which is already registered
+ RegisterBuiltin.register(resteasyProviderFactory);
+
+ final ResteasyClient client = new ResteasyClientBuilder().providerFactory(resteasyProviderFactory).build();
+ this.target = client.target(UriBuilder.fromPath("http://localhost:8082/alfresco"));
+
+ final TicketRequest rq = new TicketRequest();
+ rq.setUserId("admin");
+ rq.setPassword("admin");
+
+ final AuthenticationV1 authenticationAPI = this.target.proxy(AuthenticationV1.class);
+ final TicketEntity ticket = authenticationAPI.createTicket(rq);
+
+ final ClientRequestFilter rqAuthFilter = (requestContext) -> {
+ final String base64Token = Base64.encodeBase64String(ticket.getId().getBytes(StandardCharsets.UTF_8));
+ requestContext.getHeaders().add("Authorization", "Basic " + base64Token);
+ };
+ this.target.register(rqAuthFilter);
+
+ this.queriesAPI = this.target.proxy(QueriesV1.class);
+ this.nodesAPI = this.target.proxy(NodesV1.class);
+ }
+
+ @Test
+ public void createNewNodeAndFindItViaQueries() throws InterruptedException {
+ final NodeCreationRequestEntity nodeToCreate = new NodeCreationRequestEntity();
+ nodeToCreate.setNodeType("cm:folder");
+ final String name = "foobar";
+ nodeToCreate.setName(name);
+ final Map properties = new HashMap<>();
+ properties.put("cm:title", "foo bar");
+ nodeToCreate.setProperties(properties);
+
+ final NodeResponseEntity createdNode = this.nodesAPI.createNode("-root-", nodeToCreate);
+
+ PaginatedNodeChildrenList paginatedNodeChildrenList = this.queriesAPI.queryNodes("foobar", "-root-", 0, 10, "cm:folder", new MultiValuedParam("properties"), null, new MultiValuedParam("id", "name", "parentId"));
+
+ Assert.assertNotNull(paginatedNodeChildrenList);
+
+ System.out.println(paginatedNodeChildrenList.getEntries());
+ System.out.println(paginatedNodeChildrenList.getPagination());
+ System.out.println(paginatedNodeChildrenList.getSource());
+ }
+
+}