You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2009/03/30 14:50:17 UTC

svn commit: r759948 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/ components/jetspeed-registry/src/ma...

Author: woonsan
Date: Mon Mar 30 12:50:16 2009
New Revision: 759948

URL: http://svn.apache.org/viewvc?rev=759948&view=rev
Log:
JS2-938: Fixes the local PA's context path.
Local portlet invoker sets the local context path to set the correct portal context path for the local PAs.
Also, renames the column name, 'CONTEXT_ROOT' of table 'PORTLET_APPLICATION' to 'CONTEXT_PATH'.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/JetspeedPortletInvokerService.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/LocalPortletInvoker.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml
    portals/jetspeed-2/portal/trunk/src/site/xdoc/guides/guide-migration.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/JetspeedPortletInvokerService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/JetspeedPortletInvokerService.java?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/JetspeedPortletInvokerService.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/JetspeedPortletInvokerService.java Mon Mar 30 12:50:16 2009
@@ -69,6 +69,7 @@
     public final static String DEFAULT_MAPPING_NAME = "/container";
     
     private ServletConfig servletConfig;
+    private PortalContext portalContext;
     private PortletFactory portletFactory;
     private ContainerRequestResponseUnwrapper requestResponseUnwrapper;
     private String servletMappingName;
@@ -82,6 +83,7 @@
                                          PortletFactory portletFactory, ContainerRequestResponseUnwrapper requestResponseUnwrapper)
     {
         this.servletConfig = servletConfig;
+        this.portalContext = portalContext;
         this.portletFactory = portletFactory;
         this.requestResponseUnwrapper = requestResponseUnwrapper;
         this.servletMappingName = portalContext.getConfigurationProperty(INVOKER_SERVLET_MAPPING_NAME, DEFAULT_MAPPING_NAME);
@@ -143,7 +145,7 @@
         PortletDefinition portletDefinition = (PortletDefinition)requestContext.getPortletWindow().getPortletEntity().getPortletDefinition();
         if (portletDefinition.getApplication().getApplicationType() == PortletApplication.LOCAL)
         {
-            invoker = new LocalPortletInvoker();
+            invoker = new LocalPortletInvoker(portalContext);
         }
         else
         {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/LocalPortletInvoker.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/LocalPortletInvoker.java?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/LocalPortletInvoker.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/invoker/LocalPortletInvoker.java Mon Mar 30 12:50:16 2009
@@ -31,11 +31,13 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.jetspeed.PortalContext;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.container.FilterManager;
 import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.factory.PortletFactory;
 import org.apache.jetspeed.factory.PortletInstance;
+import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
 import org.apache.jetspeed.request.JetspeedRequestContext;
@@ -60,14 +62,16 @@
  */
 public class LocalPortletInvoker implements JetspeedPortletInvoker
 {
+    protected PortalContext portalContext;
     protected PortletFactory portletFactory;
     protected ServletContext jetspeedContext;
     protected ServletConfig jetspeedConfig;
     protected PortletDefinition portletDefinition;
     protected boolean activated = false;
     
-    public LocalPortletInvoker()
+    public LocalPortletInvoker(PortalContext portalContext)
     {
+        this.portalContext = portalContext;
         activated = false;
     }
     
@@ -114,7 +118,10 @@
         
         PortletWindowImpl window = (PortletWindowImpl)requestContext.getPortletWindow();
         
-        ClassLoader paClassLoader = portletFactory.getPortletApplicationClassLoader(portletDefinition.getApplication());
+        PortletApplication pa = portletDefinition.getApplication();
+        pa.setLocalContextPath(portalContext.getContextPath());
+
+        ClassLoader paClassLoader = portletFactory.getPortletApplicationClassLoader(pa);
         PortletInstance portletInstance = portletFactory.getPortletInstance(jetspeedContext, portletDefinition);
         
         ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java Mon Mar 30 12:50:16 2009
@@ -45,7 +45,7 @@
  * PortletApplicationManager
  *
  * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
- * @version $Id: PortletApplicationManager.java,v 1.21 2005/04/09 00:24:44 shinsuke Exp $
+ * @version $Id$
  */
 public class PortletApplicationManager implements PortletApplicationManagement
 {
@@ -60,8 +60,6 @@
     protected PermissionManager     permissionManager;
     protected boolean               autoCreateRoles;
     protected List<String>          permissionRoles;
-    protected String                portalContextPath;
-    
     protected int  descriptorChangeMonitorInterval = DEFAULT_DESCRIPTOR_CHANGE_MONITOR_INTERVAL;
     /**
      * holds the max number of retries in case of unsuccessful PA start
@@ -75,30 +73,24 @@
     protected JetspeedDescriptorService descriptorService;
     
     /**
-	 * Creates a new PortletApplicationManager object.
-	 */
-	public PortletApplicationManager(PortletFactory portletFactory, PortletRegistry registry,
+     * Creates a new PortletApplicationManager object.
+     */
+    public PortletApplicationManager(PortletFactory portletFactory, PortletRegistry registry,
         PermissionManager permissionManager, SearchEngine searchEngine,
         RoleManager roleManager, List<String> permissionRoles, NodeManager nodeManager, String appRoot,
         JetspeedDescriptorService descriptorService)
-	{
-		this.portletFactory     = portletFactory;
-		this.registry		    = registry;
+    {
+        this.portletFactory     = portletFactory;
+        this.registry           = registry;
         this.permissionManager  = permissionManager;
         this.searchEngine       = searchEngine;
         this.roleManager        = roleManager;        
         this.permissionRoles    = permissionRoles;
-        this.nodeManager		= nodeManager;
+        this.nodeManager        = nodeManager;
         this.appRoot            = appRoot;
         this.descriptorService  = descriptorService;
-        portalContextPath  = appRoot.replace('\\','/');
-        if (portalContextPath.endsWith("/"))
-        {
-            portalContextPath = portalContextPath.substring(0, portalContextPath.length()-1 );
-        }
-        portalContextPath = portalContextPath.substring(portalContextPath.lastIndexOf('/'));
-	}
-	
+    }
+    
     public void start()
     {
         if ( descriptorChangeMonitorInterval > 0 )
@@ -147,10 +139,10 @@
         this.autoCreateRoles = autoCreateRoles;
     }
 
-	public void setSearchEngine(SearchEngine searchEngine)
-	{
-		this.searchEngine = searchEngine;
-	}
+    public void setSearchEngine(SearchEngine searchEngine)
+    {
+        this.searchEngine = searchEngine;
+    }
     
     protected void checkStarted()
     {
@@ -160,21 +152,21 @@
         }
     }
 
-	public void startLocalPortletApplication(String contextName, FileSystemHelper warStruct,
-		ClassLoader paClassLoader)
-		throws RegistryException
-	{
+    public void startLocalPortletApplication(String contextName, FileSystemHelper warStruct,
+        ClassLoader paClassLoader)
+        throws RegistryException
+    {
         checkStarted();
-        startPA(contextName, portalContextPath, warStruct, paClassLoader, PortletApplication.LOCAL);
-	}
+        startPA(contextName, "/"+contextName, warStruct, paClassLoader, PortletApplication.LOCAL);
+    }
 
-	public void startPortletApplication(String contextName, FileSystemHelper warStruct,
-		ClassLoader paClassLoader)
-		throws RegistryException
-	{
+    public void startPortletApplication(String contextName, FileSystemHelper warStruct,
+        ClassLoader paClassLoader)
+        throws RegistryException
+    {
          startPortletApplication(contextName, "/"+contextName, warStruct, paClassLoader);
-	}
-	
+    }
+    
     public void startPortletApplication(String contextName, String contextPath, FileSystemHelper warStruct,
             ClassLoader paClassLoader) throws RegistryException
     {
@@ -192,15 +184,15 @@
         
     }    
 
-	public void stopLocalPortletApplication(String contextName)
-		throws RegistryException
-	{
-		stopPA(contextName, PortletApplication.LOCAL);
-	}
-
-	public void stopPortletApplication(String contextName)
-		throws RegistryException
-	{
+    public void stopLocalPortletApplication(String contextName)
+        throws RegistryException
+    {
+        stopPA(contextName, PortletApplication.LOCAL);
+    }
+
+    public void stopPortletApplication(String contextName)
+        throws RegistryException
+    {
         ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
         try
@@ -211,11 +203,11 @@
         {
             Thread.currentThread().setContextClassLoader(contextClassLoader);
         }
-	}
+    }
 
-	public void unregisterPortletApplication(String paName)
-		throws RegistryException
-	{
+    public void unregisterPortletApplication(String paName)
+        throws RegistryException
+    {
         ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
         Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
         try
@@ -247,7 +239,7 @@
                 }
                 catch (Exception ee)
                 {
-                	// we actually do not care about an exception in the remove operation...
+                    // we actually do not care about an exception in the remove operation...
                 }
             }
         }
@@ -255,80 +247,85 @@
         {
             Thread.currentThread().setContextClassLoader(contextClassLoader);
         }
-	}
+    }
     
-	protected void checkValidContextName(String contextName, boolean local)
-		throws RegistryException
-	{
-		int prefixLength = LOCAL_PA_PREFIX.length();
-
-		if ((contextName.length() >= prefixLength)
-			&& contextName.substring(0, prefixLength).equalsIgnoreCase(LOCAL_PA_PREFIX))
-		{
-			if (!local)
-			{
-				throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
-					+ "\" is reserved for Local Portlet Applications only.");
-			}
-		}
-		else if (local)
-		{
-			throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
-				+ "\" is required for Local Portlet Applications.");
-		}
-	}
-
-	protected PortletApplication registerPortletApplication(PortletApplicationWar paWar,
-		PortletApplication oldPA, int paType, ClassLoader paClassLoader)
-		throws RegistryException
-	{
-	    long revision = 0;
-		if (oldPA != null)
-		{
-		    revision = oldPA.getRevision();
-			unregisterPortletApplication(oldPA, false);
-			oldPA = null;
-		}
-
-		PortletApplication pa		 = null;
-		boolean					  registered = false;
-		String					  paName     = paWar.getPortletApplicationName();
+    protected void checkValidContextName(String contextName, boolean local)
+        throws RegistryException
+    {
+        int prefixLength = LOCAL_PA_PREFIX.length();
+
+        if ((contextName.length() >= prefixLength)
+            && contextName.substring(0, prefixLength).equalsIgnoreCase(LOCAL_PA_PREFIX))
+        {
+            if (!local)
+            {
+                throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
+                    + "\" is reserved for Local Portlet Applications only.");
+            }
+        }
+        else if (local)
+        {
+            throw new RegistryException("Prefix \"" + LOCAL_PA_PREFIX
+                + "\" is required for Local Portlet Applications.");
+        }
+    }
 
