⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 systemcheck.java

📁 WebMail is a server application that allows ISPs to provide a WWW interface for each user to his mai
💻 JAVA
字号:
/* CVS ID: $Id: SystemCheck.java,v 1.5 2001/01/16 10:41:21 wastl Exp $ */package net.wastl.webmail.server;import java.io.*;import gnu.regexp.*;import net.wastl.webmail.exceptions.*;/** * SystemCheck.java * * Created: Tue Aug 31 15:40:57 1999 * * Copyright (C) 1999-2000 Sebastian Schaffert *  * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *//** * * * * @author Sebastian Schaffert * @version */public class SystemCheck  {        public SystemCheck(WebMailServer parent) throws WebMailException {	System.err.println("- Checking Java Virtual Machine ... ");	System.err.print("  * Version: "+System.getProperty("java.version")+" ... ");	/* Test if the Java version might cause trouble */	if(System.getProperty("java.version").compareTo("1.1")>=0) {	    System.err.println("ok.");	} else {	    System.err.println("warn. At least Java 1.1 is required for WebMail.");	    //System.exit(1);	}	/* Test if the operating system is supported */	System.err.print("  * Operating System: "+System.getProperty("os.name")+"/"+System.getProperty("os.arch")+" "+System.getProperty("os.version")+" ... ");	if(System.getProperty("os.name").equals("SunOS") || 	   System.getProperty("os.name").equals("Solaris") || 	   System.getProperty("os.name").equals("Linux")) {	    System.err.println("ok.");	} else {	    System.err.println("warning. WebMail was only tested\n   on Solaris, HP-UX and Linux and may cause problems on your platform.");	}	/* Check if we are running as root and issue a warning */	System.err.print("  * User name: "+System.getProperty("user.name")+" ... ");	if(!System.getProperty("user.name").equals("root")) {	    System.err.println("ok.");	} else {	    System.err.println("warning. You are running WebMail as root. This may be a potential security problem.");	}	/* Check whether all WebMail system properties are defined */	System.err.print("  * WebMail System Properties: ");	//checkPathProperty(parent,"webmail.plugin.path");	//checkPathProperty(parent,"webmail.auth.path");	checkPathProperty(parent,"webmail.lib.path");	checkPathProperty(parent,"webmail.template.path");	checkPathProperty(parent,"webmail.data.path");	checkPathProperty(parent,"webmail.xml.path");	System.err.println("ok!");	System.err.print("  * Setting DTD-path in webmail.xml ... ");	File f1=new File(parent.getProperty("webmail.data.path")+System.getProperty("file.separator")+"webmail.xml");	File f2=new File(parent.getProperty("webmail.data.path")+System.getProperty("file.separator")+"webmail.xml."+Long.toHexString(System.currentTimeMillis()));		try {	    RE regexp=new RE("<!DOCTYPE SYSDATA SYSTEM \".*\">");	    BufferedReader file1=new BufferedReader(new FileReader(f1));	    PrintWriter file2=new PrintWriter(new FileWriter(f2));	    try {		String line=file1.readLine();		while(line != null) {		    String s=regexp.substituteAll(line,"<!DOCTYPE SYSDATA SYSTEM \"file://"+						  parent.getProperty("webmail.xml.path")+						  System.getProperty("file.separator")+						  "sysdata.dtd"+"\">");		    //System.err.println(s);		    file2.println(s);		    line=file1.readLine();		}	    } catch(EOFException ex) {	    }	    file2.close();	    file1.close();	} catch(Exception ex) {	    ex.printStackTrace();	    throw new WebMailException("Error parsing webmail.xml!");	}	f2.renameTo(f1);	System.err.println("done!");    }        protected static void checkPathProperty(WebMailServer parent,String property) throws WebMailException {	if(parent.getProperty(property) == null ||	   parent.getProperty(property).equals("")) {	    System.err.println("fatal error. "+property+" not defined.");	    throw new WebMailException();	} else {	    try {		File f=new File(parent.getProperty(property));		parent.setProperty(property,f.getCanonicalPath());	    } catch(IOException ex) {		throw new WebMailException(ex.getMessage());	    }	}    }} // SystemCheck

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -