Coverage Report - org.apache.maven.archiva.dependency.graph.tasks.FlagCyclicEdgesVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
FlagCyclicEdgesVisitor
0%
0/12
0%
0/2
0
 
 1  
 package org.apache.maven.archiva.dependency.graph.tasks;
 2  
 
 3  
 /*
 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
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 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
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.archiva.dependency.graph.DependencyGraph;
 23  
 import org.apache.maven.archiva.dependency.graph.DependencyGraphEdge;
 24  
 import org.apache.maven.archiva.dependency.graph.walk.BaseVisitor;
 25  
 import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphVisitor;
 26  
 import org.apache.maven.archiva.dependency.graph.walk.DependencyGraphWalker;
 27  
 import org.apache.maven.archiva.model.ArtifactReference;
 28  
 
 29  
 import java.util.HashSet;
 30  
 import java.util.Set;
 31  
 
 32  
 /**
 33  
  * FlagCyclicEdgesVisitor 
 34  
  *
 35  
  * @version $Id: FlagCyclicEdgesVisitor.java 755277 2009-03-17 15:18:35Z brett $
 36  
  */
 37  
 public class FlagCyclicEdgesVisitor
 38  
     extends BaseVisitor
 39  
     implements DependencyGraphVisitor
 40  
 {
 41  
     private DependencyGraphWalker walker;
 42  
 
 43  0
     private Set<DependencyGraphEdge> cyclicEdges = new HashSet<DependencyGraphEdge>();
 44  
 
 45  
     public FlagCyclicEdgesVisitor( DependencyGraphWalker walker )
 46  0
     {
 47  0
         this.walker = walker;
 48  0
     }
 49  
 
 50  
     public void discoverEdge( DependencyGraphEdge edge )
 51  
     {
 52  0
         ArtifactReference artifact = edge.getNodeTo();
 53  
 
 54  
         // Process for cyclic edges.
 55  0
         if ( walker.getNodeVisitState( artifact ) == DependencyGraphWalker.PROCESSING )
 56  
         {
 57  0
             edge.setDisabled( true );
 58  0
             edge.setDisabledType( DependencyGraph.DISABLED_CYCLIC );
 59  0
             edge.setDisabledReason( "Cycle detected" );
 60  
             // TODO: insert into reason the path for the cycle that was detected.
 61  0
             cyclicEdges.add( edge );
 62  
         }
 63  0
     }
 64  
 
 65  
     public Set<DependencyGraphEdge> getCyclicEdges()
 66  
     {
 67  0
         return cyclicEdges;
 68  
     }
 69  
 }