You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by sh...@apache.org on 2008/03/28 17:57:20 UTC

svn commit: r642290 - /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java

Author: shivahr
Date: Fri Mar 28 09:57:09 2008
New Revision: 642290

URL: http://svn.apache.org/viewvc?rev=642290&view=rev
Log:
GERONIMODEVTOOLS-317 CoreException when creating Enterprise Application Project

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java?rev=642290&r1=642289&r2=642290&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/jaxb/JAXBUtils.java Fri Mar 28 09:57:09 2008
@@ -29,7 +29,9 @@
 
 import org.apache.geronimo.st.core.Activator;
 import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.runtime.CoreException;
 
 /**
@@ -68,13 +70,14 @@
 			if(file.exists()) {
 				file.setContents(inBuffer, true, false, null);
 			} else {
+				prepareFolder(file.getParent());
 				file.create(inBuffer, true, null);
 			}
 		} catch (JAXBException jaxbException) {
-			Trace.tracePoint("JAXBException", "JAXBUtils.marshallToIFile()", file.getFullPath());
+			Trace.tracePoint("JAXBException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
 			jaxbException.printStackTrace();
 		} catch (CoreException coreException) {
-			Trace.tracePoint("CoreException", "JAXBUtils.marshallToIFile()", file.getFullPath());
+			Trace.tracePoint("CoreException", "JAXBUtils.marshalDeploymentPlan()", file.getFullPath());
 			coreException.printStackTrace();
 		}
 	}
@@ -85,11 +88,22 @@
 			JAXBElement plan = (JAXBElement) unmarshaller.unmarshal(file.getContents());
 			return plan;
 		} catch (JAXBException e) {
+			Trace.tracePoint("JAXBException", "JAXBUtils.unmarshalDeploymentPlan()", file.getFullPath());
 			e.printStackTrace();
 		} catch (CoreException e) {
+			Trace.tracePoint("CoreException", "JAXBUtils.unmarshalDeploymentPlan()", file.getFullPath());
 			e.printStackTrace();
 		}
 		return null;
+	}
+
+	private static void prepareFolder(IContainer folder) throws CoreException {
+		if (folder.exists() || !(folder instanceof IFolder)) {
+			return;
+		}
+		// prepare the upper level folders recursively
+		prepareFolder(folder.getParent());
+		((IFolder) folder).create(true, true, null);
 	}
 
 	public static Object getValue( Object element, String name ) {