|
|
|
@ -6,7 +6,7 @@ import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorEntity;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Don't forget to comment!
|
|
|
|
|
* Manager for extracting information held inside a {@link SerializableErrorEntity}.
|
|
|
|
|
*
|
|
|
|
|
* @author Manuele Simi (ISTI CNR)
|
|
|
|
|
*
|
|
|
|
@ -21,18 +21,34 @@ public class ErrorEntityManager {
|
|
|
|
|
this.entity = entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if there is an {@link Exception} in the entity.
|
|
|
|
|
* @return true if the entity holds an exception, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasException() {
|
|
|
|
|
return Objects.nonNull(this.entity.getExceptionClass());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the {@link Exception} inside the entity.
|
|
|
|
|
* @return the exception or null
|
|
|
|
|
*/
|
|
|
|
|
public <E extends Exception> E getException() {
|
|
|
|
|
return ExceptionDeserializer.deserialize(this.entity.getExceptionClass(),this.entity.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if there is an {@link ErrorCode} in the entity.
|
|
|
|
|
* @return true if the entity holds an errorcode, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasErrorCode() {
|
|
|
|
|
return this.entity.getId() != -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the {@link ErrorCode} inside the entity.
|
|
|
|
|
* @return the error code or null
|
|
|
|
|
*/
|
|
|
|
|
public ErrorCode getErrorCode(){
|
|
|
|
|
return ErrorCodeDeserializer.deserialize(this.entity.getId(), this.entity.getMessage());
|
|
|
|
|
}
|
|
|
|
|