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