Returns object instead of string
This commit is contained in:
parent
b32ff04e97
commit
e2c84401f2
|
@ -5,37 +5,58 @@ import java.net.URL;
|
||||||
|
|
||||||
import javax.xml.ws.WebServiceException;
|
import javax.xml.ws.WebServiceException;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class Configuration extends GCatClient implements org.gcube.gcat.api.interfaces.Configuration<String,Void> {
|
public class Configuration extends GCatClient implements org.gcube.gcat.api.interfaces.Configuration<CatalogueConfiguration,Void> {
|
||||||
|
|
||||||
|
protected ObjectMapper mapper;
|
||||||
|
|
||||||
public Configuration() throws MalformedURLException {
|
public Configuration() throws MalformedURLException {
|
||||||
super(CONFIGURATION);
|
super(CONFIGURATION);
|
||||||
|
mapper = new ObjectMapper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration(URL enforcedServiceURL) throws MalformedURLException {
|
public Configuration(URL enforcedServiceURL) throws MalformedURLException {
|
||||||
super(enforcedServiceURL, CONFIGURATION);
|
super(enforcedServiceURL, CONFIGURATION);
|
||||||
|
mapper = new ObjectMapper();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CatalogueConfiguration getCatalogueConfigurationFromString(String json) throws WebServiceException {
|
||||||
|
try {
|
||||||
|
return mapper.readValue(json, CatalogueConfiguration.class);
|
||||||
|
} catch (WebServiceException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new WebServiceException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String create(String json) throws WebServiceException {
|
public CatalogueConfiguration create(String json) throws WebServiceException {
|
||||||
return super.create(json);
|
String ret = super.create(json);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String read() throws WebServiceException {
|
public CatalogueConfiguration read() throws WebServiceException {
|
||||||
return super.read(CURRENT_CONTEXT_PATH_PARAMETER);
|
String ret = super.read(CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String update(String json) throws WebServiceException {
|
public CatalogueConfiguration update(String json) throws WebServiceException {
|
||||||
return super.update(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
String ret = super.update(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String patch(String json) throws WebServiceException {
|
public CatalogueConfiguration patch(String json) throws WebServiceException {
|
||||||
return super.patch(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
String ret = super.patch(json, CURRENT_CONTEXT_PATH_PARAMETER);
|
||||||
|
return getCatalogueConfigurationFromString(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue