2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.pap.xacml.rest.components;
23 import com.att.research.xacml.api.pap.PAPException;
24 import com.att.research.xacml.api.pap.PDPPolicy;
25 import com.att.research.xacml.util.XACMLProperties;
27 import java.io.ByteArrayInputStream;
29 import java.io.FileWriter;
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.nio.file.Files;
33 import java.nio.file.Path;
34 import java.nio.file.Paths;
35 import java.util.HashMap;
36 import java.util.HashSet;
37 import java.util.List;
39 import javax.persistence.PersistenceException;
41 import org.apache.commons.io.FilenameUtils;
42 import org.hibernate.Query;
43 import org.hibernate.Session;
44 import org.hibernate.SessionFactory;
45 import org.onap.policy.common.logging.eelf.MessageCodes;
46 import org.onap.policy.common.logging.eelf.PolicyLogger;
47 import org.onap.policy.common.logging.flexlogger.FlexLogger;
48 import org.onap.policy.common.logging.flexlogger.Logger;
49 import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
50 import org.onap.policy.rest.XacmlRestProperties;
51 import org.onap.policy.rest.dao.PolicyDBException;
52 import org.onap.policy.rest.jpa.GroupEntity;
53 import org.onap.policy.rest.jpa.PdpEntity;
54 import org.onap.policy.rest.jpa.PolicyEntity;
55 import org.onap.policy.xacml.api.pap.OnapPDP;
56 import org.onap.policy.xacml.api.pap.OnapPDPGroup;
57 import org.onap.policy.xacml.std.pap.StdPDPGroup;
58 import org.onap.policy.xacml.std.pap.StdPDPPolicy;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.stereotype.Component;
63 public class HandleIncomingNotifications {
65 private static final Logger logger = FlexLogger.getLogger(HandleIncomingNotifications.class);
67 private static final String POLICY_NOTIFICATION = "policy";
68 private static final String PDP_NOTIFICATION = "pdp";
69 private static final String GROUP_NOTIFICATION = "group";
70 public static final String JSON_CONFIG = "JSON";
71 public static final String XML_CONFIG = "XML";
72 public static final String PROPERTIES_CONFIG = "PROPERTIES";
73 public static final String OTHER_CONFIG = "OTHER";
74 public static final String AUDIT_USER = "audit";
76 private static SessionFactory sessionfactory;
79 public HandleIncomingNotifications(SessionFactory sessionfactory) {
80 HandleIncomingNotifications.sessionfactory = sessionfactory;
83 public HandleIncomingNotifications() {
84 // Default Constructor
87 public void handleIncomingHttpNotification(String url, String entityId, String entityType, String extraData,
88 XACMLPapServlet xacmlPapServlet) {
89 logger.info("DBDao url: " + url + " has reported an update on " + entityType + " entity " + entityId);
90 PolicyDBDaoTransaction transaction = PolicyDBDao.getPolicyDBDaoInstance().getNewTransaction();
91 // although its named retries, this is the total number of tries
95 .parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_INCOMINGNOTIFICATION_TRIES));
96 } catch (Exception e) {
97 logger.error("xacml.rest.pap.incomingnotification.tries property not set, using a default of 3." + e);
100 // if someone sets it to some dumb value, we need to make sure it will
105 int pauseBetweenRetries = 1000;
106 switch (entityType) {
108 case POLICY_NOTIFICATION:
109 for (int i = 0; i < retries; i++) {
111 handleIncomingPolicyChange(entityId);
113 } catch (Exception e) {
115 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
116 "Caught exception on handleIncomingPolicyChange(" + url + ", " + entityId + ", "
120 Thread.sleep(pauseBetweenRetries);
121 } catch (InterruptedException ie) {
122 Thread.currentThread().interrupt();
127 case PDP_NOTIFICATION:
128 for (int i = 0; i < retries; i++) {
130 handleIncomingPdpChange(entityId, transaction);
132 } catch (Exception e) {
134 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
135 "Caught exception on handleIncomingPdpChange(" + url + ", " + entityId + ", "
136 + transaction + ")");
139 Thread.sleep(pauseBetweenRetries);
140 } catch (InterruptedException ie) {
141 Thread.currentThread().interrupt();
146 case GROUP_NOTIFICATION:
147 for (int i = 0; i < retries; i++) {
149 handleIncomingGroupChange(entityId, extraData, transaction);
151 } catch (Exception e) {
153 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
154 "Caught exception on handleIncomingGroupChange(" + url + ", " + entityId + ", "
155 + extraData + ", " + transaction + ", " + xacmlPapServlet + ")");
158 Thread.sleep(pauseBetweenRetries);
159 } catch (InterruptedException ie) {
160 Thread.currentThread().interrupt();
166 // no changes should be being made in this function, we still need to
168 transaction.rollbackTransaction();
171 private void handleIncomingGroupChange(String groupId, String extraData, PolicyDBDaoTransaction transaction)
172 throws PAPException, PolicyDBException {
173 GroupEntity groupRecord = null;
174 long groupIdLong = -1;
176 groupIdLong = Long.parseLong(groupId);
177 } catch (NumberFormatException e) {
178 throw new IllegalArgumentException("groupId " + groupId + " cannot be parsed into a long");
181 groupRecord = transaction.getGroup(groupIdLong);
182 } catch (Exception e) {
183 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
184 "Caught Exception trying to get pdp group record with transaction.getGroup(" + groupIdLong + ");");
185 throw new PAPException("Could not get local group " + groupIdLong);
187 if (groupRecord == null) {
188 throw new PersistenceException("The group record returned is null");
190 // compare to local fs
191 // does group folder exist
192 OnapPDPGroup localGroup = null;
194 localGroup = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getGroup(groupRecord.getGroupId());
195 } catch (Exception e) {
196 logger.warn("Caught PAPException trying to get local pdp group with papEngine.getGroup(" + groupId + ");",
199 if (localGroup == null && extraData != null) {
200 // here we can try to load an old group id from the extraData
202 localGroup = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getGroup(extraData);
203 } catch (Exception e) {
205 "Caught PAPException trying to get local pdp group with papEngine.getGroup(" + extraData + ");",
209 if (localGroup != null && groupRecord.isDeleted()) {
210 OnapPDPGroup newLocalGroup = null;
211 if (extraData != null) {
213 newLocalGroup = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getGroup(extraData);
214 } catch (PAPException e) {
215 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
216 "Caught PAPException trying to get new pdp group with papEngine.getGroup(" + extraData
221 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().removeGroup(localGroup, newLocalGroup);
222 } catch (NullPointerException | PAPException e) {
223 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
224 "Caught PAPException trying to get remove pdp group with papEngine.removeGroup(" + localGroup
225 + ", " + newLocalGroup + ");");
226 throw new PAPException("Could not remove group " + groupId);
228 } else if (localGroup == null) {
229 // creating a new group
231 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().newGroup(groupRecord.getgroupName(),
232 groupRecord.getDescription());
233 } catch (NullPointerException | PAPException e) {
234 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
235 "Caught PAPException trying to create pdp group with papEngine.newGroup(groupRecord.getgroupName(), groupRecord.getDescription());");
236 throw new PAPException("Could not create group " + groupRecord);
239 localGroup = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getGroup(groupRecord.getGroupId());
240 } catch (PAPException e1) {
241 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, PolicyDBDao.POLICYDBDAO_VAR,
242 "Caught PAPException trying to get pdp group we just created with papEngine.getGroup(groupRecord.getGroupId());\nAny PDPs or policies in the new group may not have been added");
245 // add possible pdps to group
246 List<?> pdpsInGroup = transaction.getPdpsInGroup(Long.parseLong(groupRecord.getGroupId()));
247 for (Object pdpO : pdpsInGroup) {
248 PdpEntity pdp = (PdpEntity) pdpO;
250 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().newPDP(pdp.getPdpId(), localGroup,
251 pdp.getPdpName(), pdp.getDescription(), pdp.getJmxPort());
252 } catch (NullPointerException | PAPException e) {
253 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
254 "Caught PAPException trying to get create pdp with papEngine.newPDP(pdp.getPdpId(), localGroup, pdp.getPdpName(), pdp.getDescription(), pdp.getJmxPort());");
255 throw new PAPException("Could not create pdp " + pdp);
258 // add possible policies to group (file system only, apparently)
260 if (!(localGroup instanceof StdPDPGroup)) {
261 throw new PAPException("group is not a StdPDPGroup");
264 // because it will be comparing the new group to its own version
265 StdPDPGroup localGroupClone = new StdPDPGroup(localGroup.getId(), localGroup.isDefaultGroup(),
266 localGroup.getName(), localGroup.getDescription(), ((StdPDPGroup) localGroup).getDirectory());
267 localGroupClone.setOnapPdps(localGroup.getOnapPdps());
268 localGroupClone.setPipConfigs(localGroup.getPipConfigs());
269 localGroupClone.setStatus(localGroup.getStatus());
270 // we are updating a group or adding a policy or changing default
271 // set default if it should be
272 if (!localGroupClone.isDefaultGroup() && groupRecord.isDefaultGroup()) {
274 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().setDefaultGroup(localGroup);
276 } catch (PAPException e) {
277 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
278 "Caught PAPException trying to set default group with papEngine.SetDefaultGroup("
279 + localGroupClone + ");");
280 throw new PAPException("Could not set default group to " + localGroupClone);
283 boolean needToUpdate = false;
284 if (updateGroupPoliciesInFileSystem(localGroupClone, localGroup, groupRecord, transaction)) {
287 if (!PolicyDBDao.stringEquals(localGroupClone.getId(), groupRecord.getGroupId())
288 || !PolicyDBDao.stringEquals(localGroupClone.getName(), groupRecord.getgroupName())) {
290 // we do not want to change the id, the papEngine will do this
291 // for us, it needs to know the old id
292 localGroupClone.setName(groupRecord.getgroupName());
295 if (!PolicyDBDao.stringEquals(localGroupClone.getDescription(), groupRecord.getDescription())) {
296 localGroupClone.setDescription(groupRecord.getDescription());
301 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().updateGroup(localGroupClone);
302 } catch (PAPException e) {
303 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
304 "Caught PAPException trying to update group with papEngine.updateGroup(" + localGroupClone
306 throw new PAPException("Could not update group " + localGroupClone);
312 // this will also handle removes, since incoming pdpGroup has no policies
313 // internally, we are just going to add them all in from the db
314 private boolean updateGroupPoliciesInFileSystem(OnapPDPGroup pdpGroup, OnapPDPGroup oldPdpGroup,
315 GroupEntity groupRecord, PolicyDBDaoTransaction transaction) throws PAPException, PolicyDBException {
316 if (!(pdpGroup instanceof StdPDPGroup)) {
317 throw new PAPException("group is not a StdPDPGroup");
319 StdPDPGroup group = (StdPDPGroup) pdpGroup;
320 // this must always be true since we don't explicitly know when a delete
322 boolean didUpdate = true;
323 HashMap<String, PDPPolicy> currentPolicySet = new HashMap<>(oldPdpGroup.getPolicies().size());
324 HashSet<PDPPolicy> newPolicySet = new HashSet<>();
325 for (PDPPolicy pdpPolicy : oldPdpGroup.getPolicies()) {
326 currentPolicySet.put(pdpPolicy.getId(), pdpPolicy);
328 for (PolicyEntity policy : groupRecord.getPolicies()) {
329 String pdpPolicyName =
330 PolicyDBDao.getPolicyDBDaoInstance().getPdpPolicyName(policy.getPolicyName(), policy.getScope());
331 if (group.getPolicy(pdpPolicyName) == null) {
333 if (currentPolicySet.containsKey(pdpPolicyName)) {
334 newPolicySet.add(currentPolicySet.get(pdpPolicyName));
337 "PolicyDBDao: Adding the new policy to the PDP group after notification: " + pdpPolicyName);
338 InputStream policyStream = new ByteArrayInputStream(policy.getPolicyData().getBytes());
339 group.copyPolicyToFile(pdpPolicyName, policyStream);
340 ((StdPDPPolicy) (group.getPolicy(pdpPolicyName))).setName(PolicyDBDao.getPolicyDBDaoInstance()
341 .removeExtensionAndVersionFromPolicyName(pdpPolicyName));
343 policyStream.close();
344 } catch (IOException e) {
346 PolicyLogger.error(e.getMessage() + e);
351 logger.info("PolicyDBDao: Adding updated policies to group after notification.");
353 newPolicySet.addAll(group.getPolicies());
354 group.setPolicies(newPolicySet);
359 private void handleIncomingPdpChange(String pdpId, PolicyDBDaoTransaction transaction) throws PAPException {
363 pdpIdLong = Long.parseLong(pdpId);
364 } catch (NumberFormatException e) {
365 throw new IllegalArgumentException("pdpId " + pdpId + " cannot be parsed into a long");
367 PdpEntity pdpRecord = null;
369 pdpRecord = transaction.getPdp(pdpIdLong);
370 } catch (Exception e) {
371 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
372 "Caught Exception trying to get pdp record with transaction.getPdp(" + pdpIdLong + ");");
373 throw new PAPException("Could not get local pdp " + pdpIdLong);
375 if (pdpRecord == null) {
376 throw new PersistenceException("The pdpRecord returned is null");
378 OnapPDP localPdp = null;
380 localPdp = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getPDP(pdpRecord.getPdpId());
381 } catch (PAPException e) {
382 logger.warn("Caught PAPException trying to get local pdp with papEngine.getPDP(" + pdpId + ");", e);
384 if (localPdp != null && pdpRecord.isDeleted()) {
386 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().removePDP(localPdp);
387 } catch (PAPException e) {
388 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
389 "Caught PAPException trying to get remove pdp with papEngine.removePDP(" + localPdp + ");");
390 throw new PAPException("Could not remove pdp " + pdpId);
392 } else if (localPdp == null) {
395 OnapPDPGroup localGroup = null;
398 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getGroup(pdpRecord.getGroup().getGroupId());
399 } catch (PAPException e1) {
400 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, PolicyDBDao.POLICYDBDAO_VAR,
401 "Caught PAPException trying to get local group to add pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
402 throw new PAPException("Could not get local group");
405 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().newPDP(pdpRecord.getPdpId(), localGroup,
406 pdpRecord.getPdpName(), pdpRecord.getDescription(), pdpRecord.getJmxPort());
407 } catch (NullPointerException | PAPException e) {
408 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
409 "Caught PAPException trying to create pdp with papEngine.newPDP(" + pdpRecord.getPdpId() + ", "
410 + localGroup + ", " + pdpRecord.getPdpName() + ", " + pdpRecord.getDescription() + ", "
411 + pdpRecord.getJmxPort() + ");");
412 throw new PAPException("Could not create pdp " + pdpRecord);
415 boolean needToUpdate = false;
416 if (!PolicyDBDao.stringEquals(localPdp.getId(), pdpRecord.getPdpId())
417 || !PolicyDBDao.stringEquals(localPdp.getName(), pdpRecord.getPdpName())) {
418 // again, we don't want to change the id, the papEngine will do
420 localPdp.setName(pdpRecord.getPdpName());
423 if (!PolicyDBDao.stringEquals(localPdp.getDescription(), pdpRecord.getDescription())) {
424 localPdp.setDescription(pdpRecord.getDescription());
427 String localPdpGroupId = null;
429 localPdpGroupId = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().getPDPGroup(localPdp).getId();
430 } catch (PAPException e) {
431 // could be null or something, just warn at this point
433 "Caught PAPException trying to get id of local group that pdp is in with localPdpGroupId = papEngine.getPDPGroup(localPdp).getId();",
436 if (!PolicyDBDao.stringEquals(localPdpGroupId, pdpRecord.getGroup().getGroupId())) {
437 OnapPDPGroup newPdpGroup = null;
439 newPdpGroup = PolicyDBDao.getPolicyDBDaoInstance().getPapEngine()
440 .getGroup(pdpRecord.getGroup().getGroupId());
441 } catch (PAPException e) {
442 // ok, now we have an issue. Time to stop things
443 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
444 "Caught PAPException trying to get id of local group to move pdp to with papEngine.getGroup(pdpRecord.getGroup().getGroupId());");
445 throw new PAPException("Could not get local group");
448 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().movePDP(localPdp, newPdpGroup);
449 } catch (PAPException e) {
450 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
451 "Caught PAPException trying to move pdp with papEngine.movePDP(localPdp, newPdpGroup);");
452 throw new PAPException("Could not move pdp " + localPdp);
455 if (localPdp.getJmxPort() != pdpRecord.getJmxPort()) {
456 localPdp.setJmxPort(pdpRecord.getJmxPort());
461 PolicyDBDao.getPolicyDBDaoInstance().getPapEngine().updatePDP(localPdp);
462 } catch (PAPException e) {
463 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
464 "Caught PAPException trying to update pdp with papEngine.updatePdp(" + localPdp + ");");
465 throw new PAPException("Could not update pdp " + localPdp);
469 // compare to local situation
470 // call command to update
473 private void handleIncomingPolicyChange(String policyId) {
474 String policyName = null;
475 Session session = sessionfactory.openSession();
476 Query getPolicyEntityQuery = session.getNamedQuery("PolicyEntity.FindById");
477 getPolicyEntityQuery.setParameter("id", Long.valueOf(policyId));
479 @SuppressWarnings("unchecked")
480 List<PolicyEntity> policies = getPolicyEntityQuery.list();
481 PolicyEntity policy = null;
482 if (!policies.isEmpty()) {
483 policy = policies.get(0);
485 String action = "unknown action";
487 if (policy != null) {
488 policyName = policy.getPolicyName();
489 logger.info("Deleting old Policy Config File for " + policy.getPolicyName());
493 if (policy.getConfigurationData() != null) {
495 getPolicySubFile(policy.getConfigurationData().getConfigurationName(), PolicyDBDao.CONFIG);
496 } else if (policy.getActionBodyEntity() != null) {
497 subFile = getPolicySubFile(policy.getActionBodyEntity().getActionBodyName(), PolicyDBDao.ACTION);
500 if (subFile != null) {
501 Files.deleteIfExists(subFile);
503 if (policy.getConfigurationData() != null) {
504 writePolicySubFile(policy, PolicyDBDao.CONFIG);
505 } else if (policy.getActionBodyEntity() != null) {
506 writePolicySubFile(policy, action);
509 } catch (IOException e1) {
510 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e1, PolicyDBDao.POLICYDBDAO_VAR,
511 "Error occurred while performing [" + action + "] of Policy File: " + policyName);
517 private boolean writePolicySubFile(PolicyEntity policy, String policyType) {
518 logger.info("writePolicySubFile with policyName[" + policy.getPolicyName() + "] and policyType[" + policyType
521 String subTypeName = null;
522 String subTypeBody = null;
523 if (PolicyDBDao.CONFIG.equalsIgnoreCase(policyType)) {
524 type = PolicyDBDao.CONFIG;
525 subTypeName = FilenameUtils.removeExtension(policy.getConfigurationData().getConfigurationName());
526 subTypeBody = policy.getConfigurationData().getConfigBody();
528 String configType = policy.getConfigurationData().getConfigType();
530 if (configType != null) {
531 if (configType.equals(JSON_CONFIG)) {
532 subTypeName = subTypeName + ".json";
534 if (configType.equals(XML_CONFIG)) {
535 subTypeName = subTypeName + ".xml";
537 if (configType.equals(PROPERTIES_CONFIG)) {
538 subTypeName = subTypeName + ".properties";
540 if (configType.equals(OTHER_CONFIG)) {
541 subTypeName = subTypeName + ".txt";
544 } else if (PolicyDBDao.ACTION.equalsIgnoreCase(policyType)) {
545 type = PolicyDBDao.ACTION;
546 subTypeName = policy.getActionBodyEntity().getActionBodyName();
547 subTypeBody = policy.getActionBodyEntity().getActionBody();
549 Path filePath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS).toString(), type);
551 if (subTypeBody == null) {
554 boolean success = false;
556 Files.deleteIfExists(Paths.get(filePath.toString(), subTypeName));
557 File file = Paths.get(filePath.toString(), subTypeName).toFile();
558 boolean value = file.createNewFile();
559 logger.debug("New file created successfully" + value);
560 try (FileWriter fileWriter = new FileWriter(file, false)) {
561 // false to overwrite
562 fileWriter.write(subTypeBody);
566 } catch (Exception e) {
567 PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, PolicyDBDao.POLICYDBDAO_VAR,
568 "Exception occured while creating Configuration File for Policy : " + policy.getPolicyName());
573 Path getPolicySubFile(String inputFileName, String subFileType) {
574 String filename = inputFileName;
575 logger.info("getPolicySubFile(" + filename + ", " + subFileType + ")");
576 Path filePath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS), subFileType);
579 filename = FilenameUtils.removeExtension(filename);
581 for (File tmpFile : filePath.toFile().listFiles()) {
582 if (FilenameUtils.removeExtension(tmpFile.getName()).equals(filename)) {
587 Path finalPath = null;
589 finalPath = Paths.get(file.getAbsolutePath());
592 logger.info("end of getPolicySubFile: " + finalPath);