summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-01-22 12:11:11 +0000
committerliamfallon <liam.fallon@est.tech>2020-01-23 12:15:19 +0000
commit755eb9df282d80273043a2e902e2a51bf6eaab24 (patch)
treefb603fff3d378bb868dba63e3d766d7723e03839 /examples
parent37da84e2a40f7f39fe73fa2ceb6a7166618e9ddb (diff)
Run apex-pdp in Java 11: base changes
This change brings in the minimum changes to get apex-pdp running in Java 11. Other reviews will bring in changes to remove Java 11 warnings and to convert apex-pdp Javascript handling from the now deprecated nashorn engine. Issue-ID: POLICY-1581 Change-Id: I879bbae08d4e67aca3f1bfeedeca639d8dbbc281 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples-myfirstpolicy/pom.xml63
-rw-r--r--examples/examples-pcvs/pom.xml30
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java72
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java62
-rw-r--r--examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java30
5 files changed, 69 insertions, 188 deletions
diff --git a/examples/examples-myfirstpolicy/pom.xml b/examples/examples-myfirstpolicy/pom.xml
index 0e3424120..ec61748f0 100644
--- a/examples/examples-myfirstpolicy/pom.xml
+++ b/examples/examples-myfirstpolicy/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2020 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +18,10 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
@@ -30,7 +34,8 @@
<description>Specific code for the Apex MyFirstPolicy Example</description>
<properties>
- <apex-domains-myfirstpolicy-dir>${project.basedir}/src</apex-domains-myfirstpolicy-dir>
+ <policymodel1.name>MyFirstPolicyModel_0.0.1</policymodel1.name>
+ <policymodel2.name>MyFirstPolicyModel_0.0.1</policymodel2.name>
</properties>
<dependencies>
@@ -55,7 +60,6 @@
<groupId>org.onap.policy.apex-pdp.auth</groupId>
<artifactId>cli-editor</artifactId>
<version>${project.version}</version>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
@@ -79,24 +83,61 @@
<executions>
<execution>
<id>generate-models</id>
- <phase>process-classes</phase>
+ <phase>compile</phase>
<goals>
- <goal>exec</goal>
+ <goal>java</goal>
</goals>
<configuration>
- <executable>java</executable>
+ <mainClass>org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelSaver</mainClass>
+ <classpathScope>compile</classpathScope>
<arguments>
- <argument>-classpath</argument>
- <!-- automatically creates the classpath using all project dependencies,
- also adding the project build directory -->
- <classpath />
- <argument>org.onap.policy.apex.examples.myfirstpolicy.model.MfpDomainModelSaver</argument>
<argument>${project.build.directory}/classes/examples/models/MyFirstPolicy</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <!-- Generate the APEX Policy JSON files from the APEX CLI command -->
+ <execution>
+ <id>generate-policy1</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass>
+ <classpathScope>compile</classpathScope>
+ <arguments>
+ <argument>--command-file=${project.basedir}/src/main/resources/examples/models/MyFirstPolicy/1/${policymodel1.name}.apex</argument>
+ <argument>--output-model-file=${project.build.directory}/classes/examples/models/MyFirstPolicy/1/${policymodel1.name}.json</argument>
+ <argument>--log-file=${project.build.directory}/${policymodel1.name}_policygeneration.log</argument>
+ <argument>--working-dir=${project.basedir}</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ <execution>
+ <id>generate-policy2</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass>
+ <classpathScope>compile</classpathScope>
+ <arguments>
+ <argument>--command-file=${project.basedir}/src/main/resources/examples/models/MyFirstPolicy/2/${policymodel2.name}.apex</argument>
+ <argument>--output-model-file=${project.build.directory}/classes/examples/models/MyFirstPolicy/2/${policymodel2.name}.json</argument>
+ <argument>--log-file=${project.build.directory}/${policymodel2.name}_policygeneration.log</argument>
+ <argument>--working-dir=${project.basedir}</argument>
+ </arguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
diff --git a/examples/examples-pcvs/pom.xml b/examples/examples-pcvs/pom.xml
index 720ebf7a9..9f0b08ae8 100644
--- a/examples/examples-pcvs/pom.xml
+++ b/examples/examples-pcvs/pom.xml
@@ -1,6 +1,7 @@
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2020 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +18,10 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.policy.apex-pdp.examples</groupId>
@@ -30,11 +34,11 @@
<description>Example for Policy-controlled Video Streaming</description>
<properties>
- <apex-domains-pcvs-dir>${project.basedir}/src</apex-domains-pcvs-dir>
+ <policymodel.name>vpnsla</policymodel.name>
</properties>
<dependencies>
- <dependency>
+ <dependency>
<groupId>org.onap.policy.common</groupId>
<artifactId>utils</artifactId>
</dependency>
@@ -80,19 +84,19 @@
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
- <id>generate-models</id>
- <phase>process-classes</phase>
+ <id>generate-policy</id>
+ <phase>compile</phase>
<goals>
- <goal>exec</goal>
+ <goal>java</goal>
</goals>
<configuration>
- <executable>java</executable>
+ <mainClass>org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain</mainClass>
+ <classpathScope>compile</classpathScope>
<arguments>
- <argument>-classpath</argument>
- <classpath />
- <argument>org.onap.policy.apex.examples.pcvs.model.PcvsDomainModelSaver</argument>
- <argument>${project.basedir}</argument>
- <argument>${project.build.directory}/classes/examples/models/pcvs/</argument>
+ <argument>-command-file=${project.basedir}/src/main/resources/org/onap/policy/apex/examples/pcvs/vpnsla/${policymodel.name}.apex</argument>
+ <argument>-output-model-file=${project.build.directory}/classes/examples/models/pcvs/vpnsla/${policymodel.name}.json</argument>
+ <argument>-log-file=${project.build.directory}/${policymodel.name}_policygeneration.log</argument>
+ <argument>-working-dir=${project.basedir}</argument>
</arguments>
</configuration>
</execution>
@@ -150,4 +154,4 @@
</build>
</profile>
</profiles>
-</project> \ No newline at end of file
+</project>
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java
deleted file mode 100644
index fa8903b62..000000000
--- a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.examples.pcvs.model;
-
-import java.io.File;
-
-import org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain;
-import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelReader;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.onap.policy.common.utils.resources.ResourceUtils;
-
-/**
- * A factory for creating PCVSDomainModel objects.
- *
- * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
- */
-public class PcvsDomainModelFactory {
-
- /**
- * Generates the PCVS VPN-SLA policy model from CLI commands and creates an APEX model.
- *
- * @param workingDirectory The working directory for the CLI editor for includes
- *
- * @return the PCVS VPN-SLA policy model
- */
- public AxPolicyModel getPcvsVpnSlaSPolicyModel(final String workingDirectory) {
- final String path = "target/model-gen/pcvs/vpnsla";
- final String file = "policy.json";
- final String full = path + "/" + file;
-
- final File pathFile = new File(path);
- pathFile.mkdirs();
-
- final String[] args =
- new String[] {"-c", "src/main/resources/org/onap/policy/apex/examples/pcvs/vpnsla/vpnsla.apex", "-wd",
- workingDirectory, "-o", full};
-
- final ApexCommandLineEditorMain cliEditor = new ApexCommandLineEditorMain(args);
- if (cliEditor.getErrorCount() > 0) {
- throw new ApexRuntimeException(
- "Apex CLI editor execution failed with " + cliEditor.getErrorCount() + " errors");
- }
-
- java.util.TimeZone.getTimeZone("gmt");
- try {
- final ApexModelReader<AxPolicyModel> reader = new ApexModelReader<>(AxPolicyModel.class);
- return reader.read(ResourceUtils.getResourceAsString(full));
- } catch (final Exception e) {
- throw new ApexRuntimeException("Failed to build PCVS SLA1 policy from path: " + full, e);
- }
- }
-
-}
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java
deleted file mode 100644
index 02b107767..000000000
--- a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.apex.examples.pcvs.model;
-
-import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelSaver;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
-
-/**
- * The Class PcvsDomainModelSaver.
- *
- * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
- */
-public final class PcvsDomainModelSaver {
- // Logger for this class
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(PcvsDomainModelSaver.class);
-
- /** Private constructor to prevent instantiation. */
- private PcvsDomainModelSaver() {
- }
-
- /**
- * Write all PCVS models to args[0].
- *
- * @param args uses <code>arg[0]</code> for directory information
- * @throws ApexException the apex exception
- */
- public static void main(final String[] args) throws ApexException {
- if (args.length != 2) {
- LOGGER.error("usage: " + PcvsDomainModelSaver.class.getName() + " workingDirectory modelDirectory");
- return;
- }
-
- final AxPolicyModel pcvsPolicyModel = new PcvsDomainModelFactory().getPcvsVpnSlaSPolicyModel(args[0]);
- final ApexModelSaver<AxPolicyModel> pcvsModelSaver = new ApexModelSaver<>(AxPolicyModel.class, pcvsPolicyModel,
- args[1] + "vpnsla/");
- pcvsModelSaver.apexModelWriteJson();
- pcvsModelSaver.apexModelWriteXml();
-
- }
-}
diff --git a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java
deleted file mode 100644
index ff9b39730..000000000
--- a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2016-2018 Ericsson. 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-/**
- * Contains the model for Policy-controlled Video Streaming.
- *
- * @author Sven van der Meer (sven.van.der.meer@ericsson.com)
- * @author Joseph McNamara (joseph.mcnamara@ericsson.com)
- * @author John Keeney (john.keeney@ericsson.com)
- */
-
-package org.onap.policy.apex.examples.pcvs.model;
-