-		try
-		{
+    protected PortletApplication registerPortletApplication(PortletApplicationWar paWar,
+        PortletApplication oldPA, int paType, ClassLoader paClassLoader)
+        throws RegistryException
+    {
+        long revision = 0;
+        if (oldPA != null)
+        {
+            revision = oldPA.getRevision();
+            unregisterPortletApplication(oldPA, false);
+            oldPA = null;
+        }
+
+        PortletApplication pa        = null;
+        boolean                   registered = false;
+        String                    paName     = paWar.getPortletApplicationName();
+
+        try
+        {
             log.info("Loading deployment descriptors for "+paName+" ....");
-			pa = paWar.createPortletApp(paClassLoader);
+            pa = paWar.createPortletApp(paClassLoader);
             pa.setApplicationType(paType);
-			if (revision > 0)
-			{
-			    pa.setRevision(revision);
-			}
-		}
-		catch (Exception e)
-		{
-			String msg = "Failed to load portlet application for "
-				+ paWar.getPortletApplicationName();
-			log.error(msg, e);
-			throw new RegistryException(msg);
-		}
-
-		// register the portlet application
-		try
-		{
-			registry.registerPortletApplication(pa);
-			registered = true;
-			log.info("Registered the portlet application " + paName);
-
-			// add to search engine result
-			this.updateSearchEngine(false, pa);
-			
-			// and add to the current node info
+            if (revision > 0)
+            {
+                pa.setRevision(revision);
+            }
+
+            if (paType == PortletApplication.LOCAL)
+            {
+                pa.setContextPath("<portal>");
+            }
+        }
+        catch (Exception e)
+        {
+            String msg = "Failed to load portlet application for "
+                + paWar.getPortletApplicationName();
+            log.error(msg, e);
+            throw new RegistryException(msg);
+        }
+
+        // register the portlet application
+        try
+        {
+            registry.registerPortletApplication(pa);
+            registered = true;
+            log.info("Registered the portlet application " + paName);
+
+            // add to search engine result
+            this.updateSearchEngine(false, pa);
+            
+            // and add to the current node info
             if (nodeManager != null)
             {            
                 nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
             }
             // grant default permissions to portlet application
-			grantDefaultPermissions(paName);
+            grantDefaultPermissions(paName);
             
             if ( autoCreateRoles && roleManager != null && pa.getSecurityRoles() != null )
             {
@@ -347,40 +344,40 @@
                 }
             }
 
-			return pa;
-		}
-		catch (Exception e)
-		{
-			String msg = "Failed to register portlet application, " + paName;
-			log.error(msg, e);
-
-			if (registered)
-			{
-				try
-				{
-					unregisterPortletApplication(pa, (paType == PortletApplication.LOCAL));
-				}
-				catch (Exception re)
-				{
-					log.error("Failed to rollback registration of portlet application " + paName, re);
-				}
-			}
-
-			throw new RegistryException(msg, e);
-		}
-	}
-
-	protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
-	        ClassLoader paClassLoader, int paType)
-	throws RegistryException
-	{
-	    startPA(contextName, contextPath, warStruct, paClassLoader, paType, 0);
-	}
-	
-	protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
-	        ClassLoader paClassLoader, int paType, long checksum)
-	throws RegistryException
-	{
+            return pa;
+        }
+        catch (Exception e)
+        {
+            String msg = "Failed to register portlet application, " + paName;
+            log.error(msg, e);
+
+            if (registered)
+            {
+                try
+                {
+                    unregisterPortletApplication(pa, (paType == PortletApplication.LOCAL));
+                }
+                catch (Exception re)
+                {
+                    log.error("Failed to rollback registration of portlet application " + paName, re);
+                }
+            }
+
+            throw new RegistryException(msg, e);
+        }
+    }
+
+    protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
+            ClassLoader paClassLoader, int paType)
+    throws RegistryException
+    {
+        startPA(contextName, contextPath, warStruct, paClassLoader, paType, 0);
+    }
+    
+    protected void startPA(String contextName, String contextPath, FileSystemHelper warStruct,
+            ClassLoader paClassLoader, int paType, long checksum)
+    throws RegistryException
+    {
         boolean register = true;
         boolean monitored = false;
         DescriptorChangeMonitor changeMonitor = this.monitor;
@@ -393,8 +390,8 @@
             log.debug("Is portlet application " + contextName + " monitored? -> " + monitored);
         }
         PortletApplicationWar paWar = null;
