From 755eb9df282d80273043a2e902e2a51bf6eaab24 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Wed, 22 Jan 2020 12:11:11 +0000 Subject: 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 --- .../apex/auth/clieditor/CommandLineParameters.java | 39 +++++++++++----------- .../policy/apex/auth/clieditor/utils/CliUtils.java | 7 +++- 2 files changed, 25 insertions(+), 21 deletions(-) (limited to 'auth/cli-editor/src') diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java index 87c7a0828..27af9538c 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/CommandLineParameters.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-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. @@ -28,8 +28,10 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; + import lombok.Getter; import lombok.Setter; + import org.onap.policy.apex.auth.clieditor.utils.CliUtils; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -173,7 +175,11 @@ public class CommandLineParameters { if (logFileName == null) { return System.out; } else { - return new FileOutputStream(new File(logFileName), true); + File logFile = new File(logFileName); + if (!logFile.getParentFile().exists()) { + logFile.getParentFile().mkdirs(); + } + return new FileOutputStream(logFile, true); } } @@ -187,11 +193,9 @@ public class CommandLineParameters { } /** - * Check if the file name of the file containing properties that are used for command default - * values is set. + * Check if the file name of the file containing properties that are used for command default values is set. * - * @return true, if the file name of the file containing properties that are used for command - * default values is set + * @return true, if the file name of the file containing properties that are used for command default values is set */ public boolean checkSetApexPropertiesFileName() { return apexPropertiesFileName != null && apexPropertiesFileName.length() > 0; @@ -200,41 +204,36 @@ public class CommandLineParameters { /** * Check if the name of the file containing commands to be streamed into the CLI editor is set. * - * @return true, if the name of the file containing commands to be streamed into the CLI editor - * is set + * @return true, if the name of the file containing commands to be streamed into the CLI editor is set */ public boolean checkSetCommandFileName() { return commandFileName != null && commandFileName.length() > 0; } /** - * Check if the name of the file containing the Apex model that will be used to initialize the - * Apex model in the CLI editor is set. + * Check if the name of the file containing the Apex model that will be used to initialize the Apex model in the CLI + * editor is set. * - * @return true, if the name of the file containing the Apex model that will be used to - * initialize the Apex model in the CLI editor is set + * @return true, if the name of the file containing the Apex model that will be used to initialize the Apex model in + * the CLI editor is set */ public boolean checkSetInputModelFileName() { return inputModelFileName != null && inputModelFileName.length() > 0; } /** - * Check if the name of the file that the Apex CLI editor will save the Apex model to when it - * exits is set. + * Check if the name of the file that the Apex CLI editor will save the Apex model to when it exits is set. * - * @return true, if the name of the file that the Apex CLI editor will save the Apex model to - * when it exits is set + * @return true, if the name of the file that the Apex CLI editor will save the Apex model to when it exits is set */ public boolean checkSetOutputModelFileName() { return outputModelFileName != null && outputModelFileName.length() > 0; } /** - * Check if the name of the file to which the Apex CLI editor will log commands and responses is - * set. + * Check if the name of the file to which the Apex CLI editor will log commands and responses is set. * - * @return true, if the name of the file to which the Apex CLI editor will log commands and - * responses is set + * @return true, if the name of the file to which the Apex CLI editor will log commands and responses is set */ public boolean checkSetLogFileName() { return logFileName != null; diff --git a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java index 9459a7ffd..c4e9956ea 100644 --- a/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java +++ b/auth/cli-editor/src/main/java/org/onap/policy/apex/auth/clieditor/utils/CliUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-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. @@ -21,6 +21,7 @@ package org.onap.policy.apex.auth.clieditor.utils; import com.google.gson.JsonObject; + import java.beans.PropertyDescriptor; import java.io.File; import java.io.IOException; @@ -29,6 +30,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; import java.util.Properties; + import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; import org.apache.commons.lang3.StringUtils; @@ -138,6 +140,9 @@ public class CliUtils { } } else { try { + if (!theFile.getParentFile().exists()) { + theFile.getParentFile().mkdirs(); + } if (theFile.createNewFile()) { LOGGER.info("File {} does not exist. New file created.", fileName); } -- cgit 1.2.3-korg