Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.wookie.server;
Runs some basic diagnostic tests, and raises warnings if there are potential issues both in the log and also through flash messages on the Admin page.
public class Diagnostics {
	static Logger _logger = Logger.getLogger(Diagnostics.class.getName());

Run the diagnostic tests

Parameters:
context
configuration
	public static void run(ServletContext contextConfiguration configuration){
		final File UPLOADFOLDER = new File(context.getRealPath(configuration.getString("widget.useruploadfolder")));
		checkFolder("Upload"UPLOADFOLDER);	
		final File WIDGETFOLDER = new File(context.getRealPath(configuration.getString("widget.widgetfolder")));
		checkFolder("Widget"WIDGETFOLDER);	
		final File DEPLOYFOLDER = new File(WidgetPackageUtils.convertPathToPlatform(context.getRealPath(configuration.getString("widget.deployfolder"))));
		checkFolder("Deploy"DEPLOYFOLDER);	
	}

Check that a folder exists, is readable, and is writable TODO use localized messages

Parameters:
name the name of the folder being checked
folder the folder to be checked
	public static void checkFolder(String nameFile folder){
		if (!folder.exists()){
			String error = name+" folder does not exist: "+folder.getAbsolutePath(); 
			.error(error);	
else {
			if (!folder.canRead()){
				String error = name+" folder cannot be read from: "+folder.getAbsolutePath(); 
				.error(error);	
			}
			if (!folder.canWrite()){
				String error = name+" folder cannot be written to: "+folder.getAbsolutePath(); 
				.error(error);	
			}
		}
	}
New to GrepCode? Check out our FAQ X