2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.vendorsoftwareproduct.types;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
29 public class UploadFileResponse {
30 private List<String> fileNames;
31 private Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> errors =
33 private UploadFileStatus status = UploadFileStatus.Success;
40 public UploadFileStatus getStatus() {
47 * @param status the status
49 public void setStatus(UploadFileStatus status) {
56 * @return the file names
58 public List<String> getFileNames() {
65 * @param fileNames the file names
67 public void setFileNames(List<String> fileNames) {
68 this.fileNames = fileNames;
72 * Add new file to list.
74 * @param filename the filename
76 public void addNewFileToList(String filename) {
77 this.fileNames.add(filename);
81 * Remove file from list.
83 * @param toRemove the to remove
85 public void removeFileFromList(String toRemove) {
86 this.fileNames.remove(toRemove);
90 * Add structure error.
92 * @param fileName the file name
93 * @param errorMessage the error message
95 public void addStructureError(String fileName,
96 org.openecomp.sdc.datatypes.error.ErrorMessage errorMessage) {
97 List<org.openecomp.sdc.datatypes.error.ErrorMessage> errorList = errors.get(fileName);
98 if (errorList == null) {
99 errorList = new ArrayList<>();
100 errors.put(fileName, errorList);
102 errorList.add(errorMessage);
103 if (org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR.equals(errorMessage.getLevel())) {
104 status = UploadFileStatus.Failure;
109 * Add structure errors.
111 * @param errorsByFileName the errors by file name
113 public void addStructureErrors(
114 Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> errorsByFileName) {
115 if (errorsByFileName == null) {
119 errors.putAll(errorsByFileName);
121 if (status == UploadFileStatus.Failure) {
124 for (Map.Entry<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> entry
125 : errorsByFileName.entrySet()) {
126 for (org.openecomp.sdc.datatypes.error.ErrorMessage errorMessage : entry.getValue()) {
127 if (errorMessage.getLevel() == org.openecomp.sdc.datatypes.error.ErrorLevel.ERROR) {
128 status = UploadFileStatus.Failure;
140 public Map<String, List<org.openecomp.sdc.datatypes.error.ErrorMessage>> getErrors() {