cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r233153 - in /cocoon/blocks/portal/trunk: java/org/apache/cocoon/portal/ java/org/apache/cocoon/portal/impl/ samples/skins/common/images/
Date Wed, 17 Aug 2005 10:22:21 GMT
Author: cziegeler
Date: Wed Aug 17 03:22:08 2005
New Revision: 233153

URL: http://svn.apache.org/viewcvs?rev=233153&view=rev
Log:
Implement secure url handling
Fix javadocs
Add new icons

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
    cocoon/blocks/portal/trunk/samples/skins/common/images/delete.gif
    cocoon/blocks/portal/trunk/samples/skins/common/images/edit.gif
    cocoon/blocks/portal/trunk/samples/skins/common/images/help.gif
    cocoon/blocks/portal/trunk/samples/skins/common/images/view.gif

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/LinkService.java Wed Aug 17 03:22:08
2005
@@ -108,6 +108,13 @@
     String getRefreshLinkURI();
 
     /**
+     * Get a link that simply refreshs the portal
+     * @param secure true if a secure protocol is required, false otherwise.
+     * @return A URI
+     */
+    String getRefreshLinkURI(Boolean secure);
+
+    /**
      * Determine whether the current url is using a secure protocol
      * @return true if the current url is using a secure protocol
      */
@@ -116,7 +123,7 @@
     /**
      * @param url The url to encode.
      * @return The enocoded URL.
-     * @see javax.servlet.http.ServletResponse#encodeURL(String).
+     * @see javax.servlet.http.HttpServletResponse#encodeURL(java.lang.String) 
      */
     String encodeURL(String url);
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
Wed Aug 17 03:22:08 2005
@@ -61,8 +61,18 @@
         ArrayList     comparableEvents = new ArrayList(5);
 
         public String getBase(Boolean secure) {
-            //Todo actually implement secure
-            return linkBase.toString();
+            // TODO - Does null always mean FALSE?
+            // it might be that the current request is also https,
+            // in that case we return https even if secure is FALSE.
+            if ( secure == null || secure.equals(Boolean.FALSE) ) {
+                return linkBase.toString();
+            }
+            // FIXME - Perhaps there is a better way
+            String link = linkBase.toString();
+            if ( link.startsWith("https") ) {
+                return link;
+            }
+            return "https" + linkBase.toString().substring(4);
         }
     }
     
@@ -73,7 +83,7 @@
     /** The cocoon context */
     protected Context context;
 
-    protected Boolean eventsMarshalled = null;
+    protected Boolean eventsMarshalled;
 
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
@@ -96,12 +106,22 @@
                 if ( info == null ) {
                     info = new Info();
                     request.setAttribute(DefaultLinkService.class.getName(), info);
-                    String baseURI = request.getSitemapURI();
-                    final int pos = baseURI.lastIndexOf('/');
-                    if ( pos != -1 ) {
-                        baseURI = baseURI.substring(pos+1);
+                    info.linkBase.append(request.getScheme());
+                    info.linkBase.append("://");
+                    info.linkBase.append(request.getServerName());
+                    if ( request.getServerPort() != 80 ) {
+                        info.linkBase.append(':');
+                        info.linkBase.append(request.getServerPort());
+                    }
+                    if ( request.getContextPath().length() > 0 ) {
+                        info.linkBase.append(request.getContextPath());
+                    } else {
+                        info.linkBase.append('/');                        
                     }
-                    info.linkBase.append(baseURI);
+                    if ( request.getSitemapURIPrefix().length() > 0 ) {
+                        info.linkBase.append(request.getSitemapURIPrefix());
+                    }
+                    info.linkBase.append(request.getSitemapURI());
                 }
             }
         }
@@ -134,7 +154,7 @@
     */
     public String getLinkURI(Event event, Boolean secure) {
         if (event == null) {
-            return this.getRefreshLinkURI();
+            return this.getRefreshLinkURI(secure);
         }
         final Info info = this.getInfo();
         final StringBuffer buffer = new StringBuffer(info.getBase(secure));
@@ -199,7 +219,7 @@
     */
     public String getLinkURI(List events, Boolean secure) {
         if (events == null || events.size() == 0) {
-            return this.getRefreshLinkURI();
+            return this.getRefreshLinkURI(secure);
         }
         final Info info = this.getInfo();
         boolean hasParams = info.hasParameters;
@@ -330,13 +350,20 @@
         this.addParameterToLink(name, value);
     }
     
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.LinkService#getRefreshLinkURI()
      */
     public String getRefreshLinkURI() {
+        return this.getRefreshLinkURI(null);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.LinkService#getRefreshLinkURI(java.lang.Boolean)
+     */
+    public String getRefreshLinkURI(Boolean secure) {
         final Info info = this.getInfo();
 
-        final StringBuffer buffer = new StringBuffer(info.linkBase.toString());
+        final StringBuffer buffer = new StringBuffer(info.getBase(secure));
 
         // add comparable events
         Iterator iter = info.comparableEvents.iterator();

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelLinkService.java
Wed Aug 17 03:22:08 2005
@@ -70,7 +70,7 @@
      */
     public String getLinkURI(Event event, Boolean secure) {
         if (event == null) {
-            return this.getRefreshLinkURI();
+            return this.getRefreshLinkURI(secure);
         }
         if (this.labelManager == null) {
             return super.getLinkURI(event);
@@ -134,7 +134,7 @@
      */
     public String getLinkURI(List events, Boolean secure) {
         if (events == null || events.size() == 0) {
-            return this.getRefreshLinkURI();
+            return this.getRefreshLinkURI(secure);
         }
         if (this.labelManager == null) {
             return super.getLinkURI(events);

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java Wed
Aug 17 03:22:08 2005
@@ -247,7 +247,7 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.PortalService#setEntryLayout(org.apache.cocoon.portal.layout.Layout)
+     * @see org.apache.cocoon.portal.PortalService#setEntryLayout(java.lang.String, org.apache.cocoon.portal.layout.Layout)
      */
     public void setEntryLayout(String layoutKey, Layout object) {
         if ( layoutKey == null ) {
@@ -261,7 +261,7 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.PortalService#getEntryLayout()
+     * @see org.apache.cocoon.portal.PortalService#getEntryLayout(java.lang.String)
      */
     public Layout getEntryLayout(String layoutKey) {
         if ( layoutKey == null ) {

Modified: cocoon/blocks/portal/trunk/samples/skins/common/images/delete.gif
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/skins/common/images/delete.gif?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
Binary files - no diff available.

Modified: cocoon/blocks/portal/trunk/samples/skins/common/images/edit.gif
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/skins/common/images/edit.gif?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
Binary files - no diff available.

Modified: cocoon/blocks/portal/trunk/samples/skins/common/images/help.gif
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/skins/common/images/help.gif?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
Binary files - no diff available.

Modified: cocoon/blocks/portal/trunk/samples/skins/common/images/view.gif
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/samples/skins/common/images/view.gif?rev=233153&r1=233152&r2=233153&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message