-		try
-		{
+        try
+        {
             if (log.isDebugEnabled())
             {
                 log.debug("Try to start portlet application " + contextName + ".");
@@ -428,15 +425,15 @@
                 register = false;
             }
 
-			// try to get the PA from database by context name
-			PortletApplication pa = registry.getPortletApplication(contextName);
+            // try to get the PA from database by context name
+            PortletApplication pa = registry.getPortletApplication(contextName);
 
             if (pa != null)
             {
                 if (log.isDebugEnabled())
                 {
                     log.debug("Portlet Application " + contextName + " found in registry.");
-            	}
+                }
                 if ( pa.getApplicationType() != paType )
                 {
                     throw new RegistryException("Cannot start portlet application "+contextName+": as Application Types don't match: " + pa.getApplicationType() + " != " + paType);
@@ -454,125 +451,125 @@
 //            if (register && (pa == null || checksum != pa.getChecksum()))
             if (register)
             {
-            	if (pa == null)
-            	{ 
-            		// new
-	                try
-	                {
-	                    if (log.isDebugEnabled())
-                        {
-	                        log.debug("Register new portlet application " + contextName + ".");
-                        }
-	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
-	                }
-	                catch (Exception e)
-	                {
-	                    String msg = "Error register new portlet application " + contextName + ".";
-	                	
-	                    if (log.isDebugEnabled())
-	                	{
-	                	    log.debug(msg);
-	                	}
-                    	throw new RegistryException(msg);
-	                    
-	                }
-            	}
-            	else
-            	{
+                if (pa == null)
+                { 
+                    // new
+                    try
+                    {
+                        if (log.isDebugEnabled())
+                        {
+                            log.debug("Register new portlet application " + contextName + ".");
+                        }
+                        pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
+                    }
+                    catch (Exception e)
+                    {
+                        String msg = "Error register new portlet application " + contextName + ".";
+                        
+                        if (log.isDebugEnabled())
+                        {
+                            log.debug(msg);
+                        }
+                        throw new RegistryException(msg);
+                        
+                    }
+                }
+                else
+                {
                     if (log.isDebugEnabled())
                     {
                         log.debug("Re-register existing portlet application " + contextName + ".");
                     }
-            		int status = nodeManager.checkNode(new Long(pa.getRevision()), pa.getName());
-        			boolean reregister = false;
-        			boolean deploy = false;
-        			switch (status)
-        			{
-        				case  NodeManager.NODE_NEW:
-        				{
+                    int status = nodeManager.checkNode(new Long(pa.getRevision()), pa.getName());
+                    boolean reregister = false;
+                    boolean deploy = false;
+                    switch (status)
+                    {
+                        case  NodeManager.NODE_NEW:
+                        {
                             if (log.isDebugEnabled())
                             {
                                 log.debug("Node for Portlet application " + contextName + " is NEW.");
                             }
-            				//only reason is that the file got somehow corrupted 
-            				// so we really do not know what is going on here...
-            				// the best chance at this point is to reregister (which might be the absolute wrong choice)
-            				log.warn("The portlet application " + pa.getName() + " is registered in the database but not locally .... we will reregister");
-            				reregister = true;
-        					if (checksum != pa.getChecksum())
-        					{
-        					    log.warn("The provided portlet application " + pa.getName() + " is a different version than in the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will redeploy (also to the database)");
-    							deploy = true;
-        					}
-        					break;
-        				}
-        				case  NodeManager.NODE_SAVED:
-        				{
+                            //only reason is that the file got somehow corrupted 
+                            // so we really do not know what is going on here...
+                            // the best chance at this point is to reregister (which might be the absolute wrong choice)
+                            log.warn("The portlet application " + pa.getName() + " is registered in the database but not locally .... we will reregister");
+                            reregister = true;
+                            if (checksum != pa.getChecksum())
+                            {
+                                log.warn("The provided portlet application " + pa.getName() + " is a different version than in the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will redeploy (also to the database)");
+                                deploy = true;
+                            }
+                            break;
+                        }
+                        case  NodeManager.NODE_SAVED:
+                        {
                             if (log.isDebugEnabled())
                             {
                                 log.debug("Node for Portlet application " + contextName + " is SAVED.");
                             }
-        					if (checksum != pa.getChecksum())
-                    		{	
-        					    log.warn("The provided portlet application " + pa.getName() + " is a different version than in the local node info and the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will reregister AND redeploy (also to the database)");
-        						//database and local node info are in synch, so we assume that this is a brand new
-        						// war .... let's deploy
-        						reregister = true;
-        						deploy = true;
-                    		}
-        					break;
-        				}
-        				case  NodeManager.NODE_OUTDATED:
-        				{
+                            if (checksum != pa.getChecksum())
+                            {   
+                                log.warn("The provided portlet application " + pa.getName() + " is a different version than in the local node info and the database (db-checksum=" + pa.getChecksum() + ", local-checksum=: " + checksum + ") .... we will reregister AND redeploy (also to the database)");
+                                //database and local node info are in synch, so we assume that this is a brand new
+                                // war .... let's deploy
+                                reregister = true;
+                                deploy = true;
+                            }
+                            break;
+                        }
+                        case  NodeManager.NODE_OUTDATED:
+                        {
                             // new version in database, maybe changed by a different cluster node
-        				    if (log.isDebugEnabled())
-        				    {
-        				        log.debug("Node for Portlet application " + contextName + " is OUTDATED (local PA.id < DB PA.id).");
-        				    }
-            				//database version is older (determined by id) than the database 
-        					//let's deploy and reregister
-        				    if (checksum != pa.getChecksum())
-        				    {
-        					    log.error("The portlet application " + pa.getName() + " provided for the upgrade IS WRONG. The database checksum= " + pa.getChecksum() + ", but the local=" + checksum + "....THIS NEEDS TO BE CORRECTED");
-        					    // if the checksums do not match make sure the database is updated with the new PA from file system
-        					    // I've observed "unavailable PA" in clustered env for the cluster node that reported OUTDATED state
-        					    deploy = true;
-        					}
-        				    reregister = true;
-        				    break;
-        				}
-        			}
-        			if (deploy)
-        			{
-        			    if (log.isDebugEnabled())
-        			    {
-        			        log.debug("Register (deploy=true) Portlet application " + contextName + " in database.");
-                        }
-	                    pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
-        			}
-        			else
-        				if (reregister)
-        				{
+                            if (log.isDebugEnabled())
+                            {
+                                log.debug("Node for Portlet application " + contextName + " is OUTDATED (local PA.id < DB PA.id).");
+                            }
+                            //database version is older (determined by id) than the database 
+                            //let's deploy and reregister
+                            if (checksum != pa.getChecksum())
+                            {
+                                log.error("The portlet application " + pa.getName() + " provided for the upgrade IS WRONG. The database checksum= " + pa.getChecksum() + ", but the local=" + checksum + "....THIS NEEDS TO BE CORRECTED");
+                                // if the checksums do not match make sure the database is updated with the new PA from file system
+                                // I've observed "unavailable PA" in clustered env for the cluster node that reported OUTDATED state
+                                deploy = true;
+                            }
+                            reregister = true;
+                            break;
+                        }
+                    }
+                    if (deploy)
+                    {
+                        if (log.isDebugEnabled())
+                        {
+                            log.debug("Register (deploy=true) Portlet application " + contextName + " in database.");
+                        }
+                        pa = registerPortletApplication(paWar, pa, paType, paClassLoader);
+                    }
+                    else
+                        if (reregister)
+                        {
                             if (log.isDebugEnabled())
                             {
                                 log.debug("Re-Register (reregister=true) Portlet application " + contextName + ".");
                             }
-        					// add to search engine result
-        					this.updateSearchEngine(true, pa);
-        					this.updateSearchEngine(false, pa);
-        					
-        					// and add to the current node info
-        					try
-        					{
-        						nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
-        					} catch (Exception e)
-        					{
-        					    log.error("Adding node for portlet application " + pa.getName() + " caused exception" , e);
-        					}
-        				}
-        				
-            	
-            	}
+                            // add to search engine result
+                            this.updateSearchEngine(true, pa);
+                            this.updateSearchEngine(false, pa);
+                            
+                            // and add to the current node info
+                            try
+                            {
+                                nodeManager.addNode(new Long(pa.getRevision()), pa.getName());
+                            } catch (Exception e)
+                            {
+                                log.error("Adding node for portlet application " + pa.getName() + " caused exception" , e);
+                            }
+                        }
+                        
+                
+                }
             }
             if (register)
             {
@@ -591,7 +588,7 @@
                 }
                 changeMonitor.monitor(contextName, contextPath, paClassLoader, paType, warStruct.getRootDirectory(), checksum);
             }
-		}
+        }
         catch (Exception e)
         {
             String msg = "Error starting portlet application " + contextName;
@@ -611,12 +608,12 @@
             }
             throw new RegistryException(msg);
         }
-	}
+    }
 
-	protected void stopPA(String contextName, int paType)
-		throws RegistryException
-	{
-		PortletApplication pa = null;
+    protected void stopPA(String contextName, int paType)
+        throws RegistryException
+    {
+        PortletApplication pa = null;
         
         try
         {
@@ -635,45 +632,45 @@
         {
             monitor.remove(contextName);
         }
-		if (pa != null)
-		{
+        if (pa != null)
+        {
             portletFactory.unregisterPortletApplication(pa);
-		}
-	}
+        }
+    }
 
-	
-	protected void updateSearchEngine(boolean remove,PortletApplication pa )
-	{
-		if (searchEngine != null)
-		{
-			if (remove)
-			{
-				searchEngine.remove(pa);
-				searchEngine.remove(pa.getPortlets());
-				log.info("Un-Registered the portlet application in the search engine... " + pa.getName());
-			}
-			else
-			{
-			    searchEngine.add(pa);
+    
+    protected void updateSearchEngine(boolean remove,PortletApplication pa )
+    {
+        if (searchEngine != null)
+        {
+            if (remove)
+            {
+                searchEngine.remove(pa);
+                searchEngine.remove(pa.getPortlets());
+                log.info("Un-Registered the portlet application in the search engine... " + pa.getName());
+            }
+            else
+            {
+                searchEngine.add(pa);
                 searchEngine.add(pa.getPortlets());
                 log.info("Registered the portlet application in the search engine... " + pa.getName());
-			}
-		}
-		
-	}
-	protected void unregisterPortletApplication(PortletApplication pa,
-		boolean purgeEntityInfo)
-		throws RegistryException
-	{
+            }
+        }
+        
+    }
+    protected void unregisterPortletApplication(PortletApplication pa,
+        boolean purgeEntityInfo)
+        throws RegistryException
+    {
 
-		updateSearchEngine(true,pa);
+        updateSearchEngine(true,pa);
         // TODO: PortletDefinition cache invalidation?
-//		log.info("Remove all registry entries defined for portlet application " + pa.getName());
+//      log.info("Remove all registry entries defined for portlet application " + pa.getName());
 
-		// todo keep (User)Prefs?
-		registry.removeApplication(pa);
+        // todo keep (User)Prefs?
+        registry.removeApplication(pa);
         revokeDefaultPermissions(pa.getName());
-	}
+    }
     
     protected void grantDefaultPermissions(String paName)
     {
@@ -817,16 +814,16 @@
                         descriptorModificationTime = newDescriptorModificationTime;
                         extendedDescriptorModificationTime = newExtendedDescriptorModificationTime;
                         long newChecksum = MultiFileChecksumHelper.getChecksum(descriptors);
-                    	if (log.isDebugEnabled())
+                        if (log.isDebugEnabled())
                         {
-                    		log.debug("checksum check for descriptors for application " + contextName + ": old (" + checksum + ") new (" + newChecksum + ").");
-                    	}
+                            log.debug("checksum check for descriptors for application " + contextName + ": old (" + checksum + ") new (" + newChecksum + ").");
+                        }
                         if ( checksum != newChecksum )
                         {
-                        	if (log.isDebugEnabled())
+                            if (log.isDebugEnabled())
                             {
-                        		log.debug("portlet descriptors for application " + contextName + " have changed.");
-                        	}
+                                log.debug("portlet descriptors for application " + contextName + " have changed.");
+                            }
                             checksum = newChecksum;
                             // reset this to restart unsuccessful PA start handling for evers PA descriptor change
                             unsuccessfulStarts = 0;
@@ -949,11 +946,11 @@
         
         public boolean isMonitored(String contextName)
         {
-        	DescriptorChangeMonitorInfo monitorInfo = this.get(contextName);
-        	if (monitorInfo != null && !monitorInfo.isObsolete())
+            DescriptorChangeMonitorInfo monitorInfo = this.get(contextName);
+            if (monitorInfo != null && !monitorInfo.isObsolete())
             {
-        		return true;
-        	}
+                return true;
+            }
             return false;
         }
         
