Subversion Repositories XServices

Rev

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

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