weaver 2003/11/26 12:55:35
Modified: portal/src/java/org/apache/jetspeed/services/page/impl
DatabasePageManagerService.java
portal/src/java/org/apache/jetspeed/services/entity
PortletEntityService.java PortletEntityAccess.java
PortletEntityServiceImpl.java
portal/src/java/org/apache/jetspeed/om/entity/impl
PortletEntityImpl.java
portal/src/java/org/apache/jetspeed/services/page
PageManager.java PageManagerService.java
portal/src/java/org/apache/jetspeed/services/registry
JetspeedPortletRegistry.java
PortletRegistryService.java
portal/src/java/org/apache/jetspeed/services/registry/impl
PersistentPortletRegistryService.java
portal/src/java/org/apache/jetspeed/tools/pamanager
FileSystemPAM.java
Added: portal/src/java/org/apache/jetspeed/services/entity
PortletEntityNotDeletedException.java
PortletEntityNotStoredException.java
portal/src/java/org/apache/jetspeed/services/page
PageNotUpdatedException.java
PageNotRemovedException.java
Log:
Changed all services that use persistence to have methods to control
beginning, committing and rolling back transactions. Any add, update
or delete methods must be called within the confines of a transaction or
an exception occurs.
Revision Changes Path
1.3 +38 -22
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/impl/DatabasePageManagerService.java
Index: DatabasePageManagerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/impl/DatabasePageManagerService.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DatabasePageManagerService.java 20 Nov 2003 19:02:24 -0000 1.2
+++ DatabasePageManagerService.java 26 Nov 2003 20:55:34 -0000 1.3
@@ -66,7 +66,9 @@
import org.apache.jetspeed.persistence.LookupCriteria;
import org.apache.jetspeed.persistence.PersistencePlugin;
import org.apache.jetspeed.persistence.PersistenceService;
+import org.apache.jetspeed.persistence.TransactionStateException;
import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator;
+import org.apache.jetspeed.services.page.*;
import org.apache.jetspeed.services.page.PageManagerService;
/**
@@ -75,21 +77,19 @@
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @version $Id$
*/
-public class DatabasePageManagerService
- extends AbstractPageManagerService
- implements PageManagerService
+public class DatabasePageManagerService extends AbstractPageManagerService
implements PageManagerService
{
protected final static Log log =
LogFactory.getLog(DatabasePageManagerService.class);
-
+
private PersistencePlugin plugin;
private PersistencePlugin originalPlugin;
private String originalAlias;
-
+
// TODO: this should eventually use a system cach like JCS
private Map pageCache = new HashMap();
-
+
/* (non-Javadoc)
* @see org.apache.fulcrum.Service#init()
*/
@@ -98,17 +98,16 @@
if (!isInitialized())
{
super.init();
-
+
PersistenceService ps = (PersistenceService)
CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
String pluginName =
getConfiguration().getString("persistence.plugin.name", "jetspeed");
plugin = ps.getPersistencePlugin(pluginName);
-
+
setInit(true);
}
}
-
-
+
/* (non-Javadoc)
* @see
org.apache.jetspeed.services.page.PageManagerService#getPage(java.lang.String)
*/
@@ -129,7 +128,7 @@
return page;
}
}
-
+
/* (non-Javadoc)
* @see org.apache.jetspeed.services.page.PageManagerService#listPages()
*/
@@ -138,7 +137,7 @@
// TODO Auto-generated method stub
return null;
}
-
+
/* (non-Javadoc)
* @see
org.apache.jetspeed.services.page.PageManagerService#registerPage(org.apache.jetspeed.om.page.Page)
*/
@@ -159,28 +158,45 @@
id = page.getId();
log.warn("Page with no Id, created new Id : " + id);
}
-
-
+
}
-
+
/* (non-Javadoc)
* @see
org.apache.jetspeed.services.page.PageManagerService#updatePage(org.apache.jetspeed.om.page.Page)
*/
- public void updatePage(Page page) throws JetspeedException
+ public void updatePage(Page page) throws JetspeedException,
PageNotUpdatedException
{
- plugin.update(page);
+ try
+ {
+ plugin.prepareForUpdate(page);
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to update Page.";
+ log.error(msg, e);
+ throw new PageNotUpdatedException(msg, e);
+ }
}
-
+
/* (non-Javadoc)
* @see
org.apache.jetspeed.services.page.PageManagerService#removePage(org.apache.jetspeed.om.page.Page)
*/
- public void removePage(Page page)
+ public void removePage(Page page) throws PageNotRemovedException
{
if (pageCache.containsKey(page.getId()))
{
pageCache.remove(pageCache.get(page.getId()));
}
- plugin.delete(page);
+ try
+ {
+ plugin.prepareForDelete(page);
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to remove Page.";
+ log.error(msg, e);
+ throw new PageNotRemovedException(msg, e);
+ }
}
-
+
}
1.6 +3 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityService.java
Index: PortletEntityService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PortletEntityService.java 20 Nov 2003 19:02:23 -0000 1.5
+++ PortletEntityService.java 26 Nov 2003 20:55:34 -0000 1.6
@@ -76,9 +76,9 @@
PortletEntity getPortletEntity(PortletDefinition portletDefinition, String
portletName);
- void storePortletEntity(PortletEntity portletEntity);
+ void storePortletEntity(PortletEntity portletEntity) throws
PortletEntityNotStoredException;
- void removePortletEntity(PortletEntity portletEntity);
+ void removePortletEntity(PortletEntity portletEntity) throws
PortletEntityNotDeletedException;
PortletEntity newPortletEntityInstance(PortletDefinition portletDefinition);
1.6 +2 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityAccess.java
Index: PortletEntityAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityAccess.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PortletEntityAccess.java 18 Oct 2003 19:54:51 -0000 1.5
+++ PortletEntityAccess.java 26 Nov 2003 20:55:34 -0000 1.6
@@ -74,7 +74,7 @@
return getService().getPortletEntity(def, entityName);
}
- public static void storePortletEntity(PortletEntity portletEntity)
+ public static void storePortletEntity(PortletEntity portletEntity) throws
PortletEntityNotStoredException
{
getService().storePortletEntity(portletEntity);
}
1.11 +47 -8
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java
Index: PortletEntityServiceImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityServiceImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PortletEntityServiceImpl.java 20 Nov 2003 19:02:23 -0000 1.10
+++ PortletEntityServiceImpl.java 26 Nov 2003 20:55:34 -0000 1.11
@@ -63,6 +63,7 @@
import org.apache.jetspeed.persistence.LookupCriteria;
import org.apache.jetspeed.persistence.PersistencePlugin;
import org.apache.jetspeed.persistence.PersistenceService;
+import org.apache.jetspeed.persistence.TransactionStateException;
import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.pluto.om.common.ObjectID;
import org.apache.pluto.om.entity.PortletEntity;
@@ -98,7 +99,7 @@
PersistenceService ps = (PersistenceService)
CommonPortletServices.getPortalService(PersistenceService.SERVICE_NAME);
String pluginName =
getConfiguration().getString("persistence.plugin.name", "jetspeed");
autoCreateNewEntities = getConfiguration().getBoolean("autocreate",
false);
- entityClass = this.loadModelClass("entity.impl");
+ entityClass = this.loadModelClass("entity.impl");
plugin = ps.getPersistencePlugin(pluginName);
setInit(true);
}
@@ -145,21 +146,59 @@
/**
* @see
org.apache.jetspeed.services.entity.PortletEntityService#storePortletEntity(org.apache.pluto.om.entity.PortletEntity)
*/
- public void storePortletEntity(PortletEntity portletEntity)
+ public void storePortletEntity(PortletEntity portletEntity) throws
PortletEntityNotStoredException
{
- plugin.update(portletEntity);
+ try
+ {
+ plugin.beginTransaction();
+ plugin.markDirty(portletEntity);
+ plugin.commitTransaction();
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to store Portlet Entity.";
+ log.error(msg, e);
+ try
+ {
+ plugin.rollbackTransaction();
+ }
+ catch (TransactionStateException e1)
+ {
+ log.error("Could not rollback transaction", e1);
+ }
+ throw new PortletEntityNotStoredException(msg, e);
+ }
}
/**
* @see
org.apache.jetspeed.services.entity.PortletEntityService#removePortletEntity(org.apache.pluto.om.entity.PortletEntity)
*/
- public void removePortletEntity(PortletEntity portletEntity)
+ public void removePortletEntity(PortletEntity portletEntity) throws
PortletEntityNotDeletedException
{
if (entityCache.containsKey(portletEntity.getId()))
{
entityCache.remove(entityCache.get(portletEntity.getId()));
}
- plugin.delete(portletEntity);
+ try
+ {
+ plugin.beginTransaction();
+ plugin.prepareForDelete(this);
+ plugin.commitTransaction();
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to delete Portlet Entity.";
+ log.error(msg, e);
+ try
+ {
+ plugin.rollbackTransaction();
+ }
+ catch (TransactionStateException e1)
+ {
+ log.error("Could not rollback transaction", e1);
+ }
+ throw new PortletEntityNotDeletedException(msg, e);
+ }
}
/**
@@ -167,9 +206,9 @@
*/
public PortletEntity newPortletEntityInstance(PortletDefinition
portletDefinition)
{
- PortletEntityCtrl portletEntity =
(PortletEntityCtrl)this.createObject(entityClass);
+ PortletEntityCtrl portletEntity = (PortletEntityCtrl)
this.createObject(entityClass);
portletEntity.setPortletDefinition(portletDefinition);
- return (PortletEntity)portletEntity;
+ return (PortletEntity) portletEntity;
}
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityNotDeletedException.java
Index: PortletEntityNotDeletedException.java
===================================================================
/**
* Created on Nov 26, 2003
*
*
* @author
*/
package org.apache.jetspeed.services.entity;
import org.apache.jetspeed.exception.JetspeedException;
/**
* <p>
* PortletEntityNotDeletedException
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: PortletEntityNotDeletedException.java,v 1.1 2003/11/26 20:55:34
weaver Exp $
*
*/
public class PortletEntityNotDeletedException extends JetspeedException
{
/**
*
*/
public PortletEntityNotDeletedException()
{
super();
}
/**
* @param message
*/
public PortletEntityNotDeletedException(String message)
{
super(message);
}
/**
* @param nested
*/
public PortletEntityNotDeletedException(Throwable nested)
{
super(nested);
}
/**
* @param msg
* @param nested
*/
public PortletEntityNotDeletedException(String msg, Throwable nested)
{
super(msg, nested);
}
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/entity/PortletEntityNotStoredException.java
Index: PortletEntityNotStoredException.java
===================================================================
/**
* Created on Nov 26, 2003
*
*
* @author
*/
package org.apache.jetspeed.services.entity;
import org.apache.jetspeed.exception.JetspeedException;
/**
* <p>
* PortletEntityNotStoredException
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: PortletEntityNotStoredException.java,v 1.1 2003/11/26 20:55:34
weaver Exp $
*
*/
public class PortletEntityNotStoredException extends JetspeedException
{
/**
*
*/
public PortletEntityNotStoredException()
{
super();
}
/**
* @param message
*/
public PortletEntityNotStoredException(String message)
{
super(message);
}
/**
* @param nested
*/
public PortletEntityNotStoredException(Throwable nested)
{
super(nested);
}
/**
* @param msg
* @param nested
*/
public PortletEntityNotStoredException(String msg, Throwable nested)
{
super(msg, nested);
}
}
1.3 +11 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/entity/impl/PortletEntityImpl.java
Index: PortletEntityImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/om/entity/impl/PortletEntityImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PortletEntityImpl.java 17 Oct 2003 19:38:25 -0000 1.2
+++ PortletEntityImpl.java 26 Nov 2003 20:55:34 -0000 1.3
@@ -53,6 +53,7 @@
*/
package org.apache.jetspeed.om.entity.impl;
+import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
@@ -63,6 +64,7 @@
import org.apache.jetspeed.om.preference.impl.PreferenceSetImpl;
import org.apache.jetspeed.om.window.impl.PortletWindowListImpl;
import org.apache.jetspeed.services.entity.PortletEntityAccess;
+import org.apache.jetspeed.services.entity.PortletEntityNotStoredException;
import org.apache.jetspeed.util.JetspeedObjectID;
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerAware;
@@ -134,7 +136,14 @@
public void store() throws java.io.IOException
{
- PortletEntityAccess.storePortletEntity(this);
+ try
+ {
+ PortletEntityAccess.storePortletEntity(this);
+ }
+ catch (PortletEntityNotStoredException e)
+ {
+ throw new IOException("Unable to store Portlet Entity. "+e.toString());
+ }
}
1.5 +2 -2
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageManager.java
Index: PageManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageManager.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PageManager.java 18 Nov 2003 17:56:24 -0000 1.4
+++ PageManager.java 26 Nov 2003 20:55:35 -0000 1.5
@@ -133,7 +133,7 @@
/**
* @see
org.apache.jetspeed.services.page.PageManagerService#removePage(org.apache.jetspeed.om.page.Page)
*/
- public static void removePage(Page page)
+ public static void removePage(Page page) throws PageNotRemovedException
{
getService().removePage(page);
}
1.5 +3 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageManagerService.java
Index: PageManagerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageManagerService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PageManagerService.java 18 Nov 2003 17:56:24 -0000 1.4
+++ PageManagerService.java 26 Nov 2003 20:55:35 -0000 1.5
@@ -120,13 +120,13 @@
*
* @param locator The description of the profile to be removed.
*/
- public void updatePage(Page page) throws JetspeedException;
+ public void updatePage(Page page) throws JetspeedException,
PageNotUpdatedException;
/** Remove a document.
*
* @param locator The description of the profile to be removed.
*/
- public void removePage(Page page);
+ public void removePage(Page page) throws PageNotRemovedException;
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageNotUpdatedException.java
Index: PageNotUpdatedException.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.page;
import org.apache.jetspeed.exception.JetspeedException;
/**
* <p>
* PageNotUpdatedException
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: PageNotUpdatedException.java,v 1.1 2003/11/26 20:55:35 weaver Exp $
*
*/
public class PageNotUpdatedException extends JetspeedException
{
/**
*
*/
public PageNotUpdatedException()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @param message
*/
public PageNotUpdatedException(String message)
{
super(message);
// TODO Auto-generated constructor stub
}
/**
* @param nested
*/
public PageNotUpdatedException(Throwable nested)
{
super(nested);
// TODO Auto-generated constructor stub
}
/**
* @param msg
* @param nested
*/
public PageNotUpdatedException(String msg, Throwable nested)
{
super(msg, nested);
// TODO Auto-generated constructor stub
}
}
1.1
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/page/PageNotRemovedException.java
Index: PageNotRemovedException.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.services.page;
import org.apache.jetspeed.exception.JetspeedException;
/**
* <p>
* PageNotRemovedException
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: PageNotRemovedException.java,v 1.1 2003/11/26 20:55:35 weaver Exp $
*
*/
public class PageNotRemovedException extends JetspeedException
{
/**
*
*/
public PageNotRemovedException()
{
super();
// TODO Auto-generated constructor stub
}
/**
* @param message
*/
public PageNotRemovedException(String message)
{
super(message);
// TODO Auto-generated constructor stub
}
/**
* @param nested
*/
public PageNotRemovedException(Throwable nested)
{
super(nested);
// TODO Auto-generated constructor stub
}
/**
* @param msg
* @param nested
*/
public PageNotRemovedException(String msg, Throwable nested)
{
super(msg, nested);
// TODO Auto-generated constructor stub
}
}
1.6 +36 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/JetspeedPortletRegistry.java
Index: JetspeedPortletRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/JetspeedPortletRegistry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JetspeedPortletRegistry.java 18 Oct 2003 19:54:51 -0000 1.5
+++ JetspeedPortletRegistry.java 26 Nov 2003 20:55:35 -0000 1.6
@@ -65,6 +65,7 @@
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
import org.apache.jetspeed.om.common.preference.PreferenceComposite;
import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
+import org.apache.jetspeed.persistence.TransactionStateException;
import org.apache.pluto.om.common.Language;
import org.apache.pluto.om.common.ObjectID;
@@ -199,7 +200,7 @@
/**
* @see
org.apache.jetspeed.services.registry.PortletRegistryService#removeApplication(org.apache.pluto.om.portlet.PortletApplicationDefinition)
*/
- public static void removeApplication(PortletApplicationDefinition app) throws
RegistryException
+ public static void removeApplication(PortletApplicationDefinition app) throws
RegistryException, TransactionStateException
{
getService().removeApplication(app);
@@ -208,7 +209,7 @@
/**
* @see
org.apache.jetspeed.services.registry.PortletRegistryService#updatePortletApplication(org.apache.pluto.om.portlet.PortletApplicationDefinition)
*/
- public static void updatePortletApplication(PortletApplicationDefinition app)
+ public static void updatePortletApplication(PortletApplicationDefinition app)
throws TransactionStateException
{
getService().updatePortletApplication(app);
}
@@ -275,5 +276,37 @@
{
getService().resetDeploymentSystem();
}
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#beginTransaction()
+ */
+ public static void beginTransaction() throws TransactionStateException
+ {
+ getService().beginTransaction();
+
+ }
+
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#commitTransaction()
+ */
+ public static void commitTransaction() throws TransactionStateException
+ {
+ getService().commitTransaction();
+
+ }
+
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#rollbackTransaction()
+ */
+ public static void rollbackTransaction() throws TransactionStateException
+ {
+ getService().rollbackTransaction();
+
+ }
+
+
+
}
1.5 +11 -3
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/PortletRegistryService.java
Index: PortletRegistryService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/PortletRegistryService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PortletRegistryService.java 18 Oct 2003 19:54:51 -0000 1.4
+++ PortletRegistryService.java 26 Nov 2003 20:55:35 -0000 1.5
@@ -66,6 +66,7 @@
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
import org.apache.jetspeed.om.common.preference.PreferenceComposite;
import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
+import org.apache.jetspeed.persistence.TransactionStateException;
import org.apache.pluto.om.common.Language;
import org.apache.pluto.om.common.ObjectID;
import org.apache.pluto.om.portlet.PortletApplicationDefinition;
@@ -204,9 +205,9 @@
* persistent.
* @param app
*/
- void updatePortletApplication(PortletApplicationDefinition app);
+ void updatePortletApplication(PortletApplicationDefinition app) throws
TransactionStateException;
- void removeApplication(PortletApplicationDefinition app);
+ void removeApplication(PortletApplicationDefinition app) throws
TransactionStateException;
Language createLanguage(
Locale locale,
@@ -241,4 +242,11 @@
*
*/
void resetDeploymentSystem();
+
+
+ public void beginTransaction() throws TransactionStateException;
+
+ public void commitTransaction() throws TransactionStateException;
+
+ public void rollbackTransaction() throws TransactionStateException;
}
1.12 +52 -5
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/impl/PersistentPortletRegistryService.java
Index: PersistentPortletRegistryService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/services/registry/impl/PersistentPortletRegistryService.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- PersistentPortletRegistryService.java 18 Oct 2003 19:54:51 -0000 1.11
+++ PersistentPortletRegistryService.java 26 Nov 2003 20:55:35 -0000 1.12
@@ -80,6 +80,7 @@
import org.apache.jetspeed.persistence.LookupCriteria;
import org.apache.jetspeed.persistence.PersistencePlugin;
import org.apache.jetspeed.persistence.PersistenceService;
+import org.apache.jetspeed.persistence.TransactionStateException;
import org.apache.jetspeed.services.registry.PortletRegistryService;
import org.apache.jetspeed.util.ArgUtil;
import org.apache.pluto.om.common.Language;
@@ -241,21 +242,21 @@
/**
* @see
org.apache.jetspeed.services.registry.PortletRegistryService#updatePortletApplication(org.apache.pluto.om.portlet.PortletApplicationDefinition)
*/
- public void updatePortletApplication(PortletApplicationDefinition app)
+ public void updatePortletApplication(PortletApplicationDefinition app) throws
TransactionStateException
{
- plugin.update(app);
+ plugin.prepareForUpdate(app);
}
/**
* @see
org.apache.jetspeed.services.registry.PortletRegistryService#removeApplication(org.apache.pluto.om.portlet.PortletApplicationDefinition)
*/
- public void removeApplication(PortletApplicationDefinition app)
+ public void removeApplication(PortletApplicationDefinition app) throws
TransactionStateException
{
ArgUtil.notNull(new Object[] { app }, new String[] { "app" },
"removeApplication(PortletApplicationDefinition)");
log.info("Removing portlet application " + ((MutablePortletApplication)
app).getName());
- plugin.delete(app);
+ plugin.prepareForDelete(app);
}
/**
@@ -416,7 +417,26 @@
}
else
{
- usePlugin.add(pac);
+ try
+ {
+ plugin.beginTransaction();
+ plugin.prepareForUpdate(pac);
+ plugin.commitTransaction();
+ }
+ catch (TransactionStateException e)
+ {
+ try
+ {
+ plugin.rollbackTransaction();
+ }
+ catch (TransactionStateException e1)
+ {
+ log.error("Failed to rollback transaction.", e);
+ }
+ String msg = "Unable to register new portlet application.";
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+ }
}
}
@@ -456,6 +476,33 @@
{
plugin.setDbAlias(originalAlias);
}
+
+ }
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#beginTransaction()
+ */
+ public void beginTransaction() throws TransactionStateException
+ {
+ plugin.beginTransaction();
+
+ }
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#commitTransaction()
+ */
+ public void commitTransaction() throws TransactionStateException
+ {
+ plugin.commitTransaction();
+
+ }
+
+ /**
+ * @see
org.apache.jetspeed.services.registry.PortletRegistryService#rollbackTransaction()
+ */
+ public void rollbackTransaction() throws TransactionStateException
+ {
+ plugin.rollbackTransaction();
}
1.6 +24 -4
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FileSystemPAM.java 17 Oct 2003 20:02:07 -0000 1.5
+++ FileSystemPAM.java 26 Nov 2003 20:55:35 -0000 1.6
@@ -66,6 +66,7 @@
import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
import org.apache.jetspeed.om.servlet.impl.WebApplicationDefinitionImpl;
+import org.apache.jetspeed.persistence.TransactionStateException;
/**
* This is the catalina specific implemenation for deplyment of Portlet
Applications.
@@ -221,9 +222,9 @@
// JetspeedPortletRegistry.processPortletApplicationTree(app, "remove");
// locate the deployment home
-
+ JetspeedPortletRegistry.beginTransaction();
JetspeedPortletRegistry.removeApplication(app);
-
+ JetspeedPortletRegistry.commitTransaction();
// Remove the webapps directory
System.out.println("Remove " + webAppsDir + paName + " and all
sub-directories.");
@@ -241,6 +242,15 @@
}
catch (Exception re)
{
+ try
+ {
+ JetspeedPortletRegistry.rollbackTransaction();
+ }
+ catch (TransactionStateException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
throw new PortletApplicationException(re.getMessage());
}
@@ -299,13 +309,23 @@
System.out.println("Saving the portlet.xml in the registry...");
// locate the deployment home
identifyDeploymentSystem();
-
+ JetspeedPortletRegistry.beginTransaction();
JetspeedPortletRegistry.removeApplication(app);
+ JetspeedPortletRegistry.commitTransaction();
}
}
catch (Exception e1)
{
+ try
+ {
+ JetspeedPortletRegistry.rollbackTransaction();
+ }
+ catch (TransactionStateException e2)
+ {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ }
e1.printStackTrace();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]