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

michi at wyona.com michi at wyona.com
Tue Mar 27 11:17:04 CEST 2007


Author: michi
Date: 2007-03-27 11:17:03 +0200 (Tue, 27 Mar 2007)
New Revision: 23419

Modified:
   public/yanel/trunk/src/resources/add-realm/config/add-realm_de.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
Log:
max page size made configurable

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-27 09:16:53 UTC (rev 23418)
+++ public/yanel/trunk/src/resources/add-realm/config/add-realm_de.properties	2007-03-27 09:17:03 UTC (rev 23419)
@@ -4,7 +4,8 @@
 url = URL
 fslocation = Filesystem Pfad
 crawldepth = Crawl Tiefe
-crawlmaxpages = Max # der Seiten to Crawl
+crawlmaxpages = Maximale Anzahl der Seiten to Crawl
+crawlmaxfilesize = Maximale Filegroesse von Seiten
 message = Message
 thankYou = Vielen Dank!
 requiredFields = Felder markiert mit (*) sind zwingend

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-27 09:16:53 UTC (rev 23418)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource.java	2007-03-27 09:17:03 UTC (rev 23419)
@@ -70,7 +70,7 @@
     private final static String SESSION_ATTR_REALM_ID = "org.wyona.yanel.addrealm.realm.id";
     private final static String SESSION_ATTR_REALM_NAME = "org.wyona.yanel.addrealm.realm.name";
     
-    private String defaultLanguage;
+    private String defaultLanguage = null;
     private String language = null;
     private String parameterName = null;
     private String parameter = null;
@@ -82,8 +82,7 @@
     /**
      *
      */
-    public AddRealmResource() {
-        defaultLanguage = getRealm().getDefaultLanguage();
+    public AddRealmResource() {  
     }
 
     /**
@@ -100,6 +99,7 @@
         
         String path = getPath();
         HttpServletRequest request = getRequest();
+        defaultLanguage = getRealm().getDefaultLanguage();
         
         // Get language
         try {
@@ -136,7 +136,7 @@
             transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(XSLTFile));
             
             // Add HashMap keys with dummy values for form fields
-            String[] parameterNames = { "realmid", "realmname", "url", "fslocation", "crawldepth", "crawlmaxpages", "scope" };
+            String[] parameterNames = { "realmid", "realmname", "url", "fslocation", "crawldepth", "crawlmaxpages", "crawlmaxfilesize", "scope" };
             for (int i=0; i<parameterNames.length; i++) {
                 String property = getConfiguration().getProperty(parameterNames[i]);
                 boolean propertyExists = getConfiguration().containsKey(parameterNames[i]);
@@ -195,10 +195,17 @@
                     if (crawlStartURL != null && crawlStartURL.length() > 0) {
                         int maxPages = Integer.parseInt((String)parameters.get("crawlmaxpages"));
                         int maxDepth = Integer.parseInt((String)parameters.get("crawldepth"));
+                        int maxFileSize = 0;
+                        String tmpMaxFileSize = (String)parameters.get("crawlmaxfilesize");
+                        if (tmpMaxFileSize != null || !("").equals(tmpMaxFileSize)) {
+                        	maxFileSize = Integer.parseInt(tmpMaxFileSize);
+                        } else {
+                        	maxFileSize = -1;
+                        }
                         String crawlScopeURL = (String)parameters.get("scope");
                         String realmID = parameters.get("realmid").toString();
                         
-                        importSite(crawlStartURL, crawlScopeURL, maxPages, maxDepth, realmID);
+                        importSite(crawlStartURL, crawlScopeURL, maxPages, maxDepth, maxFileSize, realmID);
                         
                         EventLog eventLog = (EventLog)session.getAttribute(SESSION_ATTR_EVENT_LOG);
                         if (eventLog != null) {
@@ -287,7 +294,7 @@
      * @param realmID
      * @throws Exception
      */
-    protected void importSite(String crawlStartURL, String crawlScopeURL, int maxPages, int maxDepth, String realmID) throws Exception {
+    protected void importSite(String crawlStartURL, String crawlScopeURL, int maxPages, int maxDepth, int maxPageSize, String realmID) throws Exception {
         String[] crawlScopeURLs = null;
         if (crawlScopeURL == null || crawlScopeURL.length() == 0) {
             String path = new URL(crawlStartURL).getPath();
@@ -307,7 +314,7 @@
         crawler.setMaxDepth(maxDepth);
         
         DownloadParameters downloadParams = new DownloadParameters();
-        downloadParams = downloadParams.changeMaxPageSize(-1);
+        downloadParams = downloadParams.changeMaxPageSize(maxPageSize);
         crawler.setDownloadParameters(downloadParams);
         
         
@@ -404,11 +411,17 @@
         crawlMaxPagesFieldElement.setAttributeNS(NAMESPACE, "required", "true");
         crawlMaxPagesFieldElement.setAttributeNS(NAMESPACE, "samplevalue", "100");
         crawlMaxPagesFieldElement.appendChild(document.createTextNode("crawlmaxpages"));
+        
+        Element crawlMaxFileSizeFieldElement = (Element) inputFieldsElement.appendChild(document.createElementNS(NAMESPACE, "input"));
+        crawlMaxFileSizeFieldElement.setAttributeNS(NAMESPACE, "name", "crawlmaxfilesize");
+        crawlMaxFileSizeFieldElement.setAttributeNS(NAMESPACE, "required", "true");
+        crawlMaxFileSizeFieldElement.setAttributeNS(NAMESPACE, "samplevalue", "100 [size in kb]");
+        crawlMaxFileSizeFieldElement.appendChild(document.createTextNode("crawlmaxfilesize"));
 
         Element scopeFieldElement = (Element) inputFieldsElement.appendChild(document.createElementNS(NAMESPACE, "input"));
         scopeFieldElement.setAttributeNS(NAMESPACE, "name", "scope");
         scopeFieldElement.setAttributeNS(NAMESPACE, "required", "false");
-        scopeFieldElement.setAttributeNS(NAMESPACE, "samplevalue", "http://www.foo.bar");
+        scopeFieldElement.setAttributeNS(NAMESPACE, "samplevalue", "http://www.foo.bar, http://www.f-o-o.bar");
         scopeFieldElement.appendChild(document.createTextNode("scope"));
 
         return document;

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-27 09:16:53 UTC (rev 23418)
+++ public/yanel/trunk/src/resources/add-realm/xslt/add-realm.xsl	2007-03-27 09:17:03 UTC (rev 23419)
@@ -19,6 +19,7 @@
   <xsl:param name="fslocation" select="''" />
   <xsl:param name="crawldepth" select="''" />
   <xsl:param name="crawlmaxpages" select="''" />
+  <xsl:param name="crawlmaxfilesize" select="''" />
 
   <xsl:param name="realmid-prop-exists" select="''" />
   <xsl:param name="realmname-prop-exists" select="''" />
@@ -27,6 +28,7 @@
   <xsl:param name="fslocation-prop-exists" select="''" />
   <xsl:param name="crawldepth-prop-exists" select="''" />
   <xsl:param name="crawlmaxpages-prop-exists" select="''" />
+  <xsl:param name="crawlmaxfilesize-prop-exists" select="''" />
   
   <xsl:param name="downloadevents" select="''" />
   <xsl:param name="errorevents" select="''" />
@@ -114,9 +116,12 @@
                           <xsl:when test="position()='6' and $crawlmaxpages-prop-exists = 'true'">
                             <xsl:call-template name="style-display-none"/>
                           </xsl:when>
-                          <xsl:when test="position()='7' and $scope-prop-exists = 'true'">
+                          <xsl:when test="position()='7' and $crawlmaxfilesize-prop-exists = 'true'">
                             <xsl:call-template name="style-display-none"/>
                           </xsl:when>
+                          <xsl:when test="position()='8' and $scope-prop-exists = 'true'">
+                            <xsl:call-template name="style-display-none"/>
+                          </xsl:when>
                           <xsl:otherwise/>
                         </xsl:choose>
                         
@@ -128,7 +133,8 @@
                           <xsl:choose>
                             <xsl:when test="contains($realmid, 'ERROR:') or contains($realmname, 'ERROR:') 
                                             or contains($url, 'ERROR:') or contains($fslocation, 'ERROR:')
-                                            or contains($crawldepth, 'ERROR:') or contains($crawlmaxpages, 'ERROR:')">
+                                            or contains($crawldepth, 'ERROR:') or contains($crawlmaxpages, 'ERROR:')
+                                            or contains($crawlmaxfilesize, 'ERROR:') or contains($scope, 'ERROR:')">
                               <input type="text" name="{.}" class="box" size="30">
                               <xsl:choose>
                                 <xsl:when test="position()='1' and not(contains($realmid, 'ERROR:'))">
@@ -149,7 +155,10 @@
                                 <xsl:when test="position()='6' and not(contains($crawlmaxpages, 'ERROR:'))">
                                   <xsl:attribute name="value"><xsl:value-of select="$crawlmaxpages" /></xsl:attribute>
                                 </xsl:when>
-                                <xsl:when test="position()='7' and not(contains($scope, 'ERROR:'))">
+                                <xsl:when test="position()='7' and not(contains($crawlmaxfilesize, 'ERROR:'))">
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawlmaxpages" /></xsl:attribute>
+                                </xsl:when>
+                                <xsl:when test="position()='8' and not(contains($scope, 'ERROR:'))">
                                   <xsl:attribute name="value"><xsl:value-of select="$scope" /></xsl:attribute>
                                 </xsl:when>
                                 <xsl:otherwise>
@@ -229,6 +238,17 @@
                                   </xsl:choose>
                                 </xsl:when>
                                 <xsl:when test="position()='7'">
+                                  <xsl:attribute name="value"><xsl:value-of select="$crawlmaxfilesize" /></xsl:attribute>
+                                  <xsl:choose>
+                                    <xsl:when test="$crawlmaxfilesize-prop-exists != 'false'">
+                                      <xsl:attribute name="type">hidden</xsl:attribute>
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                      <xsl:attribute name="type">text</xsl:attribute>
+                                    </xsl:otherwise>
+                                  </xsl:choose>
+                                </xsl:when>
+                                <xsl:when test="position()='8'">
                                   <xsl:attribute name="value"><xsl:value-of select="$scope" /></xsl:attribute>
                                   <xsl:choose>
                                     <xsl:when test="$scope-prop-exists != 'false'">
@@ -315,11 +335,22 @@
                               </font>
                             </td>
                           </xsl:when>
-                          <xsl:when test="position()='7' and contains($scope, 'ERROR:')">
+                          <xsl:when test="position()='7' and contains($crawlmaxfilesize, 'ERROR:')">
                             <td>
                               &#160;<font color="red">
                                 <i18n:message>
                                   <xsl:attribute name="key">
+                                    <xsl:value-of select="substring-after($crawlmaxfilesize, 'ERROR:')"/>
+                                  </xsl:attribute>
+                                </i18n:message>
+                              </font>
+                            </td>
+                          </xsl:when>
+                          <xsl:when test="position()='8' and contains($scope, 'ERROR:')">
+                            <td>
+                              &#160;<font color="red">
+                                <i18n:message>
+                                  <xsl:attribute name="key">
                                     <xsl:value-of select="substring-after($scope, 'ERROR:')"/>
                                   </xsl:attribute>
                                 </i18n:message>




More information about the Yanel-commits mailing list