weaver 2004/07/09 11:28:58
Modified: portal/src/java/org/apache/jetspeed/tools/pamanager
ApplicationServerPAM.java Deployment.java
PortletApplicationManager.java FileSystemPAM.java
PortletApplicationManagement.java
Log:
Added redploy logic
removed vfs
Revision Changes Path
1.2 +34 -5
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java
Index: ApplicationServerPAM.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/ApplicationServerPAM.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ApplicationServerPAM.java 2 Jul 2004 14:23:53 -0000 1.1
+++ ApplicationServerPAM.java 9 Jul 2004 18:28:57 -0000 1.2
@@ -17,7 +17,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs.FileSystemManager;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
@@ -56,9 +55,9 @@
* @param entityAccess
* @param appServerManager
*/
- public ApplicationServerPAM( String webAppsDir, PortletRegistryComponent
registry, FileSystemManager fsManager, PortletEntityAccessComponent entityAccess,
PortletWindowAccessor windowAccess, ApplicationServerManager appServerManager )
- {
- super(webAppsDir, registry, fsManager, entityAccess, windowAccess);
+ public ApplicationServerPAM( String webAppsDir, PortletRegistryComponent
registry, PortletEntityAccessComponent entityAccess, PortletWindowAccessor
windowAccess, ApplicationServerManager appServerManager )
+ {
+ super(webAppsDir, registry, entityAccess, windowAccess);
ArgUtil.assertNotNull(ApplicationServerManager.class, appServerManager,
this);
this.appServerManager = appServerManager;
}
@@ -248,5 +247,35 @@
private boolean isServerAvailable()
{
return appServerManager.isConnected();
+ }
+ /**
+ * <p>
+ * redeploy
+ * </p>
+ *
+ * @see
org.apache.jetspeed.tools.pamanager.Deployment#redeploy(org.apache.jetspeed.util.descriptor.PortletApplicationWar)
+ * @param paWar
+ * @throws PortletApplicationException
+ */
+ public void redeploy( PortletApplicationWar paWar ) throws
PortletApplicationException
+ {
+ try
+ {
+ super.redeploy(paWar);
+ String paName = paWar.getPortletApplicationName();
+ if(isServerAvailable())
+ {
+ checkResponse(appServerManager.reload("/" + paName));
+ }
+
+ }
+ catch (PortletApplicationException pe)
+ {
+ throw pe;
+ }
+ catch (Exception e)
+ {
+ throw new PortletApplicationException(e);
+ }
}
}
1.7 +4 -1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Deployment.java
Index: Deployment.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/Deployment.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Deployment.java 2 Jul 2004 14:25:37 -0000 1.6
+++ Deployment.java 9 Jul 2004 18:28:57 -0000 1.7
@@ -50,6 +50,9 @@
throws PortletApplicationException;
String getDeploymentPath(String webAppName);
+
+ public void redeploy(PortletApplicationWar paWar)
+ throws PortletApplicationException;
}
1.15 +25 -11
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java
Index: PortletApplicationManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- PortletApplicationManager.java 2 Jul 2004 14:28:08 -0000 1.14
+++ PortletApplicationManager.java 9 Jul 2004 18:28:57 -0000 1.15
@@ -28,12 +28,16 @@
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs.VFS;
import org.apache.jetspeed.Jetspeed;
import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
+import org.apache.jetspeed.deployment.impl.FileNotDeployableException;
+import org.apache.jetspeed.deployment.impl.StandardDeploymentObject;
import org.apache.jetspeed.engine.Engine;
import org.apache.jetspeed.engine.JetspeedEngineConstants;
import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.util.DirectoryHelper;
+import org.apache.jetspeed.util.FileSystemHelper;
+import org.apache.jetspeed.util.JarHelper;
import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
/**
@@ -434,16 +438,20 @@
* @param portletApplicationName The Portlet Application name
* @throws PortletApplicationException
* @throws IOException
+ * @throws FileNotDeployableException
*/
public static void register(Registration registrator,
String portletApplicationName,
String warFile)
- throws PortletApplicationException, IOException
+ throws PortletApplicationException, FileNotDeployableException, IOException
{
- System.out.println("Registering Portlet Application [" +
portletApplicationName + "]...");
- registrator.register(new PortletApplicationWar(warFile,
portletApplicationName, "/"+portletApplicationName, VFS.getManager()) );
- System.out.println("...PAM Register done");
+ System.out.println("Registering Portlet Application [" +
portletApplicationName + "]...");
+
+ StandardDeploymentObject deploymentObject = new
StandardDeploymentObject(new File(warFile));
+ registrator.register(new
PortletApplicationWar(deploymentObject.getFileObject(), portletApplicationName,
"/"+portletApplicationName ) );
+ System.out.println("...PAM Register done");
+ deploymentObject.close();
}
/**
@@ -471,17 +479,22 @@
* @param warFile The warFile containing the Portlet Application
* @param portletApplicationName The Portlet Application name
* @throws PortletApplicationException
+ * @throws IOException
+ * @throws FileNotDeployableException
*/
public static void deploy(Deployment deployer,
String webAppsDir,
String warFile,
String portletApplicationName)
- throws PortletApplicationException, IOException
+ throws PortletApplicationException, FileNotDeployableException, IOException
{
System.out.println("Deploying Web Application [" + webAppsDir + "] to
Portlet Application [" + portletApplicationName + "]...");
- deployer.deploy(new PortletApplicationWar(warFile, portletApplicationName,
"/"+portletApplicationName, VFS.getManager()));
- System.out.println("...PAM Deploy done");
+
+ StandardDeploymentObject deploymentObject = new
StandardDeploymentObject(new File(warFile));
+ deployer.deploy(new PortletApplicationWar(deploymentObject.getFileObject(),
portletApplicationName, "/"+portletApplicationName));
+ System.out.println("...PAM Deploy done");
+ deploymentObject.close();
}
/**
@@ -507,7 +520,8 @@
System.out.println("Un-deploying Web Application [" + webApplicationName +
"], Portlet Application [" + portletApplicationName + "]...");
String webAppPath = deployer.getDeploymentPath(webApplicationName);
- deployer.undeploy(new PortletApplicationWar(webAppPath,
portletApplicationName, "/"+portletApplicationName, VFS.getManager() ));
+ File warFile = new File(webAppPath);
+ deployer.undeploy(new PortletApplicationWar(new DirectoryHelper(warFile),
portletApplicationName, "/"+portletApplicationName));
System.out.println("...PAM Undeploy done");
}
1.35 +102 -22
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java
Index: FileSystemPAM.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/FileSystemPAM.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- FileSystemPAM.java 2 Jul 2004 14:26:28 -0000 1.34
+++ FileSystemPAM.java 9 Jul 2004 18:28:58 -0000 1.35
@@ -15,13 +15,15 @@
*/
package org.apache.jetspeed.tools.pamanager;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
+import java.util.prefs.Preferences;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.commons.vfs.FileSystemManager;
+import org.apache.jetspeed.cache.PortletCache;
import org.apache.jetspeed.components.persistence.store.PersistenceStore;
import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
import org.apache.jetspeed.components.portletregistry.PortletRegistryComponent;
@@ -29,15 +31,18 @@
import org.apache.jetspeed.container.JetspeedPortletContext;
import org.apache.jetspeed.container.window.PortletWindowAccessor;
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.MutablePortletEntity;
import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
import org.apache.jetspeed.util.ArgUtil;
+import org.apache.jetspeed.util.DirectoryHelper;
import org.apache.jetspeed.util.descriptor.PortletApplicationWar;
import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.entity.PortletEntityCtrl;
import org.apache.pluto.om.portlet.PortletDefinition;
/**
- * This is the catalina specific implemenation for deplyment of Portlet
- * Applications.
+ * This PAM is the base class for most other PAM implementations. Does most of
+ * the registry and file system clean for you.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Roger Ruttimann </a>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver </a>
@@ -58,23 +63,20 @@
//private DeployUtilities util;
protected PortletRegistryComponent registry;
- private String vfsConfigUri = null;
protected String webAppsDir;
- protected FileSystemManager fsManager;
protected PortletEntityAccessComponent entityAccess;
protected PortletWindowAccessor windowAccess;
- public FileSystemPAM( String webAppsDir, PortletRegistryComponent registry,
FileSystemManager fsManager,
+ public FileSystemPAM( String webAppsDir, PortletRegistryComponent registry,
PortletEntityAccessComponent entityAccess, PortletWindowAccessor
windowAccess )
{
super();
ArgUtil.assertNotNull(PortletRegistryComponent.class, registry, this);
- ArgUtil.assertNotNull(FileSystemManager.class, fsManager, this);
ArgUtil.assertNotNull(PortletEntityAccessComponent.class, entityAccess,
this);
this.registry = registry;
this.entityAccess = entityAccess;
this.webAppsDir = webAppsDir;
- this.fsManager = fsManager;
+
this.windowAccess = windowAccess;
}
@@ -111,6 +113,20 @@
public void unregister( String paName ) throws PortletApplicationException
{
+ doUnregister(paName, true);
+
+ }
+
+ /**
+ * <p>
+ * doUnregister
+ * </p>
+ *
+ * @param paName
+ * @throws PortletApplicationException
+ */
+ protected void doUnregister( String paName, boolean purgeEntityInfo ) throws
PortletApplicationException
+ {
PersistenceStore store = registry.getPersistenceStore();
try
@@ -124,20 +140,28 @@
return;
}
+ log.info("Removing a portlets from the PortletCache that belong to
portlet application " + paName);
+ PortletCache.removeAll(app);
+
// remove entries from the registry
log.info("Remove all registry entries defined for portlet application "
+ paName);
-
+
Iterator portlets = app.getPortletDefinitions().iterator();
-
- while(portlets.hasNext())
- {
+
+ while (portlets.hasNext())
+ {
PortletDefinition portletDefinition = (PortletDefinition)
portlets.next();
Iterator entities =
entityAccess.getPortletEntities(portletDefinition).iterator();
- while(entities.hasNext())
+ while (entities.hasNext())
{
PortletEntity entity = (PortletEntity) entities.next();
+ if(purgeEntityInfo)
+ {
+ entityAccess.removePortletEntity(entity);
+ }
+ entityAccess.removeFromCache(entity);
windowAccess.removeWindows(entity);
- entityAccess.removePortletEntity(entity);
+
}
}
@@ -152,7 +176,6 @@
throw new PortletApplicationException(re.getMessage());
}
-
}
/**
@@ -365,14 +388,10 @@
log.info("Rollback: Remove " + portletAppDir + " and all
sub-directories.");
- paWar = new PortletApplicationWar(portletAppDir, paName, "/" + paName,
this.fsManager);
- paWar.removeWar();
+ DirectoryHelper dirHelper = new DirectoryHelper(new
File(portletAppDir));
+ dirHelper.remove();
}
- catch (FileNotFoundException fnfe)
- {
- log.warn(portletAppDir + " could not be found, skipping deletion.",
fnfe);
- }
catch (Exception e)
{
log.error("Error removing file system deployment artifacts: " +
e.toString(), e);
@@ -439,6 +458,67 @@
else
{
return webAppsDir;
+ }
+ }
+
+ /**
+ * <p>
+ * clearPortletEntities
+ * </p>
+ *
+ * @see
org.apache.jetspeed.tools.pamanager.PortletApplicationManagement#clearPortletEntities(org.apache.pluto.om.portlet.PortletDefinition)
+ * @param portletDefinition
+ */
+ public void clearPortletEntities( PortletDefinition portletDefinition )
+ {
+
+ Iterator entities =
entityAccess.getPortletEntities(portletDefinition).iterator();
+ while (entities.hasNext())
+ {
+ PortletEntity entity = (PortletEntity) entities.next();
+ try
+ {
+ windowAccess.removeWindows(entity);
+ entityAccess.removePortletEntity(entity);
+ String entityNodePath = MutablePortletEntity.PORTLET_ENTITY_ROOT +
"/" + entity.getId();
+ if (Preferences.userRoot().nodeExists(entityNodePath))
+ {
+ Preferences.userRoot().node(entityNodePath).removeNode();
+ }
+ }
+ catch (Exception e)
+ {
+ log.warn("Failed to delete preference node for PortletEntity: " +
entity.getId());
+ }
+
+ }
+ }
+
+ /**
+ * <p>
+ * reDeploy
+ * </p>
+ *
+ * @see
org.apache.jetspeed.tools.pamanager.Deployment#redeploy(org.apache.jetspeed.util.descriptor.PortletApplicationWar)
+ * @param paWar
+ * @throws PortletApplicationException
+ */
+ public void redeploy( PortletApplicationWar paWar ) throws
PortletApplicationException
+ {
+ try
+ {
+ doUnregister(paWar.getPortletApplicationName(), false);
+ String paName = paWar.getPortletApplicationName();
+ DirectoryHelper deployedDir = new DirectoryHelper(new File(webAppsDir +
"/" + paName));
+ PortletApplicationWar existingWar = new
PortletApplicationWar(deployedDir, paName, "/" + paName);
+
+ existingWar.removeWar();
+ existingWar.close();
+ sysDeploy(paWar, DEPLOY_WAR);
+ }
+ catch (IOException e)
+ {
+ throw new PortletApplicationException(e);
}
}
}
1.3 +17 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java
Index: PortletApplicationManagement.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/PortletApplicationManagement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PortletApplicationManagement.java 9 Jun 2004 23:16:07 -0000 1.2
+++ PortletApplicationManagement.java 9 Jul 2004 18:28:58 -0000 1.3
@@ -6,11 +6,26 @@
*/
package org.apache.jetspeed.tools.pamanager;
+import org.apache.pluto.om.portlet.PortletDefinition;
+
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
*
*/
public interface PortletApplicationManagement extends Deployment, Registration // ,
Lifecycle
-{
-
+{
+ /**
+ *
+ * <p>
+ * clearPortletEntities
+ * </p>
+ *
+ * Removes ALL portlet entity and user preference information for a specific
+ * [EMAIL PROTECTED] org.apache.pluto.om.portlet.PortletDefinition}. The
removal
+ * <strong>IS PERMENANT</strong> short of restoring a image of persistence that
+ * was taken BEFORE the removal occurred.
+ *
+ * @param portlet
+ */
+ void clearPortletEntities(PortletDefinition portlet);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]