Subversion Repositories XServices

Rev

Rev 184 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 184 Rev 185
1
/*
1
/*
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
2
 *   Copyright 2013 Brian Rosenberger (Brutex Network)
3
 *
3
 *
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
4
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   you may not use this file except in compliance with the License.
5
 *   you may not use this file except in compliance with the License.
6
 *   You may obtain a copy of the License at
6
 *   You may obtain a copy of the License at
7
 *
7
 *
8
 *       http://www.apache.org/licenses/LICENSE-2.0
8
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *
9
 *
10
 *   Unless required by applicable law or agreed to in writing, software
10
 *   Unless required by applicable law or agreed to in writing, software
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
11
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   See the License for the specific language governing permissions and
13
 *   See the License for the specific language governing permissions and
14
 *   limitations under the License.
14
 *   limitations under the License.
15
 */
15
 */
16
 
16
 
17
package net.brutex.xservices.util.cache;
17
package net.brutex.xservices.util.cache;
18
 
18
 
19
import java.io.File;
19
import java.io.File;
20
import java.io.IOException;
20
import java.io.IOException;
21
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.Enumeration;
22
import java.util.Enumeration;
23
import java.util.Iterator;
23
import java.util.Iterator;
24
import java.util.List;
24
import java.util.List;
25
import java.util.concurrent.ExecutorService;
25
import java.util.concurrent.ExecutorService;
26
import java.util.concurrent.TimeUnit;
26
import java.util.concurrent.TimeUnit;
27
import java.util.regex.Matcher;
27
import java.util.regex.Matcher;
28
import java.util.regex.Pattern;
28
import java.util.regex.Pattern;
29
import javax.servlet.ServletContext;
29
import javax.servlet.ServletContext;
30
import javax.servlet.ServletException;
30
import javax.servlet.ServletException;
31
import javax.servlet.http.HttpServlet;
31
import javax.servlet.http.HttpServlet;
32
import javax.ws.rs.core.Response;
32
import javax.ws.rs.core.Response;
33
import net.brutex.xservices.types.scm.ItemListType;
33
import net.brutex.xservices.types.scm.ItemListType;
34
import net.brutex.xservices.types.scm.ItemType;
34
import net.brutex.xservices.types.scm.ItemType;
35
import net.brutex.xservices.types.scmfindings.FindingDetailsType;
35
import net.brutex.xservices.types.scmfindings.FindingDetailsType;
36
import net.brutex.xservices.types.scmfindings.FindingType;
36
import net.brutex.xservices.types.scmfindings.FindingType;
37
import net.brutex.xservices.types.scmfindings.FindingsListType;
37
import net.brutex.xservices.types.scmfindings.FindingsListType;
38
import net.brutex.xservices.types.scmfindings.GroupMatchListType;
38
import net.brutex.xservices.types.scmfindings.GroupMatchListType;
39
import net.brutex.xservices.types.scmfindings.ObjectFactory;
39
import net.brutex.xservices.types.scmfindings.ObjectFactory;
40
import net.brutex.xservices.ws.rs.CVSInfoImpl;
40
import net.brutex.xservices.ws.rs.CVSInfoImpl;
-
 
41
 
41
import org.apache.commons.configuration.ConfigurationException;
42
import org.apache.commons.configuration2.PropertiesConfiguration;
42
import org.apache.commons.configuration.PropertiesConfiguration;
43
import org.apache.commons.configuration2.builder.fluent.Configurations;
43
import org.apache.jcs.JCS;
44
import org.apache.commons.configuration2.ex.ConfigurationException;
44
import org.apache.jcs.access.exception.CacheException;
45
import org.apache.commons.jcs.access.exception.CacheException;
-
 
46
import org.apache.logging.log4j.LogManager;
45
import org.apache.log4j.Logger;
47
import org.apache.logging.log4j.Logger;
46
 
48
 
47
/**
49
/**
48
 * @author Brian Rosenberger, bru(at)brutex.de
50
 * @author Brian Rosenberger, bru(at)brutex.de
49
 * 
51
 * 
50
 */
52
 */
