[jboss-svn-commits] JBL Code SVN: r8748 - in labs/jbossesb/trunk/product/core: listeners/src/org/jboss/soa/esb/listeners listeners/src/org/jboss/soa/esb/listeners/config listeners/src/org/jboss/soa/esb/listeners/gateway listeners/tests/src/org/jboss/soa/esb/listeners/config rosetta/src/org/jboss/internal/soa/esb/couriers rosetta/src/org/jboss/internal/soa/esb/parameters rosetta/src/org/jboss/soa/esb/notification

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Jan 7 09:05:40 EST 2007


Author: estebanschifman
Date: 2007-01-07 09:05:25 -0500 (Sun, 07 Jan 2007)
New Revision: 8748

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerUnitTest.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/parameters/ParamFileRepository.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
Log:
Fix cases where getParent() or getParentFile() returns null

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -93,7 +93,9 @@
 		{
 			File configFile = new File(configName);
 			String sParent = configFile.getParent();
-			if (null!=sParent && (sParent.endsWith("/.") || sParent.endsWith("\\.")))
+			if (null==sParent)
+				sParent=new File("").getAbsolutePath();
+			else if (sParent.endsWith("/.") || sParent.endsWith("\\."))
 				sParent = sParent.substring(0,-2+sParent.length());
 			configFile = new File(sParent,configFile.getName());
 
@@ -140,6 +142,8 @@
         
 		//Remove the listener and gateway configuration files if the exist
 		File configDir = configFile.getParentFile();
+		if (null==configDir)
+			configDir=new File("");
 		File listenerFile = new File(configDir,esbConf);
 		if (listenerFile.exists()) {
 			listenerFile.delete();

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -88,7 +88,8 @@
 	{
 		mConfigFileName = configFileName;
 		File configFile = new File(configFileName);
-		mConfigDirectory = configFile.getParentFile();
+		File parent = configFile.getParentFile();
+		mConfigDirectory = (null!=parent) ? parent : new File("");
 		//Try to obtain a handle to the validation file (xsd)
 		if (validationFileName==null) {
 			mValidationFileName=JBOSSESB_XSD;

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/AbstractFileGateway.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -109,7 +109,7 @@
 			for (File fileIn : fileList)
             {
         		// Try to rename - if unsuccessful, somebody else got it first
-        		File fileWork = new File(fileIn.getParent(),fileIn.getName()+_workingSuffix);
+        		File fileWork = new File(fileIn.toString()+_workingSuffix);
         		try 
         		{
         			if (! renameFile(fileIn,fileWork))

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/RemoteGatewayListener.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -47,7 +47,10 @@
 		super.checkMyParms();
 		File temp = File.createTempFile("FTPdown", ".tmp");
 		temp.delete();
-		_config.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, temp.getParent());
+		String localDir = temp.getParent();
+		if (null==localDir)
+			localDir=new File("").getAbsolutePath();
+		_config.setAttribute(RemoteFileSystem.PARMS_LOCAL_DIR, localDir);
 		final String remoteDir = _config.getAttribute(ListenerTagNames.FILE_INPUT_DIR_TAG) ;
 		_config.setAttribute(RemoteFileSystem.PARMS_REMOTE_DIR, remoteDir);
 		RemoteFileSystem rfs = RemoteFileSystemFactory.getRemoteFileSystem(

Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerUnitTest.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerUnitTest.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -56,6 +56,8 @@
 		}
 		//Remove the listener and gateway configuration files if the exist
 		File currentDir = configFile.getParentFile();
+		if (null==currentDir)
+			currentDir=new File("");
 		File listenerFile = new File(currentDir + File.separator + "jbossesb-listener.xml");
 		if (listenerFile.exists()) {
 			listenerFile.delete();

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/couriers/FileCourier.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -133,6 +133,8 @@
 
 				File directory = (file.isDirectory()) ? file : file
 						.getParentFile();
+				if (null==directory)
+					directory = new File("");
 				if (!directory.canRead())
 					throw new CourierException("Can't read directory "
 							+ directory.toString());
@@ -358,9 +360,7 @@
 							+ sfx);
 		}
 		
-		// TODO what if input.getParent() returns null?!
-		
-		return new File(input.getParent(), input.getName() + sfx);
+		return new File(input.toString()+ sfx);
 	} // ________________________________
 
 	protected File errorFile(File input)
@@ -392,7 +392,7 @@
 					.debug("No valid work suffix found in EPR - using default of "
 							+ sfx);
 		}
-		return new File(input.getParent(), input.getName() + sfx);
+		return new File(input.toString() + sfx);
 	} // ________________________________
 
 	protected File postFile(File input)
@@ -408,12 +408,12 @@
 			_logger.warn("Problems in FileEpr", e);
 		}
 
-		String inputDir = input.getParent();
-		
-		// getParent could return null!!
-		
+		String inputDir = new File(input.getAbsolutePath()).getParent();		
 		if (inputDir == null)
+		{
 			_logger.debug("Could not get parent directory for "+input);
+			inputDir="";
+		}
 		
 		String dir = null;
 		try
@@ -424,7 +424,7 @@
 		{
 			_logger.warn("Malformed EPR", e);
 		}
-		if (Util.isNullString(dir))
+		if (null==dir)
 		{
 			dir = inputDir;
 			_logger

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/parameters/ParamFileRepository.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/parameters/ParamFileRepository.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/parameters/ParamFileRepository.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -88,8 +88,11 @@
 		synchronized (this)
 		{
 			File paramFile = toParamFile(nameParam);
+			File parentDir = paramFile.getParentFile();
+			if (null==parentDir)
+				parentDir=new File("");
 
-			paramFile.getParentFile().mkdirs();
+			parentDir.mkdirs();
 			FileOutputStream fileStream = null;
 			try
 			{

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java	2007-01-07 11:18:25 UTC (rev 8747)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java	2007-01-07 14:05:25 UTC (rev 8748)
@@ -113,7 +113,8 @@
             }
 			
 			// Make sure the parent folder exists...
-			if(!m_oaOutF[i].getParentFile().exists()) {
+            File parent = m_oaOutF[i].getAbsoluteFile().getParentFile();
+			if(null==parent || !parent.exists()) {
 				throw new IllegalArgumentException("Bad File Notification Configuration: Parent folder for file [" + m_oaOutF[i].getAbsolutePath() + "] doesn't exist.");
 			}
 		}




More information about the jboss-svn-commits mailing list