fixed a bug on Exception catching on Collector stubs
This commit is contained in:
parent
1626dddc97
commit
ee9e001fcc
|
@ -24,7 +24,7 @@ public class CollectorStubs implements RegistryStub {
|
|||
|
||||
public static final String TOKEN_HEADER_ENTRY = "gcube-token";
|
||||
public static final String SCOPE_HEADER_ENTRY = "gcube-scope";
|
||||
|
||||
|
||||
private String endopoint;
|
||||
|
||||
public CollectorStubs(String endopoint) {
|
||||
|
@ -51,7 +51,7 @@ public class CollectorStubs implements RegistryStub {
|
|||
if (connection.getResponseCode()!=200) throw new CreateException("error creating resource "+connection.getResponseCode());
|
||||
}catch (Exception e) {
|
||||
log.error("error on create",e);
|
||||
throw new RemoveException(e.getMessage());
|
||||
throw new CreateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class CollectorStubs implements RegistryStub {
|
|||
if (connection.getResponseCode()!=200) throw new UpdateException("error updating resource "+connection.getResponseCode());
|
||||
}catch (Exception e) {
|
||||
log.error("error on update",e);
|
||||
throw new RemoveException(e.getMessage());
|
||||
throw new UpdateException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,12 @@ public class CollectorStubs implements RegistryStub {
|
|||
log.info("response code is not 200");
|
||||
if (connection.getResponseCode()==404)
|
||||
throw new ResourceDoesNotExistException("resource with id "+id+" not found");
|
||||
else throw new RemoveException("error removing resource with id "+id);
|
||||
else throw new RemoveException("generic error removing resource "+id);
|
||||
}
|
||||
}catch (ResourceDoesNotExistException | RemoveException e) {
|
||||
throw e;
|
||||
}catch (Exception e) {
|
||||
log.error("error on remove",e);
|
||||
throw new RemoveException(e.getMessage());
|
||||
throw new RemoveException("connection error removing resource");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ public class CollectorStubs implements RegistryStub {
|
|||
else if (SecurityTokenProvider.instance.get()!=null)
|
||||
connection.setRequestProperty(TOKEN_HEADER_ENTRY,SecurityTokenProvider.instance.get());
|
||||
else throw new RuntimeException("Collector requires authorization (via token or scope)");
|
||||
|
||||
|
||||
connection.setRequestMethod(method);
|
||||
return connection;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue