You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2011/02/14 22:04:01 UTC

svn commit: r1070670 - /incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java

Author: scottbw
Date: Mon Feb 14 21:04:01 2011
New Revision: 1070670

URL: http://svn.apache.org/viewvc?rev=1070670&view=rev
Log:
Use the .wgt reference to locate the input file, and also generate a good filename using RandomGUID. See WOOKIE-182

Modified:
    incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java

Modified: incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java?rev=1070670&r1=1070669&r2=1070670&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/flatpack/FlatpackFactory.java Mon Feb 14 21:04:01 2011
@@ -23,6 +23,7 @@ import org.apache.wookie.w3c.W3CWidget;
 import org.apache.wookie.w3c.W3CWidgetFactory;
 import org.apache.wookie.w3c.impl.FeatureEntity;
 import org.apache.wookie.w3c.impl.PreferenceEntity;
+import org.apache.wookie.w3c.util.RandomGUID;
 import org.apache.wookie.w3c.util.WidgetOutputter;
 import org.apache.wookie.w3c.util.WidgetPackageUtils;
 
@@ -79,9 +80,8 @@ public class FlatpackFactory {
 		if (instance == null) throw new Exception("No instance specified");
 		if (flatpackFolder == null) flatpackFolder = DEFAULT_FLATPACK_FOLDER;
 		if (inputWidget == null){
-			// TODO try to locate the widget upload package from the WidgetInstance
-			// for now we just set this manually for testing using setInputWidget()
-			throw new Exception("Input widget not specified or not found");
+			// try to locate the widget upload package from the WidgetInstance
+			inputWidget = new File(instance.getWidget().getPackagePath());
 		}
 		if (parser == null) parser = DEFAULT_PARSER;
 		
@@ -112,8 +112,11 @@ public class FlatpackFactory {
 		File configXml = new File(parser.getUnzippedWidgetDirectory(), "config.xml");
 		outputter.outputXML(widget, configXml);
 		
+		// Select a filename
+		String name = new RandomGUID().toString()+".wgt";
+		
 		// Pack up the widget
-		File outputWidget = new File(flatpackFolder,"test.wgt");
+		File outputWidget = new File(flatpackFolder,name);
 		WidgetPackageUtils.repackZip(parser.getUnzippedWidgetDirectory(), outputWidget);
 		
 		// Delete the working area