From 825ae627d4378c5cc7ab4b7d5f4b4ffefcb7977e Mon Sep 17 00:00:00 2001 From: Dinh Danh Le Date: Wed, 29 Aug 2018 17:21:52 +0100 Subject: Fix checkstyle warnings in examples Change-Id: Iad533f3987792d8713426234f3277c1ef6b72284 Issue-ID: POLICY-1034 Signed-off-by: Dinh Danh Le --- examples/examples-pcvs/pom.xml | 2 +- .../pcvs/model/PCVSDomainModelFactory.java | 72 ---------------------- .../examples/pcvs/model/PCVSDomainModelSaver.java | 57 ----------------- .../pcvs/model/PcvsDomainModelFactory.java | 72 ++++++++++++++++++++++ .../examples/pcvs/model/PcvsDomainModelSaver.java | 57 +++++++++++++++++ 5 files changed, 130 insertions(+), 130 deletions(-) delete mode 100644 examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelFactory.java delete mode 100644 examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java create mode 100644 examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java create mode 100644 examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java (limited to 'examples/examples-pcvs') diff --git a/examples/examples-pcvs/pom.xml b/examples/examples-pcvs/pom.xml index 074e8944c..2ac770287 100644 --- a/examples/examples-pcvs/pom.xml +++ b/examples/examples-pcvs/pom.xml @@ -97,7 +97,7 @@ -classpath - org.onap.policy.apex.examples.pcvs.model.PCVSDomainModelSaver + org.onap.policy.apex.examples.pcvs.model.PcvsDomainModelSaver ${project.basedir} ${project.build.directory}/classes/examples/models/pcvs/ 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 bc9eca88e..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.ApexCLIEditorMain; -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 getPCVVpnSlaSPolicyModel(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 ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(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 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 65e84a4ea..000000000 --- a/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PCVSDomainModelSaver.java +++ /dev/null @@ -1,57 +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 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; - -/** - * The Class PCVSDomainModelSaver. - * - * @author Sven van der Meer (sven.van.der.meer@ericsson.com) - */ -public final class PCVSDomainModelSaver { - - /** Private constructor to prevent instantiation. */ - private PCVSDomainModelSaver() {} - - /** - * Write all PCVS models to args[0]. - * - * @param args uses arg[0] for directory information - * @throws ApexException the apex exception - */ - public static void main(final String[] args) throws ApexException { - if (args.length != 2) { - System.err.println( - "usage: " + PCVSDomainModelSaver.class.getCanonicalName() + " workingDirectory modelDirectory"); - return; - } - - final AxPolicyModel pcvsPolicyModel = new PCVSDomainModelFactory().getPCVVpnSlaSPolicyModel(args[0]); - final ApexModelSaver 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/PcvsDomainModelFactory.java b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java new file mode 100644 index 000000000..001886370 --- /dev/null +++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelFactory.java @@ -0,0 +1,72 @@ +/*- + * ============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.ApexCLIEditorMain; +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 ApexCLIEditorMain cliEditor = new ApexCLIEditorMain(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 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 new file mode 100644 index 000000000..42d3d659b --- /dev/null +++ b/examples/examples-pcvs/src/main/java/org/onap/policy/apex/examples/pcvs/model/PcvsDomainModelSaver.java @@ -0,0 +1,57 @@ +/*- + * ============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 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; + +/** + * The Class PcvsDomainModelSaver. + * + * @author Sven van der Meer (sven.van.der.meer@ericsson.com) + */ +public final class PcvsDomainModelSaver { + + /** Private constructor to prevent instantiation. */ + private PcvsDomainModelSaver() {} + + /** + * Write all PCVS models to args[0]. + * + * @param args uses arg[0] for directory information + * @throws ApexException the apex exception + */ + public static void main(final String[] args) throws ApexException { + if (args.length != 2) { + System.err.println( + "usage: " + PcvsDomainModelSaver.class.getCanonicalName() + " workingDirectory modelDirectory"); + return; + } + + final AxPolicyModel pcvsPolicyModel = new PcvsDomainModelFactory().getPcvsVpnSlaSPolicyModel(args[0]); + final ApexModelSaver pcvsModelSaver = + new ApexModelSaver<>(AxPolicyModel.class, pcvsPolicyModel, args[1] + "vpnsla/"); + pcvsModelSaver.apexModelWriteJson(); + pcvsModelSaver.apexModelWriteXml(); + + } +} -- cgit 1.2.3-korg