[Yanel-commits] rev 21457 - in public/yanel/trunk/src/resources/importsite: config src/java/org/wyona/yanel/impl/resources xslt

michi at wyona.com michi at wyona.com
Fri Jan 5 11:25:51 CET 2007


Author: michi
Date: 2007-01-05 11:25:50 +0100 (Fri, 05 Jan 2007)
New Revision: 21457

Modified:
   public/yanel/trunk/src/resources/importsite/config/importsite_de.properties
   public/yanel/trunk/src/resources/importsite/config/importsite_en.properties
   public/yanel/trunk/src/resources/importsite/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java
   public/yanel/trunk/src/resources/importsite/xslt/importsite.xsl
Log:
input screen updated

Modified: public/yanel/trunk/src/resources/importsite/config/importsite_de.properties
===================================================================
--- public/yanel/trunk/src/resources/importsite/config/importsite_de.properties	2007-01-05 09:58:17 UTC (rev 21456)
+++ public/yanel/trunk/src/resources/importsite/config/importsite_de.properties	2007-01-05 10:25:50 UTC (rev 21457)
@@ -2,8 +2,8 @@
 realmid = Realm Id
 realmname = Realm Name
 url = URL
-crawldepth = Crawl Tiefe
-maxpages = Maximale Anzahl der Seiten to Crawl
+crawldepth = Crawl Tiefe (z.b. '3')
+maxpages = Max # der Seiten to Crawl (z.b. '100')
 message = Message
 thankYou = Vielen Dank!
-inquiryContent = This has been sent to us.
+requiredFields = fields marked with (*) are required
\ No newline at end of file

Modified: public/yanel/trunk/src/resources/importsite/config/importsite_en.properties
===================================================================
--- public/yanel/trunk/src/resources/importsite/config/importsite_en.properties	2007-01-05 09:58:17 UTC (rev 21456)
+++ public/yanel/trunk/src/resources/importsite/config/importsite_en.properties	2007-01-05 10:25:50 UTC (rev 21457)
@@ -2,8 +2,8 @@
 realmid = Realm Id
 realmname = Realm Name
 url = URL
-crawldepth = Crawl Depth
-maxpages = Maximum Number of Pages to Crawl
+crawldepth = Crawl Depth (i.e. '3')
+maxpages = Max # of Pages to Crawl (i.e. '100')
 message = Message
 thankYou = Thank you!
-inquiryContent = This has been sent to us.
+requiredFields = fields marked with (*) are required

Modified: public/yanel/trunk/src/resources/importsite/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java
===================================================================
--- public/yanel/trunk/src/resources/importsite/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java	2007-01-05 09:58:17 UTC (rev 21456)
+++ public/yanel/trunk/src/resources/importsite/src/java/org/wyona/yanel/impl/resources/ImportSiteResource.java	2007-01-05 10:25:50 UTC (rev 21457)
@@ -4,18 +4,21 @@
 
 package org.wyona.yanel.impl.resources;
 
+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.UnsupportedEncodingException;
-//import java.io.StringReader;
 import java.util.Enumeration;
-//import java.util.HashMap;
-//import java.util.Map;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.xml.parsers.SAXParser;
@@ -28,25 +31,6 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
-import org.apache.log4j.Category;
-import org.wyona.yanel.core.Path;
-import org.wyona.yanel.core.Resource;
-import org.wyona.yanel.core.ResourceTypeDefinition;
-import org.wyona.yanel.core.ResourceTypeRegistry;
-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.map.Realm;
-import org.wyona.yanel.core.util.ResourceAttributeHelper;
-import org.wyona.yarep.core.NoSuchNodeException;
-import org.wyona.yarep.core.Repository;
-import org.wyona.yarep.core.RepositoryException;
-import org.wyona.yarep.core.RepositoryFactory;
-import org.wyona.yanel.core.transformation.I18nTransformer;
-import org.wyona.yanel.core.Yanel;
-import org.wyona.yarep.util.RepoPath;
-import org.wyona.yarep.util.YarepUtil;
-import org.wyona.yanel.core.util.HttpServletRequestHelper;
 
 /**
  *
@@ -54,9 +38,6 @@
 public class ImportSiteResource extends Resource implements ViewableV2 {
 
     private static Category log = Category.getInstance(ImportSiteResource.class);
-    private Repository repository  = null;
-    private RepoPath rp = null;
-    private Path path = null;
     private String defaultLanguage = "en";
     private String language = null;
 
@@ -72,24 +53,11 @@
     public ViewDescriptor[] getViewDescriptors() {
         return null;
     }
-    
-    /**
-     * 
-     */
-    public View getView(Path path, String viewId) {
-        return null;
-    }
 
     /**
      * 
      */
     public View getView(String viewId) throws Exception {
-
-        /*
-        path = new Path(request.getServletPath());
-        rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
-        repository = rp.getRepo();
-        */
         
         // Get language
         try {
@@ -104,8 +72,7 @@
         }
 
         Transformer transformer = null;
-        //I18nTransformer i18nTransformer = null;
-        I18nTransformer i18nTransformer = new I18nTransformer("global", language);
+        I18nTransformer i18nTransformer = new I18nTransformer("importsite", language);
         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         View defaultView = new View();
 
@@ -139,25 +106,6 @@
             }
 
             defaultView.setMimeType("application/xhtml+xml");
-
-/*
-            //translate the form
-            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
-            saxParser = SAXParserFactory.newInstance().newSAXParser();
-            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
-            transformer = TransformerFactory.newInstance().newTransformer(getXSLTStreamSource(path, repository));
-            transformer.setParameter("yanel.path.name", path.getName());
-            transformer.setParameter("yanel.path", path.toString());
-            transformer.setParameter("yanel.back2context", backToRoot(path, ""));
-            transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
- 
-            byteArrayOutputStream = new ByteArrayOutputStream();
-            transformer.transform(new StreamSource(i18nTransformer.getInputStream()), new StreamResult(byteArrayOutputStream));
-            //tranlate the page
-            i18nTransformer = new I18nTransformer("global", language);
-            saxParser = SAXParserFactory.newInstance().newSAXParser();
-            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
-*/
             
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
             saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
@@ -166,139 +114,8 @@
             log.error(e.getMessage(), e);
         }
 
-        //defaultView.setInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
         defaultView.setInputStream(i18nTransformer.getInputStream());
         return defaultView;
-    }
-
-    /**
-     * 
-     * @param path
-     * @return
-     * @throws Exception
-     */
-    private RepoPath contentRepo(Path path) throws Exception {
-        return new YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(
-                path.toString()), getRepositoryFactory());
-    }
-
-    /**
-     * 
-     * @param path
-     * @param viewId
-     * @return
-     */
-    private String getMimeType(Path path, String viewId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-    
-    /**
-     * 
-     * @param path
-     * @return
-     */
-    private String getMimeType(String viewId) {
-        String mimeType = null;
-        try {
-            java.io.BufferedReader br = new java.io.BufferedReader(rp
-                    .getRepo().getReader(
-                            new org.wyona.yarep.core.Path(new Path(rp
-                                    .getPath().toString()).getRTIPath()
-                                    .toString())));
-
-            while ((mimeType = br.readLine()) != null) {
-                if (mimeType.indexOf("mime-type:") == 0) {
-                    mimeType = mimeType.substring(11);
-                    log.info("*" + mimeType + "*");
-                    return mimeType;
-                }
-            }
-        } catch (Exception e) {
-            log.warn(e);
-        }
-        // NOTE: Assuming fallback re importsite.xsl ...
-        return "application/xhtml+xml";
-    }
-    
-    /**
-     * 
-     * @param path
-     * @param repo
-     * @return
-     * @throws NoSuchNodeException
-     */
-    private StreamSource getXSLTStreamSource(Path path, Repository repo)
-            throws NoSuchNodeException, RepositoryException {
-        Path xsltPath = getXSLTPath(path);
-        if (xsltPath != null) {
-            return new StreamSource(repo
-                    .getInputStream(new org.wyona.yarep.core.Path(getXSLTPath(
-                            path).toString())));
-        } else {
-            File xsltFile = org.wyona.commons.io.FileUtil.file(rtd
-                    .getConfigFile().getParentFile().getAbsolutePath(), "xslt"
-                    + File.separator + "importsite.xsl");
-            log.error("DEBUG: XSLT file: " + xsltFile);
-            return new StreamSource(xsltFile);
-        }
-    }
-    
-    /**
-     * 
-     * @param path
-     * @return
-     */
-    private Path getXSLTPath(Path path) {
-        String xsltPath = null;
-        try {
-            java.io.BufferedReader br = new java.io.BufferedReader(rp
-                    .getRepo().getReader(
-                            new org.wyona.yarep.core.Path(new Path(rp
-                                    .getPath().toString()).getRTIPath()
-                                    .toString())));
-
-            while ((xsltPath = br.readLine()) != null) {
-                if (xsltPath.indexOf("xslt:") == 0) {
-                    xsltPath = xsltPath.substring(6);
-                    log.debug("XSLT Path: " + xsltPath);
-                    return new Path(xsltPath);
-                }
-            }
-            log.error("No XSLT Path within: " + rp.getPath());
-        } catch (Exception e) {
-            log.warn(e);
-        }
-        return null;
-    }
-    
-    /**
-     * this method reads out the specified key from rti file 
-     * if key cannot be found return null
-     * @param key
-     * @return value
-     */
-    private String getProperty(String key) {
-        try {
-            java.io.BufferedReader bufferedReader = new java.io.BufferedReader(rp.getRepo().getReader(new org.wyona.yarep.core.Path(new Path(rp.getPath().toString()).getRTIPath().toString())));
-            String line = null;
-            while((line = bufferedReader.readLine()) != null) {
-                if(line.indexOf(key) == 0) {
-                    return line.substring(key.length() + 1);
-                }
-            }
-        } catch (Exception e) {
-            log.error(e);
-        }
-        return null;
-    }
-   
-   /**
-    * 
-    * @return
-    */
-   protected RepositoryFactory getRepositoryFactory() {
-       return yanel.getRepositoryFactory("DefaultRepositoryFactory");
    }
    
    public boolean exists() throws Exception {
@@ -313,5 +130,4 @@
         return getRealm().getRepository().getSize(getPath());
     }
 
-    
 }

Modified: public/yanel/trunk/src/resources/importsite/xslt/importsite.xsl
===================================================================
--- public/yanel/trunk/src/resources/importsite/xslt/importsite.xsl	2007-01-05 09:58:17 UTC (rev 21456)
+++ public/yanel/trunk/src/resources/importsite/xslt/importsite.xsl	2007-01-05 10:25:50 UTC (rev 21457)
@@ -12,8 +12,8 @@
   <xsl:param name="realmid" select="''"/>
   <xsl:param name="realmname" select="''"/>
   <xsl:param name="url" select="''"/>
-  <xsl:param name="crawldepth" select="'100'"/>
-  <xsl:param name="maxpages" select="''"/>
+  <xsl:param name="crawldepth" select="'3'"/>
+  <xsl:param name="maxpages" select="'100'"/>
   <xsl:param name="message" select="''"/>
   <xsl:param name="error" select="''"/>
   
@@ -27,8 +27,6 @@
       
       <body>
         <h3><i18n:message key="importsite"/></h3>
-
-<p>Crawl Depth: <xsl:value-of select="$crawldepth"/></p>
         
         <div id="contentBody">
         
@@ -55,9 +53,9 @@
         <xsl:for-each select="inputfields/input">
           <xsl:variable name="inputName"><xsl:value-of select="."/></xsl:variable>
           <tr>
-            <td align="right" valign="top" class="contentfield"><i18n:message><xsl:attribute name="key"><xsl:value-of select="$inputName"/></xsl:attribute></i18n:message>:&#0160;</td>
+            <td align="right" valign="top" class="contentfield" width="150"><i18n:message><xsl:attribute name="key"><xsl:value-of select="$inputName"/></xsl:attribute></i18n:message>:&#0160;</td>
             <td>
-              <input type="text" name="{$inputName}" class="box" size="40"/>
+              <input type="text" name="{$inputName}" class="box" size="30"/>
             </td>
             <td><xsl:if test="@required = 'true'">*</xsl:if></td>
           </tr>
@@ -75,14 +73,14 @@
         </xsl:for-each>
         
         <tr>
-          <td colspan="2">&#160;
+          <td>&#160;
           </td>
-          <td>
-            <input type="submit" name="submit" value="i18n:attr key=send"/>
+          <td align="right">
+            <input type="submit" name="submit" value="i18n:attr key=import site"/>
           </td>
         </tr>
         <tr>
-          <td align="right" valign="top" class="contentfield" colspan="3"><br/><i18n:message key="requiredFields"/> (*)</td>
+          <td align="right" valign="top" class="contentfield" colspan="2"><br/><i18n:message key="requiredFields"/></td>
         </tr>
       </table>
     </form>




More information about the Yanel-commits mailing list