[Yanel-commits] rev 23199 - in public/yanel/trunk/src: realms/welcome-admin/yanel/rti resources/add-realm resources/add-realm/config resources/add-realm/src/java/org/wyona/yanel/impl/resources resources/add-realm/xml resources/add-realm/xslt

josias at wyona.com josias at wyona.com
Thu Mar 8 23:06:15 CET 2007


Author: josias
Date: 2007-03-08 23:06:13 +0100 (Thu, 08 Mar 2007)
New Revision: 23199

Added:
   public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rc
Removed:
   public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti
Modified:
   public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties
   public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties
   public/yanel/trunk/src/resources/add-realm/resource.xml
   public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java
   public/yanel/trunk/src/resources/add-realm/xml/input-screen.xml
   public/yanel/trunk/src/resources/add-realm/xml/status-screen.xml
   public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl
Log:
applied patch for bug #4991 (thanks to jonathan):

* default form field values can now be set as RC parameters.
* setting a default value marks the form field as read-only so it can't be
edited.
* enabled passing of null value as the fslocation, which creates the new realm
in the src/realms directory.
* added a link to the status page which brings you to the newly created realm.
* adds check for whether the rc properties exist before adding them to the




Added: public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rc
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rc	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rc	2007-03-08 22:06:13 UTC (rev 23199)
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+
+<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
+  <yanel:rti name="add-realm" namespace="http://www.wyona.org/yanel/resource/1.0"/>
+
+  <yanel:property name="fslocation" value=""/>
+  <yanel:property name="crawlmaxpages" value="100"/>
+</yanel:resource-config>

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti	2007-03-08 22:06:13 UTC (rev 23199)
@@ -1 +0,0 @@
-<{http://www.wyona.org/yanel/resource/1.0}add-realm/>

Modified: public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties	2007-03-08 22:06:13 UTC (rev 23199)
@@ -2,7 +2,7 @@
 realmid = Realm Id
 realmname = Realm Name
 url = URL
-fs-location = Filesystem Pfad
+fslocation = Filesystem Pfad
 crawldepth = Crawl Tiefe
 crawlmaxpages = Max # der Seiten to Crawl
 message = Message

Modified: public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties	2007-03-08 22:06:13 UTC (rev 23199)
@@ -2,7 +2,7 @@
 realmid = Realm Id
 realmname = Realm Name
 url = URL
-fs-location = Filesystem Path where Realm will be located
+fslocation = Filesystem Path where Realm will be located
 crawldepth = Crawl Depth
 crawlmaxpages = Max # of Pages to Crawl
 message = Message

Modified: public/yanel/trunk/src/resources/add-realm/resource.xml
===================================================================
--- public/yanel/trunk/src/resources/add-realm/resource.xml	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/resource.xml	2007-03-08 22:06:13 UTC (rev 23199)
@@ -8,4 +8,9 @@
 <description>
 Add Realm Resource
 </description>
+
+<rtd>
+  <property name="fslocation" default-value=""/>
+  <property name="crawlmaxpages" default-value="100"/>
+</rtd>
 </resource>

Modified: public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java	2007-03-08 22:06:13 UTC (rev 23199)
@@ -11,6 +11,7 @@
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
 import org.wyona.yanel.core.transformation.I18nTransformer;
 import org.wyona.yanel.core.util.HttpServletRequestHelper;
+import org.wyona.yanel.core.util.PathUtil;
 
 import org.apache.log4j.Category;
 
@@ -112,34 +113,50 @@
         View defaultView = new View();
 
         try {
-
-            // Check if data was sumbitted (realm ID, realm Name, URL to be dumped, depth of crawling, max number of pages)
+            
+        	 // Check if data was sumbitted (realm ID, realm Name, URL to be dumped, depth of crawling, max number of pages)
             boolean submit = false;
             Enumeration enumeration = request.getParameterNames();
             while(enumeration.hasMoreElements()){
                 if(enumeration.nextElement().toString().equals("submit")) 
                     submit = true;
             }
+            
+        	File XSLTFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "add-realm.xsl");
+        	File inputXMLFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "input-screen.xml");
+        	File statusXMLFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "status-screen.xml");
+            transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(XSLTFile));
+            
+            // Add HashMap keys with dummy values for form fields
+            String[] parameterNames = { "realmid", "realmname", "url", "fslocation", "crawldepth", "crawlmaxpages" };
+            for (int i=0; i<parameterNames.length; i++) {
+            	String property = getConfiguration().getProperty(parameterNames[i]);
+            	boolean propertyExists = getConfiguration().containsKey(parameterNames[i]);
+            	
+            	if (propertyExists == true) {
+            		if (property == null || ("").equals(property)) {
+            			parameters.put(parameterNames[i], "default");
+            		} else {
+            			parameters.put(parameterNames[i], property);
+            		}
+            	} else {
+            		parameters.put(parameterNames[i], "");
+        		}
+            }
+            
+            Set keys = parameters.keySet();
+            Iterator keysIterator = keys.iterator();
+            
             if(submit) {
-                File statusXSLTFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "add-realm.xsl");
-                File statusXMLFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "status-screen.xml");
-                transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(statusXSLTFile));
-                
-                //Add HashMap keys with dummy values for form fields
-                parameters.put("realmid", null);
-                parameters.put("realmname", null);
-                parameters.put("url", null);
-                parameters.put("fs-location", null);
-                parameters.put("crawldepth", null);
-                parameters.put("crawlmaxpages", null);
-                
-                Set keys = parameters.keySet();
-                Iterator keysIterator = keys.iterator();
+            	
                 while (keysIterator.hasNext()) {
                     parameterName = (String) keysIterator.next();
                     parameter = HttpServletRequestHelper.getParameter(request, parameterName);
                     
-                    if (parameter == null || ("").equals(parameter)) {
+                    if (("fslocation").equals(parameterName)) {
+                    	parameters.put(parameterName, parameter);
+                        transformer.setParameter(parameterName, parameters.get(parameterName).toString());
+                    } else if (parameter == null || ("").equals(parameter)) {
                         parameterErrorName = "error-" + parameterName;
                         parameterError = "Please enter correct value for '" + parameterName + "'";
                         transformer.setParameter(parameterName, "ERROR:" + parameterError);
@@ -150,22 +167,34 @@
                 }
                 
                 if (parameterError == null || ("").equals(parameterError)) {
+                	File fslocationValue = null;
+                	if (parameters.get("fslocation").toString() == null || ("").equals(parameters.get("fslocation").toString())) {
+                		fslocationValue = null;
+                	} else if (parameters.get("fslocation").toString().equals("default")) {
+                		fslocationValue = null;
+                	} else {
+                		fslocationValue = new File(parameters.get("fslocation").toString());
+                	}
                     getYanel().getRealmConfiguration().copyRealm("from-scratch-realm-template", 
                             parameters.get("realmid").toString(), 
                             parameters.get("realmname").toString(),
                             "/" + parameters.get("realmid").toString() + "/", 
-                            new File(parameters.get("fs-location").toString()));
+                            fslocationValue);
                     transformer.setParameter("submitted", "true");
+                    transformer.setParameter("yanel.back2context", PathUtil.backToContext(realm, getPath()));
                 }
                 
                 transformer.transform(new javax.xml.transform.stream.StreamSource(statusXMLFile), new StreamResult(byteArrayOutputStream));
                 
             } else {
-                File inputXSLTFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "add-realm.xsl");
-                File inputXMLFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "input-screen.xml");
-                transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(inputXSLTFile));
-
+            	
+                while (keysIterator.hasNext()) {
+                    parameterName = (String) keysIterator.next();
+                    transformer.setParameter(parameterName, parameters.get(parameterName).toString());
+                }
+                
                 transformer.transform(new javax.xml.transform.stream.StreamSource(inputXMLFile), new StreamResult(byteArrayOutputStream));
