Added the possibility to enforce service URL

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/gcat-client@178603 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Luca Frosini 5 years ago
parent 9f9149e841
commit af2d46b095

@ -61,7 +61,6 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.27</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>

@ -32,6 +32,16 @@ abstract class GCatClient {
protected GXHTTPStringRequest gxhttpStringRequest;
public void enforceServiceURL(URL enforcedServiceURL) {
this.serviceURL = enforcedServiceURL;
}
public GCatClient(URL enforcedServiceURL, String basePath, String... basePaths) throws MalformedURLException {
this.serviceURL = enforcedServiceURL;
this.basePaths = new ArrayList<>();
this.basePaths.add(basePath);
this.basePaths.addAll(Arrays.asList(basePaths));
}
public GCatClient(String basePath, String... basePaths) throws MalformedURLException {
this.serviceURL = GCatClientDiscovery.getServiceURL();

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@ -13,11 +14,15 @@ import org.gcube.gcat.api.GCatConstants;
* @author Luca Frosini (ISTI - CNR)
*/
public class Group extends GCatClient implements org.gcube.gcat.api.interfaces.Group<String,Void> {
public Group() throws MalformedURLException {
super(GROUPS);
}
public Group(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, GROUPS);
}
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@ -17,7 +18,11 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
public Item() throws MalformedURLException {
super(ITEMS);
}
public Item(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, ITEMS);
}
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();

@ -1,15 +1,19 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class License extends GCatClient implements org.gcube.gcat.api.interfaces.License {
public License() throws MalformedURLException {
super(LICENSES);
}
public License(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, LICENSES);
}
@Override
public String list() {

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author Luca Frosini (ISTI - CNR)
@ -10,7 +11,11 @@ public class Namespace extends GCatClient implements org.gcube.gcat.api.interfac
public Namespace() throws MalformedURLException {
super(NAMESPACES);
}
public Namespace(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, NAMESPACES);
}
@Override
public String list() {
return super.list(null);

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@ -16,7 +17,11 @@ public class Organization extends GCatClient implements org.gcube.gcat.api.inter
public Organization() throws MalformedURLException {
super(ORGANIZATIONS);
}
public Organization(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, ORGANIZATIONS);
}
@Override
public String list(int limit, int offset) throws WebApplicationException {
Map<String, String> queryParams = new HashMap<>();

@ -2,6 +2,7 @@ package org.gcube.gcat.client;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
@ -16,7 +17,11 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
public Profile() throws MalformedURLException {
super(PROFILES);
}
public Profile(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, PROFILES);
}
@Override
public String list() throws WebApplicationException {
return super.list(null);

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author Luca Frosini (ISTI - CNR)
@ -10,7 +11,11 @@ public class Resource extends GCatClient implements org.gcube.gcat.api.interface
public Resource() throws MalformedURLException {
super(Item.ITEMS);
}
public Resource(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, Item.ITEMS);
}
@Override
public String list(String itemID) {
return super.list(null, itemID, RESOURCES);

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.ws.WebServiceException;
@ -12,7 +13,11 @@ public class User extends GCatClient implements org.gcube.gcat.api.interfaces.Us
public User() throws MalformedURLException {
super(USERS);
}
public User(URL enforcedServiceURL) throws MalformedURLException {
super(enforcedServiceURL, USERS);
}
@Override
public String list() {
return super.list(null);

Loading…
Cancel
Save