Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 05797200C60 for ; Mon, 24 Apr 2017 21:27:30 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0409B160B99; Mon, 24 Apr 2017 19:27:30 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4B05160B93 for ; Mon, 24 Apr 2017 21:27:28 +0200 (CEST) Received: (qmail 42881 invoked by uid 500); 24 Apr 2017 19:27:27 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 42872 invoked by uid 99); 24 Apr 2017 19:27:27 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Apr 2017 19:27:27 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 3B3323A0119 for ; Mon, 24 Apr 2017 19:27:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1792535 - in /manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main: java/org/apache/manifoldcf/crawler/connectors/webcrawler/ resource/org/apache/manifoldcf/crawler/connectors/webcrawler/ Date: Mon, 24 Apr 2017 19:27:26 -0000 To: commits@manifoldcf.apache.org From: kishore@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170424192727.3B3323A0119@svn01-us-west.apache.org> archived-at: Mon, 24 Apr 2017 19:27:30 -0000 Author: kishore Date: Mon Apr 24 19:27:26 2017 New Revision: 1792535 URL: http://svn.apache.org/viewvc?rev=1792535&view=rev Log: Updated Bandwidth tab with Velocity template Added: manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm (with props) Modified: manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/WebcrawlerConnector.java Modified: manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/WebcrawlerConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/WebcrawlerConnector.java?rev=1792535&r1=1792534&r2=1792535&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/WebcrawlerConnector.java (original) +++ manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/webcrawler/WebcrawlerConnector.java Mon Apr 24 19:27:26 2017 @@ -1566,6 +1566,84 @@ public class WebcrawlerConnector extends final Map velocityContext = new HashMap(); Messages.outputResourceWithVelocity(out, locale, "editConfiguration.js.vm", velocityContext); } + + private void fillInEmailTab(Map velocityContext, IHTTPOutput out, ConfigParams parameters) + { + String email = parameters.getParameter(WebcrawlerConfig.PARAMETER_EMAIL); + if (email == null) + email = ""; + + velocityContext.put("EMAIL",email); + } + + private void fillInRobotsTab(Map velocityContext, IHTTPOutput out, ConfigParams parameters) + { + String robotsUsage = parameters.getParameter(WebcrawlerConfig.PARAMETER_ROBOTSUSAGE); + if (robotsUsage == null) + robotsUsage = "all"; + String metaRobotsTagsUsage = parameters.getParameter(WebcrawlerConfig.PARAMETER_META_ROBOTS_TAGS_USAGE); + if (metaRobotsTagsUsage == null) + metaRobotsTagsUsage = "all"; + + velocityContext.put("ROBOTSUSAGE",robotsUsage); + velocityContext.put("METAROBOTSTAGSUSAGE",metaRobotsTagsUsage); + } + + private void fillInBandwidthTab(Map velocityContext, IHTTPOutput out, ConfigParams parameters) + { + int i = 0; + int binCounter = 0; + List> throttlesMapList = new ArrayList<>(); + while (i < parameters.getChildCount()) + { + ConfigNode cn = parameters.getChild(i++); + if (cn.getType().equals(WebcrawlerConfig.NODE_BINDESC)) + { + Map throttleMap = new HashMap<>(); + // A bin description node! Look for all its parameters. + String regexp = cn.getAttributeValue(WebcrawlerConfig.ATTR_BINREGEXP); + String isCaseInsensitive = cn.getAttributeValue(WebcrawlerConfig.ATTR_INSENSITIVE); + String maxConnections = null; + String maxKBPerSecond = null; + String maxFetchesPerMinute = null; + int j = 0; + while (j < cn.getChildCount()) + { + ConfigNode childNode = cn.getChild(j++); + if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXCONNECTIONS)) + maxConnections = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); + else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXKBPERSECOND)) + maxKBPerSecond = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); + else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXFETCHESPERMINUTE)) + maxFetchesPerMinute = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); + } + if (maxConnections == null) + maxConnections = ""; + if (maxKBPerSecond == null) + maxKBPerSecond = ""; + if (maxFetchesPerMinute == null) + maxFetchesPerMinute = ""; + if(regexp == null) + regexp = ""; + + if (isCaseInsensitive == null || isCaseInsensitive.length() == 0) + isCaseInsensitive = "false"; + + throttleMap.put("regexp",regexp); + throttleMap.put("isCaseInsensitive",isCaseInsensitive); + throttleMap.put("maxConnections",maxConnections); + throttleMap.put("maxKBPerSecond",maxKBPerSecond); + throttleMap.put("maxFetchesPerMinute",maxFetchesPerMinute); + throttlesMapList.add(throttleMap); + binCounter++; + } + } + if (parameters.getChildCount() == 0) + { + velocityContext.put("BRANDNEW",true); + } + velocityContext.put("THROTTLESMAPLIST",throttlesMapList); + } /** Output the configuration body section. * This method is called in the body section of the connector's configuration page. Its purpose is to present the required form elements for editing. @@ -1587,11 +1665,14 @@ public class WebcrawlerConnector extends fillInEmailTab(velocityContext,out,parameters); fillInRobotsTab(velocityContext,out,parameters); + fillInBandwidthTab(velocityContext,out,parameters); // Email tab Messages.outputResourceWithVelocity(out,locale,"editConfiguration_Email.html.vm",velocityContext); // Robots tab Messages.outputResourceWithVelocity(out,locale,"editConfiguration_Robots.html.vm",velocityContext); + //Bandwidth tab + Messages.outputResourceWithVelocity(out,locale,"editConfiguration_Bandwidth.html.vm",velocityContext); String proxyHost = parameters.getParameter(WebcrawlerConfig.PARAMETER_PROXYHOST); if (proxyHost == null) @@ -1651,234 +1732,6 @@ public class WebcrawlerConnector extends ); } - // Bandwidth tab - if (tabName.equals(Messages.getString(locale,"WebcrawlerConnector.Bandwidth"))) - { - out.print( -"\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -"