@@ -961,10 +958,10 @@
         {
             int size = monitorInfos.size();
 
-        	if (log.isDebugEnabled())
+            if (log.isDebugEnabled())
             {
-        		log.debug("check for portlet application descriptor changes.");
-        	}
+                log.debug("check for portlet application descriptor changes.");
+            }
             
             for (int i = size-1; i > -1; i--)
             {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/JETSPEED-INF/ojb/registry_repository.xml Mon Mar 30 12:50:16 2009
@@ -146,7 +146,7 @@
       />
       <field-descriptor
          name="contextPath"
-         column="CONTEXT_ROOT"
+         column="CONTEXT_PATH"
          jdbc-type="VARCHAR"
       />
 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletApplicationDefinitionImpl.java Mon Mar 30 12:50:16 2009
@@ -124,6 +124,8 @@
     private transient Set<String> servletMappingURLPatterns;
     private transient Map<Locale, String> localeEncodingMappings;
     
+    private transient String localContextPath;
+    
     /** Creates a new instance of BaseApplication */
     public PortletApplicationDefinitionImpl()
     {
@@ -209,7 +211,14 @@
     
     public String getContextPath()
     {
-        return contextPath;
+        if (applicationType == PortletApplication.LOCAL && localContextPath != null)
+        {
+            return localContextPath;
+        }
+        else
+        {
+            return contextPath;
+        }
     }
     
     public String getDefaultNamespace()
@@ -1021,4 +1030,14 @@
     {
         revision++;
     }
+
+    public String getLocalContextPath()
+    {
+        return localContextPath;
+    }
+
+    public void setLocalContextPath(String localContextPath)
+    {
+        this.localContextPath = localContextPath;
+    }
 }

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletApplication.java Mon Mar 30 12:50:16 2009
@@ -203,4 +203,18 @@
      * @return true when this app is a Jetspeed layout application
      */
     boolean isLayoutApplication();    
+
+    /**
+     * Returns the context path of local portlet application.
+     * If the application is not local, then returns null.
+     * @return
+     */
+    String getLocalContextPath();
+    
+    /**
+     * Sets the context path of local portlet application.
+     * @param localContextPath
+     */
+    void setLocalContextPath(String localContextPath);
+
 }

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/ddl-schema/registry-schema.xml Mon Mar 30 12:50:16 2009
@@ -40,7 +40,7 @@
     <table name="PORTLET_APPLICATION">
         <column name="APPLICATION_ID" primaryKey="true" required="true" type="INTEGER"/>
         <column name="APP_NAME" required="true" size="80" type="VARCHAR"/>
