View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.index.updater;
20  
21  import java.io.File;
22  
23  import org.apache.maven.index.context.DocumentFilter;
24  import org.apache.maven.index.context.IndexingContext;
25  import org.apache.maven.index.fs.Locker;
26  
27  /**
28   * Request to update indexes.
29   *
30   * @author Eugene Kuleshov
31   * @author cstamas
32   */
33  public class IndexUpdateRequest {
34      private final IndexingContext context;
35  
36      private final ResourceFetcher resourceFetcher;
37  
38      private DocumentFilter documentFilter;
39  
40      private DocumentFilter extractionFilter;
41  
42      private boolean forceFullUpdate;
43  
44      private boolean incrementalOnly;
45  
46      private File indexTempDir;
47  
48      private File localIndexCacheDir;
49  
50      private Locker locker;
51  
52      private boolean offline;
53  
54      private boolean cacheOnly;
55  
56      private FSDirectoryFactory directoryFactory;
57  
58      private int threads;
59  
60      public IndexUpdateRequest(final IndexingContext context, final ResourceFetcher resourceFetcher) {
61          assert context != null : "Context to be updated cannot be null!";
62          assert resourceFetcher != null : "ResourceFetcher has to be provided!";
63  
64          this.context = context;
65          this.resourceFetcher = resourceFetcher;
66          this.forceFullUpdate = false;
67          this.incrementalOnly = false;
68          this.threads = 1;
69      }
70  
71      public IndexingContext getIndexingContext() {
72          return context;
73      }
74  
75      public ResourceFetcher getResourceFetcher() {
76          return resourceFetcher;
77      }
78  
79      public DocumentFilter getDocumentFilter() {
80          return documentFilter;
81      }
82  
83      public void setDocumentFilter(DocumentFilter documentFilter) {
84          this.documentFilter = documentFilter;
85      }
86  
87      public DocumentFilter getExtractionFilter() {
88          return extractionFilter;
89      }
90  
91      public void setExtractionFilter(DocumentFilter extractionFilter) {
92          this.extractionFilter = extractionFilter;
93      }
94  
95      public void setForceFullUpdate(boolean forceFullUpdate) {
96          this.forceFullUpdate = forceFullUpdate;
97      }
98  
99      public boolean isForceFullUpdate() {
100         return forceFullUpdate;
101     }
102 
103     public boolean isIncrementalOnly() {
104         return incrementalOnly;
105     }
106 
107     public void setIncrementalOnly(boolean incrementalOnly) {
108         this.incrementalOnly = incrementalOnly;
109     }
110 
111     public File getLocalIndexCacheDir() {
112         return localIndexCacheDir;
113     }
114 
115     public void setLocalIndexCacheDir(File dir) {
116         this.localIndexCacheDir = dir;
117     }
118 
119     public Locker getLocker() {
120         return locker;
121     }
122 
123     public void setLocker(Locker locker) {
124         this.locker = locker;
125     }
126 
127     public void setOffline(boolean offline) {
128         this.offline = offline;
129     }
130 
131     public boolean isOffline() {
132         return offline;
133     }
134 
135     public void setCacheOnly(boolean cacheOnly) {
136         this.cacheOnly = cacheOnly;
137     }
138 
139     public boolean isCacheOnly() {
140         return cacheOnly;
141     }
142 
143     public void setFSDirectoryFactory(FSDirectoryFactory factory) {
144         this.directoryFactory = factory;
145     }
146 
147     public FSDirectoryFactory getFSDirectoryFactory() {
148         return directoryFactory != null ? directoryFactory : FSDirectoryFactory.DEFAULT;
149     }
150 
151     public void setIndexTempDir(File indexTempDir) {
152         this.indexTempDir = indexTempDir;
153     }
154 
155     public File getIndexTempDir() {
156         return indexTempDir;
157     }
158 
159     public int getThreads() {
160         return threads;
161     }
162 
163     public void setThreads(int threads) {
164         this.threads = threads;
165     }
166 }