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

jon at wyona.com jon at wyona.com
Thu Feb 22 18:30:07 CET 2007


Author: jon
Date: 2007-02-22 18:30:05 +0100 (Thu, 22 Feb 2007)
New Revision: 22881

Added:
   public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti
   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/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java
   public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl
Removed:
   public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti
   public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties
   public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties
   public/yanel/trunk/src/resources/add-realm/resources/
   public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java
   public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl
Modified:
   public/yanel/trunk/conf/yanel.xml
   public/yanel/trunk/src/realms/welcome-admin/yanel/data/xslt/welcome.xsl
   public/yanel/trunk/src/resources/add-realm/build.xml
   public/yanel/trunk/src/resources/add-realm/resource.xml
   public/yanel/trunk/src/resources/add-realm/src/build/build.properties
Log:
updated all references to importsite to add-realm (step 2)

Modified: public/yanel/trunk/conf/yanel.xml
===================================================================
--- public/yanel/trunk/conf/yanel.xml	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/conf/yanel.xml	2007-02-22 17:30:05 UTC (rev 22881)
@@ -10,7 +10,7 @@
 <!--
   <resource src="../src/resources/tape/"                        compile="true"/>
 -->
-  <resource src="../src/resources/importsite/"                  compile="true"/>
+  <resource src="../src/resources/add-realm/"                  compile="true"/>
   <resource src="../src/resources/odt/"                         compile="true"/>
   <resource src="../src/resources/xml/"                         compile="true"/>
   <resource src="../src/realms/welcome-admin/yanel/resources/show-realms/"                 compile="true"/>

Modified: public/yanel/trunk/src/realms/welcome-admin/yanel/data/xslt/welcome.xsl
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/data/xslt/welcome.xsl	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/data/xslt/welcome.xsl	2007-02-22 17:30:05 UTC (rev 22881)
@@ -39,7 +39,7 @@
             <li>Create a realm from scratch.</li>
             <li>
               <a href="yanel-website/en/documentation/import-existing-website-as-new-realm.html">Import
-                an existing website as a new realm.</a> (Work in progress: <a href="import-site.html">Do it!</a>)
+                an existing website as a new realm.</a> (Work in progress: <a href="add-realm.html">Do it!</a>)
             </li>
             <li>
               <a

Copied: public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti (from rev 22878, public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti)
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti	2007-02-22 16:49:23 UTC (rev 22878)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/rti/add-realm.html.yanel-rti	2007-02-22 17:30:05 UTC (rev 22881)
@@ -0,0 +1 @@
+<{http://www.wyona.org/yanel/resource/1.0}add-realm/>

Deleted: public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti
===================================================================
--- public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/realms/welcome-admin/yanel/rti/import-site.html.yanel-rti	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1 +0,0 @@
-<{http://www.wyona.org/yanel/resource/1.0}importsite/>

Modified: public/yanel/trunk/src/resources/add-realm/build.xml
===================================================================
--- public/yanel/trunk/src/resources/add-realm/build.xml	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/build.xml	2007-02-22 17:30:05 UTC (rev 22881)
@@ -47,7 +47,7 @@
     </copy>
     
     <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes">
-      <fileset dir="config" includes="importsite_*.properties"/>
+      <fileset dir="config" includes="add-realm_*.properties"/>
     </copy>
   </target>
 </project>

Copied: public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties (from rev 22879, public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties)
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties	2007-02-22 17:18:36 UTC (rev 22879)
+++ public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties	2007-02-22 17:30:05 UTC (rev 22881)
@@ -0,0 +1,10 @@
+add-realm = Add Realm
+realmid = Realm Id
+realmname = Realm Name
+url = URL
+fs-location = Filesystem Pfad
+crawldepth = Crawl Tiefe
+crawlmaxpages = Max # der Seiten to Crawl
+message = Message
+thankYou = Vielen Dank!
+requiredFields = Felder markiert mit (*) sind zwingend

Copied: public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties (from rev 22879, public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties)
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties	2007-02-22 17:18:36 UTC (rev 22879)
+++ public/yanel/trunk/src/resources/add-realm/config/add-realm_en.properties	2007-02-22 17:30:05 UTC (rev 22881)
@@ -0,0 +1,10 @@
+add-realm = Add Realm
+realmid = Realm Id
+realmname = Realm Name
+url = URL
+fs-location = Filesystem Path where Realm will be located
+crawldepth = Crawl Depth
+crawlmaxpages = Max # of Pages to Crawl
+message = Message
+thankYou = Thank you!
+requiredFields = fields marked with (*) are required

Deleted: public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/config/importsite_de.properties	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,10 +0,0 @@
-importsite = Importiere Site
-realmid = Realm Id
-realmname = Realm Name
-url = URL
-fs-location = Filesystem Pfad
-crawldepth = Crawl Tiefe
-crawlmaxpages = Max # der Seiten to Crawl
-message = Message
-thankYou = Vielen Dank!
-requiredFields = Felder markiert mit (*) sind zwingend

Deleted: public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties
===================================================================
--- public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/config/importsite_en.properties	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,10 +0,0 @@
-importsite = Import Site
-realmid = Realm Id
-realmname = Realm Name
-url = URL
-fs-location = Filesystem Path where Realm will be located
-crawldepth = Crawl Depth
-crawlmaxpages = Max # of Pages to Crawl
-message = Message
-thankYou = Thank you!
-requiredFields = fields marked with (*) are required

Modified: public/yanel/trunk/src/resources/add-realm/resource.xml
===================================================================
--- public/yanel/trunk/src/resources/add-realm/resource.xml	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/resource.xml	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,11 +1,11 @@
 <?xml version="1.0"?>
 
 <resource xmlns="http://www.wyona.org/yanel/1.0"
-  name="importsite"
+  name="add-realm"
   namespace="http://www.wyona.org/yanel/resource/1.0"
-  class="org.wyona.yanel.impl.resources.ImportSiteResource"
+  class="org.wyona.yanel.impl.resources.AddRealmResource"
   >
 <description>
-Import Site Resource
+Add Realm Resource
 </description>
 </resource>

Modified: public/yanel/trunk/src/resources/add-realm/src/build/build.properties
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/build/build.properties	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/src/build/build.properties	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,2 +1,2 @@
-resource.name=importsite
+resource.name=add-realm
 resource.version=0.0.1-dev-rXXX

Copied: public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java (from rev 22879, public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java)
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java	2007-02-22 17:18:36 UTC (rev 22879)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java	2007-02-22 17:30:05 UTC (rev 22881)
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2006 Wyona
+ */
+
+package org.wyona.yanel.impl.resources;
+
+import org.wyona.yanel.core.Path;
+import org.wyona.yanel.core.Resource;
+import org.wyona.yanel.core.api.attributes.ViewableV2;
+import org.wyona.yanel.core.attributes.viewable.View;
+import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+import org.wyona.yanel.core.transformation.I18nTransformer;
+import org.wyona.yanel.core.util.HttpServletRequestHelper;
+
+import org.apache.log4j.Category;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+
+/**
+ *
+ */
+public class AddRealmResource extends Resource implements ViewableV2 {
+
+    private static final String CRAWLER_JAR = "yanel-crawler.jar";
+    private static Category log = Category.getInstance(AddRealmResource.class);
+    private String defaultLanguage = "en";
+    private String language = null;
+    private String parameterName = null;
+    private String parameter = null;
+    private String parameterErrorName = null;
+    private String parameterError = null;
+    
+    private File CrawlerJarLocation;
+    private File tmpResultDir;
+    private String errorMessage;
+    
+    private HashMap parameters = new HashMap();
+
+    /**
+     *
+     */
+    public AddRealmResource() {
+    }
+
+    /**
+     *
+     */
+    public ViewDescriptor[] getViewDescriptors() {
+        return null;
+    }
+
+    /**
+     * 
+     */
+    public View getView(String viewId) throws Exception {
+        
+        String path = getPath();
+        HttpServletRequest request = getRequest();
+        
+        // the crawler jar
+        String WEBINFPath = request.getSession().getServletContext().getRealPath("WEB-INF");
+        CrawlerJarLocation = new File(WEBINFPath + File.separator + "lib" + File.separator
+                + CRAWLER_JAR);
+        
+        if (!CrawlerJarLocation.exists()) {
+            errorMessage = errorMessage + "\n Crawler not found.";
+        }
+        
+        // create tmp status file
+        if (!new File(request.getSession().getServletContext().getRealPath("tmp")).exists()) {
+            if (!new File(request.getSession().getServletContext().getRealPath("tmp")).mkdir()) {
+                errorMessage = errorMessage + "\n Creation of tmp directory faild.";
+            }
+        }
+        
+        // Get language
+        try {
+            language = request.getParameter("yanel.meta.language");
+        } catch(Exception e) {
+            log.debug("language param is not found will use default : " + language);
+            language = defaultLanguage;
+        }
+        if(language == null || ("").equals(language)) {
+            log.debug("language param is empty or null : " + language);
+            language = defaultLanguage;
+        }
+
+        Transformer transformer = null;
+        I18nTransformer i18nTransformer = new I18nTransformer("add-realm", language);
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        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)
+            boolean submit = false;
+            Enumeration enumeration = request.getParameterNames();
+            while(enumeration.hasMoreElements()){
+                if(enumeration.nextElement().toString().equals("submit")) 
+                    submit = true;
+            }
+            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)) {
+                        parameterErrorName = "error-" + parameterName;
+                        parameterError = "Please enter correct value for '" + parameterName + "'";
+                        transformer.setParameter(parameterName, "ERROR:" + parameterError);
+                    } else {
+                        parameters.put(parameterName, parameter);
+                        transformer.setParameter(parameterName, parameters.get(parameterName).toString());
+                    }
+                }
+                
+                if (parameterError == null || ("").equals(parameterError)) {
+                    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()));
+                    transformer.setParameter("submitted", "true");
+                }
+                
+                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));
+
+                transformer.transform(new javax.xml.transform.stream.StreamSource(inputXMLFile), new StreamResult(byteArrayOutputStream));
+            }
+            
+            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
+            
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw e;
+        }
+        
+        defaultView.setMimeType(getMimeType(viewId));
+        defaultView.setInputStream(i18nTransformer.getInputStream());
+        return defaultView;
+    }
+    
+    /* TODO: add showProgress
+    private View showProgress(Path path, View defaultView) throws Exception {
+        
+        //get tmpResultDir from session
+        tmpResultDir = (File) request.getSession().getAttribute("tmpResultDir");
+        
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+        Transformer transformer = null;
+        transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(inputXSLTFile));
+        // TODO: Is this the best way to generate an InputStream from an
+        // OutputStream?
+        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
+        transformer.transform(new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())),
+                new StreamResult(baos));
+        defaultView.setMimeType(getMimeType(viewId));
+        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
+        return defaultView;
+    }*/
+   
+    /**
+     * 
+     */
+    public boolean exists() throws Exception {
+       log.warn("Not implemented yet!");
+       return true; 
+    }
+
+    /**
+     * 
+     */
+    public long getSize() throws Exception {
+        return getRealm().getRepository().getSize(new Path(getPath()));
+    }
+
+    /**
+     *
+     */
+    public String getMimeType(String viewId) {
+        return "application/xhtml+xml";
+    }
+}

Deleted: public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,225 +0,0 @@
-/*
- * Copyright 2006 Wyona
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.wyona.yanel.core.Path;
-import org.wyona.yanel.core.Resource;
-import org.wyona.yanel.core.api.attributes.ViewableV2;
-import org.wyona.yanel.core.attributes.viewable.View;
-import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-import org.wyona.yanel.core.transformation.I18nTransformer;
-import org.wyona.yanel.core.util.HttpServletRequestHelper;
-
-import org.apache.log4j.Category;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-
-/**
- *
- */
-public class ImportSiteResource extends Resource implements ViewableV2 {
-
-    private static final String CRAWLER_JAR = "yanel-crawler.jar";
-    private static Category log = Category.getInstance(ImportSiteResource.class);
-    private String defaultLanguage = "en";
-    private String language = null;
-    private String parameterName = null;
-    private String parameter = null;
-    private String parameterErrorName = null;
-    private String parameterError = null;
-    
-    private File CrawlerJarLocation;
-    private File tmpResultDir;
-    private String errorMessage;
-    
-    private HashMap parameters = new HashMap();
-
-    /**
-     *
-     */
-    public ImportSiteResource() {
-    }
-
-    /**
-     *
-     */
-    public ViewDescriptor[] getViewDescriptors() {
-        return null;
-    }
-
-    /**
-     * 
-     */
-    public View getView(String viewId) throws Exception {
-        
-        String path = getPath();
-        HttpServletRequest request = getRequest();
-        
-        // the crawler jar
-        String WEBINFPath = request.getSession().getServletContext().getRealPath("WEB-INF");
-        CrawlerJarLocation = new File(WEBINFPath + File.separator + "lib" + File.separator
-                + CRAWLER_JAR);
-        
-        if (!CrawlerJarLocation.exists()) {
-            errorMessage = errorMessage + "\n Crawler not found.";
-        }
-        
-        // create tmp status file
-        if (!new File(request.getSession().getServletContext().getRealPath("tmp")).exists()) {
-            if (!new File(request.getSession().getServletContext().getRealPath("tmp")).mkdir()) {
-                errorMessage = errorMessage + "\n Creation of tmp directory faild.";
-            }
-        }
-        
-        // Get language
-        try {
-            language = request.getParameter("yanel.meta.language");
-        } catch(Exception e) {
-            log.debug("language param is not found will use default : " + language);
-            language = defaultLanguage;
-        }
-        if(language == null || ("").equals(language)) {
-            log.debug("language param is empty or null : " + language);
-            language = defaultLanguage;
-        }
-
-        Transformer transformer = null;
-        I18nTransformer i18nTransformer = new I18nTransformer("importsite", language);
-        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-        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)
-            boolean submit = false;
-            Enumeration enumeration = request.getParameterNames();
-            while(enumeration.hasMoreElements()){
-                if(enumeration.nextElement().toString().equals("submit")) 
-                    submit = true;
-            }
-            if(submit) {
-                File statusXSLTFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "importsite.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)) {
-                        parameterErrorName = "error-" + parameterName;
-                        parameterError = "Please enter correct value for '" + parameterName + "'";
-                        transformer.setParameter(parameterName, "ERROR:" + parameterError);
-                    } else {
-                        parameters.put(parameterName, parameter);
-                        transformer.setParameter(parameterName, parameters.get(parameterName).toString());
-                    }
-                }
-                
-                if (parameterError == null || ("").equals(parameterError)) {
-                    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()));
-                    transformer.setParameter("submitted", "true");
-                }
-                
-                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 + "importsite.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));
-
-                transformer.transform(new javax.xml.transform.stream.StreamSource(inputXMLFile), new StreamResult(byteArrayOutputStream));
-            }
-            
-            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
-            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
-            
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-            throw e;
-        }
-        
-        defaultView.setMimeType(getMimeType(viewId));
-        defaultView.setInputStream(i18nTransformer.getInputStream());
-        return defaultView;
-    }
-    
-    /* TODO: add showProgress
-    private View showProgress(Path path, View defaultView) throws Exception {
-        
-        //get tmpResultDir from session
-        tmpResultDir = (File) request.getSession().getAttribute("tmpResultDir");
-        
-        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-
-        Transformer transformer = null;
-        transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(inputXSLTFile));
-        // TODO: Is this the best way to generate an InputStream from an
-        // OutputStream?
-        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
-        transformer.transform(new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())),
-                new StreamResult(baos));
-        defaultView.setMimeType(getMimeType(viewId));
-        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
-        return defaultView;
-    }*/
-   
-    /**
-     * 
-     */
-    public boolean exists() throws Exception {
-       log.warn("Not implemented yet!");
-       return true; 
-    }
-
-    /**
-     * 
-     */
-    public long getSize() throws Exception {
-        return getRealm().getRepository().getSize(new Path(getPath()));
-    }
-
-    /**
-     *
-     */
-    public String getMimeType(String viewId) {
-        return "application/xhtml+xml";
-    }
-}

Copied: public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl (from rev 22879, public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl)
===================================================================
--- public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl	2007-02-22 17:18:36 UTC (rev 22879)
+++ public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl	2007-02-22 17:30:05 UTC (rev 22881)
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns="http://www.w3.org/1999/xhtml"
+>
+
+  <xsl:output method="xhtml" encoding="UTF-8"/>
+  
+  <xsl:param name="realmid" select="''" />
+  <xsl:param name="realmname" select="''" />
+  <xsl:param name="url" select="''" />
+  <xsl:param name="fs-location" select="''" />
+  <xsl:param name="crawldepth" select="''" />
+  <xsl:param name="crawlmaxpages" select="''" />
+
+  <xsl:param name="submitted" select="'false'" />
+
+  <xsl:template match="/">
+    <html xmlns="http://www.w3.org/1999/xhtml">
+      <head>
+        <title><i18n:message key="add-realm"/></title>
+        <style>
+            .samplevalue {
+              padding-bottom:10px;
+            }
+        </style>
+      </head>
+      
+      <body>
+        <h3><i18n:message key="add-realm"/></h3>
+        
+        <div id="contentBody">
+          <xsl:choose>
+            <xsl:when test="$submitted != 'false'">
+              <p>[X] pages have been imported.</p>
+              <p>[X]% complete.</p>
+            </xsl:when>
+            <xsl:otherwise>
+              
+              <form method="post">
+                  <table cellpadding="0" cellspacing="0" border="0">
+                    <xsl:for-each select="form/inputfields/input">
+                      <tr>
+                        <td align="right" valign="top" class="contentfield" width="150">
+                          <i18n:message key="{.}"/>:&#0160;
+                        </td>
+                        <td>
+                          <xsl:choose>
+                            <xsl:when test="contains($realmid, 'ERROR:') or contains($realmname, 'ERROR:') 
+                                            or contains($url, 'ERROR:') or contains($fs-location, 'ERROR:')
+                                            or contains($crawldepth, 'ERROR:') or contains($crawlmaxpages, 'ERROR:')">
+                              <xsl:choose>
+                                <xsl:when test="position()='1' and not(contains($realmid, 'ERROR:'))">
+                                  <input type="text" name="{.}" class="box" size="30" value="{$realmid}" />
+                                </xsl:when>
+                                <xsl:when test="position()='2' and not(contains($realmname, 'ERROR:'))">
+                                  <input type="text" name="{.}" class="box" size="30" value="{$realmname}" />
+                                </xsl:when>
+                                <xsl:when test="position()='3' and not(contains($url, 'ERROR:'))">
+                                  <input type="text" name="{.}" class="box" size="30" value="{$url}" />
+                                </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>
+                                <xsl:when test="position()='5' and not(contains($crawldepth, 'ERROR:'))">
+                                  <input type="text" name="{.}" class="box" size="30" value="{$crawldepth}" />
+                                </xsl:when>
+                                <xsl:when test="position()='6' and not(contains($crawlmaxpages, 'ERROR:'))">
+                                  <input type="text" name="{.}" class="box" size="30" value="{$crawlmaxpages}" />
+                                </xsl:when>
+                                <xsl:otherwise>
+                                  <input type="text" name="{.}" class="box" size="30" value="" />
+                                </xsl:otherwise>
+                              </xsl:choose>
+                            </xsl:when>
+                            <xsl:otherwise>
+                              <input type="text" name="{.}" class="box" size="30" />
+                            </xsl:otherwise>
+                          </xsl:choose>
+                        </td>
+                        <td><xsl:if test="@required = 'true'">*</xsl:if></td>
+                        <xsl:choose>
+                          <xsl:when test="position()='1' and contains($realmid, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($realmid, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='2' and contains($realmname, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($realmname, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='3' and contains($url, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($url, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='4' and contains($fs-location, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($fs-location, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='5' and contains($crawldepth, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($crawldepth, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='6' and contains($crawlmaxpages, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($crawlmaxpages, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:otherwise>
+                            <td>
+                              &#160;
+                            </td>
+                          </xsl:otherwise>
+                        </xsl:choose>
+                        <!--<xsl:if test="$error != ''">
+                          <td>
+                            &#160;<font color="red"><i18n:message key="{$error}"/></font>
+                          </td>
+                        </xsl:if>-->
+                      </tr>
+                      <tr>
+                        <td>&#160;</td>
+                        <td class="samplevalue">
+                          (i.e. <xsl:value-of select="@samplevalue"/>)
+                        </td>
+                        <td>&#160;</td>
+                      </tr>
+                    </xsl:for-each>
+                    
+                    <tr>
+                      <td>&#160;
+                      </td>
+                      <td align="right">
+                        <input type="submit" name="submit" value="i18n:attr key=add-realm"/>
+                      </td>
+                    </tr>
+            
+                    <tr>
+                      <td align="right" valign="top" class="contentfield" colspan="2"><br/><i18n:message key="requiredFields"/></td>
+                    </tr>
+                  </table>
+              </form>
+        
+            </xsl:otherwise>
+          </xsl:choose>
+        </div>
+      </body>
+    </html>
+  </xsl:template>
+    
+</xsl:stylesheet>

Deleted: public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl
===================================================================
--- public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl	2007-02-22 17:23:44 UTC (rev 22880)
+++ public/yanel/trunk/src/resources/add-realm/xslt/importsite.xsl	2007-02-22 17:30:05 UTC (rev 22881)
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<xsl:stylesheet version="1.0"
-  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-  xmlns:xhtml="http://www.w3.org/1999/xhtml"
-  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
-  xmlns="http://www.w3.org/1999/xhtml"
->
-
-  <xsl:output method="xhtml" encoding="UTF-8"/>
-  
-  <xsl:param name="realmid" select="''" />
-  <xsl:param name="realmname" select="''" />
-  <xsl:param name="url" select="''" />
-  <xsl:param name="fs-location" select="''" />
-  <xsl:param name="crawldepth" select="''" />
-  <xsl:param name="crawlmaxpages" select="''" />
-
-  <xsl:param name="submitted" select="'false'" />
-
-  <xsl:template match="/">
-    <html xmlns="http://www.w3.org/1999/xhtml">
-      <head>
-        <title><i18n:message key="importsite"/></title>
-        <style>
-            .samplevalue {
-              padding-bottom:10px;
-            }
-        </style>
-      </head>
-      
-      <body>
-        <h3><i18n:message key="importsite"/></h3>
-        
-        <div id="contentBody">
-          <xsl:choose>
-            <xsl:when test="$submitted != 'false'">
-              <p>[X] pages have been imported.</p>
-              <p>[X]% complete.</p>
-            </xsl:when>
-            <xsl:otherwise>
-              
-              <form method="post">
-                  <table cellpadding="0" cellspacing="0" border="0">
-                    <xsl:for-each select="form/inputfields/input">
-                      <tr>
-                        <td align="right" valign="top" class="contentfield" width="150">
-                          <i18n:message key="{.}"/>:&#0160;
-                        </td>
-                        <td>
-                          <xsl:choose>
-                            <xsl:when test="contains($realmid, 'ERROR:') or contains($realmname, 'ERROR:') 
-                                            or contains($url, 'ERROR:') or contains($fs-location, 'ERROR:')
-                                            or contains($crawldepth, 'ERROR:') or contains($crawlmaxpages, 'ERROR:')">
-                              <xsl:choose>
-                                <xsl:when test="position()='1' and not(contains($realmid, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$realmid}" />
-                                </xsl:when>
-                                <xsl:when test="position()='2' and not(contains($realmname, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$realmname}" />
-                                </xsl:when>
-                                <xsl:when test="position()='3' and not(contains($url, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$url}" />
-                                </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>
-                                <xsl:when test="position()='5' and not(contains($crawldepth, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$crawldepth}" />
-                                </xsl:when>
-                                <xsl:when test="position()='6' and not(contains($crawlmaxpages, 'ERROR:'))">
-                                  <input type="text" name="{.}" class="box" size="30" value="{$crawlmaxpages}" />
-                                </xsl:when>
-                                <xsl:otherwise>
-                                  <input type="text" name="{.}" class="box" size="30" value="" />
-                                </xsl:otherwise>
-                              </xsl:choose>
-                            </xsl:when>
-                            <xsl:otherwise>
-                              <input type="text" name="{.}" class="box" size="30" />
-                            </xsl:otherwise>
-                          </xsl:choose>
-                        </td>
-                        <td><xsl:if test="@required = 'true'">*</xsl:if></td>
-                        <xsl:choose>
-                          <xsl:when test="position()='1' and contains($realmid, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($realmid, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:when test="position()='2' and contains($realmname, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($realmname, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:when test="position()='3' and contains($url, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($url, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:when test="position()='4' and contains($fs-location, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($fs-location, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:when test="position()='5' and contains($crawldepth, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($crawldepth, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:when test="position()='6' and contains($crawlmaxpages, 'ERROR:')">
-                            <td>
-                              &#160;<font color="red">
-                                <i18n:message>
-                                  <xsl:attribute name="key">
-                                    <xsl:value-of select="substring-after($crawlmaxpages, 'ERROR:')"/>
-                                  </xsl:attribute>
-                                </i18n:message>
-                              </font>
-                            </td>
-                          </xsl:when>
-                          <xsl:otherwise>
-                            <td>
-                              &#160;
-                            </td>
-                          </xsl:otherwise>
-                        </xsl:choose>
-                        <!--<xsl:if test="$error != ''">
-                          <td>
-                            &#160;<font color="red"><i18n:message key="{$error}"/></font>
-                          </td>
-                        </xsl:if>-->
-                      </tr>
-                      <tr>
-                        <td>&#160;</td>
-                        <td class="samplevalue">
-                          (i.e. <xsl:value-of select="@samplevalue"/>)
-                        </td>
-                        <td>&#160;</td>
-                      </tr>
-                    </xsl:for-each>
-                    
-                    <tr>
-                      <td>&#160;
-                      </td>
-                      <td align="right">
-                        <input type="submit" name="submit" value="i18n:attr key=importsite"/>
-                      </td>
-                    </tr>
-            
-                    <tr>
-                      <td align="right" valign="top" class="contentfield" colspan="2"><br/><i18n:message key="requiredFields"/></td>
-                    </tr>
-                  </table>
-              </form>
-        
-            </xsl:otherwise>
-          </xsl:choose>
-        </div>
-      </body>
-    </html>
-  </xsl:template>
-    
-</xsl:stylesheet>




More information about the Yanel-commits mailing list