This project has retired. For details please refer to its Attic page.
ArtifactIndexingTask xref
View Javadoc
1   package org.apache.archiva.scheduler.indexing;
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.archiva.indexer.ArchivaIndexingContext;
23  import org.apache.archiva.components.taskqueue.Task;
24  import org.apache.archiva.repository.ManagedRepository;
25  
26  import java.nio.file.Path;
27  
28  
29  public class ArtifactIndexingTask
30      implements Task
31  {
32      public enum Action
33      {
34          ADD,
35          DELETE,
36          FINISH
37      }
38  
39      private final ManagedRepository repository;
40  
41      private final Path resourceFile;
42  
43      private final Action action;
44  
45      private final ArchivaIndexingContext context;
46  
47      private boolean executeOnEntireRepo = true;
48  
49      /**
50       * @since 1.4-M1
51       */
52      private boolean onlyUpdate = false;
53  
54      public ArtifactIndexingTask( ManagedRepository repository, Path resourceFile, Action action,
55                                   ArchivaIndexingContext context )
56      {
57          this.repository = repository;
58          this.resourceFile = resourceFile;
59          this.action = action;
60          this.context = context;
61      }
62  
63      public ArtifactIndexingTask( ManagedRepository repository, Path resourceFile, Action action,
64                                   ArchivaIndexingContext context, boolean executeOnEntireRepo )
65      {
66          this( repository, resourceFile, action, context );
67          this.executeOnEntireRepo = executeOnEntireRepo;
68      }
69  
70      public ArtifactIndexingTask( ManagedRepository repository, Path resourceFile, Action action,
71                                   ArchivaIndexingContext context, boolean executeOnEntireRepo, boolean onlyUpdate )
72      {
73          this( repository, resourceFile, action, context, executeOnEntireRepo );
74          this.onlyUpdate = onlyUpdate;
75      }
76  
77      public boolean isExecuteOnEntireRepo()
78      {
79          return executeOnEntireRepo;
80      }
81  
82      public void setExecuteOnEntireRepo( boolean executeOnEntireRepo )
83      {
84          this.executeOnEntireRepo( executeOnEntireRepo );
85      }
86  
87      public ArtifactIndexingTask executeOnEntireRepo( boolean executeOnEntireRepo )
88      {
89          this.executeOnEntireRepo = executeOnEntireRepo;
90          return this;
91      }
92  
93      @Override
94      public long getMaxExecutionTime()
95      {
96          return 0;
97      }
98  
99      public Path getResourceFile()
100     {
101         return resourceFile;
102     }
103 
104     public Action getAction()
105     {
106         return action;
107     }
108 
109     public ManagedRepository getRepository()
110     {
111         return repository;
112     }
113 
114     public ArchivaIndexingContext getContext()
115     {
116         return context;
117     }
118 
119     public boolean isOnlyUpdate()
120     {
121         return onlyUpdate;
122     }
123 
124     public void setOnlyUpdate( boolean onlyUpdate )
125     {
126         this.onlyUpdate = onlyUpdate;
127     }
128 
129     @Override
130     public int hashCode()
131     {
132         final int prime = 31;
133         int result = 1;
134         result = prime * result + action.hashCode();
135         result = prime * result + repository.getId().hashCode();
136         result = prime * result + ( ( resourceFile == null ) ? 0 : resourceFile.hashCode() );
137         return result;
138     }
139 
140     @Override
141     public boolean equals( Object obj )
142     {
143         if ( this == obj )
144         {
145             return true;
146         }
147         if ( obj == null )
148         {
149             return false;
150         }
151         if ( getClass() != obj.getClass() )
152         {
153             return false;
154         }
155         ArtifactIndexingTask./org/apache/archiva/scheduler/indexing/ArtifactIndexingTask.html#ArtifactIndexingTask">ArtifactIndexingTask other = (ArtifactIndexingTask) obj;
156         if ( !action.equals( other.action ) )
157         {
158             return false;
159         }
160         if ( !repository.getId().equals( other.repository.getId() ) )
161         {
162             return false;
163         }
164         if ( resourceFile == null )
165         {
166             if ( other.resourceFile != null )
167             {
168                 return false;
169             }
170         }
171         else if ( !resourceFile.equals( other.resourceFile ) )
172         {
173             return false;
174         }
175         return true;
176     }
177 
178 
179     @Override
180     public String toString()
181     {
182         return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repository.getId() + ", resourceFile="
183             + resourceFile + "]";
184     }
185 
186 }