this.currentOperation.getTargetEntity(),
this.onset.getRequestId(), this);
this.targetLock = lock;
- LockResult<GuardResult, TargetLock> lockResult =
- LockResult.createLockResult(GuardResult.LOCK_ACQUIRED, lock);
- return lockResult;
+ return LockResult.createLockResult(GuardResult.LOCK_ACQUIRED, lock);
}
//
// Have we acquired it already?
try {
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
} catch (PIPException ex) {
- logger.error("getAttribute threw:", ex);
+ logger.error("getAttribute threw", ex);
return null;
}
if (pipResponse == null) {
Set<String> setUids = new HashSet<>();
for (Attribute attributeUid : listUids) {
Iterator<AttributeValue<String>> iterAttributeValues = attributeUid.findValues(DataTypes.DT_STRING);
- if (iterAttributeValues != null) {
- while (iterAttributeValues.hasNext()) {
- String uid = iterAttributeValues.next().getValue();
- if (uid != null) {
- setUids.add(uid);
- }
+ if (iterAttributeValues == null) {
+ continue;
+ }
+ while (iterAttributeValues.hasNext()) {
+ String uid = iterAttributeValues.next().getValue();
+ if (uid == null) {
+ continue;
}
+ setUids.add(uid);
}
}
-
return setUids;
}
props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
} catch (NullPointerException e) {
- logger.error("getStatusFromDB: {} when setting properties", e.getMessage());
+ logger.error("getStatusFromDb: when setting properties", e);
}
//
// Set opsHistPu to the correct value and clear properties if necessary.
//
String opsHistPu = System.getProperty("OperationsHistoryPU");
- if (opsHistPu == null || !opsHistPu.equals("TestOperationsHistoryPU")) {
+ if (!"TestOperationsHistoryPU".equals(opsHistPu)) {
opsHistPu = "OperationsHistoryPU";
} else {
props.clear();
emf = Persistence.createEntityManagerFactory(opsHistPu, props);
} catch (Exception ex) {
logger.error("PIP thread got Exception. Can't connect to Operations History DB -- {}", opsHistPu);
- logger.error("getStatusFromDb threw: ", ex);
+ logger.error("getStatusFromDb threw", ex);
return null;
}
try {
em = emf.createEntityManager();
} catch (Exception ex) {
logger.error("PIP thread got Exception. Problem creating EntityManager");
- logger.error("getStatusFromDb threw: ", ex);
+ logger.error("getStatusFromDb threw", ex);
emf.close();
return null;
}
try {
ret = ((String)nq.getSingleResult());
} catch (NoResultException ex) {
- logger.debug("NoResultException for getSingleResult()");
+ logger.debug("NoResultException for getSingleResult()", ex);
ret = "NO_MATCHING_ENTRY";
} catch (Exception ex) {
logger.error("getStatusFromDB threw an exception", ex);
try {
em.close();
} catch (Exception ex) {
- logger.error("getStatusFromDB threw an exception ", ex);
+ logger.error("getStatusFromDB threw an exception", ex);
}
try {
emf.close();
} catch (Exception ex) {
- logger.error("getStatusFromDB threw an exception ", ex);
+ logger.error("getStatusFromDB threw an exception", ex);
}
return ret;
}
//
// Create an artificial Guard response in case we didn't get a clear Permit or Deny
//
- if (guardResponse.getResult().equals("Indeterminate")) {
+ if ("Indeterminate".equals(guardResponse.getResult())) {
guardResponse.setOperation(recipe);
guardResponse.setRequestID(UUID.fromString(requestId));
}
private static final Logger netLogger =
LoggerFactory.getLogger(org.onap.policy.common.endpoints.event.comm.Topic.NETWORK_LOGGER);
- // Constant for the systme line separator
+ // Constant for the system line separator
private static final String SYSTEM_LS = System.lineSeparator();
- private static String propfile;
+ private String propfile;
+ private UrlEntry[] restUrls = null;
+ private int restUrlIndex = 0;
+
+ // REST timeout, initialized from 'pdpx.timeout' property
+ private int timeout = 20000;
public PolicyGuardXacmlHelperEmbedded() {
init(PolicyEngine.manager.getEnvironment());
String environment = null;
}
- private UrlEntry[] restUrls = null;
- private int restUrlIndex = 0;
-
- // REST timeout, initialized from 'pdpx.timeout' property
- private int timeout = 20000;
-
/**
* Call PDP.
*
urlEntry.authorization, urlEntry.clientAuth, urlEntry.environment);
netLogger.info("[IN|{}|{}|]{}{}", "GUARD", urlEntry.restUrl, SYSTEM_LS, response);
} catch (Exception e) {
- logger.error("Error in sending RESTful request: ", e);
+ logger.error("Error in sending RESTful request", e);
}
return response;
* @param xacmlReq the XACML request
* @return the response
*/
- public static String callEmbeddedPdp(PolicyGuardXacmlRequestAttributes xacmlReq) {
+ public String callEmbeddedPdp(PolicyGuardXacmlRequestAttributes xacmlReq) {
com.att.research.xacml.api.Response response = null;
Properties props = new Properties();
//
BufferedReader br = new BufferedReader(isr) ) {
props.load(br);
} catch (Exception e) {
- logger.error("Unable to load properties file {} {}", propfile, e.getMessage());
+ logger.error("Unable to load properties file {}", propfile, e);
}
//
// Create embedded PDPEngine
try {
xacmlPdpEngine = ATTPDPEngineFactory.newInstance().newEngine(props);
} catch (Exception e) {
- logger.error("Failed to create new PDPEngine {}", e.getMessage());
+ logger.error("callEmbeddedPdpEngine failed to create new PDPEngine", e);
return null;
}
logger.debug("embedded Engine created");
try {
response = xacmlPdpEngine.decide(RequestParser.parseRequest(xacmlReq));
} catch (Exception e) {
- logger.error(e.getMessage(), e);
+ logger.error("callEmbeddedPdpEngine failed on decide", e);
}
long timeEnd = System.currentTimeMillis();
logger.debug("Elapsed Time: {} ms", (timeEnd - timeStart));