Refs #10172: Add getFilteredResources() in ResourceRegistryClient

Task-Url: https://support.d4science.org/issues/10172

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-api@158123 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-11-02 13:42:31 +00:00
parent 49313df440
commit b2ad6d54e1
2 changed files with 16 additions and 8 deletions

View File

@ -64,7 +64,7 @@ public class HTTPCall {
} }
protected String getParametersDataString( protected String getParametersDataString(
Map<String, String> parameters) Map<String, ? extends Object> parameters)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
if (parameters == null) { if (parameters == null) {
@ -79,11 +79,9 @@ public class HTTPCall {
} else { } else {
result.append(PARAM_SEPARATOR); result.append(PARAM_SEPARATOR);
} }
result.append(URLEncoder.encode(key, UTF8)); result.append(URLEncoder.encode(key, UTF8));
result.append(PARAM_EQUALS); 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(); return result.toString();
@ -158,7 +156,7 @@ public class HTTPCall {
DataOutputStream wr = new DataOutputStream( DataOutputStream wr = new DataOutputStream(
connection.getOutputStream()); connection.getOutputStream());
wr.writeBytes(body); wr.writeBytes(URLEncoder.encode(body, UTF8));
wr.flush(); wr.flush();
wr.close(); wr.close();
} }
@ -226,7 +224,7 @@ public class HTTPCall {
return call(clz, path, method, null, null); return call(clz, path, method, null, null);
} }
public <C> C call(Class<C> clz, String path, HTTPMETHOD method, Map<String, String> parameters) throws Exception { public <C> C call(Class<C> clz, String path, HTTPMETHOD method, Map<String, ? extends Object> parameters) throws Exception {
return call(clz, path, method, parameters, null); return call(clz, path, method, parameters, null);
} }
@ -235,7 +233,7 @@ public class HTTPCall {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <C> C call(Class<C> clz, String path, HTTPMETHOD method, Map<String, String> parameters, String body) throws Exception { protected <C> C call(Class<C> clz, String path, HTTPMETHOD method, Map<String, ? extends Object> parameters, String body) throws Exception {
String urlParameters = getParametersDataString(parameters); String urlParameters = getParametersDataString(parameters);

View File

@ -6,6 +6,7 @@ import java.util.UUID;
import org.gcube.informationsystem.impl.utils.ISMapper; import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.informationsystem.model.ER; import org.gcube.informationsystem.model.ER;
import org.gcube.informationsystem.model.ISManageable; import org.gcube.informationsystem.model.ISManageable;
import org.gcube.informationsystem.types.TypeBinder;
import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
@ -41,6 +42,15 @@ public abstract class Utility {
} }
public static String getType(ISManageable isManageable){ public static String getType(ISManageable isManageable){
return isManageable.getClass().getAnnotation(JsonTypeName.class).value(); return getType(isManageable.getClass());
} }
public static String getType(Class<? extends ISManageable> clz){
if(!clz.isInterface()){
return clz.getAnnotation(JsonTypeName.class).value();
}else {
return TypeBinder.getType(clz);
}
}
} }