You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@portals.apache.org by vk...@apache.org on 2008/12/10 12:59:01 UTC

svn commit: r725060 - in /portals/applications: ./ gems/ gems/src/java/org/apache/portals/gems/browser/ gems/src/java/org/apache/portals/gems/file/ gems/src/java/org/apache/portals/gems/googlemaps/

Author: vkumar
Date: Wed Dec 10 03:59:01 2008
New Revision: 725060

URL: http://svn.apache.org/viewvc?rev=725060&view=rev
Log:
Adding new functionalities in File server pipe-line and fixing pom.xml

Modified:
    portals/applications/.project
    portals/applications/gems/pom.xml
    portals/applications/gems/src/java/org/apache/portals/gems/browser/DatabaseBrowserPortlet.java
    portals/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
    portals/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
    portals/applications/pom.xml

Modified: portals/applications/.project
URL: http://svn.apache.org/viewvc/portals/applications/.project?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/.project (original)
+++ portals/applications/.project Wed Dec 10 03:59:01 2008
@@ -5,7 +5,13 @@
 	<projects>
 	</projects>
 	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
 </projectDescription>

Modified: portals/applications/gems/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/gems/pom.xml?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/gems/pom.xml (original)
+++ portals/applications/gems/pom.xml Wed Dec 10 03:59:01 2008
@@ -47,6 +47,16 @@
 
         <!-- Build Dependencies -->
         <dependency>
+            <groupId>org.apache.portals.jetspeed-2</groupId>
+            <artifactId>jetspeed-api</artifactId>
+            <version>2.2-SNAPSHOT</version>
+        </dependency>		
+        <dependency>
+            <groupId>org.apache.portals.jetspeed-2</groupId>
+            <artifactId>jetspeed-commons</artifactId>
+            <version>2.2-SNAPSHOT</version>
+        </dependency>		
+        <dependency>
             <groupId>commons-dbcp</groupId>
             <artifactId>commons-dbcp</artifactId>
         </dependency>
@@ -70,7 +80,7 @@
             <groupId>commons-httpclient</groupId>
             <artifactId>commons-httpclient</artifactId>
         </dependency>
-        <!-- FIXME:
+   
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-portlet</artifactId>
@@ -79,11 +89,20 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-beans</artifactId>
         </dependency>
-        -->
+        
     </dependencies>
 
     <!-- Project Information -->
-
+   <build>
+        <!-- Standard Directories -->
+        <sourceDirectory>src/java</sourceDirectory>
+        <!-- Resources -->
+        <resources>
+            <resource>
+                <directory>src/java</directory>
+            </resource>
+        </resources>
+    </build>
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/portals/jetspeed-2/trunk/applications/gems</connection>
         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/portals/jetspeed-2/trunk/applications/gems</developerConnection>

Modified: portals/applications/gems/src/java/org/apache/portals/gems/browser/DatabaseBrowserPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/gems/src/java/org/apache/portals/gems/browser/DatabaseBrowserPortlet.java?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/gems/src/java/org/apache/portals/gems/browser/DatabaseBrowserPortlet.java (original)
+++ portals/applications/gems/src/java/org/apache/portals/gems/browser/DatabaseBrowserPortlet.java Wed Dec 10 03:59:01 2008
@@ -57,30 +57,33 @@
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
  * @version $Id$
  */
