} catch(Exception e2){
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e2, policyDBDaoVar, "COULD NOT CREATE DATABASELOCK ROW. WILL TRY ONE MORE TIME");
}
- em = null;
+
em = emf.createEntityManager();
try{
startTransactionSynced(em, 1000);
HttpURLConnection connection = null;
UUID requestID = UUID.randomUUID();
URL url;
+ String papUrl;
try {
- String papUrl = getPapUrlUserPass()[0];
- if(papUrl == null){
- papUrl = "undefined";
- }
+ String[] papUrlUserPass = getPapUrlUserPass();
+ if(papUrlUserPass == null ){
+ papUrl = "undefined";
+ } else {
+ papUrl = papUrlUserPass[0];
+ }
logger.debug("We are going to try to notify "+o);
//is this our own url?
String ourUrl = o;
private String[] getNameScopeAndVersionFromPdpPolicy(String fileName){
String[] splitByDots = fileName.split("\\.");
if(splitByDots.length < 3){
- //should we throw something
- return null;
+ return null;
}
String policyName = splitByDots[splitByDots.length-3];
String version = splitByDots[splitByDots.length-2];
*/
private static boolean isNullOrEmpty(String... strings){
for(String s : strings){
- if(!(s instanceof String)){
- return true;
- }
- if("".equals(s)){
+ if(s == null || "".equals(s)){
return true;
}
}
}
}
}
- if(transactionTimer instanceof Thread){
+ if(transactionTimer != null){
transactionTimer.interrupt();
}
}
}
}
- if(transactionTimer instanceof Thread){
+ if(transactionTimer != null){
transactionTimer.interrupt();
}
}
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");
}
em.close();
}
- if(transactionTimer instanceof Thread){
+ if(transactionTimer != null){
transactionTimer.interrupt();
}
}
//we need to convert the form of the policy id that is used groups into the form that is used
//for the database. (com.Config_mypol.1.xml) to (Config_mypol.xml)
- String[] policyNameScopeAndVersion = getNameScopeAndVersionFromPdpPolicy(policyID);
+ String[] policyNameScopeAndVersion = getNameScopeAndVersionFromPdpPolicy(policyID);
+ if(policyNameScopeAndVersion == null) {
+ throw new IllegalArgumentException("Invalid input - policyID must contain name, scope and version");
+ }
Query policyQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName=:policyName AND p.scope=:scope AND p.deleted=:deleted");
policyQuery.setParameter("policyName", policyNameScopeAndVersion[0]);
policyQuery.setParameter(scope, policyNameScopeAndVersion[1]);