* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
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 org.onap.policy.brmsInterface.jpa.BRMSGroupInfo;
import org.onap.policy.brmsInterface.jpa.BRMSPolicyInfo;
import org.onap.policy.brmsInterface.jpa.DependencyInfo;
-import org.onap.policy.common.im.AdministrativeStateException;
import org.onap.policy.common.im.IntegrityMonitor;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
@SuppressWarnings("deprecation")
public class BRMSPush {
private static final String GROUP_NAMES = "groupNames";
- private static final String DROOLS_APPS_PACKAGE = "org.onap.policy.drools-applications";
+ 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";
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";
if (flag)
syncGroupInfo();
}
+
+ public void resetDS(){
+ resetModifiedGroups();
+ controllers = new ArrayList<>();
+ }
private static void resetModifiedGroups() {
modifiedGroups = new HashMap<>();
PEDependency dependency = PolicyUtils.jsonStringToObject(value,
PEDependency.class);
userControllerName = key.replaceFirst("$controller:", "");
+ LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - " + dependency);
addToGroup(userControllerName, dependency);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
}
- } else if ("$dependency$".equals(key)) {
- if (value.startsWith("[") && value.endsWith("]")) {
- value = value.substring(1, value.length() - 1).trim();
- List<String> dependencyStrings = Arrays.asList(value.split("},{"));
- for (String dependencyString : dependencyStrings) {
- try {
- userDependencies
- .add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
- } catch (Exception e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW
- + "Error while resolving Dependencies: " + e);
- }
+ } else if ("$dependency$".equals(key) && value.startsWith("[") && value.endsWith("]")) {
+ value = value.substring(1, value.length() - 1).trim();
+ List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
+ for (String dependencyString : dependencyStrings) {
+ try {
+ userDependencies
+ .add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
+ } catch (Exception e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW
+ + "Error while resolving Dependencies: " + e);
}
}
}
// If the key is not got as parameters set by the user, setting the default value for kSessionName as
// closedLoop
if (kSessionName == null) {
- if (selectedName == defaultName) {
+ LOGGER.info("kSessionName is null, selectedName is : " + selectedName );
+ if (selectedName.equalsIgnoreCase(defaultName)) {
kSessionName = "closedloop";
} else {
kSessionName = "closedloop-" + selectedName;
String fileName = "rule.jar";
try {
website = new URL(artifact.getResourceURI());
- ReadableByteChannel rbc = Channels.newChannel(website.openStream());
- FileOutputStream fos = new FileOutputStream(fileName);
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- fos.close();
- extractJar(fileName, dirName);
- new File(fileName).delete();
- } catch (IOException e) {
- LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+ try( ReadableByteChannel rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(fileName)){
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ extractJar(fileName, dirName);
+ new File(fileName).delete();
+ }catch (IOException e) {
+ LOGGER.error("Error while downloading the project to File System. " + e.getMessage(), e);
+ }
+
+ } catch (IOException e1) {
+ LOGGER.error("Error while retrieve the artifact. " + e1.getMessage(), e1);
}
}
InvocationResult result = null;
String group = entry.getKey();
try {
+ LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
InvocationRequest request = new DefaultInvocationRequest();
setVersion(group);
createPom(group);
String version = StringEscapeUtils.escapeJava(brmsdependencyversion);
Dependency demoDependency = new Dependency();
- demoDependency.setGroupId(DROOLS_APPS_PACKAGE);
- demoDependency.setArtifactId("demo");
+ demoDependency.setGroupId(DROOLS_APPS_TEMPLATE_GROUP);
+ demoDependency.setArtifactId("template.demo");
demoDependency.setVersion(version);
dependencyList.add(demoDependency);
Dependency controlloopDependency = new Dependency();
- controlloopDependency.setGroupId(DROOLS_APPS_PACKAGE);
+ controlloopDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
controlloopDependency.setArtifactId("events");
controlloopDependency.setVersion(version);
dependencyList.add(controlloopDependency);
Dependency restDependency = new Dependency();
- restDependency.setGroupId(DROOLS_APPS_PACKAGE);
- restDependency.setArtifactId("rest");
+ restDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
+ restDependency.setArtifactId("controlloop.common.model-impl.rest");
restDependency.setVersion(version);
dependencyList.add(restDependency);
Dependency appcDependency = new Dependency();
- appcDependency.setGroupId(DROOLS_APPS_PACKAGE);
- appcDependency.setArtifactId("appc");
+ appcDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
+ appcDependency.setArtifactId("controlloop.common.model-impl.appc");
appcDependency.setVersion(version);
dependencyList.add(appcDependency);
Dependency aaiDependency = new Dependency();
- aaiDependency.setGroupId(DROOLS_APPS_PACKAGE);
- aaiDependency.setArtifactId("aai");
+ aaiDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
+ aaiDependency.setArtifactId("controlloop.common.model-impl.aai");
aaiDependency.setVersion(version);
dependencyList.add(aaiDependency);
Dependency msoDependency = new Dependency();
- msoDependency.setGroupId(DROOLS_APPS_PACKAGE);
- msoDependency.setArtifactId("mso");
+ msoDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
+ msoDependency.setArtifactId("controlloop.common.model-impl.so");
msoDependency.setVersion(version);
dependencyList.add(msoDependency);
Dependency trafficgeneratorDependency = new Dependency();
- trafficgeneratorDependency.setGroupId(DROOLS_APPS_PACKAGE);
- trafficgeneratorDependency.setArtifactId("trafficgenerator");
+ trafficgeneratorDependency.setGroupId(DROOLS_APPS_MODEL_GROUP);
+ trafficgeneratorDependency.setArtifactId("controlloop.common.model-impl.trafficgenerator");
trafficgeneratorDependency.setVersion(version);
dependencyList.add(trafficgeneratorDependency);
return dependencyList;