[Osaas-commits] r51 - in trunk: . client/java/owsproxy

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Nov 28 21:37:27 CET 2008


Author: bh
Date: 2008-11-28 21:37:26 +0100 (Fri, 28 Nov 2008)
New Revision: 51

Modified:
   trunk/ChangeLog
   trunk/client/java/owsproxy/owsproxy.diff
Log:
* client/java/owsproxy/owsproxy.diff: Adapt to deegree trunk
rev. 15164.  Also, make OSAAS optional.  If no OSAAS_URL is
configured, deegree with osaas client patch only logs that it
doesn't use OSAAS but never tries to actually log anything to
OSAAS.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-11-24 07:57:50 UTC (rev 50)
+++ trunk/ChangeLog	2008-11-28 20:37:26 UTC (rev 51)
@@ -1,3 +1,11 @@
+2008-11-28  Bernhard Herzog  <bh at intevation.de>
+
+	* client/java/owsproxy/owsproxy.diff: Adapt to deegree trunk
+	rev. 15164.  Also, make OSAAS optional.  If no OSAAS_URL is
+	configured, deegree with osaas client patch only logs that it
+	doesn't use OSAAS but never tries to actually log anything to
+	OSAAS.
+
 2008-11-24  Stephan Holl  <stephan.holl at intevation.de>
 
 	* packaging/rpm/osaas-10.3-gp.spec, packaging/rpm/osaas-server-path-correction.patch: 

Modified: trunk/client/java/owsproxy/owsproxy.diff
===================================================================
--- trunk/client/java/owsproxy/owsproxy.diff	2008-11-24 07:57:50 UTC (rev 50)
+++ trunk/client/java/owsproxy/owsproxy.diff	2008-11-28 20:37:26 UTC (rev 51)
@@ -1,9 +1,6 @@
-This patch was produced against revision 8074 of the deegree SVN on 2007-08-29.
-
-
 Index: src/org/deegree/enterprise/servlet/SimpleProxyServlet.java
 ===================================================================
---- src/org/deegree/enterprise/servlet/SimpleProxyServlet.java	(revision 8074)
+--- src/org/deegree/enterprise/servlet/SimpleProxyServlet.java	(revision 15164)
 +++ src/org/deegree/enterprise/servlet/SimpleProxyServlet.java	(working copy)
 @@ -106,6 +106,9 @@
              String hostAddr = this.getInitParameter( pn );
@@ -11,96 +8,86 @@
          }
 +
 +        // Make the host mapping available to the OSAAS hook.
