portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r584918 - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/applications: demo/src/webapp/WEB-INF/ demo/src/webapp/WEB-INF/_content/ demo/src/webapp/WEB-INF/_content/en/ gems/src/java/org/apache/portals/gems/file/
Date Mon, 15 Oct 2007 21:00:09 GMT
Author: taylor
Date: Mon Oct 15 14:00:07 2007
New Revision: 584918

URL: http://svn.apache.org/viewvc?rev=584918&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-788

Added:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/
    portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/bor.html
Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/menu.html
    portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java

Added: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/bor.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/bor.html?rev=584918&view=auto
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/bor.html
(added)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/en/bor.html
Mon Oct 15 14:00:07 2007
@@ -0,0 +1,107 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<p><center><b>THE B.o.R.</b><br><EM>Amendments 1-10 of
the Constitution</em></center>
+
+<HR>
+
+<p>The Conventions of a number of the States having, at the time of adopting the Constitution,
expressed a desire, in order to prevent misconstruction or abuse of its powers, that further
declaratory and restrictive clauses should be added, and as extending the ground of public
confidence in the Government will best insure the beneficent ends of its institution;
+<P>
+
+Resolved, by the Senate and House of Representatives of the United States of America, in
Congress assembled, two-thirds of both Houses concurring, that the following articles be proposed
to the Legislatures of the several States, as amendments to the Constitution of the United
States; all or any of which articles, when ratified by three-fourths of the said Legislatures,
to be valid to all intents and purposes as part of the said Constitution, namely:
+
+<P><a name="1"><strong><H3>Amendment I</h3></strong></a>
+
+<P>Congress shall make no law respecting an establishment of
+religion, or prohibiting the free exercise thereof; or
+abridging the freedom of speech, or of the press; or the
+right of the people peaceably to assemble, and to petition
+the government for a redress of grievances.
+
+<P><a name="2"><strong><H3>Amendment II</h3></strong></a>
+
+<P>A well regulated militia, being necessary to the security
+of a free state, the right of the people to keep and bear
+arms, shall not be infringed.
+
+<P><a name="3"><strong><H3>Amendment III</h3></strong></a>
+
+<P>No soldier shall, in time of peace be quartered in any house,
+without the consent of the owner, nor in time of war, but
+in a manner to be prescribed by law.
+
+<P><a name="4"><strong><H3>Amendment IV</h3></strong></a>
+
+<P>The right of the people to be secure in their persons, houses,
+papers, and effects, against unreasonable searches and seizures,
+shall not be violated, and no warrants shall issue, but upon
+probable cause, supported by oath or affirmation, and
+particularly describing the place to be searched, and the
+persons or things to be seized.
+
+<P><a name="5"><strong><H3>Amendment V</h3></strong></a>
+
+<P>No person shall be held to answer for a capital, or otherwise
+infamous crime, unless on a presentment or indictment of a grand
+jury, except in cases arising in the land or naval forces,
+or in the militia, when in actual service in time of war
+or public danger; nor shall any person be subject for the
+same offense to be twice put in jeopardy of life or limb;
+nor shall be compelled in any criminal case to be a witness
+against himself, nor be deprived of life, liberty, or property,
+without due process of law; nor shall private property be
+taken for public use, without just compensation.
+
+<P><a name="6"><strong><H3>Amendment VI</h3></strong></a>
+
+<P>In all criminal prosecutions, the accused shall enjoy the right
+to a speedy and public trial, by an impartial jury of the state
+and district wherein the crime shall have been committed, which
+district shall have been previously ascertained by law, and
+to be informed of the nature and cause of the accusation;
+to be confronted with the witnesses against him; to have
+compulsory process for obtaining witnesses in his favor,
+and to have the assistance of counsel for his defense.
+
+<P><a name="7"><strong><H3>Amendment VII</h3></strong></a>
+
+<P>In suits at common law, where the value in controversy shall
+exceed twenty dollars, the right of trial by jury shall be
+preserved, and no fact tried by a jury, shall be otherwise
+reexamined in any court of the United States, than according
+to the rules of the common law.
+
+<P><a name="8"><strong><H3>Amendment VIII</h3></strong></a>
+
+<P>Excessive bail shall not be required, nor excessive fines
+imposed, nor cruel and unusual punishments inflicted.
+
+<P><a name="9"<strong><H3>Amendment IX</h3></strong></a>
+
+<P>The enumeration in the Constitution, of certain rights, shall
+not be construed to deny or disparage others retained by the people.
+
+<P><a name="10"><strong><H3>Amendment X</h3></strong></a>
+
+<P>The powers not delegated to the United States by the
+Constitution, nor prohibited by it to the states, are
+reserved to the states respectively, or to the people.
+
+
+
+
+  	
\ No newline at end of file

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/menu.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/menu.html?rev=584918&r1=584917&r2=584918&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/menu.html
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/_content/menu.html
Mon Oct 15 14:00:07 2007
@@ -17,5 +17,6 @@
 <h1>Know Your Rights</h1>
  <ul>
     <li><a href='/jetspeed/portal/_content/Constitution.html'>Constitution</a></li>