+                
             }
             
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();

Modified: public/yanel/trunk/src/resources/add-realm/xml/input-screen.xml
===================================================================
--- public/yanel/trunk/src/resources/add-realm/xml/input-screen.xml	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/xml/input-screen.xml	2007-03-08 22:06:13 UTC (rev 23199)
@@ -4,7 +4,7 @@
     <input required="true" samplevalue="my-realm">realmid</input>
     <input required="true" samplevalue="My Realm">realmname</input>
     <input required="true" samplevalue="http://www.foo.bar">url</input>
-    <input required="true" samplevalue="D:/realms">fs-location</input>
+    <input required="true" samplevalue="D:/realms">fslocation</input>
     <input required="true" samplevalue="3">crawldepth</input>
     <input required="true" samplevalue="100">crawlmaxpages</input>
   </inputfields>

Modified: public/yanel/trunk/src/resources/add-realm/xml/status-screen.xml
===================================================================
--- public/yanel/trunk/src/resources/add-realm/xml/status-screen.xml	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/xml/status-screen.xml	2007-03-08 22:06:13 UTC (rev 23199)
@@ -4,7 +4,7 @@
     <input required="true" samplevalue="my-realm">realmid</input>
     <input required="true" samplevalue="My Realm">realmname</input>
     <input required="true" samplevalue="http://www.foo.bar">url</input>
-    <input required="true" samplevalue="D:/realms">fs-location</input>
+    <input required="true" samplevalue="D:/realms">fslocation</input>
     <input required="true" samplevalue="3">crawldepth</input>
     <input required="true" samplevalue="100">crawlmaxpages</input>
   </inputfields>