-+        getServletConfig().getServletContext().setAttribute("osaas.hostaddrs", host);
++        getServletConfig().getServletContext().setAttribute( "osaas.hostaddrs", host );
      }
  
      /**
-Index: src/org/deegree/security/owsproxy/OWSProxyServletFilter.java
+Index: src/org/deegree/security/owsproxy/ConfigurableOWSProxyServletFilter.java
 ===================================================================
---- src/org/deegree/security/owsproxy/OWSProxyServletFilter.java	(revision 8074)
-+++ src/org/deegree/security/owsproxy/OWSProxyServletFilter.java	(working copy)
-@@ -58,6 +58,7 @@
- import java.util.Enumeration;
- import java.util.Map;
- import java.util.Properties;
-+import java.util.HashMap;
- 
- import javax.servlet.Filter;
- import javax.servlet.FilterChain;
-@@ -97,6 +98,8 @@
- import org.deegree.security.owsrequestvalidator.PolicyDocument;
- import org.w3c.dom.Document;
- 
-+import de.intevation.osaas.OSAASClient;
-+
- /**
-  * An OWSProxyPolicyFilter can be registered as a ServletFilter to a web context. It offeres a
-  * facade that looks like a OWS but additionaly enables validating incoming requests and outgoing
-@@ -130,6 +133,8 @@
- 
-     private boolean imageExpected = false;
- 
-+    private OSAASClient osaasClient;
-+
-     /**
-      * initialize the filter with parameters from the deployment descriptor
-      * 
-@@ -175,6 +180,28 @@
-             }
- 
-         }
-+
-+        String urlstring = config.getInitParameter("OSAAS_URL");
-+        try {
-+            URL url = new URL(urlstring);
-+            String username = config.getInitParameter("OSAAS_USERNAME");
-+            String password = config.getInitParameter("OSAAS_PASSWORD");
-+            String errorlog = config.getInitParameter("OSAAS_FAILLOG");
-+            try {
-+                osaasClient = new OSAASClient(url, username, password,
-+                                              new File(errorlog));
-+            }
-+            catch (Exception e) {
-+                LOG.logError( "Couldn't instantiate the OSAASClient: "
-+                              + e.getMessage() );
-+            }
-+        }
-+        catch (MalformedURLException e) {
-+            LOG.logError( "Couldn't create an url from the configured OSAAS_URL parameter: " + urlstring
-+                          + " because: " + e.getMessage() );
-+
-+        }
-+
-         // } catch ( Exception e ) {
-         // LOG.logError( e.getMessage(), e );
-         // throw new ServletException( e );
-@@ -355,6 +382,9 @@
-             return;
-         }
- 
-+        logToOSAAS(owsReq, (HttpServletRequest) request,
-+                   (HttpServletResponse) response, user);
-+
-         response.setContentType( resWrap.getContentType() );
-         // write result back to the client
-         os = response.getOutputStream();
-@@ -362,6 +392,19 @@
-         os.close();
-     }
- 
-+    private void logToOSAAS(OGCWebServiceRequest owsReq,
-+                            HttpServletRequest request,
-+                            HttpServletResponse response,
-+                            User user) {
-+        HashMap<String, String> host =
-+            (HashMap<String, String>) config.getServletContext().getAttribute("osaas.hostaddrs");
-+        osaasClient.sendRequest(user.getName(),
-+                                request.getQueryString(),
-+                                config.getInitParameter("PROXYURL"),
-+                                host.get(owsReq.getServiceName()));
-+    }
-+
-+
-     /**
-      * logs a requests parameters and meta informations
-      * 
+--- src/org/deegree/security/owsproxy/ConfigurableOWSProxyServletFilter.java	(revision 15164)
++++ src/org/deegree/security/owsproxy/ConfigurableOWSProxyServletFilter.java	(working copy)
+@@ -74,6 +74,8 @@
+ import javax.servlet.http.HttpServletRequest;
+ import javax.servlet.http.HttpServletResponse;
+ 
++import de.intevation.osaas.OSAASClient;
++
+ import org.deegree.enterprise.servlet.ServletRequestWrapper;
+ import org.deegree.enterprise.servlet.ServletResponseWrapper;
+ import org.deegree.framework.log.ILogger;
+@@ -142,6 +144,8 @@
+ 
+     private String proxiedUrl;
+ 
++    private OSAASClient osaasClient =  null;
++
+     /**
+      * initialize the filter with parameters from the deployment descriptor
+      * 
+@@ -221,6 +225,28 @@
+             LOG.logDebug( "Error while initializing", e );
+             throw new ServletException( e );
+         }
++
++        String urlstring = config.getInitParameter( "OSAAS_URL" );
++        if ( urlstring == null ) {
++            LOG.logInfo( "No OSAAS_URL configured.  Not using OSAAS" );
++        } else {
++            try {
++                URL url = new URL( urlstring );
++                String username = config.getInitParameter( "OSAAS_USERNAME" );
++                String password = config.getInitParameter( "OSAAS_PASSWORD" );
++                String errorlog = config.getInitParameter( "OSAAS_FAILLOG" );
++                try {
++                    osaasClient = new OSAASClient( url, username, password,
++                                                   new File(errorlog) );
++                } catch ( Exception e ) {
++                    LOG.logError( "Couldn't instantiate the OSAASClient: "
++                                  + e.getMessage() );
++                }
++            } catch ( MalformedURLException e ) {
++                LOG.logError( "Couldn't create an url from the configured OSAAS_URL parameter: " + urlstring
++                              + " because: " + e.getMessage() );
++            }
++        }
+     }
+ 
+     /**
+@@ -448,9 +474,27 @@
+         os.write( b );
+         os.close();
+ 
++        logToOSAAS( owsReq, (HttpServletRequest) request,
++                    (HttpServletResponse) response, user );
++
+         TP.doPostTrigger( this, b );
+     }
+ 
++    private void logToOSAAS( OGCWebServiceRequest owsReq,
++                             HttpServletRequest request,
++                             HttpServletResponse response,
++                             User user ) {
++        if ( osaasClient != null ) {
++            HashMap<String, String> host =
++                (HashMap<String, String>) config.getServletContext().getAttribute( "osaas.hostaddrs" );
++            osaasClient.sendRequest( user.getName(),
++                                     request.getQueryString(),
++                                     config.getInitParameter( "PROXYURL" ),
++                                     host.get( owsReq.getServiceName() ) );
++        }
++    }
++
++
+     /**
+      * exports the changed request to a XML document/string that will substitute the original request contained in the
+      * passed {@link ServletRequestWrapper}



More information about the Osaas-commits mailing list