portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r918341 - in /portals/jetspeed-2/portal/trunk: applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/ applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/ components/jetspeed-portal/src/main/java/org/apache/jetspee...
Date Wed, 03 Mar 2010 07:10:39 GMT
Author: taylor
Date: Wed Mar  3 07:10:38 2010
New Revision: 918341

URL: http://svn.apache.org/viewvc?rev=918341&view=rev
Log:
jetui pipeline configured to use new PageValve, not ProfilerValve making all visible pages
addressable

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
  (with props)
Modified:
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/folder.metadata
    portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/folder.metadata
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/spaces/SpacesServiceImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/spaces/Spaces.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/folder.metadata
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/folder.metadata?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/folder.metadata
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/min-pages/_user/devmgr/folder.metadata
Wed Mar  3 07:10:38 2010
@@ -17,12 +17,13 @@
     xmlns="http://portals.apache.org/jetspeed"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://portals.apache.org/jetspeed http://portals.apache.org/jetspeed-2/2.1/schemas/folder-metadata.xsd">
-  <title >Home</title>  
-
+  <title >Dev Manager Home</title>
+  <short-title>My Space</short-title>  
+  <metadata name='space-owner' xml:lang='en'>devmgr</metadata>  
   <document-order>default-page.psml</document-order>
   <document-order>account.psml</document-order>
-  
   <security-constraints>
     <owner>devmgr</owner>
-  </security-constraints>  
+  </security-constraints>
+    
 </folder>

Modified: portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/folder.metadata
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/folder.metadata?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/folder.metadata
(original)
+++ portals/jetspeed-2/portal/trunk/applications/jetspeed/src/main/webapp/WEB-INF/pages/_user/user/folder.metadata
Wed Mar  3 07:10:38 2010
@@ -35,19 +35,21 @@
   <document-order>Google.link</document-order>
   <document-order>Jetspeed2.link</document-order>
 
-  <document-order>default-page.psml</document-order>
+<!--   <document-order>default-page.psml</document-order>  
   <document-order>p001.psml</document-order>
-  <document-order>p002.psml</document-order>
+  <document-order>p002.psml</document-order> -->
   <document-order>p003.psml</document-order>
+  <!-- 
   <document-order>p004.psml</document-order>
   <document-order>localeselector.psml</document-order>
   <document-order>jsf-demo.psml</document-order>
   <document-order>struts-demo.psml</document-order>
-
+ 
   <document-order>third-party</document-order>
   <document-order>non-java</document-order>
   <document-order>Administrative</document-order>
-
+ -->
+ 
   <menu name="page-navigations">
     <separator>
       <text>[USER] Top Pages</text>

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
Wed Mar  3 07:10:38 2010
@@ -285,13 +285,10 @@
                             // deep copy from the default folder template tree, creating
a deep-copy of the template
                             // in the new user's folder tree
                             Folder source = innerPageManager.getFolder(innerFolderTemplate);
-                            
-                            
                             innerPageManager.deepCopyFolder(source, innerSubsite, innerUserName);
                             Folder newFolder = pageManager.getFolder(innerSubsite);     
                      
