portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r884169 - in /portals/applications/webcontent/trunk: webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java webcontent-war/src/main/webapp/WEB-INF/portlet.xml
Date Wed, 25 Nov 2009 16:09:44 GMT
Author: woonsan
Date: Wed Nov 25 16:09:44 2009
New Revision: 884169

URL: http://svn.apache.org/viewvc?rev=884169&view=rev
Log:
APA-24: Adding proxy host and port preferences

Modified:
    portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
    portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/portlet.xml

Modified: portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java?rev=884169&r1=884168&r2=884169&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
(original)
+++ portals/applications/webcontent/trunk/webcontent-jar/src/main/java/org/apache/portals/applications/webcontent/portlet/WebContentPortlet.java
Wed Nov 25 16:09:44 2009
@@ -53,6 +53,7 @@
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpMethodBase;
 import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.ProxyHost;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.MultipartPostMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
@@ -111,6 +112,9 @@
 
     public static final String NO_URL = "<p>URL source not specified. Go to edit mode
and specify an URL.</p>";
     
+    private String defaultProxyHost;
+    private int defaultProxyPort = -1;
+    
     public WebContentPortlet()
     {
         super();
@@ -122,6 +126,26 @@
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
+        
+        String param = config.getInitParameter("PROXYHOST");
+        
+        if (param != null && !"".equals(param.trim()))
+        {
+            defaultProxyHost = param.trim();
+        }
+        
+        param = config.getInitParameter("PROXYPORT");
+        
+        if (param != null && !"".equals(param.trim()))
+        {
+            try
+            {
+                defaultProxyPort = Integer.parseInt(param.trim());
+            }
+            catch (Exception ignore)
+            {
+            }
+        }
     }
 
     /**
@@ -505,6 +529,20 @@
         // derived class hook (e.g. to set up Basic Authentication)
         HttpClient client = new HttpClient();
         
+        String proxyHost = request.getPreferences().getValue("PROXYHOST", defaultProxyHost);
+        int proxyPort = -1;
+        
+        try
+        {
+            proxyPort = Integer.parseInt(request.getPreferences().getValue("PROXYPORT", Integer.toString(defaultProxyPort)));
+        }
+        catch (Exception ignore)
+        {
+        }
+        
+        ProxyHost proxyHostObject = (proxyPort == -1 ? new ProxyHost(proxyHost) : new ProxyHost(proxyHost,
proxyPort));
+        client.getHostConfiguration().setProxyHost(proxyHostObject);
+        
         // reuse existing state, if we have been here before
         Cookie[] cookies = (Cookie[])PortletMessaging.receive(request, HTTP_STATE);
         if (cookies != null)

Modified: portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/portlet.xml?rev=884169&r1=884168&r2=884169&view=diff
==============================================================================
--- portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/portlet.xml
(original)
+++ portals/applications/webcontent/trunk/webcontent-war/src/main/webapp/WEB-INF/portlet.xml
Wed Nov 25 16:09:44 2009
@@ -223,6 +223,14 @@
         <name>SRC</name>
         <value>http://www.google.com</value>
       </preference>
+      <preference>
+        <name>PROXYHOST</name>
+        <value></value>
+      </preference>
+      <preference>
+        <name>PROXYPORT</name>
+        <value></value>
+      </preference>
     </portlet-preferences>        
   </portlet>
   



Mime
View raw message