fix(manager-jpa): Handle Oracle's lack of boolean type.
Oracle DB doesn't have a boolean type. Parse types such as "deleted" to support alternatives such as
1/0 and true/false as text.
MODIFY
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/JpaStorage.java
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/JpaStorage.java
@@ -94,6 +94,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -634,7 +635,7 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
plugin.setDescription(String.valueOf(row[7]));
plugin.setCreatedBy(String.valueOf(row[8]));
plugin.setCreatedOn((Date) row[9]);
- plugin.setDeleted((Boolean) row[10]);
+ plugin.setDeleted(parseBoolValue(row[10]));
return plugin;
} else {
return null;
@@ -645,6 +646,16 @@ public class JpaStorage extends AbstractJpaStorage implements IStorage, IStorage
}
}
+ private Boolean parseBoolValue(Object object) {
+ if (object instanceof Boolean) {
+ return (Boolean) object;
+ } else if (object instanceof Number) {
+ Byte num = ((Number) object).byteValue();
+ return num > 0;
+ }
+ return BooleanUtils.toBooleanObject(String.valueOf(object));
+ }
+
/**
* @see io.apiman.manager.api.core.IStorage#getPolicyDefinition(java.lang.String)
*/

fix(manager-jpa): Handle Oracle's lack of boolean type.

Oracle DB doesn't have a boolean type. Parse types such as "deleted" to support alternatives such as
1/0 and true/false as text.

APIMAN-1266