51
 
53
 
52
public class FindingsCacheServlet extends HttpServlet {
54
public class FindingsCacheServlet extends HttpServlet {
53
 
55
 
54
	private static final long serialVersionUID = 4041338473949999960L;
56
	private static final long serialVersionUID = 4041338473949999960L;
55
	private final static Logger logger = Logger
57
	private static final Logger logger = LogManager.getLogger();
56
			.getLogger(FindingsCacheServlet.class);
-
 
57
	private final List<File> configfiles = new ArrayList<File>();
58
	private final List<File> configfiles = new ArrayList<File>();
58
	private final ObjectFactory FACTORY = new ObjectFactory();
59
	private final ObjectFactory FACTORY = new ObjectFactory();
59
	private ExecutorService executor;
60
	private ExecutorService executor;
60
 
61
 
61
	@Override
62
	@Override
62
	public void init() throws ServletException {
63
	public void init() throws ServletException {
63
		super.init();
64
		super.init();
64
		executor = (ExecutorService) getServletContext()
65
		executor = (ExecutorService) getServletContext()
65
				.getAttribute("CACHE_EXECUTOR");
66
				.getAttribute("CACHE_EXECUTOR");
66
		
67
		
67
		if(! this.initConfigList()) return;
68
		if(! this.initConfigList()) return;
68
		if(! this.initConfigFindings()) return;
69
		if(! this.initConfigFindings()) return;
69
 
70
 
70
		int i = 1;
71
		int i = 1;
71
		for(File f: configfiles) {
72
		for(File f: configfiles) {
72
			//Initialise configuration bean using default values
73
			//Initialise configuration bean using default values
73
			FindingsConfigBean cbean = new FindingsConfigBean(i, Logger.getLogger("worker-"+i+ "." + this.getClass().getName()));
74
			FindingsConfigBean cbean = new FindingsConfigBean(i, LogManager.getLogger("worker-"+i+ "." + this.getClass().getName()));
74
			i++;
75
			i++;
75
			
76
			
76
			
77
			
77
			
78
			
78
			//Read cvs-cache-interval parameter
79
			//Read cvs-cache-interval parameter
79
			try {
80
			try {
80
				int cacheinterval = Integer.parseInt(getServletContext()
81
				int cacheinterval = Integer.parseInt(getServletContext()
81
						.getInitParameter("cvs-cache-interval"));
82
						.getInitParameter("cvs-cache-interval"));
82
				cbean.setCacheinterval(cacheinterval);
83
				cbean.setCacheinterval(cacheinterval);
83
				logger.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
84
				logger.info("FindingsCacheServlet set to "+ cacheinterval + " minutes interval.");
84
			} catch (NumberFormatException e) {
85
			} catch (NumberFormatException e) {
85
				 logger.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
86
				 logger.warn("Could not read parameter 'cvs-cache-interval' from web.xml. Using default value '"
86
						+ cbean.getCacheinterval()+ "' minutes");
87
						+ cbean.getCacheinterval()+ "' minutes");
87
			}
88
			}
-
 
89
			
88
			
90
			Configurations configs = new Configurations();
89
			PropertiesConfiguration config = null;
91
			PropertiesConfiguration config = null;
90
			try {
92
			try {
91
				config = new PropertiesConfiguration(f);
93
				config = configs.properties(f);
92
			} catch (ConfigurationException e) {
94
			} catch (ConfigurationException e) {
93
				logger.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
95
				logger.error("Could not read parameter file at '"+f.getAbsolutePath()+"'");
94
				return;
96
				return;
95
			}
97
			}
96
			
98
			
97
					
99
					
98
			File cvsconfig = new File(config.getString("CVSROOTCONFIGFILE"));
100
			File cvsconfig = new File(config.getString("CVSROOTCONFIGFILE"));
99
			cbean.setCvsconfig(cvsconfig);
101
			cbean.setCvsconfig(cvsconfig);
100
			FindingsCacheServlet.logger.debug("Fetching list of files using '"
102
			FindingsCacheServlet.logger.debug("Fetching list of files using '"
101
					+ cvsconfig.getAbsolutePath() + "' config file");
103
					+ cvsconfig.getAbsolutePath() + "' config file");
102
			
104
			
103
			
105
			
104
			List<Object> filepatterns = config.getList("FILESEARCH");
106
			List<Object> filepatterns = config.getList("FILESEARCH");
105
			cbean.setFilepatterns(filepatterns);
107
			cbean.setFilepatterns(filepatterns);
106
			FindingsCacheServlet.logger.debug("Checking '"
108
			FindingsCacheServlet.logger.debug("Checking '"
107
					+ filepatterns.size()
109
					+ filepatterns.size()
108
					+ "' patterns for file name and path matching.");
110
					+ "' patterns for file name and path matching.");
109
			
111
			
110
			
112
			
111
			List<Object> contentpatterns = config.getList("CONTENTSEARCH");
113
			List<Object> contentpatterns = config.getList("CONTENTSEARCH");
112
			cbean.setContentpatterns(contentpatterns);
114
			cbean.setContentpatterns(contentpatterns);
113
			FindingsCacheServlet.logger.debug("Checking '"
115
			FindingsCacheServlet.logger.debug("Checking '"
114
					+ contentpatterns.size()
116
					+ contentpatterns.size()
115
					+ "' patterns for content matching");
117
					+ "' patterns for content matching");
116
			
118
			
117
 
119
 
118
			
120
			
119
			
121
			
120
			executor.submit(new ThisRunnable(cbean));
122
			executor.submit(new ThisRunnable(cbean));
121
			
123
			
122
		}
124
		}
123
		logger.info("FindingsCacheServlet has been initialized.");
125
		logger.info("FindingsCacheServlet has been initialized.");
124
 
126
 
125
	}
127
	}
126
	
128
	
127
	/*
129
	/*
128
	 * Initialise CVS findings configuration
130
	 * Initialise CVS findings configuration
129
	 */
131
	 */
130
	private boolean initConfigFindings() {
132
	private boolean initConfigFindings() {
131
		String filename = getServletContext().getInitParameter(
133
		String filename = getServletContext().getInitParameter(
132
				"cvs-findings-configuration");
134
				"cvs-findings-configuration");
133
		if (filename == null) {
135
		if (filename == null) {
134
			logger.warn("'cvs-findings-configuration' init parameter is not specified.");
136
			logger.warn("'cvs-findings-configuration' init parameter is not specified.");
135
			return false;
137
			return false;
136
		}
138
		}
137
		final File findingsconfig = new File(filename);
139
		final File findingsconfig = new File(filename);
138
		logger.info("CVS findings configuration file found at '"
140
		logger.info("CVS findings configuration file found at '"
139
				+ findingsconfig.getAbsolutePath() + "'");
141
				+ findingsconfig.getAbsolutePath() + "'");
140
		if ((!findingsconfig.canRead()) || (findingsconfig.isDirectory())) {
142
		if ((!findingsconfig.canRead()) || (findingsconfig.isDirectory())) {
141
			logger.info("CVS findings configuration file '"
143
			logger.info("CVS findings configuration file '"
142
					+ findingsconfig.getAbsolutePath() + "' does not exist.");
144
					+ findingsconfig.getAbsolutePath() + "' does not exist.");
143
			return false;
145
			return false;
144
		}
146
		}
145
		return true;
147
		return true;
146
	}
148
	}
147
 
149
 
148
	/*
150
	/*
149
	 * Add all specified CVS configuration files to the list. Parameter pattern
151
	 * Add all specified CVS configuration files to the list. Parameter pattern
150
	 * is "cvs-config-XX".
152
	 * is "cvs-config-XX".
151
	 */
153
	 */
152
	private boolean initConfigList() {
154
	private boolean initConfigList() {
153
		Enumeration<String> attributes = getServletContext()
155
		Enumeration<String> attributes = getServletContext()
154
				.getInitParameterNames();
156
				.getInitParameterNames();
155
		while (attributes.hasMoreElements()) {
157
		while (attributes.hasMoreElements()) {
156
			String name = (String) attributes.nextElement();
158
			String name = (String) attributes.nextElement();
157
			if (name.startsWith("cvs-config-")) {
159
			if (name.startsWith("cvs-config-")) {
158
				String configfile = getServletContext().getInitParameter(name);
160
				String configfile = getServletContext().getInitParameter(name);
159
				logger.info("Adding CVS configuration file: " + configfile);
161
				logger.info("Adding CVS configuration file: " + configfile);
160
				this.configfiles.add(new File(configfile));
162
				this.configfiles.add(new File(configfile));
161
			}
163
			}
162
		}
164
		}
163
		/*
165
		/*
164
		 * Verify, that all configuration files do exists and are readable.
166
		 * Verify, that all configuration files do exists and are readable.
165
		 */
167
		 */
166
		List<File> removelist = new ArrayList<File>();
168
		List<File> removelist = new ArrayList<File>();
167
		for (File f : configfiles) {
169
		for (File f : configfiles) {
168
			if (!f.exists()) {
170
			if (!f.exists()) {
169
				logger.warn("CVS configuration file '"
171
				logger.warn("CVS configuration file '"
170
						+ f.getAbsolutePath()
172
						+ f.getAbsolutePath()
171
						+ "' is specified, but does not exist. Removing from list.");
173
						+ "' is specified, but does not exist. Removing from list.");
172
				removelist.add(f);
174
				removelist.add(f);
173
			} else if (!f.canRead()) {
175
			} else if (!f.canRead()) {
174
				logger.warn("CVS configuration file '"
176
				logger.warn("CVS configuration file '"
175
						+ f.getAbsolutePath()
177
						+ f.getAbsolutePath()
176
						+ "' does exist, but is not readable. Removing from list.");
178
						+ "' does exist, but is not readable. Removing from list.");
177
				removelist.add(f);
179
				removelist.add(f);
178
			}
180
			}
179
		}
181
		}
180
		configfiles.removeAll(removelist);
182
		configfiles.removeAll(removelist);
181
		return true;
183
		return true;
182
	}
184
	}
183
 
185
 
184
	
186
	
185
	
187
	
186
	
188
	
187
	class ThisRunnable implements Runnable {
189
	class ThisRunnable implements Runnable {
188
		boolean isInterrupted = false;
190
		boolean isInterrupted = false;
189
		FindingsConfigBean configuration;
191
		FindingsConfigBean configuration;
190
 
192
 
191
		public ThisRunnable(FindingsConfigBean configuration) {
193
		public ThisRunnable(FindingsConfigBean configuration) {
192
			this.configuration = configuration;
194
			this.configuration = configuration;
193
		}
195
		}
194
 
196
 
195
		public void run() {
197
		public void run() {
196
			CVSInfoImpl instance = new CVSInfoImpl();
198
			CVSInfoImpl instance = new CVSInfoImpl();
197
 
199
 
198
			ItemListType fileslist = (ItemListType) instance
200
			ItemListType fileslist = (ItemListType) instance
199
					.getRepositoryFiles(null, configuration.getCvsconfig(), "", true, true, true)
201
					.getRepositoryFiles(null, configuration.getCvsconfig(), "", true, true, true)
200
					.getEntity();
202
					.getEntity();
201
			ObjectFactory FACTORY = new ObjectFactory();
203
			ObjectFactory FACTORY = new ObjectFactory();
202
			FindingsListType findingsList = FACTORY.createFindingsListType();
204
			FindingsListType findingsList = FACTORY.createFindingsListType();
203
 
205
 
204
			FindingsCacheServlet.logger.info("Processing '"
206
			FindingsCacheServlet.logger.info("Processing '"
205
					+ fileslist.getItems().size() + "' files and directories.");
207
					+ fileslist.getItems().size() + "' files and directories.");
206
 
208
 
207
			while (!this.isInterrupted) {
209
			while (!this.isInterrupted) {
208
				Pattern p;
210
				Pattern p;
209
				for (ItemType i : fileslist.getItems()) {
211
				for (ItemType i : fileslist.getItems()) {
210
					if (this.isInterrupted)
212
					if (this.isInterrupted)
211
						break;
213
						break;
212
					Iterator<Object> iterF = configuration.getFilepatterns().iterator();
214
					Iterator<Object> iterF = configuration.getFilepatterns().iterator();
213
					while(iterF.hasNext()) {
215
					while(iterF.hasNext()) {
214
						Object o = iterF.next();
216
						Object o = iterF.next();
215
						if (this.isInterrupted)
217
						if (this.isInterrupted)
216
							break;
218
							break;
217
						FindingsCacheServlet.logger.debug("Scanning filename '"
219
						FindingsCacheServlet.logger.debug("Scanning filename '"
218
								+ i.getFullname() + "' for pattern '"
220
								+ i.getFullname() + "' for pattern '"
219
								+ (String) o + "'");
221
								+ (String) o + "'");
220
						p = Pattern.compile((String) o);
222
						p = Pattern.compile((String) o);
221
						Matcher m = p.matcher(i.getFullname());
223
						Matcher m = p.matcher(i.getFullname());
222
						if (m.find()) {
224
						if (m.find()) {
223
							FindingType finding = FACTORY.createFindingType();
225
							FindingType finding = FACTORY.createFindingType();
224
							finding.setFilesearch(p.toString());
226
							finding.setFilesearch(p.toString());
225
							ItemType it = (ItemType) instance.getFileContent(
227
							ItemType it = (ItemType) instance.getFileContent(
226
									null, configuration.getCvsconfig(), i.getFullname(), true)
228
									null, configuration.getCvsconfig(), i.getFullname(), true)
227
									.getEntity();
229
									.getEntity();
228
							finding.setContent(it.getContent());
230
							finding.setContent(it.getContent());
229
							finding.setData(it.getData());
231
							finding.setData(it.getData());
230
							finding = copyDetails(finding, i);
232
							finding = copyDetails(finding, i);
231
							findingsList.getFindings().add(finding);
233
							findingsList.getFindings().add(finding);
232
							FindingsCacheServlet.logger
234
							FindingsCacheServlet.logger
233
									.debug("Match found for '"
235
									.debug("Match found for '"
234
											+ i.getFullname() + "'");
236
											+ i.getFullname() + "'");
235
							break;
237
							break;
236
						}
238
						}
237
						FindingsCacheServlet.logger
239
						FindingsCacheServlet.logger
238
								.debug("No match found for '" + i.getFullname()
240
								.debug("No match found for '" + i.getFullname()
239
										+ "'");
241
										+ "'");
240
					}
242
					}
241
				}
243
				}
242
				FindingsCacheServlet.logger
244
				FindingsCacheServlet.logger
243
						.debug("Processing file content for '"
245
						.debug("Processing file content for '"
244
								+ findingsList.getFindings().size()
246
								+ findingsList.getFindings().size()
245
								+ "' entries in the list.");
247
								+ "' entries in the list.");
246
 
248
 
247
				for (FindingType t : findingsList.getFindings()) {
249
				for (FindingType t : findingsList.getFindings()) {
248
					if (this.isInterrupted)
250
					if (this.isInterrupted)
249
						break;
251
						break;
250
					boolean isFound = false;
252
					boolean isFound = false;
251
					Matcher m;
253
					Matcher m;
252
					Iterator<Object> iter = configuration.getContentpatterns().iterator();
254
					Iterator<Object> iter = configuration.getContentpatterns().iterator();
253
					while (iter.hasNext()) {
255
					while (iter.hasNext()) {
254
 
256
 
255
						Object o = iter.next();
257
						Object o = iter.next();
256
						if (this.isInterrupted)
258
						if (this.isInterrupted)
257
							break;
259
							break;
258
						FindingsCacheServlet.logger
260
						FindingsCacheServlet.logger
259
								.debug("Scanning file content for file '"
261
								.debug("Scanning file content for file '"
260
										+ t.getFullname() + "' for pattern '"
262
										+ t.getFullname() + "' for pattern '"
261
										+ (String) o + "'");
263
										+ (String) o + "'");
262
 
264
 
263
						Pattern p1 = Pattern.compile((String) o);
265
						Pattern p1 = Pattern.compile((String) o);
264
						m = p1.matcher(t.getContent());
266
						m = p1.matcher(t.getContent());
265
						t.setContentsearch(p1.toString());
267
						t.setContentsearch(p1.toString());
266
 
268
 
267
						isFound = true;
269
						isFound = true;
268
						int s = m.start();
270
						int s = m.start();
269
						int e = m.end();
271
						int e = m.end();
270
						String c = m.group();
272
						String c = m.group();
271
 
273
 
272
						FindingDetailsType fd = FACTORY
274
						FindingDetailsType fd = FACTORY
273
								.createFindingDetailsType();
275
								.createFindingDetailsType();
274
						GroupMatchListType gm = FACTORY
276
						GroupMatchListType gm = FACTORY
275
								.createGroupMatchListType();
277
								.createGroupMatchListType();
276
						gm.setMatchAtIndex(s);
278
						gm.setMatchAtIndex(s);
277
						gm.setMatchToIndex(e);
279
						gm.setMatchToIndex(e);
278
						gm.setMatchString(c);
280
						gm.setMatchString(c);
279
						gm.setMatchGroup(0);
281
						gm.setMatchGroup(0);
280
						fd.setFullmatch(gm);
282
						fd.setFullmatch(gm);
281
						for (int i = 1; i <= m.groupCount(); i++) {
283
						for (int i = 1; i <= m.groupCount(); i++) {
282
							GroupMatchListType gmg = FACTORY
284
							GroupMatchListType gmg = FACTORY
283
									.createGroupMatchListType();
285
									.createGroupMatchListType();
284
							s = m.start(i);
286
							s = m.start(i);
285
							e = m.end(i);
287
							e = m.end(i);
286
							c = m.group(i);
288
							c = m.group(i);
287
							gmg.setMatchAtIndex(s);
289
							gmg.setMatchAtIndex(s);
288
							gmg.setMatchToIndex(e);
290
							gmg.setMatchToIndex(e);
289
							gmg.setMatchString(c);
291
							gmg.setMatchString(c);
290
							gmg.setMatchGroup(i);
292
							gmg.setMatchGroup(i);
291
							fd.getMatchLists().add(gmg);
293
							fd.getMatchLists().add(gmg);
292
						}
294
						}
293
						t.getFindingLists().add(fd);
295
						t.getFindingLists().add(fd);
294
						FindingsCacheServlet.logger
296
						FindingsCacheServlet.logger
295
								.debug("Found matching content at index '" + s
297
								.debug("Found matching content at index '" + s
296
										+ "' in file '" + t.getFullname()
298
										+ "' in file '" + t.getFullname()
297
										+ "' with pattern '" + p1.toString()
299
										+ "' with pattern '" + p1.toString()
298
										+ "'");
300
										+ "'");
299
					}
301
					}
300
 
302
 
301
					if (!isFound) {
303
					if (!isFound) {
302
						findingsList.getFindings().remove(t);
304
						findingsList.getFindings().remove(t);
303
						FindingsCacheServlet.logger
305
						FindingsCacheServlet.logger
304
								.debug("Found matching filename for '"
306
								.debug("Found matching filename for '"
305
										+ t.getFullname()
307
										+ t.getFullname()
306
										+ "' but content didn't match. Removing.");
308
										+ "' but content didn't match. Removing.");
307
					}
309
					}
308
 
310
 
309
					try {
311
					try {
310
						instance.getCacheInstance().put(
312
						instance.getCacheInstance().put(
311
								"FINDINGS-" + t.getROOT(), findingsList);
313
								"FINDINGS-" + t.getROOT(), findingsList);
312
						FindingsCacheServlet.logger
314
						FindingsCacheServlet.logger
313
								.info("FINDINGS for CVSROOT '" + t.getROOT()
315
								.info("FINDINGS for CVSROOT '" + t.getROOT()
314
										+ "' have been updated in cache.");
316
										+ "' have been updated in cache.");
315
					} catch (CacheException e) {
317
					} catch (CacheException e) {
316
						FindingsCacheServlet.logger.error(e.getMessage(), e);
318
						FindingsCacheServlet.logger.error(e.getMessage(), e);
317
					}
319
					}
318
				}
320
				}
319
				try {
321
				try {
320
					int cacheinterval = configuration.getCacheinterval();
322
					int cacheinterval = configuration.getCacheinterval();
321
					FindingsCacheServlet.logger.debug("Now sleeping for '"
323
					FindingsCacheServlet.logger.debug("Now sleeping for '"
322
							+ cacheinterval + "' minutes");
324
							+ cacheinterval + "' minutes");
323
					Thread.currentThread();
325
					Thread.currentThread();
324
					Thread.sleep(cacheinterval * 60000);
326
					Thread.sleep(cacheinterval * 60000);
325
					FindingsCacheServlet.logger.debug("Waking up after '"
327
					FindingsCacheServlet.logger.debug("Waking up after '"
326
							+ cacheinterval + "' minutes of sleep");
328
							+ cacheinterval + "' minutes of sleep");
327
				} catch (InterruptedException e) {
329
				} catch (InterruptedException e) {
328
					this.isInterrupted = true;
330
					this.isInterrupted = true;
329
					FindingsCacheServlet.logger
331
					FindingsCacheServlet.logger
330
							.warn("FindingsCacheServlet cache was interrupted. Shutting down.");
332
							.warn("FindingsCacheServlet cache was interrupted. Shutting down.");
331
				}
333
				}
332
			}
334
			}
333
 
335
 
334
		}
336
		}
335
 
337
 
336
		private FindingType copyDetails(FindingType finding, ItemType item) {
338
		private FindingType copyDetails(FindingType finding, ItemType item) {
337
			finding.setDescription(item.getDescription());
339
			finding.setDescription(item.getDescription());
338
			finding.setFullname(item.getFullname());
340
			finding.setFullname(item.getFullname());
339
			finding.setName(item.getName());
341
			finding.setName(item.getName());
340
			finding.setPath(item.getPath());
342
			finding.setPath(item.getPath());
341
			finding.setRemotefullname(item.getRemotefullname());
343
			finding.setRemotefullname(item.getRemotefullname());
342
			finding.setRemotename(item.getRemotename());
344
			finding.setRemotename(item.getRemotename());
343
			finding.setRemotepath(item.getRemotepath());
345
			finding.setRemotepath(item.getRemotepath());
344
			finding.setROOT(item.getROOT());
346
			finding.setROOT(item.getROOT());
345
			return finding;
347
			return finding;
346
		}
348
		}
347
 
349
 
348
	}
350
	}
349
 
351
 
350
 
352
 
351
 
353
 
352
 
354
 
353
	/* (non-Javadoc)
355
	/* (non-Javadoc)
354
	 * @see javax.servlet.GenericServlet#destroy()
356
	 * @see javax.servlet.GenericServlet#destroy()
355
	 */
357
	 */
356
	@Override
358
	@Override
357
	public void destroy() {
359
	public void destroy() {
358
		// TODO Auto-generated method stub
360
		// TODO Auto-generated method stub
359
		executor.shutdown();
361
		executor.shutdown();
360
		try {
362
		try {
361
			executor.awaitTermination(3, TimeUnit.SECONDS);
363
			executor.awaitTermination(3, TimeUnit.SECONDS);
362
			logger.info("Cache Worker Threads have shut down.");
364
			logger.info("Cache Worker Threads have shut down.");
363
		} catch (InterruptedException e) {
365
		} catch (InterruptedException e) {
364
			logger.error("Cache Worker Threads did not terminate within timeout.", e);
366
			logger.error("Cache Worker Threads did not terminate within timeout.", e);
365
		}
367
		}
366
		super.destroy();
368
		super.destroy();
367
	}
369
	}
368
	
370
	
369
}
371
}
370
 
372
 
371
Generated by GNU Enscript 1.6.5.90.
373
Generated by GNU Enscript 1.6.5.90.
372
 
374
 
373
 
375