-public class DatabaseBrowserPortlet 
-    extends BrowserPortlet
-    implements Browser
-{    
+public class DatabaseBrowserPortlet extends BrowserPortlet implements Browser
+{
+    private static final String COLUMNS_TITLE = "columnTitles";
+    private static final String CATLOG_NAME = "catlogName";
+    private static final String SCHEMA_NAME = "schemaName";
+    private static final String TABLE_NAME = "tableName";
+    private String[] catlogNames;
+    private String[] tableNames;
+    private String[] schemaNames;
+    private String[] colNames;
+
     /**
-     * Execute the sql statement as specified by the user or the default, and
-     * store the resultSet in a vector.
+     * Execute the sql statement as specified by the user or the default, and store the resultSet in a vector.
      * 
-     * @param sql
+     * @param sqlt
      *            The sql statement to be executed.
      * @param data
      *            The turbine rundata context for this request.
      */
-    public void getRows(RenderRequest request, String sql, int windowSize)
-            throws Exception
+    public void getRows(RenderRequest request, String sql, int windowSize) throws Exception
     {
         List resultSetList = new ArrayList();
         List resultSetTitleList = new ArrayList();
         List resultSetTypeList = new ArrayList();
-        
         Connection con = null;
         PreparedStatement selectStmt = null;
         ResultSet rs = null;
-        
         PortletSession session = request.getPortletSession();
         try
         {
@@ -88,13 +91,12 @@
             if (poolname == null || poolname.length() == 0)
             {
                 con = getConnection(request);
-            } 
+            }
             else
             {
                 con = getConnection(poolname);
             }
             selectStmt = con.prepareStatement(sql);
-
             readSqlParameters(request);
             Iterator it = sqlParameters.iterator();
             int ix = 0;
@@ -108,8 +110,7 @@
             ResultSetMetaData rsmd = rs.getMetaData();
             int columnNum = rsmd.getColumnCount();
             /*
-             * get the user object types to be displayed and add them to the
-             * title list as well as the result set list
+             * get the user object types to be displayed and add them to the title list as well as the result set list
              */
             List userObjList = (List) session.getAttribute(USER_OBJECTS);
             int userObjListSize = 0;
@@ -117,42 +118,36 @@
             {
                 userObjListSize = userObjList.size();
             }
-            //System.out.println("User List Size = "+ userObjListSize);
+            // System.out.println("User List Size = "+ userObjListSize);
             /*
-             * the array columnDisplayed maintains a boolean value for each
-             * column index. Only the columns that are set to true are added to
-             * the resultSetList, resultSetTitleList and resultSetTypeList.
+             * the array columnDisplayed maintains a boolean value for each column index. Only the columns that are set to true are added to the resultSetList,
+             * resultSetTitleList and resultSetTypeList.
              */
             boolean[] columnDisplayed = new boolean[columnNum + userObjListSize];
-
             /*
-             * this for loop constructs the columnDisplayed array as well as
-             * adds to the resultSetTitleList and resultSetTypeList
+             * this for loop constructs the columnDisplayed array as well as adds to the resultSetTitleList and resultSetTypeList
              */
             for (int i = 1; i <= columnNum; i++)
             {
                 int type = rsmd.getColumnType(i);
-                if (!((type == Types.BLOB) || (type == Types.CLOB)
-                        || (type == Types.BINARY)
-                        || (type == Types.LONGVARBINARY) || (type == Types.VARBINARY)))
+                if (!((type == Types.BLOB) || (type == Types.CLOB) || (type == Types.BINARY) || (type == Types.LONGVARBINARY) || (type == Types.VARBINARY)))
                 {
                     resultSetTitleList.add(rsmd.getColumnName(i));
                     resultSetTypeList.add(String.valueOf(type));
                     columnDisplayed[i - 1] = true;
-                } else
+                }
+                else
                 {
                     columnDisplayed[i - 1] = false;
                 }
             }
-
             for (int i = columnNum; i < columnNum + userObjListSize; i++)
             {
-                ActionParameter usrObj = (ActionParameter) userObjList.get(i
-                        - columnNum);
+                ActionParameter usrObj = (ActionParameter) userObjList.get(i - columnNum);
                 resultSetTitleList.add(usrObj.getName());
                 resultSetTypeList.add(usrObj.getType());
                 columnDisplayed[i] = true;
-                //System.out.println("User List Name = "+ usrObj.getName()+"
+                // System.out.println("User List Name = "+ usrObj.getName()+"
                 // Type = "+usrObj.getType());
             }
             /*
@@ -162,7 +157,6 @@
             while (rs.next())
             {
                 List row = new ArrayList(columnNum);
-
                 for (int i = 1; i <= columnNum; i++)
                 {
                     if (columnDisplayed[i - 1])
@@ -177,8 +171,7 @@
                 }
                 for (int i = columnNum; i < columnNum + userObjListSize; i++)
                 {
-                    ActionParameter usrObj = (ActionParameter) userObjList
-                            .get(i - columnNum);
+                    ActionParameter usrObj = (ActionParameter) userObjList.get(i - columnNum);
                     if (columnDisplayed[i])
                     {
                         Class c = Class.forName(usrObj.getType());
@@ -186,49 +179,44 @@
                         populate(index, i, row);
                     }
                 }
-
                 if (filter(row, request))
                 {
                     continue;
                 }
-
                 resultSetList.add(row);
                 index++;
             }
-            BrowserIterator iterator = new DatabaseBrowserIterator(
-                    resultSetList, resultSetTitleList, resultSetTypeList,
-                    windowSize);
+            BrowserIterator iterator = new DatabaseBrowserIterator(resultSetList, resultSetTitleList, resultSetTypeList, windowSize);
             setBrowserIterator(request, iterator);
-
-        } catch (SQLException e)
+        }
+        catch (SQLException e)
         {
             throw e;
-        } finally
+        }
+        finally
         {
             try
             {
-                if (null != selectStmt) selectStmt.close();
-                if (null != rs) rs.close();
-                if (null != con) //closes con also
+                if (null != selectStmt)
+                    selectStmt.close();
+                if (null != rs)
+                    rs.close();
+                if (null != con) // closes con also
                 {
                     closeConnection(con);
                 }
-
-            } catch (Exception e)
+            }
+            catch (Exception e)
             {
                 throw e;
             }
         }
-
     }
-    
 
     /*
      * Connection Management
      */
-        
-    public Connection getConnection(PortletRequest request)
-    throws Exception 
+    public Connection getConnection(PortletRequest request) throws Exception
     {
         Connection con = null;
         try
@@ -237,103 +225,126 @@
             String dsType = prefs.getValue("DatasourceType", null);
             if (dsType == null)
             {
-                throw new SQLException("No DataSource provided"); 
+                throw new SQLException("No DataSource provided");
             }
             if (dsType.equals("jndi"))
             {
                 Context ctx = new InitialContext();
                 String dsName = prefs.getValue("JndiDatasource", "");
-                Context envContext  = (Context)ctx.lookup("java:/comp/env");
-                DataSource ds = (DataSource)envContext.lookup(dsName);                
+                Context envContext = (Context) ctx.lookup("java:/comp/env");
+                DataSource ds = (DataSource) envContext.lookup(dsName);
                 con = ds.getConnection();
             }
             else if (dsType.equals("dbcp"))
             {
                 BasicDataSource ds = new BasicDataSource();
-                  ds.setDriverClassName(prefs.getValue("JdbcDriver", ""));
-                  ds.setUrl(prefs.getValue("JdbcConnection", ""));                                                                                      
-                  ds.setUsername(prefs.getValue("JdbcUsername", ""));
-                  ds.setPassword(prefs.getValue("JdbcPassword", ""));
-    //            ds.setUrl("jdbc:mysql://j2-server/j2");
-                  con = ds.getConnection();                  
+                ds.setDriverClassName(prefs.getValue("JdbcDriver", ""));
+                ds.setUrl(prefs.getValue("JdbcConnection", ""));
+                ds.setUsername(prefs.getValue("JdbcUsername", ""));
+                ds.setPassword(prefs.getValue("JdbcPassword", ""));
+                // ds.setUrl("jdbc:mysql://j2-server/j2");
+                con = ds.getConnection();
             }
             else if (dsType.equals("sso"))
             {
                 /*
-                 * For SSO the user has to define the JDBCdriver and JdbcConnection (URL)
-                 * but the credentials for the db come from the SSO storage
+                 * For SSO the user has to define the JDBCdriver and JdbcConnection (URL) but the credentials for the db come from the SSO storage
                  */
                 BasicDataSource ds = new BasicDataSource();
                 ds.setDriverClassName(prefs.getValue("SSOJdbcDriver", ""));
-                ds.setUrl(prefs.getValue("SSOJdbcConnection", ""));  
+                ds.setUrl(prefs.getValue("SSOJdbcConnection", ""));
                 String ssoURL = prefs.getValue("SSOSite", "");
-                
                 // SSO API lookup
                 SSOContext credentials = null;
                 try
                 {
                     if (sso == null)
                         throw new SSOException("SSO Not supported.");
-                    
                     credentials = sso.getCredentials(getSubject(), ssoURL);
                 }
-                catch(SSOException ssoex)
+                catch (SSOException ssoex)
                 {
                     throw new Exception("SSO credential lookup failed. Error: " + ssoex.getMessage());
                 }
-                
                 String ssoUserName = credentials.getRemotePrincipalName();
                 String ssoPWD = credentials.getRemoteCredential();
                 ds.setUsername(ssoUserName);
-                ds.setPassword( ssoPWD );
+                ds.setPassword(ssoPWD);
                 con = ds.getConnection();
             }
             else
             {
-                throw new SQLException("No DataSource provided");                 
+                throw new SQLException("No DataSource provided");
             }
-                        
         }
         catch (Exception e)
         {
-            throw new Exception("Failed to connect", e); // TODO: complete this 
+            throw new Exception("Failed to connect", e); // TODO: complete this
         }
         return con;
     }
-        
+
     public Connection getConnection(String poolName)
     {
         return null;
     }
-    
+
     public void closeConnection(Connection con)
     {
         try
         {
             con.close();
         }
-        catch (SQLException e) 
+        catch (SQLException e)
         {
             log.error("Cant close connection", e);
-        }         
-        
+        }
     }
-    
-    public void doEdit(RenderRequest request, RenderResponse response)
-    throws PortletException, IOException
+
+    public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
     {
         response.setContentType("text/html");
-        StatusMessage msg = (StatusMessage)PortletMessaging.consume(request, "DatabaseBrowserPortlet", "dbConnectTest");
+        StatusMessage msg = (StatusMessage) PortletMessaging.consume(request, "DatabaseBrowserPortlet", "dbConnectTest");
         if (msg != null)
         {
-            this.getContext(request).put("statusMsg", msg);            
+            this.getContext(request).put("statusMsg", msg);
+        }
+        String editAction = request.getParameter("configPage");
+        if (editAction != null && editAction.equals("configPage1"))
+        {
+            try
+            {
+                // fillDropDowns(getConnection(request), request);
+                // getContext(request).put("catlogs", getCatalogNames());
+                // getContext(request).put("schemas", getSchemaNames());
+                // getContext(request).put("tables", getTableNames());
+                fillColumnDropDown(getConnection(request), request);
+                getContext(request).put("cols", getColNames());
+            }
+            catch (Exception e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            request.setAttribute("EditPage", "/WEB-INF/view/database-edit1.vm");
+        }
+        else if (editAction != null && editAction.equals("configPage2"))
+        {
+            try
+            {
+                fillDropDowns(getConnection(request), request);
+            }
+            catch (Exception e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            request.setAttribute("EditPage", "/WEB-INF/view/database-edit2.vm");
         }
         super.doEdit(request, response);
     }
-    
-    
-    public void processAction(ActionRequest request, ActionResponse response)
-    throws PortletException, IOException
+
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
     {
         if (request.getPortletMode() == PortletMode.EDIT)
         {
@@ -344,10 +355,10 @@
                 {
                     PortletPreferences prefs = request.getPreferences();
                     PreferencesHelper.requestParamsToPreferences(request);
-                    prefs.store();                    
+                    prefs.store();
                     getConnection(request);
-                    StatusMessage msg = new StatusMessage("Connection made successfully.", StatusMessage.SUCCESS);                    
-                    PortletMessaging.publish(request, "DatabaseBrowserPortlet", "dbConnectTest", msg);                    
+                    StatusMessage msg = new StatusMessage("Connection made successfully.", StatusMessage.SUCCESS);
+                    PortletMessaging.publish(request, "DatabaseBrowserPortlet", "dbConnectTest", msg);
                 }
                 catch (Exception e)
                 {
@@ -363,13 +374,86 @@
                 response.setPortletMode(PortletMode.EDIT);
                 return;
             }
+            String editAction = request.getParameter("configPage");
+            if (editAction != null && (editAction.equals("configPage1") || editAction.equals("configPage2")))
+            {
+                response.setPortletMode(PortletMode.EDIT);
+                response.setRenderParameter("configPage", editAction);
+                return;
+            }
         }
         super.processAction(request, response);
     }
-    
+
     private Subject getSubject()
     {
         AccessControlContext context = AccessController.getContext();
-        return JSSubject.getSubject(context);         
+        return JSSubject.getSubject(context);
+    }
+
+    private String[] getCatalogNames()
+    {
+        return catlogNames;
+    }
+
+    private String[] getSchemaNames()
+    {
+        return schemaNames;
+    }
+
+    private String[] getTableNames()
+    {
+        return tableNames;
+    }
+
+    private String[] getColNames()
+    {
+        return colNames;
+    }
+
+    public String[] getResultSetTitleList(RenderRequest request, String[] columnNames)
+    {
+        String[] columnsNames = request.getPreferences().getValues(COLUMNS_TITLE, columnNames);
+        return columnsNames;
+    }
+
+    private void fillColumnDropDown(Connection con, RenderRequest request)
+    {
+        String tableName = request.getPreferences().getValue(TABLE_NAME, "client");
+        try
+        {
+            PreparedStatement stmt = con.prepareStatement("select * from " + tableName);
+            ResultSet set = stmt.executeQuery();
+            ResultSetMetaData meta = set.getMetaData();
+            int ColumnCount = meta.getColumnCount();
+            List colums = new ArrayList();
+            for (int index = 0; index < ColumnCount; index++)
+            {
+                colums.add(meta.getColumnName(index));
+            }
+            tableNames = (String[]) colums.toArray();
+        }
+        catch (Exception e)
+        {
+            // TODO: handle exception
+        }
+    }
+
+    private void fillDropDowns(Connection con, RenderRequest request)
+    {
+        String catlogName = request.getPreferences().getValue(CATLOG_NAME, "");
+        String tableName = request.getPreferences().getValue(TABLE_NAME, "");
+        String schemaName = request.getPreferences().getValue(SCHEMA_NAME, "");
+        try
+        {
+            // catlogNames = (String[]) con.getMetaData().getCatalogs().getArray("TABLE_CATALOG").getArray();
+            // schemaNames = (String[]) con.getMetaData().getSchemas().getArray("TABLE_SCHEM").getArray();
+            tableNames = (String[]) con.getMetaData().getTables(catlogName, tableName, "%", new String[] { "TABLE" }).getArray("TABLE_NAME").getArray();
+        }
+        catch (SQLException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
     }
 }

Modified: portals/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java (original)
+++ portals/applications/gems/src/java/org/apache/portals/gems/file/FilePortlet.java Wed Dec 10 03:59:01 2008
@@ -31,9 +31,14 @@
 import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.administration.PortalConfiguration;
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.portals.bridges.common.GenericServletPortlet;
@@ -51,72 +56,104 @@
      * Name of portlet preference for source file url
      */
     public static final String PARAM_SOURCE_FILE = "file";
-
     /**
      * Name of portlet preference for source file url
      */
     public static final String PARAM_SOURCE_BASE_PATH = "basepath";
-
     /**
      * Name of portlet preference for source file url
      */
     public static final String PARAM_SOURCE_FILE_PATH = "filepath";
-
     /**
-     * Is the file stored in the webapp or outside of the webapp? valid values
-     * "webapp" and "filesystem", defaults to webapp
+     * Is the file stored in the webapp or outside of the webapp? valid values "webapp" and "filesystem", defaults to webapp
      */
+    public static final String USE_FILE_SYSTEM = "useFileSystem";
     public static final String PARAM_LOCATION = "location";
-
     private boolean webappLocation = true;
-
     /**
      * Default URL for the source file
      */
     private String defaultSourceFile = null;
-
     /**
      * Default base URL for the source file
      */
     private String defaultSourceBasePath = null;
-
     private boolean useLanguage = false;
-    
+    private PortalConfiguration configuration;
+
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
-        String use = config.getInitParameter(PARAM_USE_LANGUAGE);
+        configuration = (PortalConfiguration) getPortletContext().getAttribute(CommonPortletServices.CPS_PORTAL_CONFIGURATION);
+        String use = configuration.getString(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);
-        String location = config.getInitParameter(PARAM_LOCATION);
-        if (location != null && location.equals("filesystem"))
-            webappLocation = false;
+        String useFileSystem = configuration.getString(USE_FILE_SYSTEM);
+        if (useFileSystem != null && useFileSystem.equalsIgnoreCase("true"))
+        {
+            this.defaultSourceBasePath = configuration.getString(PARAM_LOCATION);
+            if (defaultSourceBasePath != null && defaultSourceBasePath.length() > 0)
+            {
+                webappLocation = false;
+            }
+            else
+            {
+                webappLocation = true;
+            }
+        }
         else
+        {
             webappLocation = true;
+        }
     }
 
     private RequestContext getRequestContext(PortletRequest request)
     {
-        return (RequestContext) request
-                .getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-
+        return (RequestContext) request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
     }
 
     private HttpServletRequest getHttpServletRequest(PortletRequest pRequest)
     {
         return getRequestContext(pRequest).getRequest();
+    }
+
+    private InputStream getFile(String appName, String fileName)
+    {
+        ServletContext portalAppContext = ((ServletConfig) Jetspeed.getComponentManager().getComponent("ServletConfig")).getServletContext();
+        ServletContext portletAppContext = portalAppContext.getContext(appName);
+        InputStream stream = null;
+        if (portletAppContext != null)
+        {
+            stream = portletAppContext.getResourceAsStream(fileName);
+        }
+        else
+        {
+            stream = portalAppContext.getResourceAsStream(fileName);
+        }
+        return stream;
+    }
 
+    private InputStream getLocalFile(String fileName)
+    {
+        InputStream is = null;
+        String filePath = defaultSourceBasePath.concat(fileName);
+        try
+        {
+            is = new FileInputStream(filePath);
+        }
+        catch (Exception e)
+        {
+           //File not found;
+        }
+        return is;
     }
 
-    public void doView(RenderRequest request, RenderResponse response)
-            throws PortletException, IOException
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
     {
         // NOTE: this is Jetspeed specific
         HttpServletRequest req = getHttpServletRequest(request);
         String fileName = (String) req.getSession().getAttribute("file");
+        String appName;
         if (fileName != null && !fileName.equals(""))
         {
             InputStream is = null;
@@ -126,8 +163,7 @@
                 is = new FileInputStream(fileName);
                 if (is == null)
                 {
-                    byte[] bytes = ("File " + fileName + " not found.")
-                            .getBytes();
+                    byte[] bytes = ("File " + fileName + " not found.").getBytes();
                     response.getPortletOutputStream().write(bytes);
                     return;
                 }
@@ -136,16 +172,18 @@
                 response.getPortletOutputStream().flush();
                 is.close();
                 req.getSession().removeAttribute("file");
-            } catch (Exception e)
+            }
+            catch (Exception e)
             {
-                if (is != null) is.close();
+                if (is != null)
+                    is.close();
                 byte[] bytes = ("File " + fileName + " not found.").getBytes();
                 req.getSession().removeAttribute("file");
                 response.setContentType("text/html");
                 response.getPortletOutputStream().write(bytes);
                 return;
             }
-        } 
+        }
         else
         {
             String path = (String) request.getAttribute(PortalReservedParameters.PATH_ATTRIBUTE);
@@ -164,41 +202,44 @@
                 String filepath = request.getParameter(PARAM_SOURCE_FILE_PATH);
                 if (filepath == null)
                 {
-                    filepath = (String) request
-                            .getAttribute(PARAM_SOURCE_FILE_PATH);
+                    filepath = (String) request.getAttribute(PARAM_SOURCE_FILE_PATH);
                 }
-
                 if (filepath != null)
                 {
-                    path = ((this.defaultSourceBasePath.length() > 0) ? (this.defaultSourceBasePath + "/")
-                            : "")
-                            + filepath;
+                    path = ((this.defaultSourceBasePath.length() > 0) ? (this.defaultSourceBasePath + "/") : "") + filepath;
                 }
             }
-
             if (null == path)
             {
                 response.setContentType("text/html");
                 response.getWriter().println("Could not find source document.");
-            } 
+            }
             else
             {
-                setContentType(path, response);                
-                List paths = fallback(path, request.getLocale().getLanguage());
-                renderFile(response, paths);
+                setContentType(path, response);
+                appName = getApplicationName(request);
+                List paths = fallback(path, request.getLocale().getLanguage(), appName);
+                renderFile(response, paths, appName);
             }
         }
     }
 
-    protected List fallback(String path, String language)
+    protected List fallback(String path, String language, String appName)
     {
         List paths = new LinkedList();
         if (this.useLanguage)
         {
+            if (appName != null)
+            {
+                if (path.indexOf(appName) > -1)
+                {
+                    path = path.replace(appName, "");
+                }
+            }
             if (webappLocation)
             {
-                path = concatenatePaths("/WEB-INF/", path);                
-            }            
+                path = concatenatePaths("/WEB-INF/", path);
+            }
             String fallbackPath = path;
             File temp = new File(path);
             String parentPath = temp.getParent();
@@ -212,57 +253,63 @@
         {
             if (webappLocation)
             {
-                path = concatenatePaths("/WEB-INF/", path);                
-            }                        
+                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
         if (path.endsWith(".html"))
         {
             response.setContentType("text/html");
-        } else if (path.endsWith(".pdf"))
+        }
+        else if (path.endsWith(".pdf"))
         {
             response.setContentType("application/pdf");
-        } else if (path.endsWith(".zip"))
+        }
+        else if (path.endsWith(".zip"))
         {
             response.setContentType("application/zip");
-        } else if (path.endsWith(".csv"))
+        }
+        else if (path.endsWith(".csv"))
         {
             response.setContentType("text/csv");
-        } else if (path.endsWith(".xml") || path.endsWith(".xsl"))
+        }
+        else if (path.endsWith(".xml") || path.endsWith(".xsl"))
         {
             response.setContentType("text/xml");
-        } else if (path.endsWith(".psml") || path.endsWith(".link"))
+        }
+        else if (path.endsWith(".psml") || path.endsWith(".link"))
         {
             response.setContentType("text/xml");
-        } else
+        }
+        else
         {
             response.setContentType("text/html");
         }
     }
 