Modified: public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl
===================================================================
--- public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl	2007-03-08 21:02:06 UTC (rev 23198)
+++ public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl	2007-03-08 22:06:13 UTC (rev 23199)
@@ -9,10 +9,12 @@
 
   <xsl:output method="xhtml" encoding="UTF-8"/>
   
+  <xsl:param name="yanel.back2context" select="''" />
+  
   <xsl:param name="realmid" select="''" />
   <xsl:param name="realmname" select="''" />
   <xsl:param name="url" select="''" />
-  <xsl:param name="fs-location" select="''" />
+  <xsl:param name="fslocation" select="''" />
   <xsl:param name="crawldepth" select="''" />
   <xsl:param name="crawlmaxpages" select="''" />
 
@@ -37,6 +39,13 @@
             <xsl:when test="$submitted != 'false'">
               <p>[X] pages have been imported.</p>
               <p>[X]% complete.</p>
+              <p>
+                <a>
+                  <xsl:attribute name="href">
+                    <xsl:value-of select="$yanel.back2context"/><xsl:value-of select="$realmid"/>/
+                  </xsl:attribute>View <xsl:value-of select="$realmname" />
+                </a>
+              </p>
             </xsl:when>
             <xsl:otherwise>
               
@@ -50,34 +59,66 @@
                         <td>
                           <xsl:choose>
                             <xsl:when test="contains($realmid, 'ERROR:') or contains($realmname, 'ERROR:') 
-                                            or contains($url, 'ERROR:') or contains($fs-location, 'ERROR:')
+                                            or contains($url, 'ERROR:') or contains($fslocation, 'ERROR:')
                                             or contains($crawldepth, 'ERROR:') or contains($crawlmaxpages, 'ERROR:')">
+                              <input type="text" name="{.}" class="box" size="30">
                               <xsl:choose>
                                 <xsl:when test="position()='1' and not(contains($realmid, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$realmid}" />
+                                  <xsl:attribute name="value"><xsl:value-of select="$realmid" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:when test="position()='2' and not(contains($realmname, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$realmname}" />
+                                  <xsl:attribute name="value"><xsl:value-of select="$realmname" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:when test="position()='3' and not(contains($url, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$url}" />
+                                  <xsl:attribute name="value"><xsl:value-of select="$url" /></xsl:attribute>
                                 </xsl:when>
-                                <xsl:when test="position()='4' and not(contains($fs-location, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$fs-location}" />
+                                <xsl:when test="position()='4' and not(contains($fslocation, 'ERROR:'))">
+                                  <xsl:attribute name="value"><xsl:value-of select="$fslocation" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:when test="position()='5' and not(contains($crawldepth, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$crawldepth}" />
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawldepth" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:when test="position()='6' and not(contains($crawlmaxpages, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$crawlmaxpages}" />
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawlmaxpages" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:otherwise>
-                                  <input type="text" name="{.}" class="box" size="30" value="" />
+                                  <xsl:attribute name="value"></xsl:attribute>
                                 </xsl:otherwise>
                               </xsl:choose>
+                              </input>
                             </xsl:when>
                             <xsl:otherwise>
-                              <input type="text" name="{.}" class="box" size="30" />
+                              <input type="text" name="{.}" class="box" size="30">
+                              <xsl:choose>
+                                <xsl:when test="position()='1'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$realmid" /></xsl:attribute>
+                                  <xsl:if test="$realmid != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:when test="position()='2'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$realmname" /></xsl:attribute>
+                                  <xsl:if test="$realmname != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:when test="position()='3'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$url" /></xsl:attribute>
+                                  <xsl:if test="$url != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:when test="position()='4'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$fslocation" /></xsl:attribute>
+                                  <xsl:if test="$fslocation != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:when test="position()='5'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawldepth" /></xsl:attribute>
+                                  <xsl:if test="$crawldepth != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:when test="position()='6'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawlmaxpages" /></xsl:attribute>
+                                  <xsl:if test="$crawlmaxpages != ''"><xsl:attribute name="readonly">readonly</xsl:attribute></xsl:if>
+                                </xsl:when>
+                                <xsl:otherwise>
+                                  <xsl:attribute name="value"></xsl:attribute>
+                                </xsl:otherwise>
+                              </xsl:choose>
+                              </input>
                             </xsl:otherwise>
                           </xsl:choose>
                         </td>
@@ -116,12 +157,12 @@
                               </font>
                             </td>
                           </xsl:when>
-                          <xsl:when test="position()='4' and contains($fs-location, 'ERROR:')">
+                          <xsl:when test="position()='4' and contains($fslocation, 'ERROR:')">
                             <td>
                               &#160;<font color="red">
                                 <i18n:message>
                                   <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($fs-location, 'ERROR:')"/>
+                                    <xsl:value-of select="substring-after($fslocation, 'ERROR:')"/>
                                   </xsl:attribute>
                                 </i18n:message>
                               </font>




More information about the Yanel-commits mailing list