public static final String duplicatePolicyId = "Somehow, more than one policy with the id ";
public static final String foundInDB = " were found in the database";
- public static boolean isJunit = false;
+ private static boolean isJunit = false;
public static void setJunit(boolean isJunit) {
PolicyDBDao.isJunit = isJunit;
for(PDPPolicy policy : policies){
try{
String[] stringArray = getNameScopeAndVersionFromPdpPolicy(policy.getId());
+ if(stringArray == null) {
+ throw new IllegalArgumentException("Invalid input - policyID must contain name, scope and version");
+ }
List<PolicyEntity> policyEntityList;
Query getPolicyEntitiesQuery = em.createNamedQuery("PolicyEntity.findByNameAndScope");
getPolicyEntitiesQuery.setParameter("name", stringArray[0]);
policyId = policyName;
policyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:name AND p.scope=:scope");
policyQuery.setParameter("name", policyId);
- policyQuery.setParameter(scope, scope);
+ policyQuery.setParameter("scope", scope);
} else{
policyId = String.valueOf(policyID);
policyQuery = em.createNamedQuery("PolicyEntity.FindById");
private String readConfigFile(String configPath){
String configDataString = null;
- InputStream configContentStream = null;
- try {
- configContentStream = new FileInputStream(configPath);
+
+ try(InputStream configContentStream = new FileInputStream(configPath)) {
configDataString = IOUtils.toString(configContentStream);
} catch (FileNotFoundException e) {
logger.error("Caught FileNotFoundException on new FileInputStream("+configPath+")",e);
throw new IllegalArgumentException("The config file path does not exist");
} catch(IOException e2){
- logger.error("Caught IOException on newIOUtils.toString("+configContentStream+")",e2);
+ logger.error("Caught IOException on newIOUtils.toString(configContentStream)",e2);
throw new IllegalArgumentException("The config file path cannot be read");
- } finally {
- IOUtils.closeQuietly(configContentStream);
}
if(configDataString == null){
throw new IllegalArgumentException("The config file path cannot be read");