diff options
author | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-06 11:24:26 +0100 |
---|---|---|
committer | Denes Nemeth <denes.nemeth@nokia.com> | 2018-03-06 14:26:49 +0100 |
commit | 1a29d7be6656f3fac3cacd73ddd5a2e050fb04e7 (patch) | |
tree | 1cf554cec08fd43cc95f6844131a316b01245f08 /nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util | |
parent | be56383397388d35f41089723e912856c03f4673 (diff) |
Fix most sonar issues
Change-Id: I2dfae3f808aeaf94513a6e3c917eea52d6ab6322
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728
Diffstat (limited to 'nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util')
5 files changed, 100 insertions, 15 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java index ebd4234a..3bd715e4 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java @@ -25,14 +25,10 @@ import org.slf4j.Logger; */ public class CbamUtils { - private static class OperationMustBeAborted extends RuntimeException{ - OperationMustBeAborted(String msg){ - super(msg); - } - OperationMustBeAborted(Exception e, String msg){ - super(msg, e); - } - } + /** + * Separator for multiple keys concatenated into a single string + */ + public static final String SEPARATOR = "_"; private CbamUtils() { //use static way @@ -84,4 +80,14 @@ public class CbamUtils { logger.error(msg); throw new OperationMustBeAborted(msg); } + + private static class OperationMustBeAborted extends RuntimeException { + OperationMustBeAborted(String msg) { + super(msg); + } + + OperationMustBeAborted(Exception e, String msg) { + super(msg, e); + } + } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java index 249925ea..71ddd4e2 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java @@ -18,7 +18,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util; import org.apache.commons.codec.binary.Base64; -import javax.swing.text.html.Option; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.security.KeyFactory; @@ -124,7 +123,7 @@ public final class StoreLoader { } return ks; } catch (Exception e) { - throw new RuntimeException("Unable to create keystore", e); + throw new UserInvisibleError("Unable to create keystore", e); } } @@ -142,7 +141,7 @@ public final class StoreLoader { throw fatalFailure(logger, "Unable to load certificates", e); } - if (certificates.size() > 0) { + if (!certificates.isEmpty()) { return of(certificates.toArray(new Certificate[certificates.size()])); } else { return empty(); diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/SystemFunctions.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/SystemFunctions.java index 805be641..b8c50b1a 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/SystemFunctions.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/SystemFunctions.java @@ -57,7 +57,7 @@ public class SystemFunctions { Thread.sleep(millis); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new RuntimeException(e); + throw new UserInvisibleError("Interrupted while sleep", e); } } @@ -92,7 +92,7 @@ public class SystemFunctions { InputStream stream = SystemFunctions.class.getClassLoader().getResourceAsStream(url); return ByteStreams.toByteArray(stream); } catch (Exception e) { - throw new RuntimeException("Unable to load " + url, e); + throw new UserVisibleError("Unable to load " + url, e); } } @@ -108,8 +108,9 @@ public class SystemFunctions { * variable <code>out</code>, has been redirected to a file or other * destination that is typically not continuously monitored. */ + @SuppressWarnings("squid:S106") // (intentional wrapping of system err) public PrintStream err() { - return System.err; //NO SONAR (intentional wrapping of system err + return System.err; } /** @@ -137,8 +138,9 @@ public class SystemFunctions { * @see java.io.PrintStream#println(java.lang.Object) * @see java.io.PrintStream#println(java.lang.String) */ + @SuppressWarnings("squid:S106") // (intentional wrapping of system err) public PrintStream out() { - return System.out; //NO SONAR (intentional wrapping of system out) + return System.out; } /** diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserInvisibleError.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserInvisibleError.java new file mode 100644 index 00000000..95e64256 --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserInvisibleError.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * 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. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util; + +/** + * Represents an error that should not be visible for the end user + * using the REST API + */ +public class UserInvisibleError extends RuntimeException { + + /** + * @param message the error message + */ + public UserInvisibleError(String message) { + super(message); + } + + /** + * @param message the error message + * @param cause the cause of the error + */ + public UserInvisibleError(String message, Exception cause) { + super(message, cause); + } +} diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserVisibleError.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserVisibleError.java new file mode 100644 index 00000000..afc54305 --- /dev/null +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/UserVisibleError.java @@ -0,0 +1,39 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * 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. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util; + +/** + * Represents an error that is meaningful for an end user + * using the REST interface + */ +public class UserVisibleError extends RuntimeException { + + /** + * @param message the error message + */ + public UserVisibleError(String message) { + super(message); + } + + /** + * @param message the error message + * @param cause the cause of the error + */ + public UserVisibleError(String message, Exception cause) { + super(message, cause); + } +} |