From 14b618bf417ed8c33f41bc584d1047c2d2507cf8 Mon Sep 17 00:00:00 2001 From: lucio Date: Wed, 8 Apr 2020 15:40:47 +0200 Subject: [PATCH] added specific exception on CollectorStubs --- .../publisher/stubs/registry/CollectorStubs.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/publisher/stubs/registry/CollectorStubs.java b/src/main/java/org/gcube/informationsystem/publisher/stubs/registry/CollectorStubs.java index 4690e25..dec6fac 100644 --- a/src/main/java/org/gcube/informationsystem/publisher/stubs/registry/CollectorStubs.java +++ b/src/main/java/org/gcube/informationsystem/publisher/stubs/registry/CollectorStubs.java @@ -48,7 +48,7 @@ public class CollectorStubs implements RegistryStub { os.write(profile.getBytes()); } - if (connection.getResponseCode()!=200) throw new Exception("error creating resource "+connection.getResponseCode()); + 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()); @@ -71,7 +71,7 @@ public class CollectorStubs implements RegistryStub { os.write(profile.getBytes()); } - if (connection.getResponseCode()!=200) throw new Exception("error updating resource "+connection.getResponseCode()); + 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()); @@ -89,7 +89,9 @@ public class CollectorStubs implements RegistryStub { connection.setDoInput(true); if (connection.getResponseCode()!=200){ log.info("response code is not 200"); - throw new Exception("error removing resource with id "+id); + if (connection.getResponseCode()==404) + throw new ResourceDoesNotExistException("resource with id "+id+" not found"); + else throw new RemoveException("error removing resource with id "+id); } }catch (Exception e) { log.error("error on remove",e);