-                            newFolder.setTitle("Home Folder");
-                            newFolder.setShortTitle("Home");
-                             
+                            newFolder.setTitle("My Home Space");
+                            newFolder.setShortTitle("My Space");                        
    
                             return null;
                         }
                         catch (SecurityException s1)

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java?rev=918341&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
Wed Mar  3 07:10:38 2010
@@ -0,0 +1,296 @@
+/*
+ * 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.
+ */
+package org.apache.jetspeed.pipeline.valve.impl;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.administration.AdminUtil;
+import org.apache.jetspeed.decoration.PageActionAccess;
+import org.apache.jetspeed.layout.PageLayoutComponent;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.ContentPage;
+import org.apache.jetspeed.om.page.BaseConcretePageElement;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.page.PageManager;
+import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.page.document.NodeNotFoundException;
+import org.apache.jetspeed.page.document.NodeSet;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.PageProfilerValve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.portalsite.PortalSite;
+import org.apache.jetspeed.portalsite.PortalSiteRequestContext;
+import org.apache.jetspeed.portalsite.PortalSiteSessionContext;
+import org.apache.jetspeed.profiler.ProfileLocator;
+import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.ProfilerException;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SubjectHelper;
+import org.apache.jetspeed.security.User;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Page Valve locates the page from the portal request without profiling operations using
a 1:1 URL:path location algorithm
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @version $Id$
+ */
+public class PageValveImpl extends AbstractValve implements PageProfilerValve
+{
+    protected Logger log = LoggerFactory.getLogger(PageValveImpl.class);   
+
+   
+    /**
+     * pageLayoutComponent - component used to construct and maintain ContentPage from
+     *                       profiled PSML Pages and Fragments.
+     */
+    private PageLayoutComponent pageLayoutComponent;
+
+    /**
+     * 
+     */
+    private PageManager pageManager;
+    
+    public PageValveImpl(PageManager pageManager, PageLayoutComponent pageLayoutComponent)
                           
+    {
+        this.pageManager = pageManager;
+    	this.pageLayoutComponent = pageLayoutComponent;
+    }
+
+    public void invoke( RequestContext request, ValveContext context ) throws PipelineException
+    {
+        try
+        { 
+            String requestPath = request.getPath();
+            if (log.isDebugEnabled())
+            {
+                log.debug("Request path: "+requestPath);
+            }
+            if (requestPath == null)
+            {
+            	requestPath = Folder.PATH_SEPARATOR;
+            }
+            if (!requestPath.endsWith(Page.DOCUMENT_TYPE)) // FIXME: handle dynamic pages,
pages not ending with .psml
+            {
+            		Folder folder = pageManager.getFolder(requestPath);
+                	String defaultPage = folder.getDefaultPage();
+                	if (defaultPage == null)
+                	{
+                		List<String> docs = folder.getDocumentOrder();
+                		if (docs != null || docs.size() > 0)
+                		{
+                			for (String doc: docs)
+                			{
+                				if (doc.endsWith(Page.DOCUMENT_TYPE))
+                				{
+                					defaultPage = doc;
+                					break;
+                				}
+                			}
+                		}
+                		if (defaultPage == null)
+                			defaultPage = Folder.FALLBACK_DEFAULT_PAGE;
+                	}
+                	requestPath = AdminUtil.concatenatePaths(requestPath, defaultPage); 
+            }
+            Page page = pageManager.getPage(requestPath);
+            
+            // get profiler locators for request subject/principal using the profiler
+            Subject subject = request.getSubject();
+            if (subject == null)
+            {
+                throw new ProfilerException("Missing subject for request: " + requestPath);
+            }            
+            Principal principal = SubjectHelper.getBestPrincipal(subject, User.class);
+            if (principal == null)
+            {
+                throw new ProfilerException("Missing principal for request: " + requestPath);
+            }
+
+            BaseConcretePageElement managedPage = page; //requestContext.getManagedPage();
+            PageTemplate managedPageTemplate = this.getPageTemplate(page); //requestContext.getManagedPageTemplate();
+            Map managedFragmentDefinitions = null;  //requestContext.getManagedFragmentDefinitions();
+            ContentPage contentPage = pageLayoutComponent.newContentPage(managedPage, managedPageTemplate,
managedFragmentDefinitions);
+            request.setPage(contentPage);
+
+            request.setAttribute(PortalReservedParameters.PATH_ATTRIBUTE, requestPath);
+            request.setAttribute(PortalReservedParameters.CONTENT_PATH_ATTRIBUTE, requestPath);
//requestContext.getPageContentPath());
+//            request.setAttribute(PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE,getPageActionAccess(request));
+
+                if (log.isDebugEnabled())
+                {
+                    log.debug("Page path: "+contentPage.getPath());
+                }
+            
+
+            // continue
+            if (context != null)
+            {
+                context.invokeNext(request);
+            }
+        }
+        catch (SecurityException se)
+        {
+            // fallback to root folder/default page
+            if (true) //requestFallback)
+            {
+                // fallback to portal root folder/default page if
+                // no user is available and request path is not
+                // already attempting to access the root folder;
+                // this is rarely the case since the anonymous
+                // user is normally defined unless the default
+                // security system has been replaced/overridden
+                if (request.getRequest().getUserPrincipal() == null &&
+                    request.getPath() != null &&
+                    !request.getPath().equals("/"))
+                {
+                    try 
+                    {
+                        request.getResponse().sendRedirect(request.getRequest().getContextPath());
+                    }
+                    catch (IOException ioe){}
+                    return;
+                }
+            }
+
+            // return standard HTTP 403 - FORBIDDEN status
+            log.error(se.getMessage(), se);
+            try
+            {                
+                request.getResponse().sendError(HttpServletResponse.SC_FORBIDDEN, se.getMessage());
+            }
+            catch (IOException ioe)
+            {
+                log.error("Failed to invoke HttpServletReponse.sendError: " + ioe.getMessage(),
ioe);
+            }
+        }
+        catch (NodeNotFoundException nnfe)
+        {
+            // return standard HTTP 404 - NOT FOUND status
+            log.error(nnfe.getMessage(), nnfe);
+            try
+            {
+                request.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND, nnfe.getMessage());
+            }
+            catch (IOException ioe)
+            {
+                log.error("Failed to invoke HttpServletReponse.sendError: " + ioe.getMessage(),
ioe);
+            }
+        }
+        catch (Exception e)
+        {
+            log.error("Exception in request pipeline: " + e.getMessage(), e);
+            throw new PipelineException(e.toString(), e);
+        }
+    }
+    
+    /**
+     * Returns the <code>PageActionAccess</code> for the current user request.
+     * @see PageActionAccess
+     * @param requestContext RequestContext of the current portal request.
+     * @return PageActionAccess for the current user request.
+     */
+//    protected PageActionAccess getPageActionAccess(RequestContext requestContext)
+//    { 
+//        ContentPage page = requestContext.getPage();
+//        String key = page.getId();
+//        boolean loggedOn = requestContext.getRequest().getUserPrincipal() != null;
+//        boolean anonymous = !loggedOn;
+//        PageActionAccess pageActionAccess = null;
+//
+//        Map sessionActions = null;
+//        synchronized (this)
+//        {
+//            sessionActions = (Map) requestContext.getSessionAttribute(PAGE_ACTION_ACCESS_MAP_SESSION_ATTR_KEY);
+//            if (sessionActions == null)
+//            {
+//                sessionActions = new HashMap();
+//                requestContext.setSessionAttribute(PAGE_ACTION_ACCESS_MAP_SESSION_ATTR_KEY,
sessionActions);
+//            }
+//            else
+//            {
+//                pageActionAccess = (PageActionAccess) sessionActions.get(key);
+//            }
+//        }
+//        synchronized (sessionActions)
+//        {
+//            if (pageActionAccess == null)
+//            {
+//                pageActionAccess = new PageActionAccess(anonymous, page);
+//                sessionActions.put(key, pageActionAccess);
+//            }
+//            else
+//            {
+//                pageActionAccess.checkReset(anonymous, page);
+//            }        
+//        }
+//        
+//        return pageActionAccess;
+//    }
+
+    public String toString()
+    {
+        return "PageValve";
+    }
+
+    public PageTemplate getPageTemplate(Page page2) throws NodeNotFoundException
+    {
+    	PageTemplate requestPageTemplate = null;
+        BaseConcretePageElement page = page2;
+        if (page != null)
+        {
+            // scan through site looking for first page template
+            // up the folder hierarchy from the requested page
+            try
+            {
+                Folder folder = (Folder)page.getParent();
+                while ((folder != null) && (requestPageTemplate == null))
+                {
+                    NodeSet pageTemplates = folder.getPageTemplates();
+                    if ((pageTemplates != null) && !pageTemplates.isEmpty())
+                    {
+                        // return first page template found
+                        requestPageTemplate = (PageTemplate)pageTemplates.iterator().next();
+                    }
+                    else
+                    {
+                        // continue scan
+                        folder = (Folder)folder.getParent();
+                    }
+                }
+            }
+            catch (NodeException ne)
+            {
+            }
+        }
+        return requestPageTemplate;
+    }
+    
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/pipeline/valve/impl/PageValveImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/spaces/SpacesServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/spaces/SpacesServiceImpl.java?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/spaces/SpacesServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/spaces/SpacesServiceImpl.java
Wed Mar  3 07:10:38 2010
@@ -281,7 +281,7 @@
     {
     	try 
     	{
-			Space space = new SpaceImpl(pageManager.getFolder(makeSpacePath(spaceName)));
+			Space space = loadSpace(pageManager.getFolder(makeSpacePath(spaceName)));
 			return space;
 		} 
     	catch (FolderNotFoundException e) 
@@ -294,6 +294,26 @@
     	return null;
     }
     