-    protected void renderFile(RenderResponse response, List paths)
-            throws PortletException, IOException
+    protected void renderFile(RenderResponse response, List paths, String appName) throws PortletException, IOException
     {
         boolean drained = false;
         Iterator it = paths.iterator();
         while (it.hasNext())
         {
-            String fileName = (String)it.next();
+            String fileName = (String) it.next();
             InputStream is = null;
             try
             {
                 if (this.webappLocation)
                 {
-                    is = this.getPortletContext().getResourceAsStream(fileName);
-                } else
+                    is = getFile(appName, fileName);
+                }
+                else
                 {
-                    is = new FileInputStream(fileName);
+                    is = getLocalFile(fileName);
                 }
                 if (is != null)
                 {
@@ -280,10 +327,10 @@
         }
         if (!drained)
         {
-            String fileName = (String)paths.get(0);
+            String fileName = (String) paths.get(0);
             byte[] bytes = ("File " + fileName + " not found.").getBytes();
             response.getPortletOutputStream().write(bytes);
-            return;            
+            return;
         }
     }
 
@@ -303,7 +350,8 @@
                 }
                 length = r.read(bytes);
             }
-        } finally
+        }
+        finally
         {
             bytes = null;
         }
@@ -313,13 +361,14 @@
     {
         String pageRoot = System.getProperty("java.io.tmpdir");
         String sep = System.getProperty("file.separator");
-        if (sep == null || sep.equals("")) sep = "/";
-
+        if (sep == null || sep.equals(""))
+            sep = "/";
         String ar[] = path.split("_");
-        if (ar.length == 1) return pageRoot + sep + path;
+        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 = "";
@@ -338,18 +387,17 @@
                 return base;
             }
         }
-        if (base.endsWith(Folder.PATH_SEPARATOR)) 
+        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)) 
+            if (!path.startsWith(Folder.PATH_SEPARATOR))
             {
                 result = base.concat(Folder.PATH_SEPARATOR).concat(path);
                 return result;
@@ -357,5 +405,18 @@
         }
         return base.concat(path);
     }
-    
+
+    private String getApplicationName(RenderRequest request)
+    {
+        String url = null;
+        String urls[] = ((HttpServletRequest) request).getPathInfo().split(Folder.PATH_SEPARATOR);
+        if (urls.length > 2)
+        {
+            if (!urls[1].startsWith(configuration.getString("portalurl.navigationalstate.parameter.name")))
+            {
+                url = Folder.PATH_SEPARATOR + urls[1];
+            }
+        }
+        return url;
+    }
 }
\ No newline at end of file

Modified: portals/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java
URL: http://svn.apache.org/viewvc/portals/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java (original)
+++ portals/applications/gems/src/java/org/apache/portals/gems/googlemaps/YahooGeocodeProxyServlet.java Wed Dec 10 03:59:01 2008
@@ -55,7 +55,7 @@
 		throws ServletException, java.io.IOException {
 		String location = req.getParameter("location");
 		location = URLEncoder.encode(location,"UTF-8");
-        appid = URLEncoder.encode(location,"UTF-8");
+        String appid = URLEncoder.encode(location,"UTF-8");
         String url = YAHOO_REQUEST + appid + "&location=" +location;		
 		String content = "<error/>";		
 		// get content from yahoo, code from http://jakarta.apache.org/commons/httpclient/tutorial.html

Modified: portals/applications/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/pom.xml?rev=725060&r1=725059&r2=725060&view=diff
==============================================================================
--- portals/applications/pom.xml (original)
+++ portals/applications/pom.xml Wed Dec 10 03:59:01 2008
@@ -241,7 +241,7 @@
     <nekohtml.version>0.9.5</nekohtml.version>
     <ojb.version>1.0.3</ojb.version>
     <org.apache.derby.version>10.3.2.1</org.apache.derby.version>
-    <org.apache.pluto.version>1.0.1</org.apache.pluto.version>
+    <org.apache.pluto.version>2.0.0-SNAPSHOT</org.apache.pluto.version>
     <org.apache.portals.bridges.common.version>1.0.4</org.apache.portals.bridges.common.version>
     <org.apache.portals.bridges.frameworks.version>1.0.4</org.apache.portals.bridges.frameworks.version>
     <org.apache.portals.bridges.jpetstore.version>1.0.4</org.apache.portals.bridges.jpetstore.version>
@@ -251,7 +251,7 @@
     <org.apache.portals.bridges.groovy.version>1.0.4</org.apache.portals.bridges.groovy.version>
     <org.apache.portals.bridges.portletfilter.version>1.0.4</org.apache.portals.bridges.portletfilter.version>
     <oro.version>2.0.8</oro.version>
-    <portlet-api.version>1.0</portlet-api.version>
+    <portlet-api.version>2.0</portlet-api.version>
     <regexp.version>1.2</regexp.version>
     <rome.version>0.8</rome.version>
     <saxpath.version>1.0-FCS</saxpath.version>
@@ -340,7 +340,7 @@
 
       <!-- Standard APIs -->
       <dependency>
-        <groupId>portlet-api</groupId>
+        <groupId>javax.portlet</groupId>
         <artifactId>portlet-api</artifactId>
         <version>${portlet-api.version}</version>
       </dependency>
@@ -358,7 +358,7 @@
       <!-- Pluto Container -->
       <dependency>
         <groupId>org.apache.pluto</groupId>
-        <artifactId>pluto</artifactId>
+        <artifactId>pluto-container-api</artifactId>
         <version>${org.apache.pluto.version}</version>
       </dependency>
 
@@ -951,7 +951,7 @@
 
     <!-- Provided Dependencies -->
     <dependency>
-      <groupId>portlet-api</groupId>
+      <groupId>javax.portlet</groupId>
       <artifactId>portlet-api</artifactId>
       <scope>provided</scope>
     </dependency>
@@ -967,7 +967,7 @@
       </dependency>
     <dependency>
       <groupId>org.apache.pluto</groupId>
-      <artifactId>pluto</artifactId>
+      <artifactId>pluto-container-api</artifactId>
       <scope>provided</scope>
     </dependency>
     <dependency>