diff --git a/geoportal-client/CHANGELOG.md b/geoportal-client/CHANGELOG.md
index 66630e5..37a377d 100644
--- a/geoportal-client/CHANGELOG.md
+++ b/geoportal-client/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog for org.gcube.application.geoportal-client
+## [v1.2.0-SNAPSHOT] - 2023-04-26
+- Added PATCH method [#24985]
+
## [v1.1.2] - 2023-01-10
- Pom updates
diff --git a/geoportal-client/pom.xml b/geoportal-client/pom.xml
index 0e92db2..4306284 100644
--- a/geoportal-client/pom.xml
+++ b/geoportal-client/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.gcube.application
geoportal-client
- 1.1.2
+ 1.2.0-SNAPSHOT
Geoportal Client
diff --git a/geoportal-client/src/main/java/org/gcube/application/geoportal/client/DefaultDocumentsClient.java b/geoportal-client/src/main/java/org/gcube/application/geoportal/client/DefaultDocumentsClient.java
index e412db2..707621b 100644
--- a/geoportal-client/src/main/java/org/gcube/application/geoportal/client/DefaultDocumentsClient.java
+++ b/geoportal-client/src/main/java/org/gcube/application/geoportal/client/DefaultDocumentsClient.java
@@ -15,14 +15,24 @@ import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.common.clients.Call;
import org.gcube.common.clients.delegates.ProxyDelegate;
+import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import java.io.IOException;
import java.rmi.RemoteException;
import java.util.Iterator;
+/**
+ * Instantiates a new default documents client.
+ *
+ * @param delegate the delegate
+ * @param profileID the profile ID
+ * @param managedClass the managed class
+ */
@RequiredArgsConstructor
@Slf4j
public class DefaultDocumentsClient implements Projects {
@@ -35,10 +45,22 @@ public class DefaultDocumentsClient implements Projects {
protected final Class managedClass;
+ /**
+ * Gets the managed class.
+ *
+ * @return the managed class
+ */
public Class getManagedClass() {
return managedClass;
}
+ /**
+ * Creates the new.
+ *
+ * @param toCreate the to create
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T createNew(Document toCreate) throws RemoteException {
try {
@@ -60,11 +82,24 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Delete by id.
+ *
+ * @param id the id
+ * @throws RemoteException the remote exception
+ */
@Override
public void deleteById(String id) throws RemoteException {
deleteById(id,false);
}
+ /**
+ * Delete by id.
+ *
+ * @param id the id
+ * @param force the force
+ * @throws RemoteException the remote exception
+ */
@Override
public void deleteById(String id, Boolean force) throws RemoteException {
try {
@@ -85,6 +120,13 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Gets the by id.
+ *
+ * @param id the id
+ * @return the by id
+ * @throws RemoteException the remote exception
+ */
@Override
public T getById(String id) throws RemoteException {
try {
@@ -104,6 +146,12 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Gets the configuration.
+ *
+ * @return the configuration
+ * @throws RemoteException the remote exception
+ */
@Override
public Configuration getConfiguration() throws RemoteException {
try {
@@ -122,11 +170,27 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Query.
+ *
+ * @param request the request
+ * @return the iterator
+ * @throws RemoteException the remote exception
+ */
@Override
public Iterator query(QueryRequest request) throws RemoteException {
return queryForClass(request,getManagedClass());
}
+ /**
+ * Query for class.
+ *
+ * @param the generic type
+ * @param request the request
+ * @param clazz the clazz
+ * @return the iterator
+ * @throws RemoteException the remote exception
+ */
@Override
public Iterator queryForClass(QueryRequest request,Class clazz) throws RemoteException {
String jsonString=queryForJSON(request);
@@ -141,6 +205,13 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Query for JSON.
+ *
+ * @param request the request
+ * @return the string
+ * @throws RemoteException the remote exception
+ */
@Override
public String queryForJSON(QueryRequest request) throws RemoteException {
try {
@@ -159,6 +230,14 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Perform step.
+ *
+ * @param id the id
+ * @param request the request
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T performStep(String id, StepExecutionRequest request) throws RemoteException{
try {
@@ -182,6 +261,15 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Register file set.
+ *
+ * @param id the id
+ * @param req the req
+ * @return the t
+ * @throws RemoteException the remote exception
+ * @throws InvalidRequestException the invalid request exception
+ */
@Override
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException, InvalidRequestException {
try {
@@ -209,6 +297,15 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Delete file set.
+ *
+ * @param id the id
+ * @param path the path
+ * @param force the force
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T deleteFileSet(String id, String path, Boolean force) throws RemoteException {
try {
@@ -232,6 +329,13 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Force unlock.
+ *
+ * @param id the id
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T forceUnlock(String id) throws RemoteException {
try {
@@ -254,6 +358,14 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Sets the access policy.
+ *
+ * @param id the id
+ * @param toSet the to set
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T setAccessPolicy(String id, Access toSet) throws RemoteException {
try {
@@ -276,6 +388,14 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Update document.
+ *
+ * @param id the id
+ * @param updatedDocument the updated document
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
@Override
public T updateDocument(String id, Document updatedDocument) throws RemoteException {
try {
@@ -297,7 +417,49 @@ public class DefaultDocumentsClient implements Projects {
throw new RemoteException("Unexpected Error", e);
}
}
+
+ /**
+ * Patch document.
+ * Added by Francesco Mangiacrapa
+ *
+ * @param id the id
+ * @param path the path
+ * @param updatedDocument the updated document
+ * @return the t
+ * @throws RemoteException the remote exception
+ */
+ @Override
+ public T patchDocument(String id, String path, Document updatedDocument) throws RemoteException {
+ try {
+ log.debug("Patching {} [useCaseDescriptor {} , class {}] with ", id, profileID, getManagedClass(),
+ updatedDocument);
+ Call call = endpoint -> {
+ WebTarget webTarget = endpoint.path(profileID).path(id);
+ webTarget.queryParam(InterfaceConstants.Parameters.PATH, path);
+ webTarget.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
+ Response response = webTarget.request(MediaType.APPLICATION_JSON).method("PATCH", Entity.entity(updatedDocument, MediaType.APPLICATION_JSON));
+ return ResponseCommons.check(response, getManagedClass());
+ };
+ T toReturn = delegate.make(call);
+ log.info("Updated ID {} useCaseDescriptor {}", id, profileID);
+ return toReturn;
+ } catch (RemoteException e) {
+ log.error("Unexpected error ", e);
+ throw e;
+ } catch (Exception e) {
+ log.error("Unexpected error ", e);
+ throw new RemoteException("Unexpected Error", e);
+ }
+ }
+
+ /**
+ * Sets the relation.
+ *
+ * @param request the request
+ * @return the project
+ * @throws RemoteException the remote exception
+ */
@Override
public Project setRelation(CreateRelationshipRequest request) throws RemoteException {
try {
@@ -328,6 +490,13 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Delete relation.
+ *
+ * @param request the request
+ * @return the project
+ * @throws RemoteException the remote exception
+ */
@Override
public Project deleteRelation(DeleteRelationshipRequest request) throws RemoteException {
try {
@@ -358,11 +527,28 @@ public class DefaultDocumentsClient implements Projects {
}
}
+ /**
+ * Gets the relationship chain.
+ *
+ * @param id the id
+ * @param relationId the relation id
+ * @return the relationship chain
+ * @throws RemoteException the remote exception
+ */
@Override
public Iterator getRelationshipChain(String id, String relationId) throws RemoteException {
return getRelationshipChain(id,relationId,null);
}
+ /**
+ * Gets the relationship chain.
+ *
+ * @param id the id
+ * @param relationId the relation id
+ * @param deep the deep
+ * @return the relationship chain
+ * @throws RemoteException the remote exception
+ */
@Override
public Iterator getRelationshipChain(String id, String relationId, Boolean deep) throws RemoteException {
try {