+    public Space lookupUserSpace(String username)
+    {
+    	String spaceName = Folder.USER_FOLDER + username;
+    	try 
+    	{    		
+			Folder folder = pageManager.getFolder(makeSpacePath(spaceName));
+			Space space = loadSpace(folder);
+			return space;
+		} 
+    	catch (FolderNotFoundException e) 
+    	{
+		} 
+    	catch (Exception e) 
+    	{
+    		log.error("lookupSpace", e);        	
+		}
+    	return null;
+    }
+
+    
     public void addSpaceToEnvironment(Space space, Environment env) throws SpacesException
     {
 		try

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/spaces/Spaces.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/spaces/Spaces.java?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/spaces/Spaces.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/spaces/Spaces.java
Wed Mar  3 07:10:38 2010
@@ -74,7 +74,6 @@
      */
     Environment lookupEnvironment(String envName);
     
-    
     /**
      * Lists all unique spaces in the portal, regardless of environment
      *  
@@ -135,6 +134,13 @@
     Space lookupSpace(String spaceName);
     
     /**
+     * Retrieve the user space for a user
+     * @param username
+     * @return the user space for a user
+     */
+    Space lookupUserSpace(String username);
+    
+    /**
      * Adds a space to the list of spaces for the given environment
      * A space can exist in zero or more environments
      * 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml?rev=918341&r1=918340&r2=918341&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pipelines.xml
Wed Mar  3 07:10:38 2010
@@ -138,6 +138,16 @@
     </constructor-arg>
   </bean>
 
+  <bean id="pageValve" class="org.apache.jetspeed.pipeline.valve.impl.PageValveImpl" init-method="initialize">
+    <meta key="j2:cat" value="default" />
+    <constructor-arg index="0">
+      <ref bean="org.apache.jetspeed.page.PageManager" />
+    </constructor-arg>
+    <constructor-arg index="1">
+      <ref bean="org.apache.jetspeed.layout.PageLayoutComponent" />
+    </constructor-arg>
+	</bean>
+	
   <!-- 
     To create a new page when a user first logs in from their roles,
     add this valve after each profilerValve entry in the pipeline configs 
@@ -924,7 +934,7 @@
         <ref bean="localizationValve" />
         <ref bean="passwordCredentialValve" />
         <ref bean="loginValidationValve" />
-        <ref bean="profilerValve" />
+        <ref bean="pageValve" />
         <ref bean="refreshUserHomepageValve" />
         <!--
           JS2-806  



---------------------------------------------------------------------
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