1 | |
package org.apache.maven.archiva.scheduled.tasks; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.File; |
23 | |
|
24 | |
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; |
25 | |
import org.codehaus.plexus.taskqueue.Task; |
26 | |
import org.sonatype.nexus.index.context.IndexingContext; |
27 | |
|
28 | |
public class ArtifactIndexingTask |
29 | |
implements Task |
30 | |
{ |
31 | 0 | public enum Action |
32 | |
{ |
33 | 0 | ADD, DELETE, FINISH |
34 | |
} |
35 | |
|
36 | |
private final ManagedRepositoryConfiguration repository; |
37 | |
|
38 | |
private final File resourceFile; |
39 | |
|
40 | |
private final Action action; |
41 | |
|
42 | |
private final IndexingContext context; |
43 | |
|
44 | 0 | private boolean executeOnEntireRepo = true; |
45 | |
|
46 | |
public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action, |
47 | |
IndexingContext context ) |
48 | 0 | { |
49 | 0 | this.repository = repository; |
50 | 0 | this.resourceFile = resourceFile; |
51 | 0 | this.action = action; |
52 | 0 | this.context = context; |
53 | 0 | } |
54 | |
|
55 | |
public ArtifactIndexingTask( ManagedRepositoryConfiguration repository, File resourceFile, Action action, |
56 | |
IndexingContext context, boolean executeOnEntireRepo ) |
57 | |
{ |
58 | 0 | this( repository, resourceFile, action, context ); |
59 | 0 | this.executeOnEntireRepo = executeOnEntireRepo; |
60 | 0 | } |
61 | |
|
62 | |
public boolean isExecuteOnEntireRepo() |
63 | |
{ |
64 | 0 | return executeOnEntireRepo; |
65 | |
} |
66 | |
|
67 | |
public void setExecuteOnEntireRepo( boolean executeOnEntireRepo ) |
68 | |
{ |
69 | 0 | this.executeOnEntireRepo = executeOnEntireRepo; |
70 | 0 | } |
71 | |
|
72 | |
public long getMaxExecutionTime() |
73 | |
{ |
74 | 0 | return 0; |
75 | |
} |
76 | |
|
77 | |
public File getResourceFile() |
78 | |
{ |
79 | 0 | return resourceFile; |
80 | |
} |
81 | |
|
82 | |
public Action getAction() |
83 | |
{ |
84 | 0 | return action; |
85 | |
} |
86 | |
|
87 | |
@Override |
88 | |
public String toString() |
89 | |
{ |
90 | 0 | return "ArtifactIndexingTask [action=" + action + ", repositoryId=" + repository.getId() + ", resourceFile=" |
91 | |
+ resourceFile + "]"; |
92 | |
} |
93 | |
|
94 | |
public ManagedRepositoryConfiguration getRepository() |
95 | |
{ |
96 | 0 | return repository; |
97 | |
} |
98 | |
|
99 | |
public IndexingContext getContext() |
100 | |
{ |
101 | 0 | return context; |
102 | |
} |
103 | |
|
104 | |
@Override |
105 | |
public int hashCode() |
106 | |
{ |
107 | 0 | final int prime = 31; |
108 | 0 | int result = 1; |
109 | 0 | result = prime * result + action.hashCode(); |
110 | 0 | result = prime * result + repository.getId().hashCode(); |
111 | 0 | result = prime * result + ( ( resourceFile == null ) ? 0 : resourceFile.hashCode() ); |
112 | 0 | return result; |
113 | |
} |
114 | |
|
115 | |
@Override |
116 | |
public boolean equals( Object obj ) |
117 | |
{ |
118 | 0 | if ( this == obj ) |
119 | 0 | return true; |
120 | 0 | if ( obj == null ) |
121 | 0 | return false; |
122 | 0 | if ( getClass() != obj.getClass() ) |
123 | 0 | return false; |
124 | 0 | ArtifactIndexingTask other = (ArtifactIndexingTask) obj; |
125 | 0 | if ( !action.equals( other.action ) ) |
126 | 0 | return false; |
127 | 0 | if ( !repository.getId().equals( other.repository.getId() ) ) |
128 | 0 | return false; |
129 | 0 | if ( resourceFile == null ) |
130 | |
{ |
131 | 0 | if ( other.resourceFile != null ) |
132 | 0 | return false; |
133 | |
} |
134 | 0 | else if ( !resourceFile.equals( other.resourceFile ) ) |
135 | 0 | return false; |
136 | 0 | return true; |
137 | |
} |
138 | |
} |