diff --git a/pom.xml b/pom.xml
index 6188154..1e1d93d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,12 +59,11 @@
org.slf4j
slf4j-api
-
org.gcube.common
gcube-jackson-databind
- test
+
junit
junit
diff --git a/src/main/java/org/gcube/gcat/client/Item.java b/src/main/java/org/gcube/gcat/client/Item.java
index ece0301..94dc460 100644
--- a/src/main/java/org/gcube/gcat/client/Item.java
+++ b/src/main/java/org/gcube/gcat/client/Item.java
@@ -8,6 +8,8 @@ import java.util.Map;
import javax.ws.rs.WebApplicationException;
import javax.xml.ws.WebServiceException;
+import org.gcube.com.fasterxml.jackson.databind.JsonNode;
+import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.gcat.api.GCatConstants;
/**
@@ -23,11 +25,27 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
super(enforcedServiceURL, ITEMS);
}
+ @Override
+ public int count() throws WebServiceException {
+ Map queryParams = new HashMap<>();
+ queryParams.put(GCatConstants.COUNT_ONLY_PARAMETER, String.valueOf(true));
+ String ret = this.list(queryParams);
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ JsonNode jsonNode = objectMapper.readTree(ret);
+ return jsonNode.get(Item.COUNT_KEY).asInt();
+ }catch (WebApplicationException e) {
+ throw e;
+ }catch (Exception e) {
+ throw new WebApplicationException(e);
+ }
+ }
+
/**
- * List the item in the organization correspondent to the current VRE.
+ * List the item in the organisation correspondent to the current VRE.
*
* If the client is entitled to run at VO or ROOT level the method return all the item in all the organization
- * in the catalogue. To filter per organization used the method {@link #list(int, int, String)}
+ * in the catalogue. To filter per organisation used the method {@link #list(int, int, String)}
*/
@Override
public String list(int limit, int offset) throws WebApplicationException {
@@ -43,7 +61,7 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
}
/**
- * List the item of a specific organization.
+ * List the item of a specific organisation.
* This API is only available if the client is entitles to run at VO and ROOT level.
*/
public String list(int limit, int offset, String organizationName) throws WebApplicationException {
@@ -103,4 +121,5 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
super.delete(true, name);
return null;
}
+
}