X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=BRMSGateway%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fbrms%2Fapi%2FBrmsPush.java;h=2aa2873f1a40bba98bbd03f6065481c8882fa6af;hp=4466afe3c6f2b15d7885a7d7b73f5bd6b7e76f4d;hb=31aa90351064401a6ef4aaea9304b745969004e0;hpb=ebf62c0900b295f06034843a1ff5fa49066a3a06 diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java index 4466afe3c..2aa2873f1 100644 --- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java +++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java @@ -2,8 +2,9 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +26,6 @@ import com.att.nsa.cambria.client.CambriaBatchingPublisher; import com.att.nsa.cambria.client.CambriaClientBuilders; import com.att.nsa.cambria.client.CambriaClientBuilders.PublisherBuilder; import com.fasterxml.jackson.core.JsonProcessingException; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -53,14 +53,12 @@ import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.regex.Pattern; - import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; import javax.persistence.TypedQuery; import javax.ws.rs.ProcessingException; - import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.maven.model.Dependency; @@ -93,12 +91,13 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.utils.BackUpHandler; import org.onap.policy.utils.BackUpMonitor; import org.onap.policy.utils.BusPublisher; +import org.onap.policy.utils.PeCryptoUtils; import org.onap.policy.utils.PolicyUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; /** - * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR). Mavenize and push policy - * to PR + * BRMSPush: Application responsible to push policies to the BRMS PDP Policy Repository (PR). + * Mavenize and push policy to PR * * @version 1.0 */ @@ -108,7 +107,7 @@ public class BrmsPush { private static final String DROOLS_APPS_TEMPLATE_GROUP = "org.onap.policy.drools-applications.controlloop.templates"; private static final String DROOLS_APPS_MODEL_GROUP = - "org.onap.policy.drools-applications.controlloop.common.model-impl"; + "org.onap.policy.models.policy-models-interactions.model-impl"; private static final String META_INF = "META-INF"; private static final String KMODULE_XML_FILE = "kmodule.xml"; private static final String POM_XML_FILE = "pom.xml"; @@ -117,9 +116,10 @@ public class BrmsPush { private static final String RESOURCES = "resources"; private static final Logger LOGGER = FlexLogger.getLogger(BrmsPush.class.getName()); private static final String PROJECTSLOCATION = "RuleProjects"; - private static final String[] GOALS = { "clean", "deploy" }; - private static final String DEFAULT_VERSION = "1.4.0-SNAPSHOT"; + private static final String[] GOALS = {"clean", "deploy"}; + private static final String DEFAULT_VERSION = "1.5.1"; private static final String DEPENDENCY_FILE = "dependency.json"; + private static final String PROP_AES_KEY = "org.onap.policy.encryption.aes.key"; public static final String BRMSPERSISTENCE = "brmsEclipselink.persistencexml"; private static Map modifiedGroups = new HashMap<>(); @@ -187,6 +187,9 @@ public class BrmsPush { throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Data/File Read Error while reading from the property file."); } + // init the aes key from prop or env + PeCryptoUtils.initAesKey(config.getProperty(PROP_AES_KEY)); + LOGGER.info("Trying to set up IntegrityMonitor"); String resourceName = null; try { @@ -254,7 +257,7 @@ public class BrmsPush { repUrlList.add(repUrl); } repUserName = config.getProperty("repositoryUsername"); - repPassword = config.getProperty("repositoryPassword"); + repPassword = PeCryptoUtils.decrypt(config.getProperty("repositoryPassword")); if (repUserName == null || repPassword == null) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "repostoryUserName and respositoryPassword properties are required."); @@ -521,8 +524,10 @@ public class BrmsPush { LOGGER.info("Updated Local Memory values with values from database."); } catch (final Exception exception) { LOGGER.error("Unable to sync group info", exception); - et.rollback(); - throw exception; + if (et.isActive()) { + et.rollback(); + } + } } @@ -581,7 +586,6 @@ public class BrmsPush { } catch (final Exception exception) { LOGGER.error("Unable add policy to database", exception); et.rollback(); - throw exception; } } @@ -1045,12 +1049,6 @@ public class BrmsPush { msoDependency.setArtifactId("controlloop.common.model-impl.so"); msoDependency.setVersion(version); dependencyList.add(msoDependency); - - final Dependency trafficgeneratorDependency = new Dependency(); - trafficgeneratorDependency.setGroupId(DROOLS_APPS_MODEL_GROUP); - trafficgeneratorDependency.setArtifactId("controlloop.common.model-impl.trafficgenerator"); - trafficgeneratorDependency.setVersion(version); - dependencyList.add(trafficgeneratorDependency); return dependencyList; } @@ -1086,7 +1084,7 @@ public class BrmsPush { if (config.getProperty(GROUP_NAMES).contains(",")) { groupNames = config.getProperty(GROUP_NAMES).replaceAll(" ", "").split(","); } else { - groupNames = new String[] { config.getProperty(GROUP_NAMES).replaceAll(" ", "") }; + groupNames = new String[] {config.getProperty(GROUP_NAMES).replaceAll(" ", "")}; } if (groupNames == null || groupNames.length == 0) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + groupNamesError); @@ -1147,7 +1145,6 @@ public class BrmsPush { } catch (final Exception exception) { LOGGER.error("Unable add/update policy group to database for controller name: " + name, exception); et.rollback(); - throw exception; } } @@ -1203,7 +1200,6 @@ public class BrmsPush { } catch (final Exception exception) { LOGGER.error("Unable remove policy from group to database for policy name: " + policyName, exception); et.rollback(); - throw exception; } }