Added exception marshalling/umarshalling via json using jackson
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@144210 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7277239d6b
commit
04d8be5aee
|
@ -32,6 +32,7 @@ import org.gcube.informationsystem.model.entity.Facet;
|
|||
import org.gcube.informationsystem.model.entity.Resource;
|
||||
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.relation.IsRelatedTo;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ExceptionMapper;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
|
||||
|
@ -258,13 +259,28 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
|||
URL url = new URL(callUrl.toString());
|
||||
HttpURLConnection connection = getConnection(url, httpInputs.method);
|
||||
|
||||
logger.debug("Response code for {} is {} : {}",
|
||||
connection.getURL(), connection.getResponseCode(),
|
||||
connection.getResponseMessage());
|
||||
|
||||
if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
throw new Exception(
|
||||
"Error Contacting Resource Registry Service");
|
||||
String responseMessage = connection.getResponseMessage();
|
||||
int responseCode = connection.getResponseCode();
|
||||
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
|
||||
logger.error("Response code for {} is {} : {}",
|
||||
connection.getURL(), responseCode,
|
||||
responseMessage);
|
||||
|
||||
ResourceRegistryException rre = null;
|
||||
try {
|
||||
rre = ExceptionMapper.unmarshal(ResourceRegistryException.class, responseMessage);
|
||||
}catch (Exception e) {
|
||||
rre = new ResourceRegistryException(responseMessage);
|
||||
}
|
||||
|
||||
throw rre;
|
||||
|
||||
}else{
|
||||
logger.debug("Response code for {} is {} : {}",
|
||||
connection.getURL(), responseCode,
|
||||
responseMessage);
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue