1package org.apache.archiva.checksum;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import java.util.ArrayList;
23import java.util.List;
24import java.util.Map;
25import java.util.TreeMap;
2627/**28 * Container for a list of update status objects.29 *30 * If there is a overall error that is not specific to a algorithm, the total status31 * flag is set to error.32 */33publicclassUpdateStatusList {
3435privateint totalStatus = UpdateStatus.NONE;
36private Throwable error;
37private Map<ChecksumAlgorithm, UpdateStatus> statusList = new TreeMap<>();
3839publicUpdateStatusList() {
4041 }
4243publicvoid addStatus(UpdateStatus status) {
44 statusList.put(status.getAlgorithm(), status);
45 }
4647publicstaticUpdateStatusList INITIALIZE(List<ChecksumAlgorithm> algorithms) {
48finalUpdateStatusListatusList.html#UpdateStatusList">UpdateStatusList list = newUpdateStatusList();
49for(ChecksumAlgorithm algorithm : algorithms) {
50 list.addStatus(newUpdateStatus(algorithm));
51 }
52return list;
53 }
5455publicint getTotalStatus() {
56return totalStatus;
57 }
5859publicvoid setTotalError(Throwable e) {
60this.error = e;
61this.totalStatus = UpdateStatus.ERROR;
62 }
6364public Throwable getTotalError() {
65return error;
66 }
6768public List<UpdateStatus> getStatusList() {
69returnnew ArrayList(statusList.values());
70 }
7172publicvoid setStatus(ChecksumAlgorithm algorithm, UpdateStatus status) {
73 statusList.put(algorithm, status);
74 }
7576publicvoid setStatus(ChecksumAlgorithm algorithm, int status) {
77 statusList.put(algorithm, newUpdateStatus(algorithm, status));
78 }
7980publicvoid setErrorStatus(ChecksumAlgorithm algorithm, Throwable e) {
81 statusList.put(algorithm, newUpdateStatus(algorithm,e));
82 }
8384publicUpdateStatus getStatus(ChecksumAlgorithm algorithm) {
85return statusList.get(algorithm);
86 }
87 }