" + Messages.getBodyString(locale,"WebcrawlerConnector.Throttles") + "\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n" - ); - int i = 0; - int binCounter = 0; - while (i < parameters.getChildCount()) - { - ConfigNode cn = parameters.getChild(i++); - if (cn.getType().equals(WebcrawlerConfig.NODE_BINDESC)) - { - // A bin description node! Look for all its parameters. - String regexp = cn.getAttributeValue(WebcrawlerConfig.ATTR_BINREGEXP); - String isCaseInsensitive = cn.getAttributeValue(WebcrawlerConfig.ATTR_INSENSITIVE); - String maxConnections = null; - String maxKBPerSecond = null; - String maxFetchesPerMinute = null; - int j = 0; - while (j < cn.getChildCount()) - { - ConfigNode childNode = cn.getChild(j++); - if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXCONNECTIONS)) - maxConnections = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXKBPERSECOND)) - maxKBPerSecond = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXFETCHESPERMINUTE)) - maxFetchesPerMinute = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - } - if (maxConnections == null) - maxConnections = ""; - if (maxKBPerSecond == null) - maxKBPerSecond = ""; - if (maxFetchesPerMinute == null) - maxFetchesPerMinute = ""; - - if (isCaseInsensitive == null || isCaseInsensitive.length() == 0) - isCaseInsensitive = "false"; - - // It's prefix will be... - String prefix = "bandwidth_" + Integer.toString(binCounter); - out.print( -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n" - ); - binCounter++; - } - } - - // If it looks like this is a brand-new configuration, add in a default throttle. - // This only works because other nodes must get created on the first post, and cannot then be deleted. - if (parameters.getChildCount() == 0) - { - // It's prefix will be... - String prefix = "bandwidth_" + Integer.toString(binCounter); - out.print( -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n" - ); - binCounter++; - } - - if (binCounter == 0) - { - out.print( -" \n" - ); - } - out.print( -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -"
" + Messages.getBodyString(locale,"WebcrawlerConnector.BinRegularExpression") + "" + Messages.getBodyString(locale,"WebcrawlerConnector.CaseInsensitive") + "" + Messages.getBodyString(locale,"WebcrawlerConnector.MaxConnections") + "" + Messages.getBodyString(locale,"WebcrawlerConnector.MaxKbytesSec") + "" + Messages.getBodyString(locale,"WebcrawlerConnector.MaxFetchesMin") + "
\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" "+Encoder.bodyEscape(regexp)+"\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -"
\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -"
"+Messages.getBodyString(locale,"WebcrawlerConnector.NoBandwidthOrConnectionThrottlingSpecified")+"

\n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -" \n"+ -"
\n"+ -"
\n" - ); - } - else - { - // Hiddens for bandwidth tab. - int i = 0; - int binCounter = 0; - while (i < parameters.getChildCount()) - { - ConfigNode cn = parameters.getChild(i++); - if (cn.getType().equals(WebcrawlerConfig.NODE_BINDESC)) - { - // A bin description node! Look for all its parameters. - String regexp = cn.getAttributeValue(WebcrawlerConfig.ATTR_BINREGEXP); - String isCaseInsensitive = cn.getAttributeValue(WebcrawlerConfig.ATTR_INSENSITIVE); - String maxConnections = null; - String maxKBPerSecond = null; - String maxFetchesPerMinute = null; - int j = 0; - while (j < cn.getChildCount()) - { - ConfigNode childNode = cn.getChild(j++); - if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXCONNECTIONS)) - maxConnections = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXKBPERSECOND)) - maxKBPerSecond = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - else if (childNode.getType().equals(WebcrawlerConfig.NODE_MAXFETCHESPERMINUTE)) - maxFetchesPerMinute = childNode.getAttributeValue(WebcrawlerConfig.ATTR_VALUE); - } - if (maxConnections == null) - maxConnections = ""; - if (maxKBPerSecond == null) - maxKBPerSecond = ""; - if (maxFetchesPerMinute == null) - maxFetchesPerMinute = ""; - if (isCaseInsensitive == null || isCaseInsensitive.length() == 0) - isCaseInsensitive = "false"; - - // It's prefix will be... - String prefix = "bandwidth_" + Integer.toString(binCounter); - out.print( -"\n"+ -"\n"+ -"\n"+ -"\n"+ -"\n" - ); - binCounter++; - } - } - - // If it looks like this is a brand-new configuration, add in a default throttle. - // This only works because other nodes must get created on the first post, and cannot then be deleted. - if (parameters.getChildCount() == 0) - { - // It's prefix will be... - String prefix = "bandwidth_" + Integer.toString(binCounter); - out.print( -"\n"+ -"\n"+ -"\n"+ -"\n"+ -"\n" - ); - binCounter++; - } - - out.print( -"\n" - ); - } - // Access Credentials tab if (tabName.equals(Messages.getString(locale,"WebcrawlerConnector.AccessCredentials"))) { Added: manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm?rev=1792535&view=auto ============================================================================== --- manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm (added) +++ manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm Mon Apr 24 19:27:26 2017 @@ -0,0 +1,149 @@ + +#set( $BINCOUNTER = 0) +#if($TABNAME == $ResourceBundle.getString('WebcrawlerConnector.Bandwidth')) + + + + + + +

$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.Throttles')) + + + + + + + + + + #foreach($throttleMap in $THROTTLESMAPLIST) + #set( $THROTTLEPREFIX = "bandwidth_" + $BINCOUNTER ) + + + + + + + + + #set( $BINCOUNTER = $BINCOUNTER + 1) + #end + + ## If it looks like this is a brand-new configuration, add in a default throttle. + ## This only works because other nodes must get created on the first post, and cannot then be deleted. + #if($BRANDNEW) + #set( $THROTTLEPREFIX = "bandwidth_" + $BINCOUNTER ) + + + + + + + + + #set( $BINCOUNTER = $BINCOUNTER + 1) + #end + + #if($BINCOUNTER == "0") + + + + #end + + + + + + + + + + +
$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.BinRegularExpression'))$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.CaseInsensitive'))$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.MaxConnections'))$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.MaxKbytesSec'))$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.MaxFetchesMin'))
+ + + + + + + $Encoder.bodyEscape($throttleMap.get("regexp")) + + + + + + + + +
+ + + + + + + + + + + + + + + +
$Encoder.bodyEscape($ResourceBundle.getString('WebcrawlerConnector.NoBandwidthOrConnectionThrottlingSpecified'))

+ + + + + + + + + + + + + + + +
+
+#else + #foreach($throttleMap in $THROTTLESMAPLIST) + #set( $THROTTLEPREFIX = "bandwidth_" + $BINCOUNTER ) + + + + + + #set( $BINCOUNTER = $BINCOUNTER + 1) + #end + #if($BRANDNEW) + #set( $THROTTLEPREFIX = "bandwidth_" + $BINCOUNTER ) + + + + + + #set( $BINCOUNTER = $BINCOUNTER + 1) + #end + +#end + Propchange: manifoldcf/branches/CONNECTORS-1403/connectors/webcrawler/connector/src/main/resource/org/apache/manifoldcf/crawler/connectors/webcrawler/editConfiguration_Bandwidth.html.vm ------------------------------------------------------------------------------ svn:eol-style = native