-        <column name="CONTEXT_ROOT" required="true" size="255" type="VARCHAR"/>
+        <column name="CONTEXT_PATH" required="true" size="255" type="VARCHAR"/>
         <column name="REVISION" required="true" type="INTEGER"/>
         <column name="VERSION" size="80" type="VARCHAR"/>
         <column name="APP_TYPE" type="INTEGER"/>

Modified: portals/jetspeed-2/portal/trunk/src/site/xdoc/guides/guide-migration.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/src/site/xdoc/guides/guide-migration.xml?rev=759948&r1=759947&r2=759948&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/src/site/xdoc/guides/guide-migration.xml (original)
+++ portals/jetspeed-2/portal/trunk/src/site/xdoc/guides/guide-migration.xml Mon Mar 30 12:50:16 2009
@@ -238,6 +238,20 @@
               <td></td>
               <td>BOOLEANINT, Required</td>
             </tr>
+            <tr>
+              <td>PORTLET_APPLICATION</td>
+              <td>CONTEXT_ROOT</td>
+              <td>DROP</td>
+              <td>VARCHAR(255), Required</td>
+              <td></td>
+            </tr>
+            <tr>
+              <td>PORTLET_APPLICATION</td>
+              <td>CONTEXT_PATH</td>
+              <td>ADD</td>
+              <td></td>
+              <td>VARCHAR(255), Required</td>
+            </tr>
           </table>
         </subsection>
         <subsection name="Added Indexes">



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