Improved exception management
This commit is contained in:
parent
84ebc54546
commit
8154011cc6
|
@ -15,6 +15,7 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
|
@ -690,6 +691,8 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
setAsEntryPoint();
|
||||
setOperation(Operation.QUERY);
|
||||
return reallyGetAll(polymorphic);
|
||||
} catch (WebApplicationException e) {
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
|
@ -715,8 +718,11 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
getElement();
|
||||
|
||||
return true;
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to find {} with UUID {}", accessType.getName(), uuid, e);
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to find {} with UUID {}", accessType.getName(), uuid);
|
||||
logger.error("Unable to find {} with UUID {}", accessType.getName(), uuid, e);
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to find {} with UUID {}", accessType.getName(), uuid, e);
|
||||
|
@ -766,8 +772,14 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
|
||||
return serializeAsJsonNode().toString();
|
||||
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid);
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
@ -807,8 +819,14 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
|
||||
return serializeAsJsonNode().toString();
|
||||
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to create {}", accessType.getName(), e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to create {}", accessType.getName());
|
||||
logger.error("Unable to create {}", accessType.getName(), e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
@ -844,8 +862,11 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
getElement();
|
||||
|
||||
return serializeAsJsonNode().toString();
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to read {} with UUID {}", accessType.getName(), uuid, e);
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to read {} with UUID {}", accessType.getName(), uuid);
|
||||
logger.error("Unable to read {} with UUID {}", accessType.getName(), uuid, e);
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to read {} with UUID {}", accessType.getName(), uuid, e);
|
||||
|
@ -880,8 +901,14 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
|
||||
return serializeAsJsonNode().toString();
|
||||
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid);
|
||||
logger.error("Unable to update {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
@ -922,8 +949,14 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
}else {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to delete {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to delete {} with UUID {}", accessType.getName(), uuid);
|
||||
logger.error("Unable to delete {} with UUID {}", accessType.getName(), uuid, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
@ -959,6 +992,9 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
|
||||
Set<String> contexts = InstanceEnvironment.getContexts(getElement());
|
||||
return contexts;
|
||||
} catch (WebApplicationException e) {
|
||||
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
||||
throw e;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue