Error pop-up contain empty/internal information 55/50055/2
authorolegb <olegb@amdocs.com>
Sun, 3 Jun 2018 04:55:57 +0000 (07:55 +0300)
committervempo <vitaliy.emporopulo@amdocs.com>
Sun, 24 Jun 2018 11:03:17 +0000 (14:03 +0300)
Issue-ID: SDC-1393
Change-Id: Ibb60e21431bb886dd7dd499202cf226af3e2465d
Signed-off-by: Oleg Beltz <olegb@amdocs.com>
onboarding/pom.xml
openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java
openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
openecomp-be/lib/openecomp-common-lib/pom.xml
openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/GeneralErrorBuilder.java

index 2887780..f1c6099 100644 (file)
                 <scope>test</scope>
                 <version>${testng.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-text</artifactId>
+                <version>1.3</version>
+                <scope>compile</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
index 28917b9..098a89d 100644 (file)
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
  * 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.
- * ============LICENSE_END=========================================================
  */
 
 package org.openecomp.sdcrests.errors;
@@ -54,7 +50,7 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
           FileUtils.readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE,
               stream -> JsonUtil.json2Object(stream, Map.class));
 
-  private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper
+  private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExceptionMapper
       .class);
 
   @Override
@@ -147,11 +143,11 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> {
   }
 
   private Response transform(Exception exception) {
-    ErrorCode generalErrorCode = new GeneralErrorBuilder(exception.getMessage()).build();
-    LOGGER.error(generalErrorCode.message(), exception);
+    ErrorCode errorCode = new GeneralErrorBuilder().build();
+    LOGGER.error(errorCode.message(), exception);
     return Response
         .status(Response.Status.INTERNAL_SERVER_ERROR)
-        .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, generalErrorCode))
+        .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, errorCode))
         .build();
   }
 
index 4d92ee8..73c2a42 100644 (file)
@@ -75,10 +75,6 @@ public class OrchestrationTemplateProcessCsarHandler
       } catch (CoreException e) {
         LOGGER.error(e.getMessage());
         response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
-      } catch (IOException ioe) {
-        LOGGER.error(ioe.getMessage());
-        ErrorCode errorCode = new GeneralErrorBuilder(ioe.getMessage()).build();
-        response.addErrorMessageToMap(errorCode.id(), errorCode.message(),ErrorLevel.ERROR);
       }
     } else {
       if (!uploadFileResponse.getErrors().isEmpty()) {
@@ -91,7 +87,7 @@ public class OrchestrationTemplateProcessCsarHandler
   private void processCsar(VspDetails vspDetails,
                            FileContentHandler fileContentHandler,
                            OrchestrationTemplateCandidateData candidateData,
-                           OrchestrationTemplateActionResponse response) throws IOException {
+                           OrchestrationTemplateActionResponse response) {
     response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
     Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
     toscaTreeManager.createTree();
index 095f8be..96218d3 100644 (file)
             <artifactId>commons-io</artifactId>
             <version>2.5</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>${commons.lang3.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-text</artifactId>
+        </dependency>
     </dependencies>
 
 </project>
index 7ded61e..05eae9d 100644 (file)
@@ -1,41 +1,39 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
  * 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.
- * ============LICENSE_END=========================================================
  */
 
 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 error has occurred: %s";
+  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.
-   *
-   * @param detailedError the detailed error
    */
-  public GeneralErrorBuilder(String detailedError) {
+  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, detailedError));
+    builder.withMessage(String.format(GENERAL_ERROR_REST_MSG, generator.generate(8)));
   }
 
   public ErrorCode build() {