Author: hoang_to
Date: 2010-11-29 00:09:51 -0500 (Mon, 29 Nov 2010)
New Revision: 5328
Added:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
portal/trunk/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
portal/trunk/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
portal/trunk/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
portal/trunk/pom.xml
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
portal/trunk/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css
portal/trunk/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
portal/trunk/web/portal/src/main/webapp/index.jsp
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
Log:
GTNPORTAL-1643: Merge branch branch-GTNPORTAL-1643 back to trunk
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/config/model/Page.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -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/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/GlobalKey.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -55,6 +55,16 @@
this.localKey = localKey;
}
+ public String getRepositoryId()
+ {
+ return repositoryId;
+ }
+
+ public Serializable getLocalKey()
+ {
+ return localKey;
+ }
+
@Override
public int hashCode()
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSession.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -55,7 +55,7 @@
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
*/
-public class POMSession
+public final class POMSession
{
/** . */
@@ -361,20 +361,40 @@
}
public void afterSynchronization(SynchronizationStatus status)
{
- if (status == SynchronizationStatus.SAVED && staleKeys != null)
+ if (status == SynchronizationStatus.SAVED)
{
- if (log.isTraceEnabled())
- {
- log.trace("Session commit about to evict entries " +
staleKeys);
- }
- for (Serializable key : staleKeys)
- {
- mgr.cacheRemove(key);
- }
+ reset();
}
}
};
+ /**
+ * Reset the session and set its state like it was a newly created session.
+ */
+ private void reset()
+ {
+ // Evict entries from the shared cache if any
+ if (staleKeys != null && staleKeys.size() > 0)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("About to evict entries " + staleKeys);
+ }
+ for (Serializable key : staleKeys)
+ {
+ mgr.cacheRemove(key);
+ }
+ staleKeys.clear();
+ }
+
+ // Reset modified flag
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting modified flag to false");
+ }
+ modified = false;
+ }
+
public <V> V execute(POMTask<V> task) throws Exception
{
if (isInTask)
@@ -404,7 +424,11 @@
{
if (!markedForRollback)
{
+ // Trigger persistent save
model.save();
+
+ // Reset modified state
+ reset();
}
else
{
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/pom/config/POMSessionManager.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -23,9 +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.config.cache.PortalNamesCache;
+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;
@@ -70,7 +73,7 @@
this.manager = manager;
this.cache = cacheService.getCacheInstance("MOPSessionManager");
this.pomService = null;
- this.executor = new PortalNamesCache(new DataCache(new ExecutorDispatcher()));
+ this.executor = new DataCache(new ExecutorDispatcher());
}
public void cachePut(Serializable key, Object value)
@@ -106,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())
@@ -115,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/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestCache.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -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);
+ }
}
Copied:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
(from rev 5326,
portal/branches/branch-GTNPORTAL-1643/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java)
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
(rev 0)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.portal.config;
+
+import java.util.concurrent.CountDownLatch;
+
+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.POMSessionManager;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * Nov 10, 2010
+ */
+
+public class TestConcurrencyDataStorage extends AbstractPortalTest
+{
+
+ private DataStorage storage_;
+
+ private POMSessionManager mgr;
+
+ public TestConcurrencyDataStorage(String name)
+ {
+ super(name);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ begin();
+ PortalContainer container = PortalContainer.getInstance();
+ storage_ = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+
+ }
+
+ public void testCreatePageConcurrently() throws Exception
+ {
+ CountDownLatch startSignal = new CountDownLatch(1);
+
+ for (int i = 0; i < 5; i++)
+ {
+ Thread thread = new Thread(new CreatePageTask(mgr, storage_, startSignal,
"test" + i, "foo" + i));
+ thread.start();
+ }
+
+ startSignal.countDown();
+ }
+
+ public void testCreatePageSequentially() throws Exception
+ {
+ for (int i = 5; i < 10; i++)
+ {
+ Thread thread = new Thread(new CreatePageTask(mgr, storage_, null,
"test" + i, "foo" + i));
+ thread.start();
+ thread.join();
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ end();
+ super.tearDown();
+ }
+
+ public class CreatePageTask implements Runnable
+ {
+ private DataStorage dataStorage;
+
+ private POMSessionManager sessionManager;
+
+ private String pageName;
+
+ private String pageTitle;
+
+ private CountDownLatch startSignal;
+
+ public CreatePageTask(POMSessionManager _sessionManager, DataStorage _dataStorage,
CountDownLatch _startSignal, String _pageName, String _pageTitle)
+ {
+ dataStorage = _dataStorage;
+ pageName = _pageName;
+ pageTitle = _pageTitle;
+ sessionManager = _sessionManager;
+ startSignal = _startSignal;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ if(startSignal != null)
+ startSignal.await();
+
+ sessionManager.openSession();
+
+ Page page = new Page();
+ page.setOwnerType(PortalConfig.PORTAL_TYPE);
+ page.setOwnerId("test");
+ page.setTitle(pageTitle);
+ page.setName(pageName);
+
+ dataStorage.create(page);
+
+ Page createdPage = dataStorage.getPage(page.getPageId());
+ assertNotNull(createdPage);
+ assertEquals(pageName, createdPage.getName());
+ assertEquals(pageTitle, createdPage.getTitle());
+
+ System.out.println("Current POMSession: " +
sessionManager.getSession().toString());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ System.out.println("Could not create the page: " + pageName +
" , " + pageTitle);
+ }
+ }
+ }
+
+}
Modified:
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java
===================================================================
---
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestDataStorage.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -21,21 +21,13 @@
import static org.exoplatform.portal.pom.config.Utils.split;
-import junit.framework.AssertionFailedError;
+import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.portal.application.PortletPreferences;
import org.exoplatform.portal.application.Preference;
-import org.exoplatform.portal.config.model.Application;
-import org.exoplatform.portal.config.model.ApplicationState;
-import org.exoplatform.portal.config.model.ApplicationType;
-import org.exoplatform.portal.config.model.Container;
-import org.exoplatform.portal.config.model.Dashboard;
-import org.exoplatform.portal.config.model.ModelObject;
-import org.exoplatform.portal.config.model.Page;
-import org.exoplatform.portal.config.model.PageNavigation;
-import org.exoplatform.portal.config.model.PageNode;
-import org.exoplatform.portal.config.model.PortalConfig;
-import org.exoplatform.portal.config.model.TransientApplicationState;
+import org.exoplatform.portal.config.model.*;
+import org.exoplatform.portal.pom.config.POMSession;
+import org.exoplatform.portal.pom.config.POMSessionManager;
import org.exoplatform.portal.pom.data.ModelChange;
import org.exoplatform.portal.pom.spi.gadget.Gadget;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
@@ -44,14 +36,7 @@
import org.exoplatform.services.listener.Listener;
import org.exoplatform.services.listener.ListenerService;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
+import java.util.*;
/**
* Created by The eXo Platform SARL Author : Tung Pham thanhtungty(a)gmail.com Nov
@@ -61,14 +46,23 @@
{
/** . */
- private final String testPage = "portal::classic::testPage";
+ private static final String CLASSIC_HOME = "portal::classic::homepage";
/** . */
+ private static final String CLASSIC_TEST = "portal::classic::testPage";
+
+ /** . */
private final String testPortletPreferences =
"portal#classic:/web/BannerPortlet/testPortletPreferences";
/** . */
private DataStorage storage_;
+ /** . */
+ private POMSessionManager mgr;
+
+ /** . */
+ private POMSession session;
+
private LinkedList<Event> events;
private ListenerService listenerService;
@@ -88,15 +82,17 @@
events.add(event);
}
};
-
- //
+
super.setUp();
+ begin();
PortalContainer container = PortalContainer.getInstance();
storage_ = (DataStorage)container.getComponentInstanceOfType(DataStorage.class);
+ mgr =
(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
+ session = mgr.openSession();
+
events = new LinkedList<Event>();
listenerService =
(ListenerService)container.getComponentInstanceOfType(ListenerService.class);
-
- //
+
listenerService.addListener(DataStorage.PAGE_CREATED, listener);
listenerService.addListener(DataStorage.PAGE_REMOVED, listener);
listenerService.addListener(DataStorage.PAGE_UPDATED, listener);
@@ -106,13 +102,11 @@
listenerService.addListener(DataStorage.PORTAL_CONFIG_CREATED, listener);
listenerService.addListener(DataStorage.PORTAL_CONFIG_UPDATED, listener);
listenerService.addListener(DataStorage.PORTAL_CONFIG_REMOVED, listener);
-
- //
- begin();
}
protected void tearDown() throws Exception
{
+ session.close();
end();
super.tearDown();
}
@@ -307,7 +301,7 @@
assertEquals(1, events.size());
//
- page = storage_.getPage(testPage);
+ page = storage_.getPage(CLASSIC_TEST);
assertNull(page);
}
@@ -878,116 +872,20 @@
gadgetApp = (Application<Gadget>)row0.getChildren().get(0);
assertEquals("foo", storage_.getId(gadgetApp.getState()));
}
-
- public void testGetAllPortalNames() throws Exception
+
+ public void testRemoveAndFindPage() throws Exception
{
- final List<String> names = storage_.getAllPortalNames();
+ Page page = storage_.getPage(CLASSIC_HOME);
+ assertNotNull(page);
+ storage_.remove(page);
- // Create new portal
- storage_.create(new PortalConfig("portal",
"testGetAllPortalNames"));
+ // This will trigger a save
+ Query<Page> query = new Query<Page>(null, null, null, null,
Page.class);
+ LazyPageList<Page> list = storage_.find(query);
+ assertNotNull(list);
- // Test during tx we see the good names
- List<String> transientNames = storage_.getAllPortalNames();
- assertTrue(transientNames.containsAll(names));
- transientNames.removeAll(names);
- assertEquals(Collections.singletonList("testGetAllPortalNames"),
transientNames);
-
- // Test we have not seen anything yet outside of tx
- final CountDownLatch addSync = new CountDownLatch(1);
- final AtomicReference<Throwable> error = new
AtomicReference<Throwable>();
- new Thread()
- {
- @Override
- public void run()
- {
- begin();
- try
- {
- List<String> isolatedNames = storage_.getAllPortalNames();
- assertEquals(new HashSet<String>(names), new
HashSet<String>(isolatedNames));
- }
- catch (Throwable t)
- {
- error.set(t);
- }
- finally
- {
- addSync.countDown();
- end();
- }
- }
- }.start();
-
- //
- addSync.await();
- if (error.get() != null)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(error.get());
- throw afe;
- }
-
- // Now commit tx
- end(true);
-
- // We test we observe the change
- begin();
- List<String> afterNames = storage_.getAllPortalNames();
- assertTrue(afterNames.containsAll(names));
- afterNames.removeAll(names);
- assertEquals(Collections.singletonList("testGetAllPortalNames"),
afterNames);
-
- // Then we remove the newly created portal
- storage_.remove(new PortalConfig("portal",
"testGetAllPortalNames"));
-
- // Test we are syeing the transient change
- transientNames.clear();
- transientNames = storage_.getAllPortalNames();
- assertEquals(names, transientNames);
-
- // Test we have not seen anything yet outside of tx
- error.set(null);
- final CountDownLatch removeSync = new CountDownLatch(1);
- new Thread()
- {
- public void run()
- {
- begin();
- try
- {
- List<String> isolatedNames = storage_.getAllPortalNames();
- assertTrue(isolatedNames.containsAll(names));
- isolatedNames.removeAll(names);
- assertEquals(Collections.singletonList("testGetAllPortalNames"),
isolatedNames);
- }
- catch (Throwable t)
- {
- error.set(t);
- }
- finally
- {
- removeSync.countDown();
- end();
- }
- }
- }.start();
-
- //
- removeSync.await();
- if (error.get() != null)
- {
- AssertionFailedError afe = new AssertionFailedError();
- afe.initCause(error.get());
- throw afe;
- }
-
- //
- end(true);
-
- // Now test it is still removed
- begin();
- afterNames = storage_.getAllPortalNames();
- assertEquals(new HashSet<String>(names), new
HashSet<String>(afterNames));
+ // We check is now seen as removed
+ assertNull(storage_.getPage(CLASSIC_HOME));
}
private Application<Portlet> create(String instanceId)
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/WebAppController.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -49,7 +49,7 @@
private HashMap<String, Object> attributes_;
- private HashMap<String, Application> applications_;
+ private volatile HashMap<String, Application> applications_;
private HashMap<String, WebRequestHandler> handlers_;
@@ -89,16 +89,42 @@
return applications;
}
- public void removeApplication(String appId)
+ public synchronized void removeApplication(String appId)
{
applications_.remove(appId);
}
- public void addApplication(Application app)
+ /**
+ * Add application (portlet, gadget) to the global application map if and only if it
has
+ * not been registered yet.
+ *
+ * @param <T>
+ * @param app
+ * @return
+ */
+ public <T extends Application> T addApplication(T app)
{
- applications_.put(app.getApplicationId(), app);
+ Application result = getApplication(app.getApplicationId());
+
+ //Double-check block
+ if(result == null)
+ {
+ synchronized(this)
+ {
+ result = getApplication(app.getApplicationId());
+ if(result == null)
+ {
+ HashMap<String, Application> temporalApplicationsMap = new
HashMap<String, Application>(applications_);
+ temporalApplicationsMap.put(app.getApplicationId(), app);
+ this.applications_ = temporalApplicationsMap;
+ result = app;
+ }
+ }
+ }
+
+ return (T)result;
}
-
+
public void register(WebRequestHandler handler) throws Exception
{
for (String path : handler.getPath())
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/Image.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -19,6 +19,8 @@
package org.exoplatform.portal.application;
+import java.util.Date;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -29,10 +31,19 @@
final ImageType type;
final byte[] bytes;
+
+ final long lastModified;
public Image(ImageType type, byte[] bytes)
{
this.type = type;
this.bytes = bytes;
+// Remove miliseconds because string of date retrieve from Http header doesn't have
miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
+
+ public long getLastModified()
+ {
+ return lastModified;
+ }
}
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/application/ResourceRequestFilter.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -36,6 +36,7 @@
import java.io.OutputStream;
import java.net.URLDecoder;
import java.nio.charset.Charset;
+import java.util.Date;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -64,6 +65,10 @@
private ConcurrentMap<String, FutureTask<Image>> mirroredImageCache = new
ConcurrentHashMap<String, FutureTask<Image>>();
+ public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
+
+ public static final String LAST_MODIFIED = "Last-Modified";
+
public void afterInit(FilterConfig filterConfig)
{
cfg = filterConfig;
@@ -77,11 +82,19 @@
final String uri = URLDecoder.decode(httpRequest.getRequestURI(),
"UTF-8");
final HttpServletResponse httpResponse = (HttpServletResponse)response;
ExoContainer portalContainer = getContainer();
- SkinService skinService =
(SkinService)portalContainer.getComponentInstanceOfType(SkinService.class);
+ final SkinService skinService = (SkinService)
portalContainer.getComponentInstanceOfType(SkinService.class);
+ long ifModifiedSince = httpRequest.getDateHeader(IF_MODIFIED_SINCE);
//
if (uri.endsWith(".css"))
{
+// Check if cached resource has not been modifed, return 304 code
+ long cssLastModified = skinService.getLastModified(uri);
+ if (isNotModified(ifModifiedSince, cssLastModified)) {
+ httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+
final OutputStream out = response.getOutputStream();
final BinaryOutput output = new BinaryOutput()
{
@@ -118,6 +131,9 @@
{
httpResponse.setHeader("Cache-Control",
"no-cache");
}
+
+ long lastModified = skinService.getLastModified(uri);
+ processIfModified(lastModified, httpResponse);
}
};
@@ -192,8 +208,16 @@
Image img = futureImg.get();
if (img != null)
{
+ //Check if cached resource has not been modifed, return 304 code
+ long imgLastModified = img.getLastModified();
+ if (isNotModified(ifModifiedSince, imgLastModified)) {
+ httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
httpResponse.setContentType(img.type.getMimeType());
httpResponse.setContentLength(img.bytes.length);
+ processIfModified(imgLastModified, httpResponse);
+
OutputStream out = httpResponse.getOutputStream();
out.write(img.bytes);
out.close();
@@ -238,6 +262,30 @@
}
}
+ /**
+ * Add Last-Modified Http header to HttpServetResponse
+ */
+ public void processIfModified(long lastModified, HttpServletResponse httpResponse) {
+ httpResponse.setDateHeader(ResourceRequestFilter.LAST_MODIFIED, lastModified);
+ }
+
+ /**
+ * If cached resource has not changed since date in http header (If_Modified_Since),
return true
+ * Else return false;
+ * @param ifModifedSince - String, and HttpHeader element
+ * @param lastModified
+ * @param httpResponse
+ * @return
+ */
+ public boolean isNotModified(long ifModifedSince, long lastModified) {
+ if (!PropertyManager.isDevelopping()) {
+ if (ifModifedSince >= lastModified) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public void destroy()
{
}
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/CachedStylesheet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -24,6 +24,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
+import java.util.Date;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -40,6 +41,8 @@
/** . */
private final byte[] bytes;
+
+ private long lastModified;
public CachedStylesheet(String text)
{
@@ -59,11 +62,18 @@
//
this.text = text;
this.bytes = bytes;
+// Remove miliseconds because string of date retrieve from Http header doesn't have
miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
public String getText()
{
return text;
+ }
+
+ public long getLastModified()
+ {
+ return lastModified;
}
public void writeTo(BinaryOutput output) throws IOException
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -51,6 +51,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@@ -455,6 +456,9 @@
// Try cache first
if (!PropertyManager.isDevelopping())
{
+ //
+ FutureExoCache<String, CachedStylesheet, Orientation> cache = orientation
== Orientation.LT ? ltCache : rtCache;
+ CachedStylesheet cachedCss = cache.get(orientation, path);
if (path.startsWith("/" + portalContainerName +
"/resource"))
{
@@ -464,11 +468,7 @@
{
renderer.setExpiration(ONE_HOUR);
}
-
- //
- FutureExoCache<String, CachedStylesheet, Orientation> cache = orientation
== Orientation.LT ? ltCache : rtCache;
- CachedStylesheet cachedCss = cache.get(orientation, path);
-
+
cachedCss.writeTo(renderer.getOutput());
}
else
@@ -546,6 +546,41 @@
}
/**
+ * Return last modifed date of cached css
+ * Return null if cached css can not be found
+ * @param path - path must not be null
+ */
+ public long getLastModified(String path)
+ {
+ if (path == null)
+ {
+ throw new IllegalArgumentException("path must not be null");
+ }
+
+ FutureExoCache<String, CachedStylesheet, Orientation> cache = ltCache;
+ Orientation orientation = Orientation.LT;
+ if (path.endsWith("-lt.css"))
+ {
+ path = path.substring(0, path.length() - "-lt.css".length()) +
".css";
+ }
+ else if (path.endsWith("-rt.css"))
+ {
+ path = path.substring(0, path.length() - "-rt.css".length()) +
".css";
+ orientation = Orientation.RT;
+ }
+
+ CachedStylesheet cachedCSS = cache.get(orientation, path);
+ if (cachedCSS == null)
+ {
+ return Long.MAX_VALUE;
+ }
+ else
+ {
+ return cachedCSS.getLastModified();
+ }
+ }
+
+ /**
* Remove SkinConfig from Portal Skin Configs by module and skin name
* @param module
* @param skinName
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -40,6 +40,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -64,6 +65,8 @@
private HashMap<String, String> extendedJavascripts;
private byte[] jsBytes = null;
+
+ private long lastModified = Long.MAX_VALUE;
/** . */
private JavascriptDeployer deployer;
@@ -278,6 +281,18 @@
*/
public void writeMergedJavascript(OutputStream out) throws IOException
{
+ jsBytes = getMergedJavascript();
+
+ //
+ out.write(jsBytes);
+ }
+
+ /**
+ * Return merged javascript in byte array
+ * @return byte[]
+ */
+ public byte[] getMergedJavascript()
+ {
if (jsBytes == null)
{
// Generate javascript in a buffer
@@ -314,10 +329,15 @@
log.error("Error when generating minified javascript, will use normal
javascript instead", e);
jsBytes = bytes;
}
+// Remove miliseconds because string of date retrieve from Http header
doesn't have miliseconds
+ lastModified = (new Date().getTime() / 1000) * 1000;
}
+ return jsBytes;
+ }
- //
- out.write(jsBytes);
+ public long getLastModified()
+ {
+ return lastModified;
}
/**
@@ -374,4 +394,4 @@
DefaultServletContainerFactory.getInstance().getServletContainer().removeWebAppListener(removal);
}
-}
\ No newline at end of file
+}
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/ErrorLoginServlet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -71,9 +71,33 @@
resp.setContentType("text/html; charset=UTF-8");
// This allows the customer to define another login page without changing the
portal
- context.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+ showLoginForm(req, resp);
}
+ private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ String initialURI =
(String)req.getAttribute("javax.servlet.forward.request_uri");
+ if (initialURI == null)
+ {
+ throw new IllegalStateException("request attribute
javax.servlet.forward.request_uri should not be null here");
+ }
+ int jsecurityIndex = initialURI.lastIndexOf("/j_security_check");
+ if (jsecurityIndex != -1)
+ {
+ initialURI = initialURI.substring(0, jsecurityIndex);
+ }
+
+ try
+ {
+ req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+
getServletContext().getRequestDispatcher("/login/jsp/login.jsp").include(req,
resp);
+ }
+ finally
+ {
+ req.removeAttribute("org.gatein.portal.login.initial_uri");
+ }
+ }
+
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
doGet(req, resp);
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/InitiateLoginServlet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -96,7 +96,7 @@
// Send authentication request
log.debug("Login initiated with no credentials in session but found
token " + token + " with existing credentials, " +
"performing authentication");
- sendAuth(resp, credentials.getUsername(), token);
+ sendAuth(req, resp, credentials.getUsername(), token);
}
}
else
@@ -116,17 +116,13 @@
// Send authentication request
log.debug("Login initiated with credentials in session, performing
authentication");
- sendAuth(resp, credentials.getUsername(), token);
+ sendAuth(req, resp, credentials.getUsername(), token);
}
}
private void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
- String initialURI =
(String)req.getAttribute("javax.servlet.forward.request_uri");
- if (initialURI == null)
- {
- throw new IllegalStateException("request attribute
javax.servlet.forward.request_uri should not be null here");
- }
+ String initialURI = getInitialURI(req);
try
{
String queryString =
(String)req.getAttribute("javax.servlet.forward.query_string");
@@ -143,14 +139,29 @@
}
}
+ private String getInitialURI(HttpServletRequest req)
+ {
+ String initialURI =
(String)req.getAttribute("javax.servlet.forward.request_uri");
+ if (initialURI == null)
+ {
+ throw new IllegalStateException("request attribute
javax.servlet.forward.request_uri should not be null here");
+ }
+ return initialURI;
+ }
+
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
doGet(req, resp);
}
- private void sendAuth(HttpServletResponse resp, String jUsername, String jPassword)
throws IOException
+ private void sendAuth(HttpServletRequest req, HttpServletResponse resp, String
jUsername, String jPassword) throws IOException
{
- String url = "j_security_check?j_username=" + jUsername +
"&j_password=" + jPassword;
+ String initialURI = getInitialURI(req);
+ if (!initialURI.endsWith("/"))
+ {
+ initialURI += "/";
+ }
+ String url = initialURI + "j_security_check?j_username=" + jUsername +
"&j_password=" + jPassword;
url = resp.encodeRedirectURL(url);
resp.sendRedirect(url);
}
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/login/PortalLoginController.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -73,7 +73,7 @@
// otherwise compute one
if (uri == null || uri.length() == 0)
{
- uri = req.getContextPath() + "/private/classic";
+ uri = req.getContextPath();
log.debug("No initial URI found, will use default " + uri + "
instead ");
}
else
@@ -85,20 +85,16 @@
String rememberme = req.getParameter("rememberme");
if ("true".equals(rememberme))
{
- boolean isRemember =
"true".equals(req.getParameter(InitiateLoginServlet.COOKIE_NAME));
- if (isRemember)
- {
//Create token
- AbstractTokenService tokenService =
AbstractTokenService.getInstance(CookieTokenService.class);
- String cookieToken = tokenService.createToken(credentials);
+ AbstractTokenService tokenService =
AbstractTokenService.getInstance(CookieTokenService.class);
+ String cookieToken = tokenService.createToken(credentials);
- log.debug("Found a remember me request parameter, created a persistent
token " + cookieToken + " for it and set it up " +
- "in the next response");
- Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
- cookie.setPath(req.getContextPath());
- cookie.setMaxAge((int)tokenService.getValidityTime());
- resp.addCookie(cookie);
- }
+ log.debug("Found a remember me request parameter, created a persistent
token " + cookieToken
+ + " for it and set it up " + "in the next response");
+ Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
+ cookie.setPath(req.getContextPath());
+ cookie.setMaxAge((int) tokenService.getValidityTime());
+ resp.addCookie(cookie);
}
//
Copied:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java
(from rev 5326,
portal/branches/branch-GTNPORTAL-1643/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java)
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java
(rev 0)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/AbstractCodec.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.web.security.security;
+
+import org.exoplatform.container.component.BaseComponentPlugin;
+
+/**
+ * Abstract codec used to encode/decode password stored/loaded on/from token entry
+ *
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * Nov 19, 2010
+ */
+
+public abstract class AbstractCodec extends BaseComponentPlugin
+{
+
+ public String getName()
+ {
+ return this.getClass().toString();
+ }
+
+ public abstract String encode(String plainInput);
+
+ public abstract String decode(String encodedInput);
+
+}
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/CookieTokenService.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -24,6 +24,7 @@
import org.exoplatform.commons.chromattic.ChromatticManager;
import org.exoplatform.commons.chromattic.ContextualTask;
import org.exoplatform.commons.chromattic.SessionContext;
+import org.exoplatform.container.component.ComponentPlugin;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.web.security.Credentials;
import org.exoplatform.web.security.GateInToken;
@@ -47,6 +48,9 @@
/** . */
private String lifecycleName="autologin";
+ //TODO: Introduce the concept of priority and store the plugins in a map structure
+ private AbstractCodec codec;
+
public CookieTokenService(InitParams initParams, ChromatticManager chromatticManager)
{
super(initParams);
@@ -56,8 +60,19 @@
lifecycleName =
(String)initParams.getValuesParam(SERVICE_CONFIG).getValues().get(3);
}
this.chromatticLifeCycle = chromatticManager.getLifeCycle(lifecycleName);
+
+ //Set the default codec
+ this.codec = new ToThrowAwayCodec();
}
+ public final void setupCodec(ComponentPlugin codecPlugin)
+ {
+ if(codecPlugin instanceof AbstractCodec)
+ {
+ this.codec = (AbstractCodec)codecPlugin;
+ }
+ }
+
public String createToken(final Credentials credentials)
{
if (validityMillis < 0)
@@ -76,7 +91,9 @@
long expirationTimeMillis = System.currentTimeMillis() + validityMillis;
GateInToken token = new GateInToken(expirationTimeMillis, credentials);
TokenContainer container = getTokenContainer();
- container.saveToken(tokenId, token.getPayload(), new
Date(token.getExpirationTimeMillis()));
+
+ //Save the token, password is encoded thanks to the codec
+ container.encodeAndSaveToken(tokenId, token.getPayload(), new
Date(expirationTimeMillis), codec);
return tokenId;
}
}.executeWith(chromatticLifeCycle);
@@ -89,7 +106,8 @@
@Override
protected GateInToken execute()
{
- return getTokenContainer().getToken((String)id);
+ //Get the token, encoded password is decoded thanks to codec
+ return getTokenContainer().getTokenAndDecode(id, codec);
}
}.executeWith(chromatticLifeCycle);
}
Copied:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java
(from rev 5326,
portal/branches/branch-GTNPORTAL-1643/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java)
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java
(rev 0)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/ToThrowAwayCodec.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.web.security.security;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * Nov 19, 2010
+ */
+
+public class ToThrowAwayCodec extends AbstractCodec
+{
+
+ @Override
+ public String decode(String encodedInput)
+ {
+ return encodedInput;
+ }
+
+ @Override
+ public String encode(String plainInput)
+ {
+ return plainInput;
+ }
+
+}
Modified:
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java
===================================================================
---
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/security/src/main/java/org/exoplatform/web/security/security/TokenContainer.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -84,5 +84,37 @@
entry.setExpirationTime(expirationTime);
return entry.getToken();
}
+
+ public GateInToken encodeAndSaveToken(String tokenId, Credentials credentials, Date
expirationTime, AbstractCodec codec)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if (entry == null)
+ {
+ entry = createToken();
+ tokens.put(tokenId, entry);
+ entry.setUserName(credentials.getUsername());
+ entry.setPassword(codec.encode(credentials.getPassword()));
+ }
+ entry.setExpirationTime(expirationTime);
+ return entry.getToken();
+ }
+
+ public GateInToken getTokenAndDecode(String tokenId, AbstractCodec codec)
+ {
+ Map<String, TokenEntry> tokens = getTokens();
+ TokenEntry entry = tokens.get(tokenId);
+ if(entry != null)
+ {
+ GateInToken gateInToken = entry.getToken();
+ Credentials payload = gateInToken.getPayload();
+
+ //Return a cloned GateInToken
+ return new GateInToken(gateInToken.getExpirationTimeMillis(), new
Credentials(payload.getUsername(), codec
+ .decode(payload.getPassword())));
+ }
+ return null;
+ }
+
}
Modified:
portal/trunk/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java
===================================================================
---
portal/trunk/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/component/web/server/src/main/java/org/exoplatform/upload/UploadService.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -109,6 +109,9 @@
DiskFileItem fileItem = (DiskFileItem)itemList.get(0);
String fileName = fileItem.getName();
+ if (fileName == null)
+ fileName = uploadId;
+ fileName = fileName.substring(fileName.lastIndexOf('\\') + 1);
String storeLocation = uploadLocation_ + "/" + uploadId + "." +
fileName;
// commons-fileupload will store the temp file with name *.tmp
Modified:
portal/trunk/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
---
portal/trunk/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/examples/extension/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -1,3 +1,6 @@
+<%
+ String initialURI =
_ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() +
"/private/" +
_ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
<div class="TRContainer">
<div class="PortletDecoration">
@@ -28,7 +31,7 @@
<div class="AccountsContainerDeco">
<div class="AccountBlock AdministratorUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
<div class="ClearBoth"><span></span></div>
@@ -42,7 +45,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock ManagerUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
<div class="ClearBoth"><span></span></div>
@@ -56,7 +59,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock NormalUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
<div class="ClearBoth"><span></span></div>
@@ -70,7 +73,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock DemoUser" style="margin-right:
0px;">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
<div class="ClearBoth"><span></span></div>
Modified:
portal/trunk/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl
===================================================================
---
portal/trunk/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/examples/portal/war/src/main/webapp/templates/groovy/webui/component/UIHomePagePortlet.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -1,3 +1,6 @@
+<%
+ String initialURI =
_ctx.getRequestContext().getParentAppRequestContext().getRequestContextPath() +
"/private/" +
_ctx.getRequestContext().getParentAppRequestContext().getPortalOwner();
+%>
<div class="UIHomePagePortlet" id="$uicomponent.id">
<div class="TRContainer">
<div class="PortletDecoration">
@@ -33,7 +36,7 @@
<div class="AccountsContainerDeco">
<div class="AccountBlock AdministratorUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=root&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Administrator")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>root</span>
<div class="ClearBoth"><span></span></div>
@@ -47,7 +50,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock ManagerUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=john&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Manager")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>john</span>
<div class="ClearBoth"><span></span></div>
@@ -61,7 +64,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock NormalUser">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=mary&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.User")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>mary</span>
<div class="ClearBoth"><span></span></div>
@@ -75,7 +78,7 @@
<div class="SeparatorLine"><span></span></div>
<div class="AccountBlock DemoUser" style="margin-right:
0px;">
<div class="AccountInfos">
- <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
+ <div class="AccountTitle"><a
href="${_ctx.getPortalContextPath()}/login?username=demo&password=gtn&initialURI=<%=initialURI%>"><%=_ctx.appRes("UIHomePagePortlet.Label.Demo")%></a></div>
<div class="Username">
<div
class="Lable"><%=_ctx.appRes("UIHomePagePortlet.Label.Username")%></div><span>demo</span>
<div class="ClearBoth"><span></span></div>
Modified: portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js
===================================================================
---
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/gadgets/eXoGadgets/src/main/webapp/gadgets/rssAggregator/script.js 2010-11-29
05:09:51 UTC (rev 5328)
@@ -43,7 +43,7 @@
if (isNaN(B)) {
return "an indeterminate amount of time ago"
}
- time = (new Date().getTime() 1000 - B) / 1000;
+ time = (new Date().getTime()*1000 - B) / 1000;
if (time < 60) {
return "less than a minute ago"
} else {
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-11-29 04:30:49 UTC (rev 5327)
+++ portal/trunk/pom.xml 2010-11-29 05:09:51 UTC (rev 5328)
@@ -1336,6 +1336,12 @@
<version>5.1.6</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarGroupPortlet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -55,7 +55,7 @@
{
if (navigation.getOwnerType().equals(PortalConfig.GROUP_TYPE))
{
- navigations.add(PageNavigationUtils.filter(navigation, remoteUser));
+ navigations.add(PageNavigationUtils.filterNavigation(navigation, remoteUser,
false, true));
}
}
return navigations;
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIUserToolBarSitePortlet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -68,7 +68,7 @@
{
PageNavigation navi = getPageNavigation(PortalConfig.PORTAL_TYPE + "::" +
getCurrentPortal());
String remoteUser = Util.getPortalRequestContext().getRemoteUser();
- return PageNavigationUtils.filter(navi, remoteUser);
+ return PageNavigationUtils.filterNavigation(navi, remoteUser, false, true);
}
private PageNavigation getPageNavigation(String owner) throws Exception
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/applicationregistry/webui/component/UIGadgetInfo.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -11,6 +11,9 @@
if(gadgetThumbnail == null || gadgetThumbnail.length() == 0){
gadgetThumbnail = srcBGError ;
}
+ def viewURL = uicomponent.getViewUrl();
+ def editURL = uicomponent.getEditUrl();
+ def refURL = gadget.getReferenceUrl();
%>
<div class="UIGadgetInfo" id="$uicomponent.id">
<div class="UIBreadcumb">
@@ -21,7 +24,7 @@
<div class="Refresh16x16Icon ControlIcon"
title="<%=_ctx.appRes("UIGadgetInfo.title.refresh")%>"
onclick="<%= uicomponent.event("Refresh")
%>"><span></span></div>
<div class="ClearBoth"><span></span></div>
</div>
- <div class="Application ClearFix">
+ <div class="Application">
<div class="PortletIcons">
<img src="$gadgetThumbnail"
onError="src='$srcBGError'" alt=""/>
</div>
@@ -41,12 +44,12 @@
<table>
<tr>
<td
class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.viewUrl")%></td>
- <td class="RightLabel" title=" <%= uicomponent.getViewUrl()
%> "><%= uicomponent.getViewUrl() %></td>
+ <td class="RightLabel" title=" <%=viewURL %>
"><a href="<%=viewURL %>"
target="_blank">$viewURL</a></td>
</tr>
<% if(gadget.isLocal()) {%>
<tr>
<td
class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.editUrl")%></td>
- <td class="RightLabel"><%= uicomponent.getEditUrl()
%></td>
+ <td class="RightLabel"><a href="<%=editURL %>"
target="_blank">$editURL</a></td>
</tr>
<% } %>
</table>
@@ -54,7 +57,7 @@
<tr>
<td
class="LeftLabel"><%=_ctx.appRes("UIGadgetInfo.label.reference")%></td>
<td class="RightLabel">
- <%= gadget.getReferenceUrl() %>
+ <a href="<%=refURL %>"
target="_blank">$refURL</a>
</td>
</tr>
</table>
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/skin/organization/webui/component/UIOrganizationPortlet/DefaultStylesheet.css 2010-11-29
05:09:51 UTC (rev 5328)
@@ -168,6 +168,7 @@
float: left; /* orientation=lt */
float: right; /* orientation=rt */
height: auto;
+ width: 100%;
}
.UIOrganizationPortlet .UISearch .UISearchForm .QuickSet {
Modified:
portal/trunk/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl
===================================================================
---
portal/trunk/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/portlet/web/src/main/webapp/groovy/portal/webui/component/UIPortalNavigation.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -95,7 +95,7 @@
<div class="MenuItem $tabStyleNavigation">
<div class="$arrowIcon" title="$title">
<div class="ItemIcon $icon">
- <a href="$pageURI">$label</a>
+ <a href="#">$label</a>
</div>
</div>
""";
Modified:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/portal/webui/component/customization/UIPageBrowser/Stylesheet.css 2010-11-29
05:09:51 UTC (rev 5328)
@@ -29,7 +29,7 @@
.UIPageBrowser .UIGrid {
width: 99.7%;
!width: 98%;
- margin: auto;
+ margin: 0px;
}
.UIPageBrowser .UIGrid .Text {
Modified: portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/UILoginForm.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -7,7 +7,7 @@
jsmanager.addCustomizedOnLoadScript('document.getElementById("UIPortalComponentLogin").username.focus();');
HttpSession session = rcontext.getRequest().getSession();
String requestPath = rcontext.getRequestContextPath() + "/private/" +
rcontext.getPortalOwner();
- session.setAttribute("initialURI", requestPath);
+ //session.setAttribute("initialURI", requestPath);
%>
<div class="UILoginForm">
<div class="LoginDecorator">
@@ -23,7 +23,7 @@
<div class="LoginDecoratorBackground">
<div class="LoginDetailBox">
<form class="UIForm" id="$uicomponent.id"
name="loginForm" action="<%= rcontext.getRequestContextPath() +
"/login"%>" method="post" style="margin: 0px;">
- <input type="hidden" name="initialURI"
value="<%=session.getAttribute("initialURI"); %>"/>
+ <input type="hidden" name="initialURI"
value="<%=requestPath %>"/>
<div class="VerticalLayout">
<table class="UIFormGrid">
<tr class="UserNameField">
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-11-29
05:09:51 UTC (rev 5328)
@@ -47,10 +47,12 @@
<link id="${portletSkin.id}" rel="stylesheet"
type="text/css" href= "$url" />
<%}%>
<script type="text/javascript">
+ <%
// This variable must be used only to initialize other variables otherwise
// please use eXo.env.portal.context or eXo.env.portal.context instead
// Those 2 last variables cannot be used to initialize variables because
// we cannot be sure that they will be initialized before initializing your script
+ %>
var currentContext = '<%=docBase%>' ;
</script>
<%if(org.exoplatform.commons.utils.PropertyManager.isDevelopping()) {
Modified: portal/trunk/web/portal/src/main/webapp/index.jsp
===================================================================
--- portal/trunk/web/portal/src/main/webapp/index.jsp 2010-11-29 04:30:49 UTC (rev 5327)
+++ portal/trunk/web/portal/src/main/webapp/index.jsp 2010-11-29 05:09:51 UTC (rev 5328)
@@ -22,8 +22,14 @@
<%@ page import="org.exoplatform.container.PortalContainer"%>
<%@ page
import="org.exoplatform.portal.config.UserPortalConfigService"%>
<%
- PortalContainer manager =
PortalContainer.getCurrentInstance(session.getServletContext()) ;
- UserPortalConfigService userPortalConfigService = (UserPortalConfigService)
manager.getComponentInstanceOfType(UserPortalConfigService.class) ;
- response.sendRedirect(request.getContextPath() +
"/public/"+userPortalConfigService.getDefaultPortal()+"/");
+ PortalContainer manager =
PortalContainer.getCurrentInstance(session.getServletContext());
+ UserPortalConfigService userPortalConfigService =
(UserPortalConfigService)manager.getComponentInstanceOfType(UserPortalConfigService.class);
+ String remoteUser = request.getRemoteUser();
+ String accessMode = "public";
+ if (remoteUser != null && remoteUser.trim().length() > 0)
+ {
+ accessMode = "private";
+ }
+ response.sendRedirect(request.getContextPath() + "/" + accessMode +
"/" + userPortalConfigService.getDefaultPortal() + "/");
%>
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java
===================================================================
---
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/account/UIUserSelector.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -412,7 +412,9 @@
uiSelectUserForm.setSelectedGroup(groupId);
OrganizationService service =
uiSelectGroupForm.getApplicationComponent(OrganizationService.class);
PageList users =
uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
+ users.setPageSize(10);
uiSelectUserForm.uiIterator_.setPageList(users);
+ uiSelectUserForm.setKeyword(null);
event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm);
}
}
@@ -423,17 +425,23 @@
{
UIUserSelector uiSelectUserForm = event.getSource();
String groupId = uiSelectUserForm.getSelectedGroup();
- uiSelectUserForm.setSelectedGroup(groupId);
OrganizationService service =
uiSelectUserForm.getApplicationComponent(OrganizationService.class);
+
+ PageList users = PageList.EMPTY_LIST;
if (groupId != null && groupId.trim().length() != 0)
{
- PageList users =
uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
- uiSelectUserForm.uiIterator_.setPageList(users);
+ if (service.getGroupHandler().findGroupById(groupId) != null)
+ {
+ users =
uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId));
+ }
}
else
{
-
uiSelectUserForm.uiIterator_.setPageList(service.getUserHandler().findUsers(new
Query()));
+ users = service.getUserHandler().findUsers(new Query());
}
+ users.setPageSize(10);
+ uiSelectUserForm.uiIterator_.setPageList(users);
+ uiSelectUserForm.setKeyword(null);
event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm);
}
}
Modified:
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java
===================================================================
---
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/framework/src/main/java/org/exoplatform/webui/core/UIComponentDecorator.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -48,14 +48,22 @@
return uicomponent_;
}
- public void setUIComponent(UIComponent uicomponent)
+ public UIComponent setUIComponent(UIComponent uicomponent)
{
+ UIComponent oldOne = uicomponent_;
if (uicomponent_ != null)
- uicomponent_.setRendered(false);
+ uicomponent_.setParent(null);
uicomponent_ = uicomponent;
- if (uicomponent_ == null)
- return;
- uicomponent_.setParent(this);
+ if (uicomponent_ != null)
+ {
+ UIComponent oldParent = uicomponent_.getParent();
+ if (oldParent != null && oldParent != this && oldParent
instanceof UIComponentDecorator)
+ {
+ ((UIComponentDecorator)oldParent).setUIComponent(null);
+ }
+ uicomponent_.setParent(this);
+ }
+ return oldOne;
}
@SuppressWarnings("unchecked")
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletActionListener.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -854,8 +854,7 @@
{
public void execute(Event<UIPortlet> event) throws Exception
{
- UIPortal uiPortal = Util.getUIPortal();
- UIPortalApplication uiApp =
uiPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
UIMaskWorkspace uiMaskWS =
uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
uiMaskWS.setUpdated(true);
UIPortlet uiPortlet = event.getSource();
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerActionListener.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -39,8 +39,7 @@
{
UIContainer uiContainer = event.getSource();
- UIPortal uiPortal = Util.getUIPortal();
- UIPortalApplication uiApp =
uiPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiApp = Util.getUIPortalApplication();
UIMaskWorkspace uiMaskWS =
uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
UIContainerForm containerForm =
uiMaskWS.createUIComponent(UIContainerForm.class, null, null);
containerForm.setValues(uiContainer);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/container/UIContainerForm.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -141,7 +141,7 @@
event.getRequestContext().addUIComponentToUpdateByAjax(uiMaskWorkspace);
- UIPortalApplication uiPortalApp =
uiForm.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
pcontext.getJavascriptManager().addJavascript("eXo.portal.UIPortal.changeComposerSaveButton();");
pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/javascript/JavascriptServlet.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -19,10 +19,14 @@
package org.exoplatform.portal.webui.javascript;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.portal.application.ResourceRequestFilter;
import org.exoplatform.web.application.javascript.JavascriptConfigService;
import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Date;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -55,14 +59,23 @@
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException,
IOException
{
- JavascriptConfigService service =
+ final JavascriptConfigService service =
(JavascriptConfigService)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(
JavascriptConfigService.class);
-
+ long lastModified = service.getLastModified();
+ long ifModifiedSince =
request.getDateHeader(ResourceRequestFilter.IF_MODIFIED_SINCE);
+
// Julien: should we also set charset along with the content type ?
response.setContentType("application/x-javascript");
- ServletOutputStream stream = response.getOutputStream();
- service.writeMergedJavascript(stream);
+ if (!PropertyManager.isDevelopping()) {
+ if (ifModifiedSince >= lastModified) {
+ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
+ }
+ }
+
+ byte[] jsBytes = service.getMergedJavascript();
+ response.setDateHeader(ResourceRequestFilter.LAST_MODIFIED, lastModified);
+ response.getOutputStream().write(jsBytes);
}
-
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/PageNavigationUtils.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -367,6 +367,12 @@
}
PageNode cloneStartNode = startNode.clone();
+
+ // Check if page reference isn't existing, page reference value of node is
setted null too.
+ if (pageReference != null && userService.getPage(pageReference) == null)
+ {
+ cloneStartNode.setPageReference(null);
+ }
ArrayList<PageNode> filteredChildren = new ArrayList<PageNode>();
List<PageNode> children = startNode.getChildren();
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UINavigationNodeSelector.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -26,7 +26,6 @@
import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.portal.config.model.PortalConfig;
import org.exoplatform.portal.mop.Visibility;
-import org.exoplatform.portal.webui.navigation.ParentChildPair;
import org.exoplatform.portal.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageNodeForm;
import org.exoplatform.portal.webui.portal.UIPortalComposer;
@@ -447,7 +446,6 @@
uiToolPanel.setWorkingComponent(UIPage.class, null);
UIPage uiPage = (UIPage)uiToolPanel.getUIComponent();
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
if(selectPage.getTitle() == null)
selectPage.setTitle(selectedPageNode.getLabel());
@@ -535,46 +533,48 @@
{
public void execute(Event<UIRightClickPopupMenu> event) throws Exception
{
- String uri = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
- WebuiRequestContext pcontext = event.getRequestContext();
- UIApplication uiApp = pcontext.getUIApplication();
- UINavigationNodeSelector uiNodeSelector =
event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
- UINavigationManagement uiManagement = uiNodeSelector.getParent();
- Class<?>[] childrenToRender = new
Class<?>[]{UINavigationNodeSelector.class};
- uiManagement.setRenderedChildrenOfTypes(childrenToRender);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
+ String uri =
event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
+ WebuiRequestContext pcontext = event.getRequestContext();
+ UIApplication uiApp = pcontext.getUIApplication();
+ UINavigationNodeSelector uiNodeSelector =
event.getSource().getAncestorOfType(UINavigationNodeSelector.class);
+ UINavigationManagement uiManagement = uiNodeSelector.getParent();
+ Class<?>[] childrenToRender = new
Class<?>[]{UINavigationNodeSelector.class};
+ uiManagement.setRenderedChildrenOfTypes(childrenToRender);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiManagement);
- PageNavigation nav = uiNodeSelector.getEdittedNavigation();
- if (nav == null)
- {
- return;
- }
-
- PageNode[] pageNodes = PageNavigationUtils.searchPageNodesByUri(nav, uri);
- if (pageNodes == null)
- {
- return;
- }
-
- for (PageNode pageNode : pageNodes) {
- if(pageNode != null && pageNode.isSystem()) {
- uiApp.addMessage(new
ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
- return;
- }
- }
-
- TreeNodeData selectedNode = new TreeNodeData(nav, pageNodes[0], pageNodes[1]);
- selectedNode.setDeleteNode(false);
- uiNodeSelector.setCopyNode(selectedNode);
- event.getSource().setActions(
- new String[]{"AddNode", "EditPageNode",
"EditSelectedNode", "CopyNode", "CloneNode",
"CutNode",
- "PasteNode", "DeleteNode", "MoveUp",
"MoveDown"});
+ PageNavigation nav = uiNodeSelector.getEdittedNavigation();
+ if (nav == null)
+ {
+ return;
+ }
- if (uiNodeSelector.getCopyNode() == null)
- {
- return;
- }
- uiNodeSelector.getCopyNode().setDeleteNode(true);
+ ParentChildPair parentChildPair =
PageNavigationUtils.searchParentChildPairByUri(nav, uri);
+ if (parentChildPair == null)
+ {
+ return;
+ }
+
+ PageNode parentNode = parentChildPair.getParentNode();
+ PageNode childNode = parentChildPair.getChildNode();
+
+ if (childNode != null && childNode.isSystem())
+ {
+ uiApp.addMessage(new
ApplicationMessage("UINavigationNodeSelector.msg.systemnode-move", null));
+ return;
+ }
+
+ TreeNodeData selectedNode = new TreeNodeData(nav, parentNode, childNode);
+ selectedNode.setDeleteNode(false);
+ uiNodeSelector.setCopyNode(selectedNode);
+ event.getSource().setActions(
+ new String[]{"AddNode", "EditPageNode",
"EditSelectedNode", "CopyNode", "CloneNode",
"CutNode",
+ "PasteNode", "DeleteNode", "MoveUp",
"MoveDown"});
+
+ if (uiNodeSelector.getCopyNode() == null)
+ {
+ return;
+ }
+ uiNodeSelector.getCopyNode().setDeleteNode(true);
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/navigation/UIPortalNavigation.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -113,7 +113,7 @@
if (context.getRemoteUser() != null)
{
- result.add(PageNavigationUtils.filter(getSelectedNavigation(),
context.getRemoteUser()));
+ result.add(PageNavigationUtils.filterNavigation(getSelectedNavigation(),
context.getRemoteUser(), false, true));
}
else
{
@@ -121,7 +121,7 @@
{
if (!showUserNavigation &&
nav.getOwnerType().equals("user"))
continue;
- result.add(PageNavigationUtils.filter(nav, null));
+ result.add(PageNavigationUtils.filterNavigation(nav, null, false, true));
}
}
return result;
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageActionListener.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -59,7 +59,7 @@
public void execute(Event<UIPortal> event) throws Exception
{
UIPortal showedUIPortal = event.getSource();
- UIPortalApplication uiPortalApp =
showedUIPortal.getAncestorOfType(UIPortalApplication.class);
+ UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
//This code snippet is to make sure that Javascript/Skin is fully loaded at the
first request
UIWorkingWorkspace uiWorkingWS =
uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBrowser.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -309,6 +309,12 @@
if(page.getOwnerType().equals(PortalConfig.USER_TYPE)){
removePageNode(page, event);
}
+
+ UIWorkingWorkspace uiWorkingWorkspace =
uiPortalApp.getChild(UIWorkingWorkspace.class);
+ uiWorkingWorkspace.updatePortletsByName("UserToolbarSitePortlet");
+ uiWorkingWorkspace.updatePortletsByName("UserToolbarGroupPortlet");
+
uiWorkingWorkspace.updatePortletsByName("UserToolbarDashboardPortlet");
+ uiWorkingWorkspace.updatePortletsByName("NavigationPortlet");
}
/**
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageForm.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -125,12 +125,12 @@
addUIFormInput(uiSettingSet);
setSelectedTab(uiSettingSet.getId());
- WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
- Param param = initParams.getParam("PageTemplate");
- List<SelectItemCategory> itemCategories =
(List<SelectItemCategory>)param.getMapGroovyObject(context);
- UIFormInputItemSelector uiTemplate = new
UIFormInputItemSelector("Template", "template");
- uiTemplate.setItemCategories(itemCategories);
- addUIFormInput(uiTemplate);
+ //WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
+ //Param param = initParams.getParam("PageTemplate");
+ //List<SelectItemCategory> itemCategories =
(List<SelectItemCategory>)param.getMapGroovyObject(context);
+ //UIFormInputItemSelector uiTemplate = new
UIFormInputItemSelector("Template", "template");
+ //uiTemplate.setItemCategories(itemCategories);
+ //addUIFormInput(uiTemplate);
uiPermissionSetting = createUIComponent(UIFormInputSet.class,
"PermissionSetting", null);
UIListPermissionSelector uiListPermissionSelector =
createUIComponent(UIListPermissionSelector.class, null, null);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIMaskWorkspace.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -93,10 +93,11 @@
return createUIComponent(clazz, null, null);
}
- public void setUIComponent(UIComponent uicomponent)
+ public UIComponent setUIComponent(UIComponent uicomponent)
{
- super.setUIComponent(uicomponent);
+ UIComponent oldOne = super.setUIComponent(uicomponent);
setShow(uicomponent != null);
+ return oldOne;
}
static public class CloseActionListener extends EventListener<UIComponent>
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplicationLifecycle.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -44,7 +44,12 @@
return;
UIComponent uiTarget = uicomponent.findComponentById(componentId);
if (uiTarget == null)
+ {
+
context.addUIComponentToUpdateByAjax(uicomponent.<UIComponent>getChildById(UIPortalApplication.UI_WORKING_WS_ID));
+
context.addUIComponentToUpdateByAjax(uicomponent.getChild(UIMaskWorkspace.class));
+ ((PortalRequestContext)context).setFullRender(true);
return;
+ }
if (uiTarget == uicomponent)
super.processDecode(uicomponent, context);
uiTarget.processDecode(context);
Modified:
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java
===================================================================
---
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-29
04:30:49 UTC (rev 5327)
+++
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplicationController.java 2010-11-29
05:09:51 UTC (rev 5328)
@@ -133,7 +133,7 @@
{
application = new PortletApplication(getPortletConfig());
application.onInit();
- controller.addApplication(application);
+ application = controller.addApplication(application);
}
return application;
}