gatein SVN: r3992 - exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/webui/core.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-31 19:41:24 -0400 (Tue, 31 Aug 2010)
New Revision: 3992
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl
Log:
EXOGTN-59: In IE7, some navigations are hidden when there are more than 5 navigations in GroupNavigationManagment portlet
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl 2010-08-31 23:32:23 UTC (rev 3991)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/groovy/webui/core/UIVirtualList.gtmpl 2010-08-31 23:41:24 UTC (rev 3992)
@@ -13,7 +13,9 @@
%>
<div id="$uicomponent.id" style="overflow:auto;"
onscroll="eXo.webui.UIVirtualList.scrollMove(this,'$url');">
- <% uicomponent.renderChildren();%>
+ <div style="width: 99%;" >
+ <% uicomponent.renderChildren();%>
+ </div>
<%
if (!hasNext) {
rcontext.getJavascriptManager().addJavascript("eXo.webui.UIVirtualList.loadFinished('$uicomponent.id');");
14 years, 3 months
gatein SVN: r3991 - exo/portal/branches/3.1.x/web/portal/src/main/webapp.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-31 19:32:23 -0400 (Tue, 31 Aug 2010)
New Revision: 3991
Modified:
exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-unavailable.jsp
exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-warning.jsp
Log:
EXOGTN-56:Remove special characters in portal-unavailable.jsp and portal-warning.jsp files
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-unavailable.jsp
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-unavailable.jsp 2010-08-31 22:13:00 UTC (rev 3990)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-unavailable.jsp 2010-08-31 23:32:23 UTC (rev 3991)
@@ -19,7 +19,7 @@
--%>
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>Portal Warning </title>
Modified: exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-warning.jsp
===================================================================
--- exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-warning.jsp 2010-08-31 22:13:00 UTC (rev 3990)
+++ exo/portal/branches/3.1.x/web/portal/src/main/webapp/portal-warning.jsp 2010-08-31 23:32:23 UTC (rev 3991)
@@ -19,7 +19,7 @@
--%>
-<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<title>Portal Warning </title>
14 years, 3 months
gatein SVN: r3990 - epp/portal/branches/EPP_5_0_Branch/webui/portal.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-08-31 18:13:00 -0400 (Tue, 31 Aug 2010)
New Revision: 3990
Modified:
epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
Log:
JBEPP-403, JBEPP-383: Fixes ported from GateIn trunk
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-08-31 22:02:02 UTC (rev 3989)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-08-31 22:13:00 UTC (rev 3990)
@@ -92,11 +92,5 @@
<groupId>org.gatein.captcha</groupId>
<artifactId>simplecaptcha</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.exoplatform.portal</groupId>
- <artifactId>exo.portal.component.test.core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
14 years, 3 months
gatein SVN: r3989 - in epp/portal/branches/EPP_5_0_Branch: component/resources/src/main/java/org/exoplatform/services/resources and 10 other directories.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-08-31 18:02:02 -0400 (Tue, 31 Aug 2010)
New Revision: 3989
Added:
epp/portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java
epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java
epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java
epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/Phase.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
Modified:
epp/portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/conf/portal/configuration.xml
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
Log:
JBEPP-403, JBEPP-383: Fixes ported from GateIn trunk
JBEPP-403: Ported a fix with cookies disabled, and LocalizationFilter applied to .jsp only
JBEPP-383: Fix overwritten and reimplemented
Added: epp/portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/component/portal/src/main/java/org/exoplatform/portal/Constants.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,35 @@
+/**
+ * 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.portal;
+
+/**
+ * @author <a href="trong.tran(a)exoplatform.com">Trong Tran</a>
+ * @version $Revision$
+ */
+
+public class Constants
+{
+ public static final String USER_LANGUAGE = "user.language";
+
+ public static final String USER_SKIN = "user.skin";
+
+ public static final String PORTAL_WINDOW_STATE = "portal:windowState";
+
+ public static final String PORTAL_PORTLET_MODE = "portal:portletMode";
+}
Added: epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.services.resources;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Data structure that holds the inputs for {@link LocalePolicy} pluggable policies mechanism.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class LocaleContextInfo
+{
+ private Set<Locale> supportedLocales;
+ private List<Locale> browserLocales;
+ private List<Locale> cookieLocales;
+ private Locale userProfileLocale;
+ private String remoteUser;
+ private Locale portalLocale;
+ private Locale sessionLocale;
+
+ /**
+ * Setter for supportedLocales
+ * @param supportedLocales locales supported by portal
+ */
+ public void setSupportedLocales(Set<Locale> supportedLocales)
+ {
+ this.supportedLocales = supportedLocales;
+ }
+
+ /**
+ * Getter for supportedLocales
+ * @return supportedLocales
+ */
+ public Set<Locale> getSupportedLocales()
+ {
+ return supportedLocales;
+ }
+
+ /**
+ * Setter for browserLocales
+ * @param browserLocales list of locales as preferred by client's browser
+ */
+ public void setBrowserLocales(List<Locale> browserLocales)
+ {
+ this.browserLocales = browserLocales;
+ }
+
+ /**
+ * Getter for browserLocales
+ * @return browserLocales
+ */
+ public List<Locale> getBrowserLocales()
+ {
+ return browserLocales;
+ }
+
+ /**
+ * Setter for cookieLocales
+ * @param cookieLocales locales stored in user's browser cookie
+ */
+ public void setCookieLocales(List<Locale> cookieLocales)
+ {
+ this.cookieLocales = cookieLocales;
+ }
+
+ /**
+ * Getter for cookieLocales
+ * @return cookieLocales
+ */
+ public List<Locale> getCookieLocales()
+ {
+ return cookieLocales;
+ }
+
+ /**
+ * Setter for userProfileLocale
+ * @param userProfileLocale locale loaded from user's profile
+ */
+ public void setUserProfileLocale(Locale userProfileLocale)
+ {
+ this.userProfileLocale = userProfileLocale;
+ }
+
+ /**
+ * Getter for userProfileLocale
+ * @return userProfileLocale
+ */
+ public Locale getUserProfileLocale()
+ {
+ return userProfileLocale;
+ }
+
+ /**
+ * Setter for remoteUser
+ * @param remoteUser username of the currently logged in user. Null for anonymous users.
+ */
+ public void setRemoteUser(String remoteUser)
+ {
+ this.remoteUser = remoteUser;
+ }
+
+ /**
+ * Getter for remoteUser
+ * @return remoteUser
+ */
+ public String getRemoteUser()
+ {
+ return remoteUser;
+ }
+
+ /**
+ * Setter for portalLocale
+ * @param portalLocale default locale configured for the portal
+ */
+ public void setPortalLocale(Locale portalLocale)
+ {
+ this.portalLocale = portalLocale;
+ }
+
+ /**
+ * Getter for portalLocale
+ * @return portalLocale
+ */
+ public Locale getPortalLocale()
+ {
+ return portalLocale;
+ }
+
+ /**
+ * Setter for sessionLocale
+ * @param locale Locale stored in current session
+ */
+ public void setSessionLocale(Locale locale)
+ {
+ this.sessionLocale = locale;
+ }
+
+ /**
+ * Getter for sessionLocale
+ * @return sessionLocale
+ */
+ public Locale getSessionLocale()
+ {
+ return sessionLocale;
+ }
+
+ /**
+ * Helper method that returns the locale only if it's supported by portal.
+ * Otherwise it returns null.
+ *
+ * @param locale locale to check
+ * @return original locale if supported, null otherwise
+ */
+ public Locale getLocaleIfSupported(Locale locale)
+ {
+ if (locale == null)
+ return null;
+ if (supportedLocales.contains(locale))
+ return locale;
+ return null;
+ }
+
+ /**
+ * Helper method that returns the locale only if it's language is supported by portal.
+ * Otherwise it returns null.
+ *
+ * @param locale locale to check
+ * @return original locale if language is supported, null otherwise
+ */
+ public Locale getLocaleIfLangSupported(Locale locale)
+ {
+ if (locale == null)
+ return null;
+ if (supportedLocales.contains(locale))
+ return locale;
+
+ if ("".equals(locale.getCountry()) == false)
+ {
+ Locale loc = new Locale(locale.getLanguage());
+ if (supportedLocales.contains(loc))
+ {
+ // return original locale
+ return locale;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Helper method to convert String representation of Locale into Locale object.
+ * @param portalLocaleName String representation of Locale
+ * @return locale
+ */
+ public static Locale getLocale(String portalLocaleName)
+ {
+ int pos = portalLocaleName.indexOf("_");
+ if (pos < 0)
+ return new Locale(portalLocaleName);
+
+ return new Locale(portalLocaleName.substring(0, pos), portalLocaleName.substring(pos+1));
+ }
+
+ /**
+ * Helper method to get a String representation of the Locale
+ * @param locale
+ * @return String representation of the locale
+ */
+ public static String getLocaleAsString(Locale locale)
+ {
+ if (locale.getCountry().length() == 0)
+ return locale.getLanguage();
+
+ return locale.getLanguage() + "_" + locale.getCountry();
+ }
+}
Added: epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.services.resources;
+
+import java.util.Locale;
+
+/**
+ * This interface represents a pluggable mechanism for different locale determining algorithms
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public interface LocalePolicy
+{
+ /**
+ * Determine the Locale to be used for current request
+ *
+ * @param localeContext locale context info available to implementations
+ * as inputs to use when determining appropriate Locale
+ * @return Locale to be used for current user's request
+ */
+ public Locale determineLocale(LocaleContextInfo localeContext);
+}
Added: epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application;
+
+/**
+ * Interface that extends {@link ApplicationLifecycle} with request phase methods that allow interception of
+ * before/after ACTION phase, and before/after RENDER phase of request processing.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public interface ApplicationRequestPhaseLifecycle<E extends RequestContext> extends ApplicationLifecycle<E>
+{
+ /**
+ * Perform any processing required at the beginning of {@link Phase#ACTION} or {@link Phase#RENDER} phase.
+ * @param app Application
+ * @param context current RequestContext
+ * @param phase starting phase
+ */
+ public void onStartRequestPhase(Application app, E context, Phase phase);
+
+ /**
+ * Perform any processing required at the end of {@link Phase#ACTION} or {@link Phase#RENDER} phase.
+ * @param app Application
+ * @param context current RequestContext
+ * @param phase ending phase
+ */
+ public void onEndRequestPhase(Application app, E context, Phase phase);
+}
Added: epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/Phase.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/Phase.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/component/web/src/main/java/org/exoplatform/web/application/Phase.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application;
+
+/**
+ * Enum representing request processing phases.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public enum Phase
+{
+ ACTION,
+ RENDER
+}
Modified: epp/portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -20,6 +20,8 @@
package org.exoplatform.organization.webui.component;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
+import org.exoplatform.portal.Constants;
+import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
import org.exoplatform.portal.webui.workspace.UIWorkingWorkspace;
@@ -123,7 +125,7 @@
{
UserProfileHandler hanlder = service.getUserProfileHandler();
UserProfile userProfile = hanlder.findUserProfileByName(event.getRequestContext().getRemoteUser());
- String language = userProfile.getAttribute("user.language");
+ String language = userProfile.getAttribute(Constants.USER_LANGUAGE);
UIPortalApplication uiApp = Util.getUIPortalApplication();
if (language == null || language.trim().length() < 1)
@@ -133,9 +135,8 @@
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
if (localeConfig == null)
localeConfig = localeConfigService.getDefaultLocaleConfig();
- uiApp.setLocale(localeConfig.getLocale());
- uiApp.setOrientation(localeConfig.getOrientation());
- uiApp.localizeNavigations();
+ PortalRequestContext prqCtx = PortalRequestContext.getCurrentInstance();
+ prqCtx.setLocale(localeConfig.getLocale());
Util.getPortalRequestContext().addUIComponentToUpdateByAjax(
uiApp.findFirstComponentOfType(UIWorkingWorkspace.class));
Modified: epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/web.xml 2010-08-31 22:02:02 UTC (rev 3989)
@@ -21,10 +21,11 @@
-->
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
- <display-name>portal</display-name>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4"> <display-name>portal</display-name>
<!--Uncomment for clustered setup-->
<!--
@@ -34,13 +35,13 @@
<context-param>
<param-name>org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsWorkspace</param-name>
<param-value>portal</param-value>
- <description>Binary assets workspace name</description>
+ <!-- Binary assets workspace name -->
</context-param>
<context-param>
<param-name>org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsPath</param-name>
<param-value>/</param-value>
- <description>Binary assets path</description>
+ <!-- Binary assets path -->
</context-param>
<!-- ================================================================== -->
@@ -50,6 +51,10 @@
<filter-name>GenericFilter</filter-name>
<filter-class>org.exoplatform.web.filter.GenericFilter</filter-class>
</filter>
+ <filter>
+ <filter-name>LocalizationFilter</filter-name>
+ <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
+ </filter>
<filter>
<filter-name>ResourceRequestFilter</filter-name>
<filter-class>org.exoplatform.portal.application.ResourceRequestFilter</filter-class>
@@ -101,6 +106,20 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <filter-mapping>
+ <filter-name>LocalizationFilter</filter-name>
+ <!-- use a wider pattern or additional mappings to include custom resources
+ that require request.getLocale() to reflect user's portal page language.
+ LocalizationFilter is re-entrant - you can safely use it as the following:
+ <url-pattern>/*</url-pattern>
+ -->
+ <url-pattern>*.jsp</url-pattern>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+
<filter-mapping>
<filter-name>GenericFilter</filter-name>
<url-pattern>/*</url-pattern>
@@ -178,7 +197,7 @@
<servlet>
<servlet-name>RestServer</servlet-name>
- <description>eXo - Platform REST Server</description>
+ <!-- eXo - Platform REST Server -->
<servlet-class>org.exoplatform.services.rest.servlet.RestServlet</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>
Modified: epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-08-31 22:02:02 UTC (rev 3989)
@@ -37,6 +37,7 @@
<listener>org.exoplatform.portal.application.PortalApplicationLifecycle</listener>
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
<listener>org.exoplatform.portal.application.UserProfileLifecycle</listener>
+ <listener>org.exoplatform.portal.application.localization.LocalizationLifecycle</listener>
</application-lifecycle-listeners>
<events>
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/pom.xml 2010-08-31 22:02:02 UTC (rev 3989)
@@ -92,5 +92,11 @@
<groupId>org.gatein.captcha</groupId>
<artifactId>simplecaptcha</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.component.test.core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-31 22:02:02 UTC (rev 3989)
@@ -30,5 +30,11 @@
<component>
<type>org.exoplatform.portal.application.PortalStatisticService</type>
- </component>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.resources.LocalePolicy</key>
+ <!--type>org.exoplatform.portal.application.NoBrowserLocalePolicyService</type-->
+ <type>org.exoplatform.portal.application.localization.DefaultLocalePolicyService</type>
+ </component>
</configuration>
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -118,6 +118,8 @@
private Map<String, String[]> parameterMap;
+ private Locale locale = Locale.ENGLISH;
+
public JavascriptManager getJavascriptManager()
{
return jsmanager_;
@@ -243,9 +245,14 @@
return ((UIPortalApplication)uiApplication_).getOrientation();
}
+ public void setLocale(Locale locale)
+ {
+ this.locale = locale;
+ }
+
public Locale getLocale()
{
- return ((UIPortalApplication)uiApplication_).getLocale();
+ return locale;
}
@SuppressWarnings("unchecked")
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -25,6 +25,8 @@
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.WebRequestHandler;
import org.exoplatform.web.application.ApplicationLifecycle;
+import org.exoplatform.web.application.ApplicationRequestPhaseLifecycle;
+import org.exoplatform.web.application.Phase;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
@@ -102,11 +104,17 @@
if (!context.isResponseComplete() && !context.getProcessRender())
{
+ startRequestPhaseLifecycle(app, context, lifecycles, Phase.ACTION);
uiApp.processAction(context);
+ endRequestPhaseLifecycle(app, context, lifecycles, Phase.ACTION);
}
if (!context.isResponseComplete())
+ {
+ startRequestPhaseLifecycle(app, context, lifecycles, Phase.RENDER);
uiApp.processRender(context);
+ endRequestPhaseLifecycle(app, context, lifecycles, Phase.RENDER);
+ }
if (uiApp != null)
uiApp.setLastAccessApplication(System.currentTimeMillis());
@@ -137,4 +145,24 @@
WebuiRequestContext.setCurrentInstance(null);
}
}
+
+ private void startRequestPhaseLifecycle(PortalApplication app, PortalRequestContext context,
+ List<ApplicationLifecycle> lifecycles, Phase phase)
+ {
+ for (ApplicationLifecycle lifecycle : lifecycles)
+ {
+ if (lifecycle instanceof ApplicationRequestPhaseLifecycle)
+ ((ApplicationRequestPhaseLifecycle) lifecycle).onStartRequestPhase(app, context, phase);
+ }
+ }
+
+ private void endRequestPhaseLifecycle(PortalApplication app, PortalRequestContext context,
+ List<ApplicationLifecycle> lifecycles, Phase phase)
+ {
+ for (ApplicationLifecycle lifecycle : lifecycles)
+ {
+ if (lifecycle instanceof ApplicationRequestPhaseLifecycle)
+ ((ApplicationRequestPhaseLifecycle) lifecycle).onEndRequestPhase(app, context, phase);
+ }
+ }
}
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -141,7 +141,7 @@
// For now do nothing....
}
- private UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws Exception
+ public static UserPortalConfig getUserPortalConfig(PortalRequestContext context) throws Exception
{
ExoContainer appContainer = context.getApplication().getApplicationServiceContainer();
UserPortalConfigService service_ = (UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
Added: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application.localization;
+
+import org.exoplatform.services.resources.LocaleContextInfo;
+import org.exoplatform.services.resources.LocalePolicy;
+import org.picocontainer.Startable;
+
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * This service represents a default policy for determining LocaleConfig to be used for user's session.
+ * This service is registered through portal services configuration file: conf/portal/configuration.xml
+ * Custom locale determination policy can be implemented by overriding or completely replacing this class,
+ * and registering an alternative implementation.
+ *
+ * To gracefully fallback from more specific locales (lang_COUNTRY) to more generic (lang) without loss
+ * of information about user's language selection use {@link LocaleContextInfo#getLocaleIfLangSupported(java.util.Locale)}
+ * and return a more specific Locale. The Locale will be appropriately narrowed by LocalePolicy caller.
+ *
+ * Special care needs to be taken to assure Locale consistency
+ * between portal requests and non-portal requests - like login redirect upon failed authentication attempt.
+ * To keep consistency at least one of {@link LocaleContextInfo#cookieLocales} and {@link LocaleContextInfo#sessionLocale}
+ * needs to be enabled.
+ *
+ * @see NoBrowserLocalePolicyService
+ * @see LocalizationFilter
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class DefaultLocalePolicyService implements LocalePolicy, Startable
+{
+ /**
+ * @see LocalePolicy#determineLocale(LocaleContextInfo)
+ */
+ public Locale determineLocale(LocaleContextInfo context)
+ {
+ Locale locale = null;
+ if (context.getRemoteUser() == null)
+ locale = getLocaleConfigForAnonymous(context);
+ else
+ locale = getLocaleConfigForRegistered(context);
+
+ if (locale == null)
+ locale = context.getPortalLocale();
+
+ return locale;
+ }
+
+ /**
+ * Override this method to change the LocaleConfig determination for registered users.
+ * Default is: use user's profile language, if not available fall back to LOCALE cookie,
+ * and finally if that is not available either fall back to browser language preference.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return Locale representing a language to use, or null
+ */
+ protected Locale getLocaleConfigForRegistered(LocaleContextInfo context)
+ {
+ Locale locale = context.getLocaleIfLangSupported(context.getUserProfileLocale());
+ if (locale == null)
+ locale = getLocaleConfigFromCookie(context);
+ if (locale == null)
+ locale = getLocaleConfigFromSession(context);
+ if (locale == null)
+ locale = getLocaleConfigFromBrowser(context);
+
+ return locale;
+ }
+
+ /**
+ * Override this method to change the Locale determination based on browser language preferences.
+ * If you want to disable the use of browser language preferences simply return null.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return Locale representing a language to use, or null
+ */
+ protected Locale getLocaleConfigFromBrowser(LocaleContextInfo context)
+ {
+ List<Locale> locales = context.getBrowserLocales();
+ if (locales != null)
+ {
+ for (Locale loc: locales)
+ return context.getLocaleIfLangSupported(loc);
+ }
+ return null;
+ }
+
+ /**
+ * Override this method to change Locale determination for users that aren't logged in.
+ * By default the request's LOCALE cookie is used, if that is not available the browser
+ * language preferences are used.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return Locale representing a language to use, or null
+ */
+ protected Locale getLocaleConfigForAnonymous(LocaleContextInfo context)
+ {
+ Locale locale = getLocaleConfigFromCookie(context);
+ if (locale == null)
+ locale = getLocaleConfigFromSession(context);
+ if (locale == null)
+ locale = getLocaleConfigFromBrowser(context);
+
+ return locale;
+ }
+
+ /**
+ * Override this method to change the Locale determination based on session attribute.
+ * Note: this is mostly a backup for cookie, as either one usually has to be enabled for
+ * locale to remain synchronized between portal and non-portal pages.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return Locale representing a language to use, or null
+ */
+ protected Locale getLocaleConfigFromSession(LocaleContextInfo context)
+ {
+ return context.getSessionLocale();
+ }
+
+ /**
+ * Override this method to change the Locale determination based on browser cookie.
+ * If you want to disable the use of browser cookies simply return null.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return Locale representing a language to use, or null
+ */
+ protected Locale getLocaleConfigFromCookie(LocaleContextInfo context)
+ {
+ List<Locale> locales = context.getCookieLocales();
+ if (locales != null)
+ {
+ for (Locale locale: locales)
+ return context.getLocaleIfLangSupported(locale);
+ }
+ return null;
+ }
+
+ /**
+ * Starter interface method
+ */
+ public void start()
+ {
+ }
+
+ /**
+ * Starter interface method
+ */
+ public void stop()
+ {
+ }
+
+}
Added: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application.localization;
+
+import org.exoplatform.portal.application.PortalRequestContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class HttpRequestWrapper extends HttpServletRequestWrapper
+{
+ private static final List<Locale> EMPTY_LOCALE_LIST = Collections.emptyList();
+
+ /**
+ * Constructs a request object wrapping the given request.
+ *
+ * @throws IllegalArgumentException if the request is null
+ */
+ public HttpRequestWrapper(HttpServletRequest request)
+ {
+ super(request);
+ }
+
+ /**
+ * Note: Keep the implementation here in sync with {@link org.exoplatform.portal.webui.application.ExoUserContext#getLocale}
+ * @return
+ */
+ @Override
+ public Locale getLocale()
+ {
+ if (PortalRequestContext.getCurrentInstance() != null)
+ return getRequest().getLocale();
+
+ Locale current = LocalizationFilter.getCurrentLocale();
+ if (current != null)
+ return current;
+
+ return getRequest().getLocale();
+ }
+
+ @Override
+ public Enumeration getLocales()
+ {
+ Locale current = LocalizationFilter.getCurrentLocale();
+ if (PortalRequestContext.getCurrentInstance() != null || current == null)
+ return getRequest().getLocales();
+
+ Locale loc = getLocale();
+ if (loc == null)
+ {
+ return Collections.enumeration(EMPTY_LOCALE_LIST);
+ }
+ else
+ {
+ LinkedList<Locale> locs = new LinkedList<Locale>();
+ locs.add(loc);
+
+ Enumeration<Locale> clientLocs = (Enumeration<Locale>) getRequest().getLocales();
+ while (clientLocs.hasMoreElements())
+ {
+ current = clientLocs.nextElement();
+ if (current.getLanguage().equals(loc.getLanguage()) && current.getCountry().equals(loc.getCountry()))
+ continue;
+ locs.add(current);
+ }
+
+ return Collections.enumeration(locs);
+ }
+ }
+}
Added: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application.localization;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.portal.Constants;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.UserProfile;
+import org.exoplatform.services.resources.LocaleConfig;
+import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.LocaleContextInfo;
+import org.exoplatform.services.resources.LocalePolicy;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * This filter provides {@link HttpServletRequest#getLocale()} and {@link HttpServletRequest#getLocales()}
+ * override for extra-portlet requests (i.e. unbridged .jsp). Thanks to it dynamic resources can be localized
+ * to keep in sync with the rest of the portal. This filter is re-entrant, and can safely be installed for
+ * INCLUDE, FORWARD, and ERROR dispatch methods.
+ *
+ * A concrete example of re-entrant use is login/jsp/login.jsp used when authentication fails at portal login.
+ *
+ * By default {@link HttpServletRequest#getLocale()} and {@link HttpServletRequest#getLocales()} reflect
+ * browser language preference. When using this filter these two calls employ the same Locale determination algorithm
+ * as LocalizationLifecycle does.
+ *
+ * This filter can be activated / deactivated via portal module's web.xml
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class LocalizationFilter implements Filter
+{
+ private static Log log = ExoLogger.getLogger("portal:LocalizationFilter");
+
+ private static ThreadLocal<Locale> currentLocale = new ThreadLocal<Locale>();
+
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+
+ HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse res = (HttpServletResponse) response;
+
+ try
+ {
+ // Due to forwards, and includes the filter might be reentered
+ // If current requestContext exists use its Locale
+ PortalRequestContext context = PortalRequestContext.getCurrentInstance();
+ if (context != null && context.getLocale() != null)
+ {
+ // No need to wrap if reentered
+ boolean skipWrapping = currentLocale.get() != null;
+ // overwrite any already set currentLocale
+ currentLocale.set(context.getLocale());
+ if (!skipWrapping)
+ {
+ req = new HttpRequestWrapper(req);
+ }
+ chain.doFilter(req, res);
+ return;
+ }
+
+ // If reentered we don't need to wrap
+ if (currentLocale.get() != null)
+ {
+ chain.doFilter(request, response);
+ return;
+ }
+
+
+ // Initialize currentLocale
+ ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ if (container == null)
+ {
+ // Nothing we can do, move on
+ chain.doFilter(req, res);
+ return;
+ }
+
+ if (container instanceof RootContainer)
+ container = (ExoContainer) container.getComponentInstance("portal");
+
+ LocaleConfigService localeConfigService = (LocaleConfigService)
+ container.getComponentInstanceOfType(LocaleConfigService.class);
+ LocalePolicy localePolicy = (LocalePolicy) container.getComponentInstanceOfType(LocalePolicy.class);
+
+ LocaleContextInfo localeCtx = new LocaleContextInfo();
+
+ Set<Locale> supportedLocales = new HashSet();
+ for (LocaleConfig lc: localeConfigService.getLocalConfigs())
+ {
+ supportedLocales.add(lc.getLocale());
+ }
+ localeCtx.setSupportedLocales(supportedLocales);
+
+ localeCtx.setBrowserLocales(Collections.list(request.getLocales()));
+ //localeCtx.setCookieLocales(LocalizationLifecycle.getCookieLocales(req));
+ localeCtx.setSessionLocale(LocalizationLifecycle.getSessionLocale(req));
+ localeCtx.setUserProfileLocale(getUserProfileLocale(container, req.getRemoteUser()));
+ localeCtx.setRemoteUser(req.getRemoteUser());
+
+ localeCtx.setPortalLocale(Locale.ENGLISH);
+ Locale locale = localePolicy.determineLocale(localeCtx);
+ boolean supported = supportedLocales.contains(locale);
+
+ if (!supported && !"".equals(locale.getCountry()))
+ {
+ locale = new Locale(locale.getLanguage());
+ supported = supportedLocales.contains(locale);
+ }
+ if (!supported)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Unsupported locale returned by LocalePolicy: " + localePolicy + ". Falling back to 'en'.");
+ locale = Locale.ENGLISH;
+ }
+
+ currentLocale.set(locale);
+ chain.doFilter(new HttpRequestWrapper(req), res);
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException("LocalizationFilter exception: ", e);
+ }
+ finally
+ {
+ currentLocale.remove();
+ }
+ }
+
+ private Locale getUserProfileLocale(ExoContainer container, String user)
+ {
+ UserProfile userProfile = null;
+ OrganizationService svc = (OrganizationService)
+ container.getComponentInstanceOfType(OrganizationService.class);
+
+ if (user != null)
+ {
+ try
+ {
+ beginContext(svc);
+ userProfile = svc.getUserProfileHandler().findUserProfileByName(user);
+ }
+ catch (Exception ignored)
+ {
+ log.error("IGNORED: Failed to load UserProfile for username: " + user, ignored);
+ }
+ finally
+ {
+ try
+ {
+ endContext(svc);
+ }
+ catch(Exception ignored)
+ {
+ // we don't care
+ }
+ }
+
+ if (userProfile == null && log.isWarnEnabled())
+ log.warn("Could not load user profile for " + user);
+ }
+
+ String lang = userProfile == null ? null : userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
+ return (lang != null) ? LocaleContextInfo.getLocale(lang) : null;
+ }
+
+ public void beginContext(OrganizationService orgService) throws Exception
+ {
+ if (orgService instanceof ComponentRequestLifecycle)
+ {
+ RequestLifeCycle.begin((ComponentRequestLifecycle)orgService);
+ }
+ }
+
+ public void endContext(OrganizationService orgService) throws Exception
+ {
+ // do the same check as in beginContext to make it symmetric
+ if (orgService instanceof ComponentRequestLifecycle)
+ {
+ RequestLifeCycle.end();
+ }
+ }
+
+ public void destroy()
+ {
+ }
+
+ public static Locale getCurrentLocale()
+ {
+ return currentLocale.get();
+ }
+}
Added: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,399 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application.localization;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.portal.Constants;
+import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.application.PortalStateManager;
+import org.exoplatform.portal.application.UserProfileLifecycle;
+import org.exoplatform.portal.config.UserPortalConfig;
+import org.exoplatform.portal.webui.workspace.UIPortalApplication;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.UserProfile;
+import org.exoplatform.services.resources.LocaleConfig;
+import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.LocaleContextInfo;
+import org.exoplatform.services.resources.LocalePolicy;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationRequestPhaseLifecycle;
+import org.exoplatform.web.application.Phase;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIApplication;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * This class takes care of loading / initializing / saving the current Locale.
+ * Current Locale is used to create properly localized response to current request.
+ *
+ * At the beginning of request {@link LocalePolicy} is used to determine the
+ * initial Locale to be used for processing the request.
+ *
+ * This Locale is then set on current {@link org.exoplatform.portal.application.PortalRequestContext} (it's presumed that current
+ * {@link org.exoplatform.web.application.RequestContext} is of type PortalRequestContext) by calling
+ * {@link org.exoplatform.portal.application.PortalRequestContext#setLocale}.
+ *
+ * During request processing {@link org.exoplatform.portal.application.PortalRequestContext#getLocale} is the ultimate reference consulted by any
+ * rendering code that needs to know about current Locale.
+ *
+ * When this Locale is changed during action processing, the new Locale choice is saved
+ * into user's profile or into browser's cookie in order to be used by future requests.
+ *
+ * This Lifecycle depends on UserProfileLifecycle being registered before this one, as it relies on it
+ * for loading the user profile. See WEB-INF/webui-configuration.xml in web/portal module.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class LocalizationLifecycle implements ApplicationRequestPhaseLifecycle<WebuiRequestContext>
+{
+ private static final String LOCALE_COOKIE = "LOCALE";
+
+ private static final String LOCALE_SESSION_ATTR = "org.gatein.LOCALE";
+
+ private static final String PREV_LOCALE_SESSION_ATTR = "org.gatein.LAST_LOCALE";
+
+ private static final ThreadLocal<Locale> calculatedLocale = new ThreadLocal<Locale>();
+
+ private static Log log = ExoLogger.getLogger("portal:LocalizationLifecycle");
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onInit
+ */
+ public void onInit(Application app) throws Exception
+ {
+ }
+
+ /**
+ * Initialize Locale to be used for the processing of current request
+ *
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onStartRequest
+ */
+ public void onStartRequest(Application app, WebuiRequestContext context) throws Exception
+ {
+ if (context instanceof PortalRequestContext == false)
+ throw new IllegalArgumentException("Expected PortalRequestContext, but got: " + context);
+
+ PortalRequestContext reqCtx = (PortalRequestContext) context;
+ ExoContainer container = app.getApplicationServiceContainer();
+
+ LocaleConfigService localeConfigService = (LocaleConfigService)
+ container.getComponentInstanceOfType(LocaleConfigService.class);
+ LocalePolicy localePolicy = (LocalePolicy) container.getComponentInstanceOfType(LocalePolicy.class);
+
+ LocaleContextInfo localeCtx = new LocaleContextInfo();
+
+ Set<Locale> supportedLocales = new HashSet();
+ for (LocaleConfig lc: localeConfigService.getLocalConfigs())
+ {
+ supportedLocales.add(lc.getLocale());
+ }
+ localeCtx.setSupportedLocales(supportedLocales);
+
+ HttpServletRequest request = HttpServletRequest.class.cast(context.getRequest());
+ localeCtx.setBrowserLocales(Collections.list(request.getLocales()));
+ //localeCtx.setCookieLocales(getCookieLocales(request));
+ localeCtx.setSessionLocale(getSessionLocale(request));
+ localeCtx.setUserProfileLocale(getUserProfileLocale(reqCtx));
+ localeCtx.setRemoteUser(reqCtx.getRemoteUser());
+
+ UserPortalConfig userPortalConfig = null;
+ try
+ {
+ userPortalConfig = PortalStateManager.getUserPortalConfig(reqCtx);
+ if (userPortalConfig == null)
+ log.warn("No UserPortalConfig available! Portal locale set to 'en'");
+ }
+ catch(Exception ignored)
+ {
+ if (log.isDebugEnabled())
+ log.debug("IGNORED: Failed to load UserPortalConfig: ", ignored);
+ }
+
+ String portalLocaleName = "en";
+ if (userPortalConfig != null)
+ portalLocaleName = userPortalConfig.getPortalConfig().getLocale();
+
+ Locale portalLocale = LocaleContextInfo.getLocale(portalLocaleName);
+ localeCtx.setPortalLocale(portalLocale);
+
+ Locale locale = localePolicy.determineLocale(localeCtx);
+ boolean supported = supportedLocales.contains(locale);
+
+ if (!supported && !"".equals(locale.getCountry()))
+ {
+ locale = new Locale(locale.getLanguage());
+ supported = supportedLocales.contains(locale);
+ }
+ if (!supported)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Unsupported locale returned by LocalePolicy: " + localePolicy + ". Falling back to 'en'.");
+ locale = Locale.ENGLISH;
+ }
+ reqCtx.setLocale(locale);
+ calculatedLocale.set(locale);
+ }
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationRequestPhaseLifecycle#onStartRequestPhase
+ */
+ public void onStartRequestPhase(Application app, WebuiRequestContext context, Phase phase)
+ {
+ }
+
+ /**
+ * Save any locale change - to cookie for anonymous users, to profile for logged-in users
+ *
+ * @see org.exoplatform.web.application.ApplicationRequestPhaseLifecycle#onEndRequestPhase
+ */
+ public void onEndRequestPhase(Application app, WebuiRequestContext context, Phase phase)
+ {
+ if (phase == Phase.ACTION)
+ {
+ // if onStartRequest survived the cast, this one should as well - no check necessary
+ PortalRequestContext reqCtx = (PortalRequestContext) context;
+ Locale loc = reqCtx.getLocale();
+ Locale remembered = calculatedLocale.get();
+ calculatedLocale.remove();
+
+ boolean refreshNeeded = false;
+
+ // if locale changed since previous request
+ Locale sessLocale = getPreviousLocale(reqCtx.getRequest());
+ if (loc != null && sessLocale != null && !loc.equals(sessLocale))
+ {
+ refreshNeeded = true;
+ }
+ // if locale changed during this request's processing
+ if (loc != null && (remembered == null || !loc.equals(remembered)))
+ {
+ refreshNeeded = true;
+ saveLocale(reqCtx, loc);
+ }
+
+ if (refreshNeeded)
+ {
+ UIApplication uiapp = context.getUIApplication();
+ // we presume PortalRequestContext, and UIPortalApplication
+ resetOrientation(reqCtx, loc);
+ ((UIPortalApplication) uiapp).localizeNavigations();
+ }
+
+ savePreviousLocale(reqCtx, loc);
+ }
+ }
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onEndRequest
+ */
+ public void onEndRequest(Application app, WebuiRequestContext context) throws Exception
+ {
+ }
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onDestroy
+ */
+ public void onDestroy(Application app) throws Exception
+ {
+ }
+
+ /**
+ * Use {@link UserProfile} already loaded by {@link org.exoplatform.portal.application.UserProfileLifecycle} or load one ourselves.
+ * @param context current PortalRequestContext
+ * @return Locale from user's profile or null
+ */
+ private Locale getUserProfileLocale(PortalRequestContext context)
+ {
+ String lang = null;
+
+ UserProfile userProfile = getLoadedProfile(context);
+ lang = userProfile == null ? null : userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
+ return (lang != null) ? LocaleContextInfo.getLocale(lang) : null;
+ }
+
+ private UserProfile loadUserProfile(ExoContainer container, PortalRequestContext context)
+ {
+ UserProfile userProfile = null;
+ OrganizationService svc = (OrganizationService)
+ container.getComponentInstanceOfType(OrganizationService.class);
+
+ String user = context.getRemoteUser();
+ if (user != null)
+ {
+ try
+ {
+ userProfile = svc.getUserProfileHandler().findUserProfileByName(user);
+ }
+ catch (Exception ignored)
+ {
+ log.error("IGNORED: Failed to load UserProfile for username: " + user, ignored);
+ }
+
+ if (userProfile == null && log.isWarnEnabled())
+ log.warn("Could not load user profile for " + user + ". Using default portal locale.");
+ }
+ return userProfile;
+ }
+
+ private UserProfile getLoadedProfile(PortalRequestContext context)
+ {
+ return (UserProfile) context.getAttribute(UserProfileLifecycle.USER_PROFILE_ATTRIBUTE_NAME);
+ }
+
+ public static List<Locale> getCookieLocales(HttpServletRequest request)
+ {
+ Cookie [] cookies = request.getCookies();
+ if (cookies != null)
+ {
+ for (Cookie cookie: cookies)
+ {
+ if (LOCALE_COOKIE.equals(cookie.getName()))
+ {
+ List<Locale> locales = new ArrayList<Locale>();
+ locales.add(LocaleContextInfo.getLocale(cookie.getValue()));
+ return locales;
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ public static Locale getSessionLocale(HttpServletRequest request)
+ {
+ return getLocaleFromSession(request, LOCALE_SESSION_ATTR);
+ }
+
+ public static Locale getPreviousLocale(HttpServletRequest request)
+ {
+ return getLocaleFromSession(request, PREV_LOCALE_SESSION_ATTR);
+ }
+
+ private static Locale getLocaleFromSession(HttpServletRequest request, String attrName)
+ {
+ String lang = null;
+ HttpSession session = request.getSession(false);
+ if (session != null)
+ lang = (String) session.getAttribute(attrName);
+ return (lang != null) ? LocaleContextInfo.getLocale(lang) : null;
+ }
+
+ private void saveLocale(PortalRequestContext context, Locale loc)
+ {
+ String user = context.getRemoteUser();
+ if (user != null)
+ {
+ saveLocaleToUserProfile(context, loc, user);
+ }
+ else
+ {
+ // disabled for now
+ //saveLocaleToCookie(context, loc);
+ }
+
+ saveSessionLocale(context, loc);
+ }
+
+ private void resetOrientation(PortalRequestContext context, Locale loc)
+ {
+ ExoContainer container = context.getApplication().getApplicationServiceContainer();
+ LocaleConfigService localeConfigService = (LocaleConfigService)
+ container.getComponentInstanceOfType(LocaleConfigService.class);
+ LocaleConfig localeConfig = localeConfigService.getLocaleConfig(LocaleContextInfo.getLocaleAsString(loc));
+ if (localeConfig == null)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Locale changed to unsupported Locale during request processing: " + loc);
+ return;
+ }
+ // we presume PortalRequestContext, and UIPortalApplication
+ ((UIPortalApplication) context.getUIApplication()).setOrientation(localeConfig.getOrientation());
+ }
+
+ private void saveSessionLocale(PortalRequestContext context, Locale loc)
+ {
+ saveLocaleToSession(context, LOCALE_SESSION_ATTR, loc);
+ }
+
+ private void savePreviousLocale(PortalRequestContext context, Locale loc)
+ {
+ saveLocaleToSession(context, PREV_LOCALE_SESSION_ATTR, loc);
+ }
+
+ private void saveLocaleToSession(PortalRequestContext context, String attrName, Locale loc)
+ {
+ HttpServletRequest res = context.getRequest();
+ HttpSession session = res.getSession(false);
+ if (session != null)
+ session.setAttribute(attrName, LocaleContextInfo.getLocaleAsString(loc));
+ }
+
+ private void saveLocaleToCookie(PortalRequestContext context, Locale loc)
+ {
+ HttpServletResponse res = context.getResponse();
+ Cookie cookie = new Cookie(LOCALE_COOKIE, LocaleContextInfo.getLocaleAsString(loc));
+ cookie.setMaxAge(Integer.MAX_VALUE);
+ cookie.setPath("/");
+ res.addCookie(cookie);
+ }
+
+ private void saveLocaleToUserProfile(PortalRequestContext context, Locale loc, String user)
+ {
+ ExoContainer container = context.getApplication().getApplicationServiceContainer();
+ OrganizationService svc = (OrganizationService)
+ container.getComponentInstanceOfType(OrganizationService.class);
+
+ // Don't rely on UserProfileLifecycle loaded UserProfile when doing
+ // an update to avoid a potential overwrite of other changes
+ UserProfile userProfile = loadUserProfile(container, context);
+ if (userProfile != null)
+ {
+ userProfile.getUserInfoMap().put(Constants.USER_LANGUAGE, LocaleContextInfo.getLocaleAsString(loc));
+ try
+ {
+ svc.getUserProfileHandler().saveUserProfile(userProfile, false);
+ }
+ catch (Exception ignored)
+ {
+ log.error("IGNORED: Failed to save profile for user: " + user, ignored);
+ userProfile = null;
+ }
+ }
+
+ if (userProfile == null)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Unable to save locale into profile for user: " + user);
+ }
+ }
+}
Added: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java (rev 0)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.application.localization;
+
+import org.exoplatform.services.resources.LocaleContextInfo;
+
+import java.util.Locale;
+
+/**
+ * This implementation of {@link org.exoplatform.services.resources.LocalePolicy} disregards client browser language preference.
+ * Localization will therefore not be affected by different OS or browser language settings.
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class NoBrowserLocalePolicyService extends DefaultLocalePolicyService
+{
+ /**
+ * Override super method with no-op.
+ *
+ * @param context locale context info available to implementations in order to determine appropriate Locale
+ * @return null
+ */
+ @Override
+ protected Locale getLocaleConfigFromBrowser(LocaleContextInfo context)
+ {
+ return null;
+ }
+}
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -19,8 +19,8 @@
package org.exoplatform.portal.webui.application;
+import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.services.organization.UserProfile;
-import org.gatein.common.util.Tools;
import org.gatein.pc.api.invocation.resolver.AttributeResolver;
import org.gatein.pc.api.invocation.resolver.PrincipalAttributeResolver;
import org.gatein.pc.api.spi.UserContext;
@@ -29,6 +29,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -119,23 +120,51 @@
return Collections.unmodifiableMap(filteredMap);
}
- /** Returns the client request locale or <code>Locale.ENGLISH</code> if no request was provided. */
+ /**
+ * Returns current PortalRequestContext's locale. It falls back to
+ * clientRequest locale ({@link HttpServletRequest#getLocale}), or <code>Locale.ENGLISH</code>
+ * if clientRequest object is not available.
+ */
public Locale getLocale()
{
+ PortalRequestContext context = PortalRequestContext.getCurrentInstance();
+ if(context != null) {
+ Locale loc = context.getLocale();
+ if (loc != null)
+ return loc;
+ }
+
return clientRequest != null ? clientRequest.getLocale() : Locale.ENGLISH;
}
- /** Returns the client request locales or an empty list if no request was provided. */
+ /**
+ * Returns the list of client request locales, making sure the first one in the List
+ * is the same as what getLocale() method returns.
+ */
@SuppressWarnings("unchecked")
public List<Locale> getLocales()
{
- if (clientRequest == null)
+ Locale loc = getLocale();
+ if (loc == null)
{
return EMPTY_LOCALE_LIST;
}
else
{
- return Tools.toList((Enumeration<Locale>)clientRequest.getLocales());
+ LinkedList<Locale> locs = new LinkedList<Locale>();
+ locs.add(loc);
+ if (clientRequest != null)
+ {
+ Enumeration<Locale> clientLocs = (Enumeration<Locale>) clientRequest.getLocales();
+ while (clientLocs.hasMoreElements())
+ {
+ Locale current = clientLocs.nextElement();
+ if (current.getLanguage().equals(loc.getLanguage()) && current.getCountry().equals(loc.getCountry()))
+ continue;
+ locs.add(current);
+ }
+ }
+ return Collections.unmodifiableList(locs);
}
}
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -21,9 +21,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-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.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.workspace.UIMaskWorkspace;
import org.exoplatform.portal.webui.workspace.UIPortalApplication;
@@ -32,9 +30,7 @@
import org.exoplatform.services.organization.UserProfileHandler;
import org.exoplatform.services.resources.LocaleConfig;
import org.exoplatform.services.resources.LocaleConfigService;
-import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.services.resources.ResourceBundleService;
-import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
import org.exoplatform.webui.core.UIContainer;
@@ -183,9 +179,10 @@
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
if (localeConfig == null)
localeConfig = localeConfigService.getDefaultLocaleConfig();
- uiApp.setLocale(localeConfig.getLocale());
- uiApp.setOrientation(localeConfig.getOrientation());
- uiApp.localizeNavigations();
+ PortalRequestContext prqCtx = PortalRequestContext.getCurrentInstance();
+ prqCtx.setLocale(localeConfig.getLocale());
+ //uiApp.setOrientation(localeConfig.getOrientation());
+ //uiApp.localizeNavigations();
OrganizationService orgService = event.getSource().getApplicationComponent(OrganizationService.class);
String remoteUser = event.getRequestContext().getRemoteUser();
if (remoteUser != null)
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -261,7 +261,7 @@
uiPageBody.setPageBody(selectedNode_, this);
//Refresh locale
- Locale locale = Util.getUIPortalApplication().getLocale();
+ Locale locale = Util.getPortalRequestContext().getLocale();
localizePageNavigation(navigation, locale);
}
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -220,7 +220,7 @@
// TODO dang.tung - change layout when portal get language from UIPortal
// (user and browser not support)
// ----------------------------------------------------------------------------------------------------
- String portalAppLanguage = uiPortalApp.getLocale().getLanguage();
+ String portalAppLanguage = prContext.getLocale().getLanguage();
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
String userLanguage = userProfile.getUserInfoMap().get("user.language");
@@ -231,9 +231,9 @@
{
if (!portalAppLanguage.equals(userLanguage) && !portalAppLanguage.equals(browserLanguage))
{
- uiPortalApp.setLocale(localeConfig.getLocale());
+ prContext.setLocale(localeConfig.getLocale());
//editPortal.refreshNavigation(localeConfig.getLocale());
- uiPortalApp.localizeNavigations();
+ //uiPortalApp.localizeNavigations();
}
uiPortalApp.setSkin(editPortal.getSkin());
}
Modified: epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-31 21:28:42 UTC (rev 3988)
+++ epp/portal/branches/EPP_5_0_Branch/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-31 22:02:02 UTC (rev 3989)
@@ -45,6 +45,7 @@
import org.exoplatform.services.organization.UserProfile;
import org.exoplatform.services.resources.LocaleConfig;
import org.exoplatform.services.resources.LocaleConfigService;
+import org.exoplatform.services.resources.LocaleContextInfo;
import org.exoplatform.services.resources.Orientation;
import org.exoplatform.services.resources.ResourceBundleManager;
import org.exoplatform.web.application.javascript.JavascriptConfigService;
@@ -93,8 +94,6 @@
private String nodePath_;
- private Locale locale_ = Locale.ENGLISH;
-
private Orientation orientation_ = Orientation.LT;
final static public String UI_WORKING_WS_ID = "UIWorkingWorkspace";
@@ -143,10 +142,9 @@
// dang.tung - set portal language by user preference -> browser ->
// default
// ------------------------------------------------------------------------------
- String portalLanguage = null;
LocaleConfigService localeConfigService = getApplicationComponent(LocaleConfigService.class);
OrganizationService orgService = getApplicationComponent(OrganizationService.class);
- LocaleConfig localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale());
+
String user = context.getRemoteUser();
String portalSkin = null;
@@ -155,7 +153,6 @@
UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user);
if (userProfile != null)
{
- portalLanguage = userProfile.getUserInfoMap().get("user.language");
portalSkin = userProfile.getUserInfoMap().get("user.skin");
}
else
@@ -164,23 +161,22 @@
log.warn("Could not load user profile for " + user + ". Using default portal locale.");
}
}
- localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
- String localeLanguage = (localeConfig.getLocale().getCountry().length() > 0) ? localeConfig.getLocale()
- .getLanguage()
- + "_" + localeConfig.getLocale().getCountry() : localeConfig.getLocale().getLanguage();
- if (portalLanguage == null || !portalLanguage.equals(localeLanguage))
+ Locale locale = context.getLocale();
+ if (locale == null)
{
- // if user language no support by portal -> get browser language if no
- // ->
- // get portal
- portalLanguage = context.getRequest().getLocale().getLanguage();
- localeConfig = localeConfigService.getLocaleConfig(portalLanguage);
- if (!portalLanguage.equals(localeConfig.getLanguage()))
- {
- localeConfig = localeConfigService.getLocaleConfig(userPortalConfig_.getPortalConfig().getLocale());
- }
+ if (log.isWarnEnabled())
+ log.warn("No locale set on PortalRequestContext! Falling back to 'en'.");
+ locale = Locale.ENGLISH;
}
- setLocale(localeConfig.getLocale());
+ String localeName = LocaleContextInfo.getLocaleAsString(locale);
+ LocaleConfig localeConfig = localeConfigService.getLocaleConfig(localeName);
+ if (localeConfig == null)
+ {
+ if (log.isWarnEnabled())
+ log.warn("Unsupported locale set on PortalRequestContext: " + localeName + "! Falling back to 'en'.");
+ localeConfig = localeConfigService.getLocaleConfig(Locale.ENGLISH.getLanguage());
+ }
+
setOrientation(localeConfig.getOrientation());
// -------------------------------------------------------------------------------
context.setUIApplication(this);
@@ -304,14 +300,9 @@
public Locale getLocale()
{
- return locale_;
+ return Util.getPortalRequestContext().getLocale();
}
- public void setLocale(Locale locale)
- {
- locale_ = locale;
- }
-
public void setModeState(int mode)
{
this.modeState = mode;
14 years, 3 months
gatein SVN: r3988 - in portal/trunk: webui/portal/src/main/java/org/exoplatform/portal/application/localization and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2010-08-31 17:28:42 -0400 (Tue, 31 Aug 2010)
New Revision: 3988
Modified:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
Log:
GTNPORTAL-1306, GTNPORTAL-1355: Fallback from more specific locale (lang_COUNTRY) - when not available - to more general one (lang)
Modified: portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
===================================================================
--- portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2010-08-31 20:20:03 UTC (rev 3987)
+++ portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2010-08-31 21:28:42 UTC (rev 3988)
@@ -171,16 +171,44 @@
* Otherwise it returns null.
*
* @param locale locale to check
- * @return locale if supported, null otherwise
+ * @return original locale if supported, null otherwise
*/
public Locale getLocaleIfSupported(Locale locale)
{
+ if (locale == null)
+ return null;
if (supportedLocales.contains(locale))
return locale;
return null;
}
/**
+ * Helper method that returns the locale only if it's language is supported by portal.
+ * Otherwise it returns null.
+ *
+ * @param locale locale to check
+ * @return original locale if language is supported, null otherwise
+ */
+ public Locale getLocaleIfLangSupported(Locale locale)
+ {
+ if (locale == null)
+ return null;
+ if (supportedLocales.contains(locale))
+ return locale;
+
+ if ("".equals(locale.getCountry()) == false)
+ {
+ Locale loc = new Locale(locale.getLanguage());
+ if (supportedLocales.contains(loc))
+ {
+ // return original locale
+ return locale;
+ }
+ }
+ return null;
+ }
+
+ /**
* Helper method to convert String representation of Locale into Locale object.
* @param portalLocaleName String representation of Locale
* @return locale
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-31 20:20:03 UTC (rev 3987)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-31 21:28:42 UTC (rev 3988)
@@ -32,7 +32,13 @@
* This service represents a default policy for determining LocaleConfig to be used for user's session.
* This service is registered through portal services configuration file: conf/portal/configuration.xml
* Custom locale determination policy can be implemented by overriding or completely replacing this class,
- * and registering an alternative implementation. Special care needs to be taken to assure Locale consistency
+ * and registering an alternative implementation.
+ *
+ * To gracefully fallback from more specific locales (lang_COUNTRY) to more generic (lang) without loss
+ * of information about user's language selection use {@link LocaleContextInfo#getLocaleIfLangSupported(java.util.Locale)}
+ * and return a more specific Locale. The Locale will be appropriately narrowed by LocalePolicy caller.
+ *
+ * Special care needs to be taken to assure Locale consistency
* between portal requests and non-portal requests - like login redirect upon failed authentication attempt.
* To keep consistency at least one of {@link LocaleContextInfo#cookieLocales} and {@link LocaleContextInfo#sessionLocale}
* needs to be enabled.
@@ -71,7 +77,7 @@
*/
protected Locale getLocaleConfigForRegistered(LocaleContextInfo context)
{
- Locale locale = context.getLocaleIfSupported(context.getUserProfileLocale());
+ Locale locale = context.getLocaleIfLangSupported(context.getUserProfileLocale());
if (locale == null)
locale = getLocaleConfigFromCookie(context);
if (locale == null)
@@ -95,7 +101,7 @@
if (locales != null)
{
for (Locale loc: locales)
- return context.getLocaleIfSupported(loc);
+ return context.getLocaleIfLangSupported(loc);
}
return null;
}
@@ -145,7 +151,7 @@
if (locales != null)
{
for (Locale locale: locales)
- return context.getLocaleIfSupported(locale);
+ return context.getLocaleIfLangSupported(locale);
}
return null;
}
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-31 20:20:03 UTC (rev 3987)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-31 21:28:42 UTC (rev 3988)
@@ -143,8 +143,15 @@
localeCtx.setPortalLocale(Locale.ENGLISH);
Locale locale = localePolicy.determineLocale(localeCtx);
- if (!supportedLocales.contains(locale))
+ boolean supported = supportedLocales.contains(locale);
+
+ if (!supported && !"".equals(locale.getCountry()))
{
+ locale = new Locale(locale.getLanguage());
+ supported = supportedLocales.contains(locale);
+ }
+ if (!supported)
+ {
if (log.isWarnEnabled())
log.warn("Unsupported locale returned by LocalePolicy: " + localePolicy + ". Falling back to 'en'.");
locale = Locale.ENGLISH;
Modified: portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
===================================================================
--- portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-31 20:20:03 UTC (rev 3987)
+++ portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-31 21:28:42 UTC (rev 3988)
@@ -149,8 +149,15 @@
localeCtx.setPortalLocale(portalLocale);
Locale locale = localePolicy.determineLocale(localeCtx);
- if (!supportedLocales.contains(locale))
+ boolean supported = supportedLocales.contains(locale);
+
+ if (!supported && !"".equals(locale.getCountry()))
{
+ locale = new Locale(locale.getLanguage());
+ supported = supportedLocales.contains(locale);
+ }
+ if (!supported)
+ {
if (log.isWarnEnabled())
log.warn("Unsupported locale returned by LocalePolicy: " + localePolicy + ". Falling back to 'en'.");
locale = Locale.ENGLISH;
14 years, 3 months
gatein SVN: r3987 - portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp.
by do-not-reply@jboss.org
Author: chris.laprun(a)jboss.com
Date: 2010-08-31 16:20:03 -0400 (Tue, 31 Aug 2010)
New Revision: 3987
Added:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
Modified:
portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
Log:
- GTNPORTAL-1452, GTNWSRP-65: Use ListenerService to register SessionEventListenerAndBroadcaster for session creation and destruction events.
Added: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java (rev 0)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/SessionEventListenerAndBroadcaster.java 2010-08-31 20:20:03 UTC (rev 3987)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, a division of 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.gatein.portal.wsrp;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.services.listener.Event;
+import org.exoplatform.services.listener.Listener;
+import org.gatein.wsrp.api.SessionEvent;
+import org.gatein.wsrp.api.SessionEventBroadcaster;
+import org.gatein.wsrp.api.SessionEventListener;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision$
+ */
+public class SessionEventListenerAndBroadcaster extends Listener<PortalContainer, HttpSessionEvent> implements SessionEventBroadcaster
+{
+ private Map<String, SessionEventListener> listeners = new ConcurrentHashMap<String, SessionEventListener>();
+ private static final String SESSION_CREATED = "org.exoplatform.web.GenericHttpListener.sessionCreated";
+ private static final String SESSION_DESTROYED = "org.exoplatform.web.GenericHttpListener.sessionDestroyed";
+
+ public void registerListener(String listenerId, SessionEventListener listener)
+ {
+ listeners.put(listenerId, listener);
+ }
+
+ public void unregisterListener(String listenerId)
+ {
+ listeners.remove(listenerId);
+ }
+
+ public void notifyListenersOf(SessionEvent event)
+ {
+ for (SessionEventListener listener : listeners.values())
+ {
+ listener.onSessionEvent(event);
+ }
+ }
+
+ @Override
+ public void onEvent(Event<PortalContainer, HttpSessionEvent> event) throws Exception
+ {
+ String eventName = event.getEventName();
+ SessionEvent.SessionEventType eventType;
+ if (SESSION_CREATED.equals(eventName))
+ {
+ eventType = SessionEvent.SessionEventType.SESSION_CREATED;
+ }
+ else if (SESSION_DESTROYED.equals(eventName))
+ {
+ eventType = SessionEvent.SessionEventType.SESSION_DESTROYED;
+ }
+ else
+ {
+ // do nothing
+ return;
+ }
+
+ notifyListenersOf(new SimpleSessionEvent(eventType, event.getData().getSession()));
+ }
+
+ private static class SimpleSessionEvent implements SessionEvent
+ {
+ private SessionEventType eventType;
+ private HttpSession session;
+
+ private SimpleSessionEvent(SessionEventType eventType, HttpSession session)
+ {
+ this.eventType = eventType;
+ this.session = session;
+ }
+
+ public SessionEventType getType()
+ {
+ return eventType;
+ }
+
+ public HttpSession getSession()
+ {
+ return session;
+ }
+ }
+}
Modified: portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java
===================================================================
--- portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-08-31 20:15:12 UTC (rev 3986)
+++ portal/trunk/component/wsrp/src/main/java/org/gatein/portal/wsrp/WSRPServiceIntegration.java 2010-08-31 20:20:03 UTC (rev 3987)
@@ -28,6 +28,7 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
+import org.exoplatform.services.listener.ListenerService;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.gatein.pc.api.PortletInvoker;
@@ -53,9 +54,6 @@
import org.gatein.wci.WebAppListener;
import org.gatein.wci.impl.DefaultServletContainerFactory;
import org.gatein.wsrp.WSRPConstants;
-import org.gatein.wsrp.api.SessionEvent;
-import org.gatein.wsrp.api.SessionEventBroadcaster;
-import org.gatein.wsrp.api.SessionEventListener;
import org.gatein.wsrp.consumer.registry.ActivatingNullInvokerHandler;
import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
import org.gatein.wsrp.producer.ProducerHolder;
@@ -65,8 +63,6 @@
import javax.servlet.ServletContext;
import java.io.InputStream;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
/**
* @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
@@ -218,11 +214,19 @@
FederatingPortletInvoker federatingPortletInvoker =
(FederatingPortletInvoker)container.getComponentInstanceOfType(PortletInvoker.class);
+ // add our Session event listener to the ListenerService for use in org.exoplatform.web.GenericHttpListener
+ ListenerService listenerService = (ListenerService)container.getComponentInstanceOfType(ListenerService.class);
+ SessionEventListenerAndBroadcaster sessionEventBroadcaster = new SessionEventListenerAndBroadcaster();
+ sessionEventBroadcaster.setName("org.exoplatform.web.GenericHttpListener.sessionCreated");
+ listenerService.addListener(sessionEventBroadcaster);
+ sessionEventBroadcaster.setName("org.exoplatform.web.GenericHttpListener.sessionDestroyed");
+ listenerService.addListener(sessionEventBroadcaster);
+
try
{
consumerRegistry = new JCRConsumerRegistry(container);
consumerRegistry.setFederatingPortletInvoker(federatingPortletInvoker);
- consumerRegistry.setSessionEventBroadcaster(new SimpleSessionEventBroadcaster());
+ consumerRegistry.setSessionEventBroadcaster(sessionEventBroadcaster);
consumerRegistry.start();
// set up a NullInvokerHandler so that when a remote producer is queried, we can start it if needed
@@ -298,27 +302,4 @@
}
}
- private static class SimpleSessionEventBroadcaster implements SessionEventBroadcaster
- {
- private Map<String, SessionEventListener> listeners = new ConcurrentHashMap<String, SessionEventListener>();
-
- public void registerListener(String listenerId, SessionEventListener listener)
- {
- listeners.put(listenerId, listener);
- }
-
- public void unregisterListener(String listenerId)
- {
- listeners.remove(listenerId);
- }
-
- public void notifyListenersOf(SessionEvent event)
- {
- for (SessionEventListener listener : listeners.values())
- {
- listener.onSessionEvent(event);
- }
- }
-
- }
-}
+}
\ No newline at end of file
14 years, 3 months
gatein SVN: r3985 - exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component.
by do-not-reply@jboss.org
Author: hoang_to
Date: 2010-08-31 14:24:04 -0400 (Tue, 31 Aug 2010)
New Revision: 3985
Modified:
exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java
Log:
EXOGTN-54: Exception after deleting last member of last page in the Group list
Modified: exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java
===================================================================
--- exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java 2010-08-31 17:23:13 UTC (rev 3984)
+++ exo/portal/branches/3.1.x/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInGroup.java 2010-08-31 18:24:04 UTC (rev 3985)
@@ -176,6 +176,10 @@
}
/** Reset the selected page index **/
+ if (backupPageIndex > pageIterator.getAvailablePage())
+ {
+ backupPageIndex = pageIterator.getAvailablePage();
+ }
pageIterator.setCurrentPage(backupPageIndex);
}
@@ -197,15 +201,10 @@
{
UIUserInGroup uiUserInGroup = event.getSource();
String id = event.getRequestContext().getRequestParameter(OBJECTID);
- UIPageIterator pageIterator = uiUserInGroup.getChild(UIGridUser.class).getUIPageIterator();
- int currentPage = pageIterator.getCurrentPage();
OrganizationService service = uiUserInGroup.getApplicationComponent(OrganizationService.class);
MembershipHandler handler = service.getMembershipHandler();
handler.removeMembership(id, true);
uiUserInGroup.refresh();
- while (currentPage > pageIterator.getAvailablePage())
- currentPage--;
- pageIterator.setCurrentPage(currentPage);
event.getRequestContext().addUIComponentToUpdateByAjax(uiUserInGroup.getChild(UIGridUser.class));
}
}
14 years, 3 months
gatein SVN: r3984 - in components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet: utils and 1 other directory.
by do-not-reply@jboss.org
Author: mvanco(a)redhat.com
Date: 2010-08-31 13:23:13 -0400 (Tue, 31 Aug 2010)
New Revision: 3984
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventConsumerPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventGeneratorPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectConsumerPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectGeneratorPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/PortletModesPortlet.java
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/utils/TestObject.java
Log:
WSRP sample portets:
- added copyrights at java classes and edited code conventions
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventConsumerPortlet.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventConsumerPortlet.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventConsumerPortlet.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet;
import java.io.IOException;
@@ -13,22 +35,22 @@
/**
* EventConsumer Portlet Class
*/
-public class EventConsumerPortlet extends GenericPortlet {
+public class EventConsumerPortlet extends GenericPortlet
+{
@Override
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
String param = request.getParameter("parameter-event");
request.setAttribute("parameter", param);
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/view_consumer.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/view_consumer.jsp");
dispatcher.include(request, response);
}
@Override
- public void processEvent(EventRequest request, EventResponse response)
- throws PortletException, IOException {
+ public void processEvent(EventRequest request, EventResponse response) throws PortletException, IOException
+ {
String param = (String) request.getEvent().getValue();
response.setRenderParameter("parameter-event", param);
}
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventGeneratorPortlet.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventGeneratorPortlet.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventGeneratorPortlet.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet;
import java.io.IOException;
@@ -14,20 +36,20 @@
/**
* EventGenerator Portlet Class
*/
-public class EventGeneratorPortlet extends GenericPortlet {
+public class EventGeneratorPortlet extends GenericPortlet
+{
@Override
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/view_generator.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/view_generator.jsp");
dispatcher.include(request, response);
}
@Override
- public void processAction(ActionRequest request, ActionResponse response)
- throws PortletException, IOException {
+ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
String param = request.getParameter("parameter");
response.setEvent(new QName("urn:jboss:gatein:samples:event", "eventsample"), param);
}
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectConsumerPortlet.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectConsumerPortlet.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectConsumerPortlet.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet;
import java.io.IOException;
@@ -17,29 +39,29 @@
/**
* EventObjectConsumer Portlet Class
*/
-public class EventObjectConsumerPortlet extends GenericPortlet {
+public class EventObjectConsumerPortlet extends GenericPortlet
+{
@Override
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
TestObject object = (TestObject) request.getPortletSession().getAttribute("object");
request.setAttribute("object", object);
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/view_consumer.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/view_consumer.jsp");
dispatcher.include(request, response);
}
@Override
- public void processEvent(EventRequest request, EventResponse response)
- throws PortletException, IOException {
+ public void processEvent(EventRequest request, EventResponse response) throws PortletException, IOException
+ {
TestObject object = (TestObject) request.getEvent().getValue();
request.getPortletSession().setAttribute("object", object);
}
@Override
- public void processAction(ActionRequest request, ActionResponse response)
- throws PortletException, IOException {
+ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
request.getPortletSession().removeAttribute("object");
}
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectGeneratorPortlet.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectGeneratorPortlet.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/EventObjectGeneratorPortlet.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet;
import java.io.IOException;
@@ -18,12 +40,14 @@
/**
* EventObjectGenerator Portlet Class
*/
-public class EventObjectGeneratorPortlet extends GenericPortlet {
+public class EventObjectGeneratorPortlet extends GenericPortlet
+{
private List<TestObject> objects;
@Override
- public void init() throws PortletException {
+ public void init() throws PortletException
+ {
super.init();
objects = new ArrayList<TestObject>();
objects.add(new TestObject("Prabhat", "Jha", "pjha", 654321, "pjha(a)redhat.com"));
@@ -32,9 +56,12 @@
objects.add(new TestObject("Viliam", "Rockai", "vrockai", 223311, "vrockai(a)redhat.com"));
}
- public TestObject getTestObjectByUserName(String username) {
- for (TestObject object : objects) {
- if (object.getUsername().equals(username)) {
+ public TestObject getTestObjectByUserName(String username)
+ {
+ for (TestObject object : objects)
+ {
+ if (object.getUsername().equals(username))
+ {
return object;
}
}
@@ -42,18 +69,17 @@
}
@Override
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
request.setAttribute("objects", objects);
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/view_generator.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/view_generator.jsp");
dispatcher.include(request, response);
}
@Override
- public void processAction(ActionRequest request, ActionResponse response)
- throws PortletException, IOException {
+ public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
String username = request.getParameter("username");
response.setEvent(new QName("urn:jboss:gatein:samples:event:object", "eventObject"), getTestObjectByUserName(username));
}
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/PortletModesPortlet.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/PortletModesPortlet.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/PortletModesPortlet.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet;
import java.io.IOException;
@@ -12,41 +34,38 @@
/**
* PortletModes Class
*/
-public class PortletModesPortlet extends GenericPortlet {
+public class PortletModesPortlet extends GenericPortlet
+{
@Override
- public void doView(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/view.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/view.jsp");
dispatcher.include(request, response);
}
@Override
- public void doHelp(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/help.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/help.jsp");
dispatcher.include(request, response);
}
@Override
- public void doEdit(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/edit.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/edit.jsp");
dispatcher.include(request, response);
}
@RenderMode(name = "TEST_MODE")
- public void doTestMode(RenderRequest request, RenderResponse response)
- throws PortletException, IOException {
+ public void doTestMode(RenderRequest request, RenderResponse response) throws PortletException, IOException
+ {
response.setContentType("text/html");
- PortletRequestDispatcher dispatcher = getPortletContext()
- .getRequestDispatcher("/test_mode.jsp");
+ PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/test_mode.jsp");
dispatcher.include(request, response);
}
}
Modified: components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/utils/TestObject.java
===================================================================
--- components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/utils/TestObject.java 2010-08-31 14:09:06 UTC (rev 3983)
+++ components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/portlet/utils/TestObject.java 2010-08-31 17:23:13 UTC (rev 3984)
@@ -1,3 +1,25 @@
+/******************************************************************************
+ * JBoss, a division of 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.gatein.wsrp.portlet.utils;
import java.io.Serializable;
@@ -5,7 +27,8 @@
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
-public class TestObject implements Serializable {
+public class TestObject implements Serializable
+{
private static final long serialVersionUID = 1L;
@@ -15,11 +38,12 @@
private Integer employeeNumber;
private String email;
- public TestObject() {
+ public TestObject()
+ {
}
- public TestObject(String firstName, String lastName, String username,
- Integer employeeNumber, String email) {
+ public TestObject(String firstName, String lastName, String username, Integer employeeNumber, String email)
+ {
this.firstName = firstName;
this.lastName = lastName;
this.username = username;
@@ -27,7 +51,8 @@
this.email = email;
}
- public TestObject(TestObject object) {
+ public TestObject(TestObject object)
+ {
this.firstName = object.getFirstName();
this.lastName = object.getLastName();
this.username = object.getUsername();
@@ -35,64 +60,77 @@
this.email = object.getEmail();
}
- public String getFirstName() {
+ public String getFirstName()
+ {
return firstName;
}
- public void setFirstName(String firstName) {
+ public void setFirstName(String firstName)
+ {
this.firstName = firstName;
}
- public String getLastName() {
+ public String getLastName()
+ {
return lastName;
}
- public void setLastName(String lastName) {
+ public void setLastName(String lastName)
+ {
this.lastName = lastName;
}
- public String getUsername() {
+ public String getUsername()
+ {
return username;
}
- public void setUsername(String username) {
+ public void setUsername(String username)
+ {
this.username = username;
}
- public Integer getEmployeeNumber() {
+ public Integer getEmployeeNumber()
+ {
return employeeNumber;
}
- public void setEmployeeNumber(Integer employeeNumber) {
+ public void setEmployeeNumber(Integer employeeNumber)
+ {
this.employeeNumber = employeeNumber;
}
- public String getEmail() {
+ public String getEmail()
+ {
return email;
}
- public void setEmail(String email) {
+ public void setEmail(String email)
+ {
this.email = email;
}
@Override
- public boolean equals(Object obj) {
- if (obj instanceof TestObject) {
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof TestObject)
+ {
TestObject object = (TestObject) obj;
- if (this.getUsername().equals(object.getUsername()))
- return true;
+ if (this.getUsername().equals(object.getUsername())) return true;
}
return false;
}
@Override
- public int hashCode() {
+ public int hashCode()
+ {
return super.hashCode() + this.getUsername().hashCode();
}
@Override
- public String toString() {
+ public String toString()
+ {
StringBuilder builder = new StringBuilder();
builder.append("TestObject: ");
builder.append(firstName);
14 years, 3 months
gatein SVN: r3983 - epp/portal/branches/EPP_5_0_Branch.
by do-not-reply@jboss.org
Author: thomas.heute(a)jboss.com
Date: 2010-08-31 10:09:06 -0400 (Tue, 31 Aug 2010)
New Revision: 3983
Modified:
epp/portal/branches/EPP_5_0_Branch/pom.xml
Log:
JBEPP-449: Upgrade eXo JCR to 1.12.3
Modified: epp/portal/branches/EPP_5_0_Branch/pom.xml
===================================================================
--- epp/portal/branches/EPP_5_0_Branch/pom.xml 2010-08-31 13:58:32 UTC (rev 3982)
+++ epp/portal/branches/EPP_5_0_Branch/pom.xml 2010-08-31 14:09:06 UTC (rev 3983)
@@ -43,10 +43,10 @@
<name>GateIn - Portal</name>
<properties>
- <org.exoplatform.kernel.version>2.2.1-GA</org.exoplatform.kernel.version>
- <org.exoplatform.core.version>2.3.1-GA</org.exoplatform.core.version>
- <org.exoplatform.ws.version>2.1.1-GA</org.exoplatform.ws.version>
- <org.exoplatform.jcr.version>1.12.1-GA</org.exoplatform.jcr.version>
+ <org.exoplatform.kernel.version>2.2.3-GA</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.3-GA</org.exoplatform.core.version>
+ <org.exoplatform.ws.version>2.1.3-GA</org.exoplatform.ws.version>
+ <org.exoplatform.jcr.version>1.12.3-GA</org.exoplatform.jcr.version>
<org.jibx.version>1.2.1</org.jibx.version>
<org.shindig.version>1.0-r790473-Patch03</org.shindig.version>
<nl.captcha.simplecaptcha.version>1.1.1-GA-Patch01</nl.captcha.simplecaptcha.version>
14 years, 3 months