gatein SVN: r2519 - in portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui: portal and 1 other directory.
by do-not-reply@jboss.org
Author: trong.tran
Date: 2010-04-07 04:49:03 -0400 (Wed, 07 Apr 2010)
New Revision: 2519
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
Log:
GTNPORTAL-1020 javascript error after creating a new page
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-04-07 08:40:10 UTC (rev 2518)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageBody.java 2010-04-07 08:49:03 UTC (rev 2519)
@@ -76,40 +76,12 @@
public void setPageBody(PageNode pageNode, UIPortal uiPortal) throws Exception
{
WebuiRequestContext context = Util.getPortalRequestContext();
- ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
- UserPortalConfigService userPortalConfigService =
- (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
- Page page = null;
- UIPage uiPage;
-
- String pageReference = null;
-
- if (pageNode != null)
- {
- pageReference = pageNode.getPageReference();
- try
- {
- if (pageReference != null)
- {
- page = userPortalConfigService.getPage(pageReference, context.getRemoteUser());
- }
- }
- catch (Exception e)
- {
- UIPortalApplication uiApp = getAncestorOfType(UIPortalApplication.class);
- uiApp.addMessage(new ApplicationMessage(e.getMessage(), new Object[]{}));
- }
- }
-
uiPortal.setMaximizedUIComponent(null);
- try
+ UIPage uiPage;
+ uiPage = getUIPage(pageNode, uiPortal, context);
+ if (uiPage == null)
{
- uiPage = getUIPage(pageReference, page, uiPortal, context);
- }
- catch (Exception ex)
- {
- // TODO: Print evokable message
setUIComponent(null);
return;
}
@@ -142,15 +114,30 @@
* @param uiPortal
* @return
*/
- private UIPage getUIPage(String pageReference, Page page, UIPortal uiPortal, WebuiRequestContext context)
+ private UIPage getUIPage(PageNode pageNode, UIPortal uiPortal, WebuiRequestContext context)
throws Exception
{
+ Page page = null;
+ String pageReference = null;
+
+ if (pageNode != null)
+ {
+ pageReference = pageNode.getPageReference();
+ if (pageReference != null)
+ {
+ ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
+ UserPortalConfigService userPortalConfigService =
+ (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
+ page = userPortalConfigService.getPage(pageReference, context.getRemoteUser());
+ }
+ }
+
//The page has been deleted
if(page == null)
{
//Clear the UIPage from cache in UIPortal
uiPortal.clearUIPage(pageReference);
- throw new Exception("The page with id " + pageReference + " has been removed");
+ return null;
}
UIPage uiPage = uiPortal.getUIPage(pageReference);
@@ -173,11 +160,6 @@
return uiPage;
}
- public void renderChildren() throws Exception
- {
- uicomponent_.processRender((WebuiRequestContext)WebuiRequestContext.getCurrentInstance());
- }
-
public void processRender(WebuiRequestContext context) throws Exception
{
if (maximizedUIComponent != null && Util.getUIPortalApplication().getModeState() % 2 == 0)
@@ -186,11 +168,6 @@
return;
}
- //TODO: Remove beneath block
- if (uicomponent_ == null)
- {
- setPageBody(Util.getUIPortal().getSelectedNode(), Util.getUIPortal());
- }
super.processRender(context);
}
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-07 08:40:10 UTC (rev 2518)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageCreationWizard.java 2010-04-07 08:49:03 UTC (rev 2519)
@@ -19,6 +19,7 @@
package org.exoplatform.portal.webui.page;
+import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserACL;
import org.exoplatform.portal.config.model.Page;
@@ -85,7 +86,7 @@
{
UIPagePreview uiPagePreview = getChild(UIPagePreview.class);
UIPage uiPage = (UIPage)uiPagePreview.getUIComponent();
- UIPortal uiPortal = Util.getUIPortal();
+
UIWizardPageSetInfo uiPageInfo = getChild(UIWizardPageSetInfo.class);
UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
@@ -116,9 +117,8 @@
DataStorage dataService = getApplicationComponent(DataStorage.class);
dataService.create(page);
dataService.save(pageNav);
+ UIPortal uiPortal = Util.getUIPortal();
setNavigation(uiPortal.getNavigations(), uiNodeSelector.getSelectedNavigation());
- PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, pageNode.getUri());
- uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
}
private void setNavigation(List<PageNavigation> navs, PageNavigation nav)
@@ -342,7 +342,11 @@
if (isDesktopPage)
{
uiWizard.saveData();
- uiWizard.updateUIPortal(uiPortalApp, event);
+ PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
+ UIPortal uiPortal = Util.getUIPortal();
+ PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, selectedNode.getUri());
+ uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
+ uiWizard.updateUIPortal(event);
return;
}
@@ -372,17 +376,14 @@
uiWizard.saveData();
UIPortalToolPanel toolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
toolPanel.setUIComponent(null);
- uiWizard.updateUIPortal(uiPortalApp, event);
- JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
- jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
-
+ uiWizard.updateUIPortal(event);
UIWizardPageSetInfo uiPageInfo = uiWizard.getChild(UIWizardPageSetInfo.class);
UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
-
- String uri = Util.getPortalRequestContext().getPortalURI() + selectedNode.getUri();
- //Util.getPortalRequestContext().sendRedirect(uri);
- jsManager.addJavascript("window.location = '" + uri + "';");
+
+ PortalRequestContext pcontext = Util.getPortalRequestContext();
+ String uri = pcontext.getPortalURI() + selectedNode.getUri();
+ pcontext.getResponse().sendRedirect(uri);
}
}
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java 2010-04-07 08:40:10 UTC (rev 2518)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/page/UIPageWizard.java 2010-04-07 08:49:03 UTC (rev 2519)
@@ -94,7 +94,7 @@
return uiHelpWindow;
}
- void updateUIPortal(UIPortalApplication uiPortalApp, Event<? extends UIPageWizard> event) throws Exception
+ protected void updateUIPortal(Event<? extends UIPageWizard> event) throws Exception
{
PortalRequestContext pcontext = (PortalRequestContext)event.getRequestContext();
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-04-07 08:40:10 UTC (rev 2518)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-04-07 08:49:03 UTC (rev 2519)
@@ -199,6 +199,12 @@
return listNavs;
}
+ /**
+ * Return cached UIPage associated to the specified pageReference
+ *
+ * @param pageReference key whose associated UIPage is to be returned
+ * @return the UIPage associated to the specified pageReference or null if not any
+ */
public UIPage getUIPage(String pageReference)
{
if(all_UIPages == null)
14 years, 8 months
gatein SVN: r2518 - in portal/branches/EPP_5_0_Branch: component/web and 10 other directories.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-04-07 04:40:10 -0400 (Wed, 07 Apr 2010)
New Revision: 2518
Added:
portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/security/CaptchaServlet.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/groovy/organization/webui/component/UIRegisterPortlet.gtmpl
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java
portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java
Modified:
portal/branches/EPP_5_0_Branch/component/web/pom.xml
portal/branches/EPP_5_0_Branch/packaging/module/src/main/javascript/portal.packaging.module.js
portal/branches/EPP_5_0_Branch/pom.xml
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterPortlet.java
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_nl.properties
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/RegisterPortlet_en.properties
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
Log:
JBEPP-229 Prevent flooding of user db by spambots
Modified: portal/branches/EPP_5_0_Branch/component/web/pom.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/component/web/pom.xml 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/component/web/pom.xml 2010-04-07 08:40:10 UTC (rev 2518)
@@ -84,9 +84,13 @@
<artifactId>json</artifactId>
<type>jar</type>
</dependency>
- <dependency>
+ <dependency>
<groupId>javax.security</groupId>
<artifactId>jacc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.captcha</groupId>
+ <artifactId>simplecaptcha</artifactId>
</dependency>
<dependency>
<groupId>org.exoplatform.portal</groupId>
Copied: portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/security/CaptchaServlet.java (from rev 2422, portal/trunk/component/web/src/main/java/org/exoplatform/web/security/CaptchaServlet.java)
===================================================================
--- portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/security/CaptchaServlet.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/security/CaptchaServlet.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss by Red Hat *
+ * Copyright 2010, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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;
+
+import static nl.captcha.Captcha.NAME;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import nl.captcha.Captcha;
+import nl.captcha.servlet.CaptchaServletUtil;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CaptchaServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String PARAM_HEIGHT = "height";
+
+ private static final String PARAM_WIDTH = "width";
+
+ protected int _width = 200;
+
+ protected int _height = 50;
+
+ @Override
+ public void init() throws ServletException
+ {
+ if (getInitParameter(PARAM_HEIGHT) != null)
+ {
+ _height = Integer.valueOf(getInitParameter(PARAM_HEIGHT));
+ }
+
+ if (getInitParameter(PARAM_WIDTH) != null)
+ {
+ _width = Integer.valueOf(getInitParameter(PARAM_WIDTH));
+ }
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ HttpSession session = req.getSession();
+ Captcha captcha;
+ if (session.getAttribute(NAME) == null)
+ {
+ captcha = new Captcha.Builder(_width, _height).addText().gimp().addNoise().addBackground().build();
+
+ session.setAttribute(NAME, captcha);
+ CaptchaServletUtil.writeImage(resp, captcha.getImage());
+
+ return;
+ }
+
+ captcha = (Captcha) session.getAttribute(NAME);
+ CaptchaServletUtil.writeImage(resp, captcha.getImage());
+ }
+
+}
Modified: portal/branches/EPP_5_0_Branch/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
--- portal/branches/EPP_5_0_Branch/packaging/module/src/main/javascript/portal.packaging.module.js 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/packaging/module/src/main/javascript/portal.packaging.module.js 2010-04-07 08:40:10 UTC (rev 2518)
@@ -46,6 +46,7 @@
var groovyVersion = "${org.codehaus.groovy.version}";
var rhinoVersion = "${rhino.version}";
var jcipVersion = "${jcip.version}";
+ var simplecapthaVersion = "${nl.captcha.simplecaptcha.version}";
//TODO versions for gatein components
@@ -176,8 +177,11 @@
addDependency(core.component.xmlProcessing).
addDependency(core.component.documents).
- addDependency(jcr.services.jcr);
+ addDependency(jcr.services.jcr).
+ addDependency(new Project("org.gatein.captcha", "simplecaptcha", "jar", simplecapthaVersion)).
+ addDependency(new Project("com.jhlabs", "filters", "jar", "2.0.235"));
+
module.portlet = {};
module.portlet.exoadmin =
Modified: portal/branches/EPP_5_0_Branch/pom.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/pom.xml 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/pom.xml 2010-04-07 08:40:10 UTC (rev 2518)
@@ -43,6 +43,7 @@
<org.exoplatform.jcr.version>1.12.0-GA</org.exoplatform.jcr.version>
<org.jibx.version>1.2.1</org.jibx.version>
<org.shindig.version>1.0-r790473-Patch02</org.shindig.version>
+ <nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
<org.gatein.common.version>2.0.0-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.0-GA</org.gatein.wci.version>
<org.gatein.pc.version>2.1.0-GA</org.gatein.pc.version>
@@ -669,8 +670,12 @@
<artifactId>shindig-social-api</artifactId>
<version>${org.shindig.version}</version>
</dependency>
-
<dependency>
+ <groupId>org.gatein.captcha</groupId>
+ <artifactId>simplecaptcha</artifactId>
+ <version>${nl.captcha.simplecaptcha.version}</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
Copied: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java (from rev 2422, portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java)
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterEditMode.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -0,0 +1,80 @@
+/*
+ * 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.account.webui.component;
+
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
+import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormCheckBoxInput;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+
+/**
+ * @author <a href="mailto:truong.le@exoplatform.com">Truong Le</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Id$
+ *
+ */
+@ComponentConfig(lifecycle = UIFormLifecycle.class,
+ template = "system:/groovy/webui/form/UIFormWithTitle.gtmpl",
+ events = {@EventConfig(listeners = UIRegisterEditMode.SaveActionListener.class)}
+ )
+@Serialized
+public class UIRegisterEditMode extends UIForm
+{
+ public static final String USE_CAPTCHA = "useCaptcha";
+
+ public UIRegisterEditMode() throws Exception
+ {
+ PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+ PortletPreferences pref = pcontext.getRequest().getPreferences();
+ boolean useCaptcha = Boolean.parseBoolean(pref.getValue(USE_CAPTCHA,"true"));
+ addUIFormInput(new UIFormCheckBoxInput<Boolean>(USE_CAPTCHA, USE_CAPTCHA, useCaptcha).setValue(useCaptcha));
+ }
+
+ static public class SaveActionListener extends EventListener<UIRegisterEditMode>
+ {
+
+ @Override
+ public void execute(Event<UIRegisterEditMode> event) throws Exception
+ {
+ // TODO Auto-generated method stub
+ UIRegisterEditMode uiForm = event.getSource();
+ boolean useCaptcha = uiForm.getUIFormCheckBoxInput(USE_CAPTCHA).isChecked();
+ PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+ PortletPreferences pref = pcontext.getRequest().getPreferences();
+ pref.setValue(USE_CAPTCHA, Boolean.toString(useCaptcha));
+ pref.store();
+ UIPortalApplication portalApp = Util.getUIPortalApplication();
+ if (portalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
+ pcontext.setApplicationMode(PortletMode.VIEW);
+
+ }
+
+ }
+}
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterForm.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -19,6 +19,10 @@
package org.exoplatform.account.webui.component;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.webui.CaptchaValidator;
+import org.exoplatform.portal.webui.UICaptcha;
+import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.services.organization.OrganizationService;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.web.application.ApplicationMessage;
@@ -40,6 +44,11 @@
import java.util.ArrayList;
import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import nl.captcha.Captcha;
+
/**
*
* @author <a href="mailto:hoang281283@gmail.com">Minh Hoang TO</a>
@@ -83,6 +92,12 @@
@Override
public void execute(Event<UIRegisterForm> event) throws Exception
{
+ // Invalidate the captcha image
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ HttpServletRequest request = prContext.getRequest();
+ HttpSession session = request.getSession();
+ session.removeAttribute(Captcha.NAME);
+
UIRegisterForm registerForm = event.getSource();
OrganizationService orgService = registerForm.getApplicationComponent(OrganizationService.class);
UserHandler userHandler = orgService.getUserHandler();
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterInputSet.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -18,11 +18,16 @@
*/
package org.exoplatform.account.webui.component;
+import javax.portlet.PortletPreferences;
+
+import org.exoplatform.portal.webui.CaptchaValidator;
+import org.exoplatform.portal.webui.UICaptcha;
import org.exoplatform.services.organization.Query;
import org.exoplatform.services.organization.User;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.webui.core.UIApplication;
import org.exoplatform.webui.form.UIFormInputWithActions;
import org.exoplatform.webui.form.UIFormStringInput;
@@ -51,7 +56,9 @@
protected static String LAST_NAME = "lastName";
protected static String EMAIL_ADDRESS = "emailAddress";
-
+
+ protected static String CAPTCHA = "captcha";
+
public UIRegisterInputSet(String name) throws Exception{
super(name);
@@ -76,7 +83,16 @@
"ResourceValidator.msg.Invalid-char"));
addUIFormInput(new UIFormStringInput(EMAIL_ADDRESS, EMAIL_ADDRESS, null).addValidator(MandatoryValidator.class).addValidator(
- EmailAddressValidator.class));
+ EmailAddressValidator.class));
+
+ PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance();
+ PortletPreferences pref = pcontext.getRequest().getPreferences();
+ boolean useCaptcha = Boolean.parseBoolean(pref.getValue(UIRegisterEditMode.USE_CAPTCHA,"true"));
+
+ if (useCaptcha)
+ {
+ addUIFormInput(new UICaptcha(CAPTCHA, CAPTCHA, null).addValidator(MandatoryValidator.class).addValidator(CaptchaValidator.class));
+ }
}
private String getUserName(){
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterPortlet.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterPortlet.java 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/account/webui/component/UIRegisterPortlet.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -30,10 +30,11 @@
*
*/
-@ComponentConfig(lifecycle = UIApplicationLifecycle.class)
+@ComponentConfig(lifecycle = UIApplicationLifecycle.class, template = "app:/groovy/organization/webui/component/UIRegisterPortlet.gtmpl")
public class UIRegisterPortlet extends UIPortletApplication {
public UIRegisterPortlet() throws Exception{
- addChild(UIRegisterForm.class, null, null);
+ addChild(UIRegisterForm.class, null, null);
+ addChild(UIRegisterEditMode.class,null,null).setRendered(false);
}
}
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_nl.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_nl.properties 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/ApplicationRegistryPortlet_nl.properties 2010-04-07 08:40:10 UTC (rev 2518)
@@ -18,9 +18,9 @@
#
##expression
-word.cancel=#{word.cancel}
-label.displayName=#{label.displayName}
-label.description=#{label.description}
+word.cancel=Annuleren
+label.displayName=Weergavenaam
+label.description=Beschrijving
category.msg.changeNotExist=Kan de wijzigingen niet opslaan omdat de categorie niet meer bestaat.
application.msg.changeNotExist=Kan de wijzigingen niet opslaan omdat de applicatie niet meer bestaat.
gadget.msg.changeNotExist=Kan de wijzigingen niet opslaan omdat de gadget niet meer bestaat.
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/RegisterPortlet_en.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/RegisterPortlet_en.properties 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/classes/locale/portlet/exoadmin/RegisterPortlet_en.properties 2010-04-07 08:40:10 UTC (rev 2518)
@@ -24,6 +24,10 @@
UIRegisterForm.label.username=User Name:
UIRegisterForm.label.password=Password:
UIRegisterForm.label.confirmPassword=Confirm Password:
-UIRegisterForm.label.firstName= First Name:
-UIRegisterForm.label.lastName= Last Name:
-UIRegisterForm.label.emailAddress= Email Address:
\ No newline at end of file
+UIRegisterForm.label.firstName=First Name:
+UIRegisterForm.label.lastName=Last Name:
+UIRegisterForm.label.emailAddress=Email Address:
+UIRegisterForm.label.captcha=Text validation:
+
+UIRegisterEditMode.title=Register Portlet Preferences
+UIRegisterEditMode.label.useCaptcha=Use captcha:
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/WEB-INF/portlet.xml 2010-04-07 08:40:10 UTC (rev 2518)
@@ -95,7 +95,7 @@
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
- <portlet-mode>help</portlet-mode>
+ <portlet-mode>edit</portlet-mode>
</supports>
<supported-locale>en</supported-locale>
Copied: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/groovy/organization/webui/component/UIRegisterPortlet.gtmpl (from rev 2422, portal/trunk/portlet/exoadmin/src/main/webapp/groovy/organization/webui/component/UIRegisterPortlet.gtmpl)
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/groovy/organization/webui/component/UIRegisterPortlet.gtmpl (rev 0)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/webapp/groovy/organization/webui/component/UIRegisterPortlet.gtmpl 2010-04-07 08:40:10 UTC (rev 2518)
@@ -0,0 +1,20 @@
+<%
+ import org.exoplatform.account.webui.component.UIRegisterEditMode;
+ import javax.portlet.PortletMode ;
+%>
+<%
+if(_ctx.getRequestContext().getApplicationMode() == PortletMode.VIEW)
+{
+ uicomponent.renderChildren();
+}
+else
+{
+ for (inputEntry in uicomponent.getChildren())
+ {
+ if (inputEntry instanceof UIRegisterEditMode)
+ {
+ uicomponent.renderUIComponent(inputEntry);
+ }
+ }
+}
+%>
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/classes/locale/portal/webui_en.properties 2010-04-07 08:40:10 UTC (rev 2518)
@@ -55,7 +55,14 @@
MandatoryValidatorIterator.msg.empty=The "{0}" list can not be empty.
+
#############################################################################
+ # Captcha Validator #
+ #############################################################################
+
+CaptchaValidator.msg.Invalid-input=Text verification isn't correct
+
+ #############################################################################
# Number Format Validator #
#############################################################################
#class org.exoplatform.webui.form.validator.Validator.NumberFormatValidator
Modified: portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2010-04-07 08:40:10 UTC (rev 2518)
@@ -213,6 +213,25 @@
<load-on-startup>0</load-on-startup>
</servlet>
+ <servlet>
+ <servlet-name>StickyCaptcha</servlet-name>
+ <servlet-class>org.exoplatform.web.security.CaptchaServlet</servlet-class>
+ <init-param>
+ <param-name>width</param-name>
+ <param-value>200</param-value>
+ </init-param>
+ <init-param>
+ <param-name>height</param-name>
+ <param-value>75</param-value>
+ </init-param>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>StickyCaptcha</servlet-name>
+ <url-pattern>/captcha</url-pattern>
+ </servlet-mapping>
+
+
<!-- ================================================================= -->
<servlet-mapping>
<servlet-name>InitiateLoginServlet</servlet-name>
Modified: portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-04-07 08:24:02 UTC (rev 2517)
+++ portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-04-07 08:40:10 UTC (rev 2518)
@@ -87,5 +87,10 @@
<groupId>org.exoplatform.portal</groupId>
<artifactId>exo.portal.gadgets-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.gatein.captcha</groupId>
+ <artifactId>simplecaptcha</artifactId>
+ </dependency>
</dependencies>
</project>
Copied: portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java (from rev 2422, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java)
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/CaptchaValidator.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -0,0 +1,80 @@
+/**
+ * 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.webui;
+
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.exception.MessageException;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormInput;
+import org.exoplatform.webui.form.validator.Validator;
+
+import nl.captcha.Captcha;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * Validator for Captcha content.
+ * Checks that the user input is equals to the content displayed by the
+ * distorted image.
+ */
+public class CaptchaValidator implements Validator, Serializable
+{
+
+ public void validate(UIFormInput uiInput) throws Exception
+ {
+ PortalRequestContext prContext = Util.getPortalRequestContext();
+ HttpServletRequest request = prContext.getRequest();
+ HttpSession session = request.getSession();
+
+ Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
+
+ if ((captcha != null) && (captcha.isCorrect((String) uiInput.getValue())))
+ {
+ return;
+ }
+
+ //modified by Pham Dinh Tan
+ UIComponent uiComponent = (UIComponent) uiInput;
+ UIForm uiForm = uiComponent.getAncestorOfType(UIForm.class);
+ String label;
+ try
+ {
+ label = uiForm.getLabel(uiInput.getName());
+ }
+ catch (Exception e)
+ {
+ label = uiInput.getName();
+ }
+ label = label.trim();
+ if (label.charAt(label.length() - 1) == ':')
+ label = label.substring(0, label.length() - 1);
+ Object[] args =
+ {label, uiInput.getBindingField()};
+ throw new MessageException(new ApplicationMessage("CaptchaValidator.msg.Invalid-input", args,
+ ApplicationMessage.WARNING));
+ }
+}
Copied: portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java (from rev 2422, portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java)
===================================================================
--- portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java (rev 0)
+++ portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/UICaptcha.java 2010-04-07 08:40:10 UTC (rev 2518)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss by Red Hat *
+ * Copyright 2010, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.webui;
+
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.form.UIFormStringInput;
+
+/**
+ * @author <a href="mailto:theute@redhat.com">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UICaptcha extends UIFormStringInput
+{
+
+ public UICaptcha(String name, String bindingExpression, String value)
+ {
+ super(name, bindingExpression, value);
+ }
+
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ context.getWriter().write("<img src=\"" + context.getPortalContextPath() + "/captcha\" /><br/>");
+ super.processRender(context);
+ }
+
+}
14 years, 8 months
gatein SVN: r2517 - portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-04-07 04:24:02 -0400 (Wed, 07 Apr 2010)
New Revision: 2517
Modified:
portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
Log:
JBEPP-289: 'EditPage' link is not showed while loging in with non-empty path node in private mode
Modified: portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
===================================================================
--- portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-04-07 08:07:44 UTC (rev 2516)
+++ portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-04-07 08:24:02 UTC (rev 2517)
@@ -19,8 +19,11 @@
package org.exoplatform.toolbar.webui.component;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserACL;
+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.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageBody;
@@ -48,15 +51,6 @@
public PageNavigation getSelectedNavigation() throws Exception
{
return Util.getUIPortal().getSelectedNavigation();
-
- /*
- PageNavigation nav = Util.getUIPortal().getSelectedNavigation();
- if (nav != null)
- return nav;
- if (Util.getUIPortal().getNavigations().size() < 1)
- return null;
- return Util.getUIPortal().getNavigations().get(0);
- */
}
@Override
@@ -100,16 +94,34 @@
UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
UIPage uiPage = (UIPage)pageBody.getUIComponent();
+ UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- if (uiPage == null)
+ if(uiPage != null)
{
- return false;
+ return userACL.hasEditPermissionOnPage(uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
}
else
{
- UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- return userACL.hasEditPermissionOnPage(uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
+ UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID).findFirstComponentOfType(UIPortal.class);
+ PageNode currentNode = currentUIPortal.getSelectedNode();
+ String pageReference = currentNode.getPageReference();
+ if(pageReference == null)
+ {
+ return false;
+ }
+ else
+ {
+ DataStorage dataStorage = portalApp.getApplicationComponent(DataStorage.class);
+ Page page = dataStorage.getPage(pageReference);
+ if(page == null)
+ {
+ return false;
+ }
+ else
+ {
+ return userACL.hasEditPermission(page);
+ }
+ }
}
}
-
}
14 years, 8 months
gatein SVN: r2516 - portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-04-07 04:07:44 -0400 (Wed, 07 Apr 2010)
New Revision: 2516
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
Log:
GTNPORTAL-1039: EditPage link is not showed while loging in with non-empty path in private mode
Modified: portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java
===================================================================
--- portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-04-07 07:39:09 UTC (rev 2515)
+++ portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/toolbar/webui/component/UIAdminToolbarPortlet.java 2010-04-07 08:07:44 UTC (rev 2516)
@@ -19,8 +19,11 @@
package org.exoplatform.toolbar.webui.component;
+import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.UserACL;
+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.webui.page.UIPage;
import org.exoplatform.portal.webui.page.UIPageBody;
@@ -48,15 +51,6 @@
public PageNavigation getSelectedNavigation() throws Exception
{
return Util.getUIPortal().getSelectedNavigation();
-
- /*
- PageNavigation nav = Util.getUIPortal().getSelectedNavigation();
- if (nav != null)
- return nav;
- if (Util.getUIPortal().getNavigations().size() < 1)
- return null;
- return Util.getUIPortal().getNavigations().get(0);
- */
}
@Override
@@ -100,16 +94,34 @@
UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
UIPage uiPage = (UIPage)pageBody.getUIComponent();
+ UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- if (uiPage == null)
+ if(uiPage != null)
{
- return false;
+ return userACL.hasEditPermissionOnPage(uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
}
else
{
- UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
- return userACL.hasEditPermissionOnPage(uiPage.getOwnerType(), uiPage.getOwnerId(), uiPage.getEditPermission());
+ UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace>findComponentById(UIPortalApplication.UI_WORKING_WS_ID).findFirstComponentOfType(UIPortal.class);
+ PageNode currentNode = currentUIPortal.getSelectedNode();
+ String pageReference = currentNode.getPageReference();
+ if(pageReference == null)
+ {
+ return false;
+ }
+ else
+ {
+ DataStorage dataStorage = portalApp.getApplicationComponent(DataStorage.class);
+ Page page = dataStorage.getPage(pageReference);
+ if(page == null)
+ {
+ return false;
+ }
+ else
+ {
+ return userACL.hasEditPermission(page);
+ }
+ }
}
}
-
}
14 years, 8 months
gatein SVN: r2515 - in portal/branches/EPP_5_0_Branch/component: common/src/test/java/org/exoplatform/commons/cache/future and 1 other directories.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-04-07 03:39:09 -0400 (Wed, 07 Apr 2010)
New Revision: 2515
Removed:
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
Modified:
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
Log:
JBEPP-265: Handle gracefully concurrent compilation of the same template
Deleted: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -1,58 +0,0 @@
-/*
- * 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.commons.cache.future;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Entry<V> implements Serializable
-{
-
- public static <V> Entry<V> create(V v)
- {
- return new Entry<V>(v);
- }
-
- /** . */
- private final V value;
-
- private Entry(V value)
- {
- if (value == null)
- {
- throw new NullPointerException();
- }
- this.value = value;
- }
-
- public V getValue()
- {
- return value;
- }
-
- @Override
- public String toString()
- {
- return "Entry[" + value + "]";
- }
-}
Modified: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -30,6 +30,9 @@
*
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
*/
public abstract class FutureCache<K, V, C>
{
@@ -38,7 +41,7 @@
private final Loader<K, V, C> loader;
/** . */
- private final ConcurrentMap<K, FutureTask<Entry<V>>> local;
+ private final ConcurrentMap<K, FutureTask<V>> futureEntries;
/** . */
private final Logger log = LoggerFactory.getLogger(FutureCache.class);
@@ -46,26 +49,35 @@
public FutureCache(Loader<K, V, C> loader)
{
this.loader = loader;
- this.local = new ConcurrentHashMap<K, FutureTask<Entry<V>>>();
+ this.futureEntries = new ConcurrentHashMap<K, FutureTask<V>>();
}
- protected abstract Entry<V> get(K key);
+ protected abstract V get(K key);
- protected abstract void put(K key, Entry<V> entry);
+ protected abstract void put(K key, V value);
- public V get(final C context, final K key)
+ /**
+ * Perform a cache lookup for the specified key within the specified context.
+ * When the value cannot be loaded (because it does not exist or it failed or anything else that
+ * does not come to my mind), the value null is returned.
+ *
+ * @param context the context in which the resource is accessed
+ * @param key the key identifying the resource
+ * @return the value
+ */
+ public final V get(final C context, final K key)
{
// First we try a simple cache get
- Entry<V> entry = get(key);
+ V value = get(key);
// If it does not succeed then we go through a process that will avoid to load
// the same resource concurrently
- if (entry == null)
+ if (value == null)
{
// Create our future
- FutureTask<Entry<V>> future = new FutureTask<Entry<V>>(new Callable<Entry<V>>()
+ FutureTask<V> future = new FutureTask<V>(new Callable<V>()
{
- public Entry<V> call() throws Exception
+ public V call() throws Exception
{
// Retrieve the value from the loader
V value = loader.retrieve(context, key);
@@ -73,14 +85,11 @@
//
if (value != null)
{
- // Create the entry
- Entry<V> entry = Entry.create(value);
-
// Cache it, it is made available to other threads (unless someone removes it)
- put(key, entry);
+ put(key, value);
- // Return entry
- return entry;
+ // Return value
+ return value;
}
else
{
@@ -89,15 +98,15 @@
}
});
- // Was our means that we inserted in the local
+ // This boolean means we inserted in the local
boolean inserted = true;
//
try
{
- FutureTask<Entry<V>> phantom = local.putIfAbsent(key, future);
+ FutureTask<V> phantom = futureEntries.putIfAbsent(key, future);
- // Use the entry that could have been inserted by another thread
+ // Use the value that could have been inserted by another thread
if (phantom != null)
{
future = phantom;
@@ -108,8 +117,8 @@
future.run();
}
- // Returns the entry
- entry = future.get();
+ // Returns the value
+ value = future.get();
}
catch (ExecutionException e)
{
@@ -124,12 +133,12 @@
// Clean up the per key map but only if our insertion succeeded and with our future
if (inserted)
{
- local.remove(key, future);
+ futureEntries.remove(key, future);
}
}
}
//
- return entry != null ? entry.getValue() : null;
+ return value;
}
}
Modified: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -31,9 +31,9 @@
{
/** . */
- private final ExoCache<K, Entry<V>> cache;
+ private final ExoCache<K, V> cache;
- public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, Entry<V>> cache)
+ public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, V> cache)
{
super(loader);
@@ -42,13 +42,13 @@
}
@Override
- protected Entry<V> get(K key)
+ protected V get(K key)
{
return cache.get(key);
}
@Override
- protected void put(K key, Entry<V> entry)
+ protected void put(K key, V entry)
{
cache.put(key, entry);
}
Modified: portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -19,15 +19,27 @@
package org.exoplatform.commons.cache.future;
-import java.io.Serializable;
-
/**
+ * The loader interface is used by the future cache to retrieves the value from the key when it does not exist.
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
*/
public interface Loader<K, V, C>
{
+ /**
+ * Retrieves the value from the key within the specified context. If the resource is not found then the value
+ * null must be returned.
+ *
+ * @param context the context
+ * @param key the key
+ * @return the value
+ * @throws Exception any exception that would prevent the value to be loaded
+ */
V retrieve(C context, K key) throws Exception;
}
Modified: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -21,8 +21,6 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.exoplatform.commons.cache.future.Entry;
-import org.exoplatform.commons.cache.future.FutureCache;
import org.gatein.common.util.Tools;
import java.util.*;
@@ -39,13 +37,13 @@
private AssertionFailedError failure;
/** . */
- private LinkedList<String> events = new LinkedList<String>();
+ private List<String> events = Collections.synchronizedList(new LinkedList<String>());
FutureCache<String, String, Callable<String>> futureCache = new FutureCache<String, String, Callable<String>>(new StringLoader()) {
@Override
- protected Entry<String> get(String key)
+ protected String get(String key)
{
if (key == key1)
{
@@ -53,7 +51,7 @@
{
failure = new AssertionFailedError();
}
- events.addLast("get/key1");
+ events.add("get/key1");
}
else if (key == key2)
{
@@ -61,7 +59,7 @@
{
failure = new AssertionFailedError();
}
- events.addLast("get/key2");
+ events.add("get/key2");
}
else
{
@@ -71,13 +69,13 @@
}
@Override
- protected void put(String key, Entry<String> entry)
+ protected void put(String key, String value)
{
if (key == key1)
{
if (Thread.currentThread() == thread1)
{
- events.addLast("begin_put/key1/" + entry);
+ events.add("begin_put/key1/" + value);
//
thread2.start();
@@ -89,7 +87,7 @@
}
//
- events.addLast("end_put/key1");
+ events.add("end_put/key1");
}
else
{
@@ -118,11 +116,11 @@
{
public String call() throws Exception
{
- events.addLast("call/key1");
+ events.add("call/key1");
return "foo_value_1";
}
}, key1);
- events.addLast("retrieved/key1/" + v);
+ events.add("retrieved/key1/" + v);
}
};
@@ -139,7 +137,7 @@
return "foo_value_2";
}
}, key2);
- events.addLast("retrieved/key2/" + v);
+ events.add("retrieved/key2/" + v);
}
};
@@ -161,7 +159,7 @@
List<String> expectedEvents = Arrays.asList(
"get/key1",
"call/key1",
- "begin_put/key1/Entry[foo_value_1]",
+ "begin_put/key1/foo_value_1",
"get/key2",
"end_put/key1"
);
Modified: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -19,10 +19,6 @@
package org.exoplatform.commons.cache.future;
-import org.exoplatform.commons.cache.future.Entry;
-import org.exoplatform.commons.cache.future.FutureCache;
-import org.exoplatform.commons.cache.future.Loader;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -35,25 +31,25 @@
{
/** . */
- final Map<String, Entry<String>> data;
+ final Map<String, String> data;
public FutureMap(Loader<String, String, C> loader)
{
super(loader);
//
- this.data = Collections.synchronizedMap(new HashMap<String, Entry<String>>());
+ this.data = Collections.synchronizedMap(new HashMap<String, String>());
}
@Override
- protected Entry<String> get(String key)
+ protected String get(String key)
{
return data.get(key);
}
@Override
- protected void put(String key, Entry<String> entry)
+ protected void put(String key, String value)
{
- data.put(key, entry);
+ data.put(key, value);
}
}
Modified: portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -40,7 +40,7 @@
return "foo_value";
}
}, "foo"));
- Assert.assertEquals("foo_value", futureCache.data.get("foo").getValue());
+ Assert.assertEquals("foo_value", futureCache.data.get("foo"));
}
public void testNullValue()
Modified: portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
===================================================================
--- portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-07 06:54:06 UTC (rev 2514)
+++ portal/branches/EPP_5_0_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-07 07:39:09 UTC (rev 2515)
@@ -22,7 +22,6 @@
import groovy.lang.Writable;
import groovy.text.Template;
-import org.exoplatform.commons.cache.future.Entry;
import org.exoplatform.commons.cache.future.FutureCache;
import org.exoplatform.commons.cache.future.FutureExoCache;
import org.exoplatform.commons.cache.future.Loader;
@@ -59,7 +58,7 @@
private GroovyTemplateEngine engine_;
- private ExoCache<ResourceKey, Entry<GroovyTemplate>> templatesCache_;
+ private ExoCache<ResourceKey, GroovyTemplate> templatesCache_;
private TemplateStatisticService statisticService;
@@ -169,7 +168,7 @@
getTemplatesCache().remove(resourceId);
}
- public ExoCache<ResourceKey, Entry<GroovyTemplate>> getTemplatesCache()
+ public ExoCache<ResourceKey, GroovyTemplate> getTemplatesCache()
{
return templatesCache_;
}
@@ -219,13 +218,9 @@
try
{
ArrayList<String> list = new ArrayList<String>();
- for (Entry<GroovyTemplate> entry : templatesCache_.getCachedObjects())
+ for (GroovyTemplate template : templatesCache_.getCachedObjects())
{
- GroovyTemplate template = entry.getValue();
- if (template != null)
- {
- list.add(template.getId());
- }
+ list.add(template.getId());
}
return list.toArray(new String[list.size()]);
}
14 years, 8 months
gatein SVN: r2514 - in portal/trunk/component: common/src/test/java/org/exoplatform/commons/cache/future and 1 other directories.
by do-not-reply@jboss.org
Author: julien_viet
Date: 2010-04-07 02:54:06 -0400 (Wed, 07 Apr 2010)
New Revision: 2514
Removed:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
Modified:
portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
Log:
GTNPORTAL-945 : simplification + javadoc
Deleted: portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Entry.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -1,58 +0,0 @@
-/*
- * 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.commons.cache.future;
-
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
- * @version $Revision$
- */
-public class Entry<V> implements Serializable
-{
-
- public static <V> Entry<V> create(V v)
- {
- return new Entry<V>(v);
- }
-
- /** . */
- private final V value;
-
- private Entry(V value)
- {
- if (value == null)
- {
- throw new NullPointerException();
- }
- this.value = value;
- }
-
- public V getValue()
- {
- return value;
- }
-
- @Override
- public String toString()
- {
- return "Entry[" + value + "]";
- }
-}
Modified: portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureCache.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -30,6 +30,9 @@
*
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
*/
public abstract class FutureCache<K, V, C>
{
@@ -38,7 +41,7 @@
private final Loader<K, V, C> loader;
/** . */
- private final ConcurrentMap<K, FutureTask<Entry<V>>> local;
+ private final ConcurrentMap<K, FutureTask<V>> futureEntries;
/** . */
private final Logger log = LoggerFactory.getLogger(FutureCache.class);
@@ -46,26 +49,35 @@
public FutureCache(Loader<K, V, C> loader)
{
this.loader = loader;
- this.local = new ConcurrentHashMap<K, FutureTask<Entry<V>>>();
+ this.futureEntries = new ConcurrentHashMap<K, FutureTask<V>>();
}
- protected abstract Entry<V> get(K key);
+ protected abstract V get(K key);
- protected abstract void put(K key, Entry<V> entry);
+ protected abstract void put(K key, V value);
- public V get(final C context, final K key)
+ /**
+ * Perform a cache lookup for the specified key within the specified context.
+ * When the value cannot be loaded (because it does not exist or it failed or anything else that
+ * does not come to my mind), the value null is returned.
+ *
+ * @param context the context in which the resource is accessed
+ * @param key the key identifying the resource
+ * @return the value
+ */
+ public final V get(final C context, final K key)
{
// First we try a simple cache get
- Entry<V> entry = get(key);
+ V value = get(key);
// If it does not succeed then we go through a process that will avoid to load
// the same resource concurrently
- if (entry == null)
+ if (value == null)
{
// Create our future
- FutureTask<Entry<V>> future = new FutureTask<Entry<V>>(new Callable<Entry<V>>()
+ FutureTask<V> future = new FutureTask<V>(new Callable<V>()
{
- public Entry<V> call() throws Exception
+ public V call() throws Exception
{
// Retrieve the value from the loader
V value = loader.retrieve(context, key);
@@ -73,14 +85,11 @@
//
if (value != null)
{
- // Create the entry
- Entry<V> entry = Entry.create(value);
-
// Cache it, it is made available to other threads (unless someone removes it)
- put(key, entry);
+ put(key, value);
- // Return entry
- return entry;
+ // Return value
+ return value;
}
else
{
@@ -89,15 +98,15 @@
}
});
- // Was our means that we inserted in the local
+ // This boolean means we inserted in the local
boolean inserted = true;
//
try
{
- FutureTask<Entry<V>> phantom = local.putIfAbsent(key, future);
+ FutureTask<V> phantom = futureEntries.putIfAbsent(key, future);
- // Use the entry that could have been inserted by another thread
+ // Use the value that could have been inserted by another thread
if (phantom != null)
{
future = phantom;
@@ -108,8 +117,8 @@
future.run();
}
- // Returns the entry
- entry = future.get();
+ // Returns the value
+ value = future.get();
}
catch (ExecutionException e)
{
@@ -124,12 +133,12 @@
// Clean up the per key map but only if our insertion succeeded and with our future
if (inserted)
{
- local.remove(key, future);
+ futureEntries.remove(key, future);
}
}
}
//
- return entry != null ? entry.getValue() : null;
+ return value;
}
}
Modified: portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/FutureExoCache.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -31,9 +31,9 @@
{
/** . */
- private final ExoCache<K, Entry<V>> cache;
+ private final ExoCache<K, V> cache;
- public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, Entry<V>> cache)
+ public FutureExoCache(Loader<K, V, C> loader, ExoCache<K, V> cache)
{
super(loader);
@@ -42,13 +42,13 @@
}
@Override
- protected Entry<V> get(K key)
+ protected V get(K key)
{
return cache.get(key);
}
@Override
- protected void put(K key, Entry<V> entry)
+ protected void put(K key, V entry)
{
cache.put(key, entry);
}
Modified: portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java
===================================================================
--- portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/main/java/org/exoplatform/commons/cache/future/Loader.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -19,15 +19,27 @@
package org.exoplatform.commons.cache.future;
-import java.io.Serializable;
-
/**
+ * The loader interface is used by the future cache to retrieves the value from the key when it does not exist.
+ *
* @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a>
* @version $Revision$
+ * @param <K> the key type parameter
+ * @param <V> the value type parameter
+ * @param <C> the context type parameter
*/
public interface Loader<K, V, C>
{
+ /**
+ * Retrieves the value from the key within the specified context. If the resource is not found then the value
+ * null must be returned.
+ *
+ * @param context the context
+ * @param key the key
+ * @return the value
+ * @throws Exception any exception that would prevent the value to be loaded
+ */
V retrieve(C context, K key) throws Exception;
}
Modified: portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/ConcurrentGetWhenPutTestCase.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -21,8 +21,6 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.exoplatform.commons.cache.future.Entry;
-import org.exoplatform.commons.cache.future.FutureCache;
import org.gatein.common.util.Tools;
import java.util.*;
@@ -45,7 +43,7 @@
@Override
- protected Entry<String> get(String key)
+ protected String get(String key)
{
if (key == key1)
{
@@ -71,13 +69,13 @@
}
@Override
- protected void put(String key, Entry<String> entry)
+ protected void put(String key, String value)
{
if (key == key1)
{
if (Thread.currentThread() == thread1)
{
- events.add("begin_put/key1/" + entry);
+ events.add("begin_put/key1/" + value);
//
thread2.start();
@@ -161,7 +159,7 @@
List<String> expectedEvents = Arrays.asList(
"get/key1",
"call/key1",
- "begin_put/key1/Entry[foo_value_1]",
+ "begin_put/key1/foo_value_1",
"get/key2",
"end_put/key1"
);
Modified: portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/FutureMap.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -19,10 +19,6 @@
package org.exoplatform.commons.cache.future;
-import org.exoplatform.commons.cache.future.Entry;
-import org.exoplatform.commons.cache.future.FutureCache;
-import org.exoplatform.commons.cache.future.Loader;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -35,25 +31,25 @@
{
/** . */
- final Map<String, Entry<String>> data;
+ final Map<String, String> data;
public FutureMap(Loader<String, String, C> loader)
{
super(loader);
//
- this.data = Collections.synchronizedMap(new HashMap<String, Entry<String>>());
+ this.data = Collections.synchronizedMap(new HashMap<String, String>());
}
@Override
- protected Entry<String> get(String key)
+ protected String get(String key)
{
return data.get(key);
}
@Override
- protected void put(String key, Entry<String> entry)
+ protected void put(String key, String value)
{
- data.put(key, entry);
+ data.put(key, value);
}
}
Modified: portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java
===================================================================
--- portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/common/src/test/java/org/exoplatform/commons/cache/future/GetTestCase.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -40,7 +40,7 @@
return "foo_value";
}
}, "foo"));
- Assert.assertEquals("foo_value", futureCache.data.get("foo").getValue());
+ Assert.assertEquals("foo_value", futureCache.data.get("foo"));
}
public void testNullValue()
Modified: portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java
===================================================================
--- portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-07 04:20:55 UTC (rev 2513)
+++ portal/trunk/component/scripting/src/main/java/org/exoplatform/groovyscript/text/TemplateService.java 2010-04-07 06:54:06 UTC (rev 2514)
@@ -22,7 +22,6 @@
import groovy.lang.Writable;
import groovy.text.Template;
-import org.exoplatform.commons.cache.future.Entry;
import org.exoplatform.commons.cache.future.FutureCache;
import org.exoplatform.commons.cache.future.FutureExoCache;
import org.exoplatform.commons.cache.future.Loader;
@@ -59,7 +58,7 @@
private GroovyTemplateEngine engine_;
- private ExoCache<ResourceKey, Entry<GroovyTemplate>> templatesCache_;
+ private ExoCache<ResourceKey, GroovyTemplate> templatesCache_;
private TemplateStatisticService statisticService;
@@ -169,7 +168,7 @@
getTemplatesCache().remove(resourceId);
}
- public ExoCache<ResourceKey, Entry<GroovyTemplate>> getTemplatesCache()
+ public ExoCache<ResourceKey, GroovyTemplate> getTemplatesCache()
{
return templatesCache_;
}
@@ -219,13 +218,9 @@
try
{
ArrayList<String> list = new ArrayList<String>();
- for (Entry<GroovyTemplate> entry : templatesCache_.getCachedObjects())
+ for (GroovyTemplate template : templatesCache_.getCachedObjects())
{
- GroovyTemplate template = entry.getValue();
- if (template != null)
- {
- list.add(template.getId());
- }
+ list.add(template.getId());
}
return list.toArray(new String[list.size()]);
}
14 years, 8 months
gatein SVN: r2511 - portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design.
by do-not-reply@jboss.org
Author: hangnguyen
Date: 2010-04-06 23:17:06 -0400 (Tue, 06 Apr 2010)
New Revision: 2511
Added:
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_05_001_CopyPasteNodeToSamePlace.html
Log:
GTNPORTAL-1029: Create new test for "POR_25_05_001"
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_05_001_CopyPasteNodeToSamePlace.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_05_001_CopyPasteNodeToSamePlace.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_05_001_CopyPasteNodeToSamePlace.html 2010-04-07 03:17:06 UTC (rev 2511)
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_POR_25_001_CopyPasteNodeToSamePlace</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_POR_25_001_CopyPasteNodeToSamePlace</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Login portal--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Open Navigation Management pop-up --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Site</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Site</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Edit Navigation</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Edit Navigation</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Copy node--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>componentExoContextMenu</td>
+ <td>xpath=//div[@id="UINavigationNodeSelector"]/div/div/div/div[2]/div/div/div[6]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Copy Node</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Copy Node</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Paste node to same place--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>componentExoContextMenu</td>
+ <td>xpath=//div[@id="UINavigationNodeSelector"]/div/div/div/div[2]/div/div/div[6]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='NavigationNodePopupMenu']/div[@class='UIContextMenuContainer']/div[2]/div/div/div[7]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='NavigationNodePopupMenu']/div/div[2]/div/div/div[7]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Verify text Message--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>The source and the destination must be different.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIPortalApplication']//div[@class='ExoMessageDecorator']//div[@class='MiddleRightSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='UIPortalApplication']//div[@class='ExoMessageDecorator']//div[@class='MiddleRightSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Sign out--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
14 years, 8 months
gatein SVN: r2510 - portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design.
by do-not-reply@jboss.org
Author: hangnguyen
Date: 2010-04-06 23:14:42 -0400 (Tue, 06 Apr 2010)
New Revision: 2510
Added:
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_001_CopyPasteNodeToSamePlace.html
Log:
GTNPORTAL-1029: Create new test for "POR_25_001"
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_001_CopyPasteNodeToSamePlace.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_001_CopyPasteNodeToSamePlace.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_25_001_CopyPasteNodeToSamePlace.html 2010-04-07 03:14:42 UTC (rev 2510)
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_POR_25_001_CopyPasteNodeToSamePlace</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_POR_25_001_CopyPasteNodeToSamePlace</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Login portal--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Open Navigation Management pop-up --</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Site</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Site</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Edit Navigation</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Edit Navigation</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Copy node--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>componentExoContextMenu</td>
+ <td>xpath=//div[@id="UINavigationNodeSelector"]/div/div/div/div[2]/div/div/div[6]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Copy Node</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Copy Node</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Paste node to same place--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>componentExoContextMenu</td>
+ <td>xpath=//div[@id="UINavigationNodeSelector"]/div/div/div/div[2]/div/div/div[6]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='NavigationNodePopupMenu']/div[@class='UIContextMenuContainer']/div[2]/div/div/div[7]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='NavigationNodePopupMenu']/div/div[2]/div/div/div[7]//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Verify text Message--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>verifyTextPresent</td>
+ <td>The source and the destination must be different.</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>//div[@id='UIPortalApplication']//div[@class='ExoMessageDecorator']//div[@class='MiddleRightSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>//div[@id='UIPortalApplication']//div[@class='ExoMessageDecorator']//div[@class='MiddleRightSideDecorator']//div[@class='UIPopupMessages']/div[@class='MessageActionBar']//a</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Save</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>-- Sign out--</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Sign out</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
14 years, 8 months
gatein SVN: r2509 - portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design.
by do-not-reply@jboss.org
Author: hangnguyen
Date: 2010-04-06 23:14:11 -0400 (Tue, 06 Apr 2010)
New Revision: 2509
Added:
portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_01_004_SignInWithBlankUserNameAndPassword.html
Log:
GTNPORTAL-1030: Create new test for "POR_01_004"
Added: portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_01_004_SignInWithBlankUserNameAndPassword.html
===================================================================
--- portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_01_004_SignInWithBlankUserNameAndPassword.html (rev 0)
+++ portal/trunk/testsuite/selenium-snifftests/src/suite/org/exoplatform/portal/selenium/design/Test_POR_01_004_SignInWithBlankUserNameAndPassword.html 2010-04-07 03:14:11 UTC (rev 2509)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>Test_POR_01_004_SignInWithBlankUserNameAndPassword</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">Test_POR_01_004_SignInWithBlankUserNameAndPassword</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Sign in with blank password</td>
+ <td></td>
+</tr>
+<tr>
+ <td>clickAt</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>waitForElementPresent</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>username</td>
+ <td>root</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/portal/public/classic/</td>
+ <td></td>
+</tr>
+<tr>
+ <td>echo</td>
+ <td>--Sign in with blank username</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>link=Sign in</td>
+ <td></td>
+</tr>
+<tr>
+ <td>type</td>
+ <td>password</td>
+ <td>gtn</td>
+</tr>
+<tr>
+ <td>clickAndWait</td>
+ <td>//div[@id='UIPortalLoginFormAction']/div/div/div/</td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
14 years, 8 months