-    <li><a href='/jetspeed/portal/_content/BillOfRights.html'>Bill of Rights</a></li>
   
+    <li><a href='/jetspeed/portal/_content/BillOfRights.html'>Bill of Rights</a></li>
   
+    <li><a href='/jetspeed/portal/_content/bor.html'>Bill of Rights English</a></li>
 </ul>

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml?rev=584918&r1=584917&r2=584918&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/demo/src/webapp/WEB-INF/portlet.xml
Mon Oct 15 14:00:07 2007
@@ -870,7 +870,11 @@
         <init-param>
             <name>portlet-icon</name>
             <value>folder-remote.png</value>
-        </init-param>                                        
+        </init-param>   
+        <init-param>
+        	<name>use-language</name>
+        	<value>true</value>
+        </init-param>                                     
         <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
@@ -904,6 +908,7 @@
             </preference>
         </portlet-preferences>
     </portlet>
+
     <!--
     <portlet id="SSOProxyPortlet">
     <portlet-name>SSOProxyPortletPortlet</portlet-name>

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java?rev=584918&r1=584917&r2=584918&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
Mon Oct 15 14:00:07 2007
@@ -21,6 +21,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
@@ -31,6 +34,7 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.portals.bridges.common.GenericServletPortlet;
 
@@ -42,7 +46,7 @@
  */
 public class FilePortlet extends GenericServletPortlet
 {
-
+    public static final String PARAM_USE_LANGUAGE = "use-language";
     /**
      * Name of portlet preference for source file url
      */
@@ -76,9 +80,14 @@
      */
     private String defaultSourceBasePath = null;
 
+    private boolean useLanguage = false;
+    
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
+        String use = config.getInitParameter(PARAM_USE_LANGUAGE);
+        if (use != null && use.equalsIgnoreCase("true"))
+            this.useLanguage = true;
         this.defaultSourceFile = config.getInitParameter(PARAM_SOURCE_FILE);
         this.defaultSourceBasePath = config
                 .getInitParameter(PARAM_SOURCE_BASE_PATH);
@@ -136,15 +145,14 @@
                 response.getPortletOutputStream().write(bytes);
                 return;
             }
-        } else
+        } 
+        else
         {
-            String path = (String) request
-                    .getAttribute(PortalReservedParameters.PATH_ATTRIBUTE);
+            String path = (String) request.getAttribute(PortalReservedParameters.PATH_ATTRIBUTE);
             if (null == path)
             {
                 PortletPreferences prefs = request.getPreferences();
-                path = prefs
-                        .getValue(PARAM_SOURCE_FILE, this.defaultSourceFile);
+                path = prefs.getValue(PARAM_SOURCE_FILE, this.defaultSourceFile);
             }
 
             if (null == path && this.defaultSourceBasePath != null)
@@ -168,20 +176,45 @@
             {
                 response.setContentType("text/html");
                 response.getWriter().println("Could not find source document.");
-            } else
+            } 
+            else
             {
-                // default to 'content' area
-                File temp = new File(path);
-                if (webappLocation)
-                {
-                    path = "/WEB-INF/" + temp.getPath();
-                }
-                setContentType(path, response);
-                renderFile(response, path);
+                setContentType(path, response);                
+                List paths = fallback(path, request.getLocale().getLanguage());
+                renderFile(response, paths);
             }
         }
     }
 
+    protected List fallback(String path, String language)
+    {
+        List paths = new LinkedList();
+        if (this.useLanguage)
+        {
+            if (webappLocation)
+            {
+                path = concatenatePaths("/WEB-INF/", path);                
+            }            
+            String fallbackPath = path;
+            File temp = new File(path);
+            String parentPath = temp.getParent();
+            String name = temp.getName();
+            path = concatenatePaths(parentPath, language);
+            path = concatenatePaths(path, name);
+            paths.add(path);
+            paths.add(fallbackPath);
+        }
+        else
+        {
+            if (webappLocation)
+            {
+                path = concatenatePaths("/WEB-INF/", path);                
+            }                        
+            paths.add(path);
+        }
+        return paths;
+    }
+    
     protected void setContentType(String path, RenderResponse response)
     {
         // Note these content types need to be added to the portlet.xml
@@ -209,27 +242,45 @@
         }
     }
 
-    protected void renderFile(RenderResponse response, String fileName)
+    protected void renderFile(RenderResponse response, List paths)
             throws PortletException, IOException
     {
-        InputStream is = null;
-
-        if (this.webappLocation)
+        boolean drained = false;
+        Iterator it = paths.iterator();
+        while (it.hasNext())
         {
-            is = this.getPortletContext().getResourceAsStream(fileName);
-        } else
-        {
-            is = new FileInputStream(fileName);
+            String fileName = (String)it.next();
+            InputStream is = null;
+            try
+            {
+                if (this.webappLocation)
+                {
+                    is = this.getPortletContext().getResourceAsStream(fileName);
+                } else
+                {
+                    is = new FileInputStream(fileName);
+                }
+                if (is != null)
+                {
+                    drain(is, response.getPortletOutputStream());
+                    response.getPortletOutputStream().flush();
+                    is.close();
+                    drained = true;
+                    break;
+                }
+            }
+            catch (Exception e)
+            {
+                // do nothing, find next file
+            }
         }
-        if (is == null)
+        if (!drained)
         {
+            String fileName = (String)paths.get(0);
             byte[] bytes = ("File " + fileName + " not found.").getBytes();
             response.getPortletOutputStream().write(bytes);
-            return;
+            return;            
         }
-        drain(is, response.getPortletOutputStream());
-        response.getPortletOutputStream().flush();
-        is.close();
     }
 
     static final int BLOCK_SIZE = 4096;
@@ -264,4 +315,43 @@
         if (ar.length == 1) return pageRoot + sep + path;
         return pageRoot + sep + ar[0] + sep + ar[1];
     }
+    
+    protected static String concatenatePaths(String base, String path)
+    {
+        String result = "";
+        if (base == null)
+        {
+            if (path == null)
+            {
+                return result;
+            }
+            return path;
+        }
+        else
+        {
+            if (path == null)
+            {
+                return base;
+            }
+        }
+        if (base.endsWith(Folder.PATH_SEPARATOR)) 
+        {
+            if (path.startsWith(Folder.PATH_SEPARATOR))
+            {
+                result = base.concat(path.substring(1));
+                return result;
+            }
+        
+        }
+        else
+        {
+            if (!path.startsWith(Folder.PATH_SEPARATOR)) 
+            {
+                result = base.concat(Folder.PATH_SEPARATOR).concat(path);
+                return result;
+            }
+        }
+        return base.concat(path);
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message