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 boolean forceFullUpdate;
41  
42      private boolean incrementalOnly;
43  
44      private File indexTempDir;
45  
46      private File localIndexCacheDir;
47  
48      private Locker locker;
49  
50      private boolean offline;
51  
52      private boolean cacheOnly;
53  
54      private FSDirectoryFactory directoryFactory;
55  
56      private int threads;
57  
58      public IndexUpdateRequest(final IndexingContext context, final ResourceFetcher resourceFetcher) {
59          assert context != null : "Context to be updated cannot be null!";
60          assert resourceFetcher != null : "ResourceFetcher has to be provided!";
61  
62          this.context = context;
63          this.resourceFetcher = resourceFetcher;
64          this.forceFullUpdate = false;
65          this.incrementalOnly = false;
66          this.threads = 1;
67      }
68  
69      public IndexingContext getIndexingContext() {
70          return context;
71      }
72  
73      public ResourceFetcher getResourceFetcher() {
74          return resourceFetcher;
75      }
76  
77      public DocumentFilter getDocumentFilter() {
78          return documentFilter;
79      }
80  
81      public void setDocumentFilter(DocumentFilter documentFilter) {
82          this.documentFilter = documentFilter;
83      }
84  
85      public void setForceFullUpdate(boolean forceFullUpdate) {
86          this.forceFullUpdate = forceFullUpdate;
87      }
88  
89      public boolean isForceFullUpdate() {
90          return forceFullUpdate;
91      }
92  
93      public boolean isIncrementalOnly() {
94          return incrementalOnly;
95      }
96  
97      public void setIncrementalOnly(boolean incrementalOnly) {
98          this.incrementalOnly = incrementalOnly;
99      }
100 
101     public File getLocalIndexCacheDir() {
102         return localIndexCacheDir;
103     }
104 
105     public void setLocalIndexCacheDir(File dir) {
106         this.localIndexCacheDir = dir;
107     }
108 
109     public Locker getLocker() {
110         return locker;
111     }
112 
113     public void setLocker(Locker locker) {
114         this.locker = locker;
115     }
116 
117     public void setOffline(boolean offline) {
118         this.offline = offline;
119     }
120 
121     public boolean isOffline() {
122         return offline;
123     }
124 
125     public void setCacheOnly(boolean cacheOnly) {
126         this.cacheOnly = cacheOnly;
127     }
128 
129     public boolean isCacheOnly() {
130         return cacheOnly;
131     }
132 
133     public void setFSDirectoryFactory(FSDirectoryFactory factory) {
134         this.directoryFactory = factory;
135     }
136 
137     public FSDirectoryFactory getFSDirectoryFactory() {
138         return directoryFactory != null ? directoryFactory : FSDirectoryFactory.DEFAULT;
139     }
140 
141     public void setIndexTempDir(File indexTempDir) {
142         this.indexTempDir = indexTempDir;
143     }
144 
145     public File getIndexTempDir() {
146         return indexTempDir;
147     }
148 
149     public int getThreads() {
150         return threads;
151     }
152 
153     public void setThreads(int threads) {
154         this.threads = threads;
155     }
156 }