[gatein-commits] gatein SVN: r5082 - in portal/branches/branch-GTNPORTAL-1643/component/portal/src: main/java/org/exoplatform/portal/pom/config and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Nov 13 17:25:56 EST 2010
Author: julien_viet
Date: 2010-11-13 17:25:56 -0500 (Sat, 13 Nov 2010)
New Revision: 5082
Modified:
portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
Log:
GTNPORTAL-1512 : Always show message "This page name already exists. " after delete group
Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-13 12:50:52 UTC (rev 5081)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-13 22:25:56 UTC (rev 5082)
@@ -50,6 +50,13 @@
{
}
+ public Page(String ownerType, String ownerId, String name)
+ {
+ this.ownerType = ownerType;
+ this.ownerId = ownerId;
+ this.name = name;
+ }
+
public Page(PageData data)
{
super(data);
Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java 2010-11-13 12:50:52 UTC (rev 5081)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/config/model/PortalConfig.java 2010-11-13 22:25:56 UTC (rev 5082)
@@ -78,7 +78,13 @@
public PortalConfig(String type)
{
+ this(type, null);
+ }
+
+ public PortalConfig(String type, String ownerId)
+ {
this.type = type;
+ this.name = ownerId;
//
setPortalLayout(new Container());
@@ -99,14 +105,6 @@
this.portalLayout = new Container(data.getPortalLayout());
}
- PortalConfig(String storageId, String type)
- {
- super(storageId);
-
- //
- this.type = type;
- }
-
public String getType()
{
return type;
Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-13 12:50:52 UTC (rev 5081)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-13 22:25:56 UTC (rev 5082)
@@ -55,6 +55,16 @@
this.localKey = localKey;
}
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
+ public Serializable getLocalKey()
+ {
+ return localKey;
+ }
+
@Override
public int hashCode()
{
Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-13 12:50:52 UTC (rev 5081)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-13 22:25:56 UTC (rev 5082)
@@ -23,8 +23,12 @@
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.chromattic.SessionContext;
import org.exoplatform.portal.pom.config.cache.DataCache;
+import org.exoplatform.portal.pom.data.OwnerKey;
+import org.exoplatform.portal.pom.data.PortalKey;
import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.CachedObjectSelector;
import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.cache.ObjectCacheInfo;
import org.exoplatform.services.jcr.RepositoryService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
@@ -105,7 +109,7 @@
public void cacheRemove(Serializable key)
{
- GlobalKey globalKey = GlobalKey.wrap(configurator.getRepositoryName(), key);
+ final GlobalKey globalKey = GlobalKey.wrap(configurator.getRepositoryName(), key);
//
if (log.isTraceEnabled())
@@ -114,7 +118,47 @@
}
//
- cache.remove(globalKey);
+ if (key instanceof PortalKey)
+ {
+ // This code seems complex but actually it tries to find all objects in cache that have the same
+ // owner key than the portal key, for instance if we remove (portal,classic) then all pages
+ // related to (portal,classic) are also evicted
+ final PortalKey portalKey = (PortalKey)key;
+ try
+ {
+ cache.select(new CachedObjectSelector<GlobalKey, Object>()
+ {
+ public boolean select(GlobalKey selectedGlobalKey, ObjectCacheInfo<?> ocinfo)
+ {
+ if (globalKey.getRepositoryId().equals(selectedGlobalKey.getRepositoryId()))
+ {
+ Serializable selectedLocalKey = selectedGlobalKey.getLocalKey();
+ if (selectedLocalKey instanceof OwnerKey)
+ {
+ OwnerKey selectedOwnerKey = (OwnerKey)selectedLocalKey;
+ if (selectedOwnerKey.getType().equals(portalKey.getType()) && selectedOwnerKey.getId().equals(portalKey.getId()))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ public void onSelect(ExoCache<? extends GlobalKey, ?> exoCache, GlobalKey key, ObjectCacheInfo<?> ocinfo) throws Exception
+ {
+ cache.remove(key);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ log.error("Unexpected error when clearing pom cache", e);
+ }
+ }
+ else
+ {
+ cache.remove(globalKey);
+ }
}
public void start()
Modified: portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-13 12:50:52 UTC (rev 5081)
+++ portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-13 22:25:56 UTC (rev 5082)
@@ -20,9 +20,9 @@
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.config.model.Page;
+import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.pom.config.POMSession;
import org.exoplatform.portal.pom.config.POMSessionManager;
-
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -128,4 +128,48 @@
//
end();
}
+
+ public void testGetPageFromRemovedPortal() throws Exception
+ {
+ // Create what we need for the test
+ begin();
+ session = mgr.openSession();
+ PortalConfig portalConfig = new PortalConfig("portal", "testGetPageFromRemovedPortal");
+ storage_.create(portalConfig);
+ storage_.create(new Page("portal", "testGetPageFromRemovedPortal", "home"));
+ end(true);
+
+ // Clear cache
+ mgr.clearCache();
+
+ // The first transaction
+ begin();
+ session = mgr.openSession();
+
+ // Get page from JCR and it should be stored in cache
+ Page page = storage_.getPage("portal::testGetPageFromRemovedPortal::home");
+ assertNotNull(page);
+
+ // Now remove the portal
+ PortalConfig portal = storage_.getPortalConfig("portal", "testGetPageFromRemovedPortal");
+ storage_.remove(portal);
+
+ // Terminate the first transaction
+ end(true);
+
+ // The second transaction
+ begin();
+ session = mgr.openSession();
+
+ // The portal should be null
+ portal = storage_.getPortalConfig("portal", "testGetPageFromRemovedPortal");
+ assertNull(portal);
+
+ // The portal home page should also be null
+ page = storage_.getPage("portal::testGetPageFromRemovedPortal::home");
+ assertNull(page);
+
+ // End second transaction
+ end(true);
+ }
}
More information about the gatein-commits
mailing list