diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/api/rest/httputils/HTTPCall.java b/src/main/java/org/gcube/informationsystem/resourceregistry/api/rest/httputils/HTTPCall.java index e38c5a4..0ab4c2c 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/api/rest/httputils/HTTPCall.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/api/rest/httputils/HTTPCall.java @@ -64,7 +64,7 @@ public class HTTPCall { } protected String getParametersDataString( - Map parameters) + Map parameters) throws UnsupportedEncodingException { if (parameters == null) { @@ -79,11 +79,9 @@ public class HTTPCall { } else { result.append(PARAM_SEPARATOR); } - result.append(URLEncoder.encode(key, UTF8)); result.append(PARAM_EQUALS); - result.append(URLEncoder.encode(parameters.get(key), UTF8)); - + result.append(URLEncoder.encode(String.valueOf(parameters.get(key)), UTF8)); } return result.toString(); @@ -158,7 +156,7 @@ public class HTTPCall { DataOutputStream wr = new DataOutputStream( connection.getOutputStream()); - wr.writeBytes(body); + wr.writeBytes(URLEncoder.encode(body, UTF8)); wr.flush(); wr.close(); } @@ -226,7 +224,7 @@ public class HTTPCall { return call(clz, path, method, null, null); } - public C call(Class clz, String path, HTTPMETHOD method, Map parameters) throws Exception { + public C call(Class clz, String path, HTTPMETHOD method, Map parameters) throws Exception { return call(clz, path, method, parameters, null); } @@ -235,7 +233,7 @@ public class HTTPCall { } @SuppressWarnings("unchecked") - protected C call(Class clz, String path, HTTPMETHOD method, Map parameters, String body) throws Exception { + protected C call(Class clz, String path, HTTPMETHOD method, Map parameters, String body) throws Exception { String urlParameters = getParametersDataString(parameters); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/api/utils/Utility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/api/utils/Utility.java index 448da37..e77eac8 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/api/utils/Utility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/api/utils/Utility.java @@ -6,6 +6,7 @@ import java.util.UUID; import org.gcube.informationsystem.impl.utils.ISMapper; import org.gcube.informationsystem.model.ER; import org.gcube.informationsystem.model.ISManageable; +import org.gcube.informationsystem.types.TypeBinder; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.core.JsonProcessingException; @@ -41,6 +42,15 @@ public abstract class Utility { } public static String getType(ISManageable isManageable){ - return isManageable.getClass().getAnnotation(JsonTypeName.class).value(); + return getType(isManageable.getClass()); } + + public static String getType(Class clz){ + if(!clz.isInterface()){ + return clz.getAnnotation(JsonTypeName.class).value(); + }else { + return TypeBinder.getType(clz); + } + } + }