aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-common-lib/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-common-lib/src
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-common-lib/src')
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/BaseErrorBuilder.java20
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CoreException.java27
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCategory.java78
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCode.java139
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCodeAndMessage.java58
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java38
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/JsonMappingErrorBuilder.java41
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java119
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcConfigurationException.java18
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java19
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ValidationErrorBuilder.java58
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/exception/ZipException.java1
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java188
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java31
14 files changed, 370 insertions, 465 deletions
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/BaseErrorBuilder.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/BaseErrorBuilder.java
index 367cbf7df6..8c090d68b8 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/BaseErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/BaseErrorBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,17 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
public abstract class BaseErrorBuilder {
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public ErrorCode build() {
- return builder.build();
- }
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public ErrorCode build() {
+ return builder.build();
+ }
- protected ErrorCode.ErrorCodeBuilder getErrorCodeBuilder() {
- return builder;
- }
+ protected ErrorCode.ErrorCodeBuilder getErrorCodeBuilder() {
+ return builder;
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CoreException.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CoreException.java
index b41d6647f5..12e10fdb4e 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CoreException.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/CoreException.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,23 +17,22 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
public class CoreException extends RuntimeException {
- private final ErrorCode errorCode;
+ private final ErrorCode errorCode;
- public CoreException(ErrorCode errorCode) {
- this(errorCode, null);
- }
+ public CoreException(ErrorCode errorCode) {
+ this(errorCode, null);
+ }
- public CoreException(ErrorCode errorCode, Throwable cause) {
- super(errorCode.toString(), cause);
- this.errorCode = errorCode;
- }
+ public CoreException(ErrorCode errorCode, Throwable cause) {
+ super(errorCode.toString(), cause);
+ this.errorCode = errorCode;
+ }
- public ErrorCode code() {
- return errorCode;
- }
+ public ErrorCode code() {
+ return errorCode;
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCategory.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCategory.java
index 00f8d74fb7..bb8f84711c 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCategory.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCategory.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,48 +17,40 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
public enum ErrorCategory {
- /**
- * System-level problems caused by external factors, resources shortage and similar. For instance:
- * <ul>
- * <li>I/O problems (network connectivity, filesystem access etc)</li>
- * <li>Java issues (missing or incompatible class definitions etc)</li>
- * <li>Environment problems</li>
- * </ul>
- */
- SYSTEM,
-
- /**
- * Application-level issues related to implementation of certain functionality (such as detected
- * illegal states of a program or data inconsistency).
- */
- APPLICATION,
-
- /**
- * Problems related to violations of different rules set either by product metadata (catalog
- * definitions or similar) or other types of constraints.
- */
- VALIDATION,
-
- /**
- * Problems caused by attempt of a user to perform certain operations which contradict the system
- * rules. Mostly applicable to UI-driven flows in presentation tier.
- */
- USER,
-
- /**
- * Improper values set in the system configuration (negative numbers, missing or inconsistent
- * definitions, mismatch with valid values list etc).
- */
- CONFIGURATION,
-
- /**
- * Security constraint violations (failed login attempts, lack of permissions to perform operation
- * and so on). Any problems related to authentication/authorization should use the special
- * category for system auditing purposes.
- */
- SECURITY
+ /**
+ * System-level problems caused by external factors, resources shortage and similar. For instance:
+ * <ul>
+ * <li>I/O problems (network connectivity, filesystem access etc)</li>
+ * <li>Java issues (missing or incompatible class definitions etc)</li>
+ * <li>Environment problems</li>
+ * </ul>
+ */
+ SYSTEM,
+ /**
+ * Application-level issues related to implementation of certain functionality (such as detected illegal states of a program or data
+ * inconsistency).
+ */
+ APPLICATION,
+ /**
+ * Problems related to violations of different rules set either by product metadata (catalog definitions or similar) or other types of
+ * constraints.
+ */
+ VALIDATION,
+ /**
+ * Problems caused by attempt of a user to perform certain operations which contradict the system rules. Mostly applicable to UI-driven flows in
+ * presentation tier.
+ */
+ USER,
+ /**
+ * Improper values set in the system configuration (negative numbers, missing or inconsistent definitions, mismatch with valid values list etc).
+ */
+ CONFIGURATION,
+ /**
+ * Security constraint violations (failed login attempts, lack of permissions to perform operation and so on). Any problems related to
+ * authentication/authorization should use the special category for system auditing purposes.
+ */
+ SECURITY
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCode.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCode.java
index 6a9990dcf1..dede69b3d0 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCode.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCode.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,92 +17,89 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
import java.io.Serializable;
public class ErrorCode implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String id;
- private String message;
- private ErrorCategory category;
-
- protected ErrorCode() {
- }
- /*
- For backward compatibility only - will be removed soon
- */
-
- @Override
- public String toString() {
- return message;
- }
-
- public String id() {
- return id;
- }
-
- @Deprecated
- protected void id(String id) {
- this.id = id;
- }
-
- public String message() {
- return message;
- }
-
- @Deprecated
- protected void message(String message) {
- this.message = message;
- }
+ private static final long serialVersionUID = 1L;
+ private String id;
+ private String message;
+ private ErrorCategory category;
- public ErrorCategory category() {
- return category;
- }
+ protected ErrorCode() {
+ }
- @Deprecated
- protected void category(ErrorCategory category) {
- this.category = category;
- }
+ /*
+ For backward compatibility only - will be removed soon
+ */
+ @Override
+ public String toString() {
+ return message;
+ }
- public static class ErrorCodeBuilder {
+ public String id() {
+ return id;
+ }
- private String id;
- private String message;
- private ErrorCategory category = ErrorCategory.APPLICATION;
+ @Deprecated
+ protected void id(String id) {
+ this.id = id;
+ }
- public ErrorCodeBuilder withId(String id) {
- this.id = id;
- return this;
+ public String message() {
+ return message;
}
- //todo remove later
+ @Deprecated
+ protected void message(String message) {
+ this.message = message;
+ }
- public ErrorCodeBuilder withMessage(String message) {
- this.message = message;
- return this;
+ public ErrorCategory category() {
+ return category;
}
- //todo remove later
- public ErrorCodeBuilder withCategory(ErrorCategory category) {
- this.category = category;
- return this;
+ @Deprecated
+ protected void category(ErrorCategory category) {
+ this.category = category;
}
- /**
- * Build error code.
- *
- * @return the error code
- */
- public ErrorCode build() {
- ErrorCode inst = new ErrorCode();
- inst.id = id;
- inst.message = message;
- inst.category = category;
- return inst;
+ public static class ErrorCodeBuilder {
+
+ private String id;
+ private String message;
+ private ErrorCategory category = ErrorCategory.APPLICATION;
+
+ public ErrorCodeBuilder withId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ //todo remove later
+ public ErrorCodeBuilder withMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+ //todo remove later
+ public ErrorCodeBuilder withCategory(ErrorCategory category) {
+ this.category = category;
+ return this;
+ }
+
+ /**
+ * Build error code.
+ *
+ * @return the error code
+ */
+ public ErrorCode build() {
+ ErrorCode inst = new ErrorCode();
+ inst.id = id;
+ inst.message = message;
+ inst.category = category;
+ return inst;
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCodeAndMessage.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCodeAndMessage.java
index d7c5c63506..d6f5848478 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCodeAndMessage.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ErrorCodeAndMessage.java
@@ -17,49 +17,43 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
-
+import javax.ws.rs.core.Response;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
-import javax.ws.rs.core.Response;
-
/**
- * This class represents an error object to be returned in failed REST instead of just returning one
- * of HTTP fail statuses.
+ * This class represents an error object to be returned in failed REST instead of just returning one of HTTP fail statuses.
*/
@Getter
@Setter
@NoArgsConstructor
public class ErrorCodeAndMessage {
- /**
- * the HTTP status code.
- */
- private Response.Status status;
-
- /**
- * Error code no. if available.
- */
- private String errorCode;
-
- /**
- * the error message to be displayed.
- */
- private String message;
-
- /**
- * Instantiates a new Error code and message.
- *
- * @param status the status
- * @param errorCode the error code
- */
- public ErrorCodeAndMessage(Response.Status status, ErrorCode errorCode) {
- this.status = status;
- this.message = errorCode.message();
- this.errorCode = errorCode.id();
- }
+ /**
+ * the HTTP status code.
+ */
+ private Response.Status status;
+ /**
+ * Error code no. if available.
+ */
+ private String errorCode;
+ /**
+ * the error message to be displayed.
+ */
+ private String message;
+
+ /**
+ * Instantiates a new Error code and message.
+ *
+ * @param status the status
+ * @param errorCode the error code
+ */
+ public ErrorCodeAndMessage(Response.Status status, ErrorCode errorCode) {
+ this.status = status;
+ this.message = errorCode.message();
+ this.errorCode = errorCode.id();
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java
index 05eae9d7e5..8096b4d7a5 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java
@@ -13,31 +13,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.common.errors;
import org.apache.commons.text.RandomStringGenerator;
public class GeneralErrorBuilder {
- private static final String GENERAL_ERROR_REST_ID = "GENERAL_ERROR_REST_ID";
- private static final String GENERAL_ERROR_REST_MSG =
- "An internal error has occurred. Please contact support. Error ID: %s";
-
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
-
- /**
- * Instantiates a new General error builder.
- */
- public GeneralErrorBuilder() {
- RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('A', 'Z').build();
- builder.withId(GENERAL_ERROR_REST_ID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(GENERAL_ERROR_REST_MSG, generator.generate(8)));
- }
-
- public ErrorCode build() {
- return builder.build();
- }
-
+ private static final String GENERAL_ERROR_REST_ID = "GENERAL_ERROR_REST_ID";
+ private static final String GENERAL_ERROR_REST_MSG = "An internal error has occurred. Please contact support. Error ID: %s";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new General error builder.
+ */
+ public GeneralErrorBuilder() {
+ RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('A', 'Z').build();
+ builder.withId(GENERAL_ERROR_REST_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(GENERAL_ERROR_REST_MSG, generator.generate(8)));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/JsonMappingErrorBuilder.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/JsonMappingErrorBuilder.java
index 8c5b1cd2ad..f890828014 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/JsonMappingErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/JsonMappingErrorBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,29 +17,24 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
public class JsonMappingErrorBuilder {
- private static final String JSON_MAPPING_ERROR_ERR_ID = "JSON_MAPPING_ERROR_ERR_ID";
- private static final String JSON_MAPPING_ERROR_ERR_ERR_MSG =
- "Error occurred while parsing the JSON input/body. Further info can be found in the log";
-
-
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
-
- /**
- * Instantiates a new Json mapping error builder.
- */
- public JsonMappingErrorBuilder() {
- builder.withId(JSON_MAPPING_ERROR_ERR_ID);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(JSON_MAPPING_ERROR_ERR_ERR_MSG));
- }
-
- public ErrorCode build() {
- return builder.build();
- }
-
+ private static final String JSON_MAPPING_ERROR_ERR_ID = "JSON_MAPPING_ERROR_ERR_ID";
+ private static final String JSON_MAPPING_ERROR_ERR_ERR_MSG = "Error occurred while parsing the JSON input/body. Further info can be found in the log";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Json mapping error builder.
+ */
+ public JsonMappingErrorBuilder() {
+ builder.withId(JSON_MAPPING_ERROR_ERR_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(JSON_MAPPING_ERROR_ERR_ERR_MSG));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index d9186bc3b2..91ed6ae2f8 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.common.errors;
import lombok.AllArgsConstructor;
@@ -22,11 +21,9 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum Messages {
+ // @formatter:off
CANT_LOAD_HEALING_CLASS("Can't load healing class %s."),
-
- VERSION_UPGRADE("Item %s is of old version. A check out was made in order to get new " +
- "functionalities"),
-
+ VERSION_UPGRADE("Item %s is of old version. A check out was made in order to get new " + "functionalities"),
PACKAGE_PROCESS_ERROR("Could not process package '%s'"),
PACKAGE_INVALID_EXTENSION("Invalid package '%s' extension. Expecting %s."),
PACKAGE_EMPTY_ERROR("The given package is empty '%s'"),
@@ -49,8 +46,7 @@ public enum Messages {
MANIFEST_METADATA_INVALID_ENTRY("Manifest metadata should only have pnf or vnf entries"),
MANIFEST_METADATA_INVALID_ENTRY1("Invalid Manifest metadata entry: '%s'."),
MANIFEST_METADATA_DUPLICATED_ENTRY("Duplicated Manifest metadata entry: '%s'."),
- MANIFEST_METADATA_UNEXPECTED_ENTRY_TYPE(
- "Manifest metadata should have either pnf or vnf entries, not both together"),
+ MANIFEST_METADATA_UNEXPECTED_ENTRY_TYPE("Manifest metadata should have either pnf or vnf entries, not both together"),
MANIFEST_INVALID_PNF_METADATA("%s TOSCA.meta file is applicable for VF only"),
MANIFEST_INVALID_NON_MANO_KEY("Invalid non mano key '%s'"),
MANIFEST_EMPTY_NON_MANO_KEY("Expecting a 'Source' entry for the non mano key '%s'"),
@@ -66,8 +62,7 @@ public enum Messages {
MANIFEST_DUPLICATED_CMS_SIGNATURE("Duplicated CMS signature"),
MANIFEST_SIGNATURE_DUPLICATED("Duplicated manifest signature"),
MANIFEST_SIGNATURE_LAST_ENTRY("The manifest signature must be the last entry of the manifest."),
- MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number [%s] of "
- + "entries"),
+ MANIFEST_METADATA_DOES_NOT_MATCH_LIMIT("Manifest metadata must only have the required number [%s] of " + "entries"),
MANIFEST_EMPTY("The manifest is empty"),
MANIFEST_ERROR_WITH_LINE("%s;%nAt line %s: '%s'."),
MANIFEST_PARSER_INTERNAL("Invalid manifest file"),
@@ -83,48 +78,35 @@ public enum Messages {
METADATA_MISSING_ENTRY("TOSCA.meta file in TOSCA-metadata directory missing entry %s"),
METADATA_NO_ENTRY_DEFINITIONS("TOSCA.meta must contain Entry Definitions"),
METADATA_INVALID_ENTRY_DEFINITIONS("TOSCA.meta must contain key:value entries"),
-
- EMPTY_SW_INFORMATION_NON_MANO_ERROR(
- "Non-mano Software Information artifact was declared in the manifest, but not provided"),
- UNIQUE_SW_INFORMATION_NON_MANO_ERROR("Only one software information non-mano artifact is allowed. "
- + "Found %s."),
+ EMPTY_SW_INFORMATION_NON_MANO_ERROR("Non-mano Software Information artifact was declared in the manifest, but not provided"),
+ UNIQUE_SW_INFORMATION_NON_MANO_ERROR("Only one software information non-mano artifact is allowed. " + "Found %s."),
INVALID_SW_INFORMATION_NON_MANO_ERROR("Invalid software information non-mano artifact: '%s'"),
- INCORRECT_SW_INFORMATION_NON_MANO_ERROR(
- "Incorrect software information non-mano artifact. The software version information is missing "
- + "or it has one or more incorrect software version entries: '%s'"),
- EMPTY_ONAP_CNF_HELM_NON_MANO_ERROR(
- "Non-mano onap_cnf_helm artifact was declared in the manifest, but not provided"),
- UNIQUE_ONAP_CNF_HELM_NON_MANO_ERROR("Only one onap_cnf_helm non-mano artifact is allowed. "
- + "Found %s."),
+ INCORRECT_SW_INFORMATION_NON_MANO_ERROR("Incorrect software information non-mano artifact. The software version information is missing or it has "
+ + "one or more incorrect software version entries: '%s'"),
+ EMPTY_ONAP_CNF_HELM_NON_MANO_ERROR("Non-mano onap_cnf_helm artifact was declared in the manifest, but not provided"),
+ UNIQUE_ONAP_CNF_HELM_NON_MANO_ERROR("Only one onap_cnf_helm non-mano artifact is allowed. " + "Found %s."),
FAILED_TO_VALIDATE_METADATA("Failed to validate metadata file"),
ARTIFACT_INVALID_SIGNATURE("Invalid signature '%s' provided for artifact '%s'"),
- ARTIFACT_SIGNATURE_VALIDATION_ERROR(
- "Could not validate signature '%s' provided for artifact '%s' with certificate '%s': %s"),
+ ARTIFACT_SIGNATURE_VALIDATION_ERROR("Could not validate signature '%s' provided for artifact '%s' with certificate '%s': %s"),
FAILED_TO_TRANSLATE_ZIP_FILE("Failed to translate zip file"),
ZIP_NOT_EXIST("Zip file doesn't exist"),
-
PERMISSIONS_ERROR("Permissions Error. The user does not have permission to perform this action."),
PERMISSIONS_OWNER_ERROR("Permissions Error. Only one owner is allowed."),
-
ENTITY_NOT_FOUND("Incorrect item/version details provided."),
SUB_ENTITY_NOT_FOUND("Incorrect sub entity details provided."),
FAILED_TO_SYNC("Non existing version cannot be synced."),
FAILED_TO_PUBLISH_OUT_OF_SYNC("Publish is not allowed since the version status is Out of sync"),
-
DELETE_VSP_ERROR("VSP has been certified and cannot be deleted."),
DELETE_VLM_ERROR("VLM has been certified and cannot be deleted."),
-
ZIP_SHOULD_NOT_CONTAIN_FOLDERS("Zip file should not contain folders"),
- VES_ZIP_SHOULD_CONTAIN_YML_ONLY(
- "Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files" +
- " (using .yaml/.yml extensions)"),
+ VES_ZIP_SHOULD_CONTAIN_YML_ONLY("Wrong VES EVENT Artifact was uploaded - all files contained in Artifact must be YAML files"
+ + " (using .yaml/.yml extensions)"),
MANIFEST_NOT_EXIST("Manifest doesn't exist"),
MANIFEST_NOT_FOUND("Manifest file %s referenced in TOSCA.meta does not exist"),
FILE_TYPE_NOT_LEGAL("File type not legal as data for other file"),
MODULE_IN_MANIFEST_NO_YAML("Module '%s', has no yaml file reference"),
NO_MODULES_IN_MANIFEST("At least one Base/Module must be defined \n"),
- MODULE_IN_MANIFEST_VOL_ENV_NO_VOL("Module '%s', has volume Env. reference with no Volume " +
- "reference"),
+ MODULE_IN_MANIFEST_VOL_ENV_NO_VOL("Module '%s', has volume Env. reference with no Volume " + "reference"),
ILLEGAL_MANIFEST("Illegal Manifest"),
NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST("no %s file was uploaded or file doesn't exist"),
MAPPING_OBJECTS_FAILURE("Failed to map object %s to %s. Exception message: %s"),
@@ -133,12 +115,9 @@ public enum Messages {
CREATE_MANIFEST_FROM_ZIP("cannot create manifest from the attached zip file"),
CANDIDATE_PROCESS_FAILED("Candidate zip file process failed"),
FOUND_UNASSIGNED_FILES("cannot process zip since it has unassigned files"),
- GENERATED_ARTIFACT_IN_USE("Artifact with file name %s is generated by SDC. "
- + "Please remove this artifact from manifest and zip files"),
-
+ GENERATED_ARTIFACT_IN_USE("Artifact with file name %s is generated by SDC. " + "Please remove this artifact from manifest and zip files"),
/* Monitor uploads related errors*/
- ILLEGAL_MONITORING_ARTIFACT_TYPE("Illegal monitoring artifact type for component id %s, vsp id " +
- "%s"),
+ ILLEGAL_MONITORING_ARTIFACT_TYPE("Illegal monitoring artifact type for component id %s, vsp id %s"),
/* manifest errors*/
MISSING_FILE_IN_ZIP("Missing file in zip"),
MISSING_FILE_IN_MANIFEST("Missing file in manifest"),
@@ -156,14 +135,12 @@ public enum Messages {
CSAR_MANIFEST_FILE_NOT_EXIST("CSAR manifest file does not exist"),
CSAR_FAILED_TO_READ("CSAR file is not readable"),
TOSCA_PARSING_FAILURE("Invalid tosca file. Error code : %s, Error message : %s/"),
-
/*definition errors*/
MISSING_DEFINITION_FILE("Definition file %s referenced in TOSCA.meta does not exist"),
MISSING_IMPORT_FILE("Package must contain the referenced import file '%s'"),
MISSING_MAIN_DEFINITION_FILE("Package must contain the given main definition file '%s'"),
INVALID_IMPORT_STATEMENT("Definition file '%s' contains an invalid import statement: '%s'"),
INVALID_YAML_EXTENSION("Expecting yaml or yml extension for file: %s"),
-
/* content errors*/
INVALID_YAML_FORMAT("Invalid YAML format: %s"),
INVALID_YAML_FORMAT_1("Invalid YAML format in file '%s'. Format error:%n%s"),
@@ -176,8 +153,7 @@ public enum Messages {
MISSING_RESOURCE_IN_DEPENDS_ON("a Missing resource in depend On, Missing Resource ID [%s]"),
REFERENCED_PARAMETER_NOT_FOUND("Referenced parameter - %s - not found, used in resource [%s]"),
GET_ATTR_NOT_FOUND("get_attr attribute not found, Attribute name [%s], Resource ID [%s]"),
- MISSING_PARAMETER_IN_NESTED(
- "Referenced parameter not found in nested file - %s, parameter name [%s], Resource ID [%s]"),
+ MISSING_PARAMETER_IN_NESTED("Referenced parameter not found in nested file - %s, parameter name [%s], Resource ID [%s]"),
NESTED_LOOP("Nested files loop - %s"),
MORE_THAN_ONE_BIND_FROM_NOVA_TO_PORT("Resource Port %s exceed allowed relations from NovaServer"),
SERVER_NOT_DEFINED_FROM_NOVA("Missing server group definition - %s, %s"),
@@ -185,64 +161,48 @@ public enum Messages {
MISSING_IMAGE_AND_FLAVOR("Missing both Image and Flavor in NOVA Server, Resource ID [%s]"),
ENV_INCLUDES_PARAMETER_NOT_IN_HEAT("Env file %s includes a parameter not in HEAT - %s"),
PARAMETER_ENV_VALUE_NOT_ALIGN_WITH_TYPE("Parameter env value %s not align with type"),
- PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE(
- "Parameter - %s default value not align with type %s"),
+ PARAMETER_DEFAULT_VALUE_NOT_ALIGN_WITH_TYPE("Parameter - %s default value not align with type %s"),
INVALID_RESOURCE_TYPE("A resource has an invalid or unsupported type - %s, Resource ID [%s]"),
ARTIFACT_FILE_NOT_REFERENCED("Artifact file is not referenced."),
RESOURCE_NOT_IN_USE("%s not in use, Resource Id [%s]"),
PORT_NO_BIND_TO_ANY_NOVA_SERVER("Port not bind to any NOVA Server, Resource Id [%s]"),
- INVALID_GET_RESOURCE_SYNTAX(
- "invalid get_resource syntax is in use - %s , get_resource"
- + " function should get the resource id of the referenced resource"),
- INVALID_RESOURCE_GROUP_TYPE(
- "OS::Heat::ResourceGroup resource with resource_def which is not pointing to "
- + "nested heat file is not supported, Resource ID [%s], resource_def type [%s]"),
- WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT(
- "Wrong value type assigned to a nested input parameter, nested resource [%s],"
- + " property name [%s], nested file [%s]"),
- NOVA_NAME_IMAGE_FLAVOR_NOT_CONSISTENT(
- "Nova Server naming convention in image, flavor and name properties is not "
- + "consistent, Resource ID [%s]"),
- RESOURCE_GROUP_INVALID_INDEX_VAR(
- "Wrong value assigned to a ResourceGroup index_var property (functions are not allowed"
- + " but only strings), Resource ID [%s]"),
+ INVALID_GET_RESOURCE_SYNTAX("invalid get_resource syntax is in use - %s , get_resource function should get the resource id of the "
+ + "referenced resource"),
+ INVALID_RESOURCE_GROUP_TYPE("OS::Heat::ResourceGroup resource with resource_def which is not pointing to nested heat file is not supported, "
+ + "Resource ID [%s], resource_def type [%s]"),
+ WRONG_VALUE_TYPE_ASSIGNED_NESTED_INPUT("Wrong value type assigned to a nested input parameter, nested resource [%s], property name [%s], "
+ + "nested file [%s]"),
+ NOVA_NAME_IMAGE_FLAVOR_NOT_CONSISTENT("Nova Server naming convention in image, flavor and name properties is not consistent, Resource ID [%s]"),
+ RESOURCE_GROUP_INVALID_INDEX_VAR("Wrong value assigned to a ResourceGroup index_var property (functions are not allowed but only strings),"
+ + " Resource ID [%s]"),
CONTRAIL_2_IN_USE("Contrail 2.x deprecated resource is in use, Resource ID [%s]"),
-
/* warnings */
REFERENCED_RESOURCE_NOT_FOUND("Referenced resource - %s not found"),
MISSING_GET_PARAM("Missing get_param in %s, Resource Id [%s]"),
-
/*OPENECOMP Guide lines*/
MISSING_NOVA_SERVER_METADATA("Missing Nova Server Metadata property, Resource ID [%s]"),
MISSING_NOVA_SERVER_VNF_ID("Missing VNF_ID in Metadata property, Resource ID [%s]"),
MISSING_NOVA_SERVER_VF_MODULE_ID("Missing VF_MODULE_ID in Metadata property, Resource id [%s]"),
- NETWORK_PARAM_NOT_ALIGNED_WITH_GUIDE_LINE(
- "Network Parameter Name not aligned with Guidelines, Parameter Name [%s] Resource ID [%s]"),
- MISSIN_BASE_HEAT_FILE(
- "Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources"),
+ NETWORK_PARAM_NOT_ALIGNED_WITH_GUIDE_LINE("Network Parameter Name not aligned with Guidelines, Parameter Name [%s] Resource ID [%s]"),
+ MISSIN_BASE_HEAT_FILE("Missing Base HEAT. Pay attention that without Base HEAT, there will be no shared resources"),
MULTI_BASE_HEAT_FILE("Multi Base HEAT. Expected only one. Files %s."),
- RESOURCE_NOT_DEFINED_IN_OUTPUT(
- "Resource is not defined as output and thus cannot be Shared, Resource ID [%s]"),
- RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE(
- "A resource is connected twice to the same network role, Network Role [%s],"
- + " Resource ID [%s]"),
+ RESOURCE_NOT_DEFINED_IN_OUTPUT("Resource is not defined as output and thus cannot be Shared, Resource ID [%s]"),
+ RESOURCE_CONNECTED_TO_TWO_EXTERNAL_NETWORKS_WITH_SAME_ROLE("A resource is connected twice to the same network role, Network Role [%s], "
+ + "Resource ID [%s]"),
VOLUME_HEAT_NOT_EXPOSED("Volume is not defined as output and thus cannot be attached %s"),
FORBIDDEN_RESOURCE_IN_USE("%s is in use, Resource ID [%s]"),
- PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES(
- "%s '%s' Parameter Name not aligned with Guidelines, Parameter Name [%s], Resource ID [%s]."
- + " As a result, VF/VFC Profile may miss this information"),
+ PARAMETER_NAME_NOT_ALIGNED_WITH_GUIDELINES("%s '%s' Parameter Name not aligned with Guidelines, Parameter Name [%s], Resource ID [%s]."
+ + " As a result, VF/VFC Profile may miss this information"),
/* Contrail validator messages*/
- MERGE_OF_CONTRAIL2_AND_CONTRAIL3_RESOURCES(
- "HEAT Package includes both Contrail 2 and Contrail 3 resources. "
- + "Contrail 2 resources can be found in %s. Contrail 3 resources can be found in %s"),
- CONTRAIL_VM_TYPE_NAME_NOT_ALIGNED_WITH_NAMING_CONVENSION(
- "Service Template naming convention in Image and Flavor "
- + "properties is not consistent in Resource, Resource ID %s"),
-
+ MERGE_OF_CONTRAIL2_AND_CONTRAIL3_RESOURCES("HEAT Package includes both Contrail 2 and Contrail 3 resources. "
+ + "Contrail 2 resources can be found in %s. Contrail 3 resources can be found in %s"),
+ CONTRAIL_VM_TYPE_NAME_NOT_ALIGNED_WITH_NAMING_CONVENSION("Service Template naming convention in Image and Flavor "
+ + "properties is not consistent in Resource, Resource ID %s"),
/* Notifications */
FAILED_TO_MARK_NOTIFICATION_AS_READ("Failed to mark notifications as read"),
FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION("Failed to update last seen notification for user %s"),
FAILED_TO_VERIFY_SIGNATURE("Could not verify signature of signed package.");
+ // @formatter:on
private String errorMessage;
@@ -255,5 +215,4 @@ public enum Messages {
public String formatMessage(final Object... params) {
return String.format(errorMessage, params);
}
-
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcConfigurationException.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcConfigurationException.java
index 4fb8cadedc..fca6038e49 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcConfigurationException.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcConfigurationException.java
@@ -17,15 +17,15 @@ package org.openecomp.sdc.common.errors;
public class SdcConfigurationException extends RuntimeException {
- public SdcConfigurationException(String message) {
- super(message);
- }
+ public SdcConfigurationException(String message) {
+ super(message);
+ }
- public SdcConfigurationException(String message, Throwable cause) {
- super(message, cause);
- }
+ public SdcConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public SdcConfigurationException(Throwable cause) {
- super(cause);
- }
+ public SdcConfigurationException(Throwable cause) {
+ super(cause);
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
index f71dd454a3..63383c4df3 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/SdcRuntimeException.java
@@ -13,20 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.common.errors;
public class SdcRuntimeException extends RuntimeException {
- public SdcRuntimeException(String message) {
- super(message);
- }
+ public SdcRuntimeException(String message) {
+ super(message);
+ }
- public SdcRuntimeException(String message, Throwable cause) {
- super(message, cause);
- }
+ public SdcRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public SdcRuntimeException(Throwable cause) {
- super(cause);
- }
+ public SdcRuntimeException(Throwable cause) {
+ super(cause);
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ValidationErrorBuilder.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ValidationErrorBuilder.java
index 129abf3ab7..2f9a0464fc 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ValidationErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/ValidationErrorBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,41 +17,33 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.errors;
public class ValidationErrorBuilder {
- public static final String FIELD_VALIDATION_ERROR_ERR_ID = "FIELD_VALIDATION_ERROR_ERR_ID";
- private static final String FIELD_VALIDATION_ERROR_ERR_MSG =
- "Field does not conform to predefined criteria : %s : %s";
- private static final String FIELD_VALIDATION_ERROR_ERR_MSG_USE_PREDEFINED_FOR_FIELD = "%s";
- private static final String FIELD_WITH_PREDEFINED_MESSAGE = "arg\\d";
-
-
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
-
- /**
- * Instantiates a new Validation error builder.
- *
- * @param detailedMessage the detailed message
- * @param fieldName the field name
- */
- public ValidationErrorBuilder(String detailedMessage, String fieldName) {
- builder.withId(FIELD_VALIDATION_ERROR_ERR_ID);
- builder.withCategory(ErrorCategory.APPLICATION);
-
- if (fieldName.matches(FIELD_WITH_PREDEFINED_MESSAGE)) {
- builder.withMessage(
- String.format(FIELD_VALIDATION_ERROR_ERR_MSG_USE_PREDEFINED_FOR_FIELD, detailedMessage));
- } else {
- builder
- .withMessage(String.format(FIELD_VALIDATION_ERROR_ERR_MSG, fieldName, detailedMessage));
+ public static final String FIELD_VALIDATION_ERROR_ERR_ID = "FIELD_VALIDATION_ERROR_ERR_ID";
+ private static final String FIELD_VALIDATION_ERROR_ERR_MSG = "Field does not conform to predefined criteria : %s : %s";
+ private static final String FIELD_VALIDATION_ERROR_ERR_MSG_USE_PREDEFINED_FOR_FIELD = "%s";
+ private static final String FIELD_WITH_PREDEFINED_MESSAGE = "arg\\d";
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Validation error builder.
+ *
+ * @param detailedMessage the detailed message
+ * @param fieldName the field name
+ */
+ public ValidationErrorBuilder(String detailedMessage, String fieldName) {
+ builder.withId(FIELD_VALIDATION_ERROR_ERR_ID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ if (fieldName.matches(FIELD_WITH_PREDEFINED_MESSAGE)) {
+ builder.withMessage(String.format(FIELD_VALIDATION_ERROR_ERR_MSG_USE_PREDEFINED_FOR_FIELD, detailedMessage));
+ } else {
+ builder.withMessage(String.format(FIELD_VALIDATION_ERROR_ERR_MSG, fieldName, detailedMessage));
+ }
}
- }
-
- public ErrorCode build() {
- return builder.build();
- }
+ public ErrorCode build() {
+ return builder.build();
+ }
}
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/exception/ZipException.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/exception/ZipException.java
index d26fae62e4..490fef8442 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/exception/ZipException.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/exception/ZipException.java
@@ -16,7 +16,6 @@
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.exception;
import java.io.IOException;
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
index a564928820..66a295eba3 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
@@ -16,7 +16,6 @@
* Modifications copyright (c) 2019 Nokia
* ================================================================================
*/
-
package org.openecomp.sdc.common.utils;
import com.google.common.collect.Multimap;
@@ -44,118 +43,105 @@ import org.openecomp.sdc.common.zip.exception.ZipException;
public class CommonUtil {
- private CommonUtil() {
- // prevent instantiation
- }
-
- /**
- * Reads the files from the zip AND validates zip is flat (no folders).
- *
- * @param type the onboarding type
- * @param uploadedFileData zip file bytes
- * @return FileContentHandler if input is valid and has no folders
- * @throws IOException when the zip could not be read
- */
- public static FileContentHandler validateAndUploadFileContent(final OnboardingTypesEnum type,
- final byte[] uploadedFileData) throws IOException {
- final Pair<FileContentHandler, List<String>> pair;
- try {
- pair = getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
- } catch (final ZipException e) {
- throw new IOException(e);
+ private CommonUtil() {
+ // prevent instantiation
}
- if (isFileOriginFromZip(type.toString())) {
- validateNoFolders(pair.getRight());
- }
-
- return pair.getLeft();
- }
-
- /**
- * Extracts the zip in memory and build a pair of {@link FileContentHandler} and the zip folder list. The {@link
- * FileContentHandler} will only contain the files, not the folders.
- *
- * @param uploadFileData the zip file to extract
- * @return a pair of {@link FileContentHandler} only with the zip files and a list of the zip folders.
- * @throws ZipException when there was a problem during the zip reading
- */
- public static Pair<FileContentHandler, List<String>> getFileContentMapFromOrchestrationCandidateZip(
- byte[] uploadFileData) throws ZipException {
- final Map<String, byte[]> zipFileMap = ZipUtils.readZip(uploadFileData, true);
- final List<String> folderList = new ArrayList<>();
- final FileContentHandler mapFileContent = new FileContentHandler();
-
- zipFileMap.forEach((key, value) -> {
- if (value == null) {
- folderList.add(key);
- } else {
- mapFileContent.addFile(key, value);
- }
- });
-
- return new ImmutablePair<>(mapFileContent, folderList);
- }
- /**
- * Extracts the zip in memory and build the {@link FileContentHandler}.
- *
- * @param zipFile the zip file to extract
- * @return The {@link FileContentHandler} based on the zip content
- * @throws ZipException when there was a problem during the zip reading
- */
- public static FileContentHandler getZipContent(final byte[] zipFile) throws ZipException {
- final Map<String, byte[]> zipFileMap = ZipUtils.readZip(zipFile, true);
- final FileContentHandler fileContentHandler = new FileContentHandler();
- zipFileMap.forEach((key, value) -> {
- if (value == null) {
- fileContentHandler.addFolder(key);
- } else {
- fileContentHandler.addFile(key, value);
- }
- });
- return fileContentHandler;
- }
+ /**
+ * Reads the files from the zip AND validates zip is flat (no folders).
+ *
+ * @param type the onboarding type
+ * @param uploadedFileData zip file bytes
+ * @return FileContentHandler if input is valid and has no folders
+ * @throws IOException when the zip could not be read
+ */
+ public static FileContentHandler validateAndUploadFileContent(final OnboardingTypesEnum type, final byte[] uploadedFileData) throws IOException {
+ final Pair<FileContentHandler, List<String>> pair;
+ try {
+ pair = getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
+ } catch (final ZipException e) {
+ throw new IOException(e);
+ }
+ if (isFileOriginFromZip(type.toString())) {
+ validateNoFolders(pair.getRight());
+ }
+ return pair.getLeft();
+ }
- private static void validateNoFolders(List<String> folderList) {
- if (CollectionUtils.isNotEmpty(folderList)) {
- throw new CoreException((new ErrorCode.ErrorCodeBuilder())
- .withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
- .withCategory(ErrorCategory.APPLICATION).build());
+ /**
+ * Extracts the zip in memory and build a pair of {@link FileContentHandler} and the zip folder list. The {@link FileContentHandler} will only
+ * contain the files, not the folders.
+ *
+ * @param uploadFileData the zip file to extract
+ * @return a pair of {@link FileContentHandler} only with the zip files and a list of the zip folders.
+ * @throws ZipException when there was a problem during the zip reading
+ */
+ public static Pair<FileContentHandler, List<String>> getFileContentMapFromOrchestrationCandidateZip(byte[] uploadFileData) throws ZipException {
+ final Map<String, byte[]> zipFileMap = ZipUtils.readZip(uploadFileData, true);
+ final List<String> folderList = new ArrayList<>();
+ final FileContentHandler mapFileContent = new FileContentHandler();
+ zipFileMap.forEach((key, value) -> {
+ if (value == null) {
+ folderList.add(key);
+ } else {
+ mapFileContent.addFile(key, value);
+ }
+ });
+ return new ImmutablePair<>(mapFileContent, folderList);
}
- }
- private static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler
- files) {
- for (String fileName : files.getFileList()) {
- if (!allowedExtensions.contains(FilenameUtils.getExtension(fileName))) {
- return false;
- }
+ /**
+ * Extracts the zip in memory and build the {@link FileContentHandler}.
+ *
+ * @param zipFile the zip file to extract
+ * @return The {@link FileContentHandler} based on the zip content
+ * @throws ZipException when there was a problem during the zip reading
+ */
+ public static FileContentHandler getZipContent(final byte[] zipFile) throws ZipException {
+ final Map<String, byte[]> zipFileMap = ZipUtils.readZip(zipFile, true);
+ final FileContentHandler fileContentHandler = new FileContentHandler();
+ zipFileMap.forEach((key, value) -> {
+ if (value == null) {
+ fileContentHandler.addFolder(key);
+ } else {
+ fileContentHandler.addFile(key, value);
+ }
+ });
+ return fileContentHandler;
}
- return true;
- }
- public static boolean validateAllFilesYml(FileContentHandler files) {
- Set<String> allowedExtensions = new HashSet<>(Arrays.asList("yml", "yaml"));
- return validateFilesExtensions(allowedExtensions, files);
- }
+ private static void validateNoFolders(List<String> folderList) {
+ if (CollectionUtils.isNotEmpty(folderList)) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage())
+ .withId(Messages.ZIP_SHOULD_NOT_CONTAIN_FOLDERS.getErrorMessage()).withCategory(ErrorCategory.APPLICATION).build());
+ }
+ }
- public static boolean isFileOriginFromZip(String fileOrigin) {
- return Objects.nonNull(fileOrigin)
- && fileOrigin.equalsIgnoreCase(OnboardingTypesEnum.ZIP.toString());
- }
+ private static boolean validateFilesExtensions(Set<String> allowedExtensions, FileContentHandler files) {
+ for (String fileName : files.getFileList()) {
+ if (!allowedExtensions.contains(FilenameUtils.getExtension(fileName))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ public static boolean validateAllFilesYml(FileContentHandler files) {
+ Set<String> allowedExtensions = new HashSet<>(Arrays.asList("yml", "yaml"));
+ return validateFilesExtensions(allowedExtensions, files);
+ }
- public static <T> Optional<T> createObjectUsingSetters(Object objectCandidate,
- Class<T> classToCreate)
- throws Exception {
- return org.onap.sdc.tosca.services.CommonUtil.createObjectUsingSetters(objectCandidate, classToCreate);
- }
+ public static boolean isFileOriginFromZip(String fileOrigin) {
+ return Objects.nonNull(fileOrigin) && fileOrigin.equalsIgnoreCase(OnboardingTypesEnum.ZIP.toString());
+ }
+ public static <T> Optional<T> createObjectUsingSetters(Object objectCandidate, Class<T> classToCreate) throws Exception {
+ return org.onap.sdc.tosca.services.CommonUtil.createObjectUsingSetters(objectCandidate, classToCreate);
+ }
- public static Map<String, Object> getObjectAsMap(Object obj) {
- return org.onap.sdc.tosca.services.CommonUtil.getObjectAsMap(obj);
- }
+ public static Map<String, Object> getObjectAsMap(Object obj) {
+ return org.onap.sdc.tosca.services.CommonUtil.getObjectAsMap(obj);
+ }
public static <K, V> boolean isMultimapEmpty(Multimap<K, V> obj) {
return Objects.isNull(obj) || obj.isEmpty();
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
index 9de0e7b0e1..4c1424287f 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/SdcCommon.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,23 +17,20 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.utils;
public class SdcCommon {
- public static final String MANIFEST_NAME = "MANIFEST.json";
- public static final String CSAR_MANIFEST_NAME = "MainServiceTemplate.mf";
- public static final String UPLOAD_FILE = "uploadFile";
- public static final String PROCESS_FILE = "Process File";
- public static final String ILLEGAL_MANIFEST = "Illegal manifest";
-
- public static final String HEAT_TO_TOSCA_MAPPING_CONF = "heatToToscaMapping.json";
- public static final String HEAT_META = "HEAT.meta";
- public static final String PARENT = "parent";
-
- public static final String VSP_ID = "vspId";
- public static final String VLM_ID = "vlmId";
- public static final String VERSION = "version";
- public static final String USER = "user";
+ public static final String MANIFEST_NAME = "MANIFEST.json";
+ public static final String CSAR_MANIFEST_NAME = "MainServiceTemplate.mf";
+ public static final String UPLOAD_FILE = "uploadFile";
+ public static final String PROCESS_FILE = "Process File";
+ public static final String ILLEGAL_MANIFEST = "Illegal manifest";
+ public static final String HEAT_TO_TOSCA_MAPPING_CONF = "heatToToscaMapping.json";
+ public static final String HEAT_META = "HEAT.meta";
+ public static final String PARENT = "parent";
+ public static final String VSP_ID = "vspId";
+ public static final String VLM_ID = "vlmId";
+ public static final String VERSION = "version";
+ public static final String USER = "user";
}