[gatein-commits] gatein SVN: r6722 - in epp/portal/branches/EPP_5_2_Branch/component: portal/src/test/java/org/exoplatform/portal/config and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 23 07:56:21 EDT 2011


Author: hfnukal
Date: 2011-06-23 07:56:21 -0400 (Thu, 23 Jun 2011)
New Revision: 6722

Added:
   epp/portal/branches/EPP_5_2_Branch/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java
   epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
   epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/resources/locale/portlet_en.properties
   epp/portal/branches/EPP_5_2_Branch/component/web/api/src/main/java/org/exoplatform/web/filter/RedefinableResourceFilter.java
   epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
Log:
JBEPP-952 Merge Revision 5822

Added: epp/portal/branches/EPP_5_2_Branch/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java	                        (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/application-registry/src/main/java/org/exoplatform/application/gadget/RemoteImporter.java	2011-06-23 11:56:21 UTC (rev 6722)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 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.application.gadget;
+
+import org.exoplatform.application.gadget.impl.GadgetDefinition;
+import org.exoplatform.application.gadget.impl.RemoteGadgetData;
+import org.gatein.common.net.URLTools;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien.viet at exoplatform.com">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RemoteImporter extends GadgetImporter
+{
+
+   public RemoteImporter(String name, String gadgetPath)
+   {
+      super(name, gadgetPath);
+   }
+
+   @Override
+   protected byte[] getGadgetBytes(String gadgetURI) throws IOException
+   {
+      URL url = new URL(gadgetURI);
+      return URLTools.getContent(url, 5000, 5000);
+   }
+
+   @Override
+   protected String getGadgetURL(String gadgetURI) throws Exception
+   {
+      return "http://www.gatein.org";
+   }
+
+   @Override
+   protected void process(String gadgetURI, GadgetDefinition def) throws Exception
+   {
+      def.setLocal(false);
+
+      //
+      RemoteGadgetData data = (RemoteGadgetData)def.getData();
+
+      // Set remote URL
+      data.setURL(gadgetURI);
+   }
+}

Added: epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java	                        (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/config/TestConcurrencyDataStorage.java	2011-06-23 11:56:21 UTC (rev 6722)
@@ -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 at 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);
+         }
+      }
+   }
+
+}

Added: epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/resources/locale/portlet_en.properties
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/resources/locale/portlet_en.properties	                        (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/resources/src/test/resources/locale/portlet_en.properties	2011-06-23 11:56:21 UTC (rev 6722)
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+language.language=English

Added: epp/portal/branches/EPP_5_2_Branch/component/web/api/src/main/java/org/exoplatform/web/filter/RedefinableResourceFilter.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/api/src/main/java/org/exoplatform/web/filter/RedefinableResourceFilter.java	                        (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/api/src/main/java/org/exoplatform/web/filter/RedefinableResourceFilter.java	2011-06-23 11:56:21 UTC (rev 6722)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.web.filter;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.exoplatform.container.PortalContainer;
+
+/**
+ * A filter enables resource overriding via extension mechanism.
+ * 
+ * @author <a href="mailto:hoang281283 at gmail.com">Minh Hoang TO</a>
+ * Sep 8, 2010
+ */
+
+public class RedefinableResourceFilter implements Filter {
+
+	@Override
+	public void doFilter(ServletRequest request, ServletResponse response,
+			FilterChain chain) throws IOException, ServletException {
+		
+		HttpServletRequest upcastedRequest = (HttpServletRequest)request;
+		
+		PortalContainer portalContainer = PortalContainer.getInstance();
+		ServletContext mergedContext = portalContainer.getPortalContext();
+		
+		String path = upcastedRequest.getRequestURI();
+		String ctx = upcastedRequest.getContextPath();
+		
+		if(ctx != null && ctx.length() > 0 && path.startsWith(ctx))
+		{
+			path = path.substring(ctx.length());
+		}
+
+		mergedContext.getRequestDispatcher(path).include(request, response);
+	}
+
+}

Added: epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java	                        (rev 0)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/security/src/main/java/org/exoplatform/web/login/GateinWCIController.java	2011-06-23 11:56:21 UTC (rev 6722)
@@ -0,0 +1,99 @@
+/*
+* Copyright (C) 2003-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.login;
+
+import org.gatein.wci.security.Credentials;
+import org.gatein.wci.security.WCIController;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:alain.defrance at exoplatform.com">Alain Defrance</a>
+ * @version $Revision$
+ */
+public class GateinWCIController extends WCIController
+{
+   private ServletContext servletContext;
+
+   public GateinWCIController(final ServletContext servletContext)
+   {
+      if (servletContext == null)
+      {
+         throw new IllegalArgumentException("servletContext is null");
+      }
+      this.servletContext = servletContext;
+   }
+
+   public void showLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+   {
+      String initialURI = getInitialURI(req);
+      try
+      {
+         String queryString = (String)req.getAttribute("javax.servlet.forward.query_string");
+         if (req.getAttribute("javax.servlet.forward.query_string") != null)
+         {
+            initialURI = initialURI + "?" + queryString;
+         }
+         req.setAttribute("org.gatein.portal.login.initial_uri", initialURI);
+         servletContext.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+      }
+      finally
+      {
+         req.removeAttribute("org.gatein.portal.login.initial_uri");
+      }
+   }
+
+   public void showErrorLoginForm(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+   {
+      String initialURI = getInitialURI(req);
+      
+      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);
+         servletContext.getRequestDispatcher("/login/jsp/login.jsp").include(req, resp);
+      }
+      finally
+      {
+         req.removeAttribute("org.gatein.portal.login.initial_uri");
+      }
+   }
+
+   @Override
+   public Credentials getCredentials(final HttpServletRequest req, final HttpServletResponse resp)
+   {
+      return (Credentials)req.getSession().getAttribute(Credentials.CREDENTIALS);
+   }
+
+   @Override
+   public String getHomeURI(final HttpServletRequest req)
+   {
+      return "/portal/private/classic";
+   }
+}



More information about the gatein-commits mailing list