1 package org.apache.maven.archiva.common.consumers;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.common.utils.BaseFile;
23 import org.codehaus.plexus.util.StringUtils;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.Iterator;
28 import java.util.List;
35 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
38 public class FileProblemsTracker
40 private Map problemMap = new HashMap();
42 public void addProblem( BaseFile file, String message )
44 String path = file.getRelativePath();
45 addProblem( path, message );
48 private void addProblem( String path, String message )
50 path = StringUtils.replace( path, "\\", "/" );
51 List problems = getProblems( path );
52 problems.add( message );
53 problemMap.put( path, problems );
56 public void addProblem( ConsumerException e )
58 if ( e.getFile() != null )
60 this.addProblem( e.getFile(), e.getMessage() );
64 this.addProblem( "|fatal|", e.getMessage() );
68 public boolean hasProblems( String path )
70 if ( !problemMap.containsKey( path ) )
72 // No tracking of path at all.
76 List problems = (List) problemMap.get( path );
77 if ( problems == null )
79 // found path, but no list.
83 return !problems.isEmpty();
88 return problemMap.keySet();
91 public List getProblems( String path )
93 List problems = (List) problemMap.get( path );
94 if ( problems == null )
96 problems = new ArrayList();
102 public int getProblemCount()
105 for ( Iterator it = problemMap.values().iterator(); it.hasNext(); )
107 List problems = (List) it.next();
108 count += problems.size();