click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From take...@apache.org
Subject svn commit: r795922 - in /incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse: ClickUtils.java core/facet/ClickFacetInstallDelegate.java
Date Mon, 20 Jul 2009 17:09:27 GMT
Author: takezoe
Date: Mon Jul 20 17:09:27 2009
New Revision: 795922

URL: http://svn.apache.org/viewvc?rev=795922&view=rev
Log: (empty)

Modified:
    incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/ClickUtils.java
    incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/core/facet/ClickFacetInstallDelegate.java

Modified: incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/ClickUtils.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/ClickUtils.java?rev=795922&r1=795921&r2=795922&view=diff
==============================================================================
--- incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/ClickUtils.java
(original)
+++ incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/ClickUtils.java
Mon Jul 20 17:09:27 2009
@@ -18,9 +18,12 @@
  */
 package org.apache.click.eclipse;
 
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -758,15 +761,27 @@
 		} catch(IOException ex){
 			ClickPlugin.log(ex);
 		} finally {
-			if(in!=null){
-				try {
-					in.close();
-				} catch(Exception ex){}
-			}
-			if(out!=null){
-				try {
-					out.close();
-				} catch(Exception ex){}
+			closeQuietly(in);
+			closeQuietly(out);
+		}
+	}
+	
+	public static String readStream(InputStream in){
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		copyStream(in, out);
+		try {
+			return new String(out.toByteArray(), "UTF-8");
+		} catch(UnsupportedEncodingException ex){
+			throw new RuntimeException(ex);
+		}
+	}
+	
+	public static void closeQuietly(Closeable closeable){
+		if(closeable != null){
+			try {
+				closeable.close();
+			} catch(Exception ex){
+				;
 			}
 		}
 	}

Modified: incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/core/facet/ClickFacetInstallDelegate.java
URL: http://svn.apache.org/viewvc/incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/core/facet/ClickFacetInstallDelegate.java?rev=795922&r1=795921&r2=795922&view=diff
==============================================================================
--- incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/core/facet/ClickFacetInstallDelegate.java
(original)
+++ incubator/click/trunk/tools/eclipse/org.apache.click.eclipse/src/org/apache/click/eclipse/core/facet/ClickFacetInstallDelegate.java
Mon Jul 20 17:09:27 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.click.eclipse.core.facet;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.net.URL;
@@ -182,9 +183,18 @@
 			if(!file.exists()){
 				file.createNewFile();
 			}
-			ClickUtils.copyStream(ClickPlugin.getDefault().getBundle().getEntry(
-					ClickFacetUtil.SPRING_DIR + "/spring-beans.xml").openStream(),
+			
+			URL url = ClickPlugin.getDefault().getBundle().getEntry(
+					ClickFacetUtil.SPRING_DIR + "/spring-beans.xml");
+			
+			// Replaces ${rootPackage} by the input package name.
+			String contents = ClickUtils.readStream(url.openStream());
+			contents = contents.replace("${rootPackage}", 
+					config.getStringProperty(ClickFacetInstallDataModelProvider.ROOT_PACKAGE));
+			
+			ClickUtils.copyStream(new ByteArrayInputStream(contents.getBytes("UTF-8")), 
 					new FileOutputStream(file));
+			
 		} catch(Exception ex){
 			ClickPlugin.log(ex);
 		}
@@ -240,7 +250,18 @@
 
 				URL url = ClickPlugin.getDefault().getBundle().getEntry(
 						ClickFacetUtil.CLICK_DIR + ClickFacetUtil.COPY_FILES[i]);
-				ClickUtils.copyStream(url.openStream(), new FileOutputStream(file));
+				if(file.getName().equals("click.xml")){
+					// Replaces ${rootPackage} by the input package name.
+					String contents = ClickUtils.readStream(url.openStream());
+					contents = contents.replace("${rootPackage}", 
+							config.getStringProperty(ClickFacetInstallDataModelProvider.ROOT_PACKAGE));
+					
+					ClickUtils.copyStream(new ByteArrayInputStream(contents.getBytes("UTF-8")), 
+							new FileOutputStream(file));
+					
+				} else {
+					ClickUtils.copyStream(url.openStream(), new FileOutputStream(file));
+				}
 			} catch(Exception ex){
 				ClickPlugin.log(ex);
 			}



Mime
View raw message