Author: hoang_to
Date: 2010-08-15 23:50:59 -0400 (Sun, 15 Aug 2010)
New Revision: 3830
Added:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Phase.java
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/background/NullItemIcon.gif
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/
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/HttpRequestWrapper.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
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
Removed:
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/HttpRequestWrapper.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
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
portal/trunk/component/management/src/main/java/org/exoplatform/management/data/RestResource.java
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/trunk/pom.xml
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortalControl.js
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/Stylesheet.css
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/background/Dotted.gif
portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
portal/trunk/web/portal/src/main/webapp/groovy/webui/form/UISearchForm.gtmpl
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UITree.java
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/DashboardParent.java
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardEditForm.java
portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserProfileLifecycle.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java
Log:
Merge changes from branch r3776 into trunk
Modified:
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java
===================================================================
---
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/application-registry/src/main/java/org/exoplatform/application/gadget/impl/GadgetRegistryServiceImpl.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -26,6 +26,7 @@
import org.exoplatform.application.registry.impl.ApplicationRegistryChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticLifeCycle;
import org.exoplatform.commons.chromattic.ChromatticManager;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
import org.exoplatform.container.xml.ValueParam;
@@ -260,7 +261,9 @@
public boolean isGadgetDeveloper(String username)
{
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public String getCountry()
Modified:
portal/trunk/component/management/src/main/java/org/exoplatform/management/data/RestResource.java
===================================================================
---
portal/trunk/component/management/src/main/java/org/exoplatform/management/data/RestResource.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/management/src/main/java/org/exoplatform/management/data/RestResource.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -26,6 +26,8 @@
import org.exoplatform.management.spi.ManagedPropertyMetaData;
import org.exoplatform.management.spi.ManagedResource;
import org.exoplatform.management.spi.ManagedTypeMetaData;
+import org.exoplatform.services.rest.impl.ApplicationContextImpl;
+import org.exoplatform.services.rest.impl.MultivaluedMapImpl;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
@@ -38,6 +40,10 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.ext.MessageBodyReader;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -126,6 +132,8 @@
@Produces(MediaType.APPLICATION_JSON)
public Object get(@Context UriInfo info, @PathParam("name") String name)
{
+ MultivaluedMap<String, String> parameters = info.getQueryParameters();
+
// Try first to get a property
RestResourceProperty property = properties.get(name);
if (property != null)
@@ -133,12 +141,12 @@
MethodInvoker getter = property.getGetterInvoker();
if (getter != null)
{
- return safeInvoke(getter, info.getQueryParameters());
+ return safeInvoke(getter, parameters);
}
}
//
- return tryInvoke(name, info, ImpactType.READ);
+ return tryInvoke(name, parameters, ImpactType.READ);
}
@PUT
@@ -146,6 +154,7 @@
@Produces(MediaType.APPLICATION_JSON)
public Object put(@Context UriInfo info, @PathParam("name") String name)
{
+ MultivaluedMap<String, String> parameters = getParameters(info);
// Try first to get a property
RestResourceProperty property = properties.get(name);
if (property != null)
@@ -153,12 +162,12 @@
MethodInvoker setter = property.getSetterInvoker();
if (setter != null)
{
- return safeInvoke(setter, info.getQueryParameters());
+ return safeInvoke(setter, parameters);
}
}
//
- return tryInvoke(name, info, ImpactType.IDEMPOTENT_WRITE);
+ return tryInvoke(name, parameters, ImpactType.IDEMPOTENT_WRITE);
}
@POST
@@ -166,7 +175,7 @@
@Produces(MediaType.APPLICATION_JSON)
public Object post(@Context UriInfo info, @PathParam("name") String name)
{
- return tryInvoke(name, info, ImpactType.WRITE);
+ return tryInvoke(name, getParameters(info), ImpactType.WRITE);
}
/**
@@ -177,10 +186,8 @@
* @param impact the expected impact
* @return a suitable response
*/
- private Object tryInvoke(String methodName, UriInfo info, ImpactType impact)
+ private Object tryInvoke(String methodName, MultivaluedMap<String, String>
parameters, ImpactType impact)
{
- MultivaluedMap<String, String> parameters = info.getQueryParameters();
-
//
RestResourceMethod method = lookupMethod(methodName, parameters.keySet(), impact);
@@ -237,4 +244,32 @@
managedResource.afterInvoke(resource);
}
}
+
+ @SuppressWarnings("unchecked")
+ private MultivaluedMap<String, String> getParameters(UriInfo info)
+ {
+ MultivaluedMap<String, String> parameters = info.getQueryParameters();
+ ApplicationContextImpl context = (ApplicationContextImpl)info;
+
+ Type formType =
(ParameterizedType)MultivaluedMapImpl.class.getGenericInterfaces()[0];
+ MediaType contentType = context.getHttpHeaders().getMediaType();
+ if (contentType == null) {
+ contentType = MediaType.APPLICATION_FORM_URLENCODED_TYPE;
+ }
+
+ MultivaluedMap<String, String> form = new MultivaluedMapImpl();
+ try {
+ MessageBodyReader reader =
+ context.getProviders().getMessageBodyReader(MultivaluedMap.class, formType,
null, contentType);
+ if (reader != null) {
+ form = (MultivaluedMap<String,
String>)reader.readFrom(MultivaluedMap.class, formType, null, contentType, context
+ .getHttpHeaders().getRequestHeaders(),
context.getContainerRequest().getEntityStream());
+ }
+ } catch (Exception e) {
+ }
+
+ parameters.putAll(form);
+ return parameters;
+ }
+
}
Modified:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java
===================================================================
---
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/ExoResourceBundle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -20,14 +20,10 @@
package org.exoplatform.services.resources;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.List;
import java.util.ListResourceBundle;
import java.util.Map;
import java.util.ResourceBundle;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
/**
* May 7, 2004
@@ -78,7 +74,7 @@
String key = keys.nextElement();
if (key != null)
{
- map.put(key, getString(key));
+ map.put(key.trim(), getString(key));
}
}
}
Copied:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
(from rev 3829,
portal/branches/branched-r3776/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java)
===================================================================
---
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java
(rev 0)
+++
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocaleContextInfo.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -0,0 +1,190 @@
+/*
+ * 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;
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Helper method that returns the locale only if it's supported by portal.
+ * Otherwise it returns null.
+ *
+ * @param locale locale to check
+ * @return locale if supported, null otherwise
+ */
+ public Locale getLocaleIfSupported(Locale locale)
+ {
+ if (supportedLocales.contains(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();
+ }
+}
Copied:
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java
(from rev 3829,
portal/branches/branched-r3776/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java)
===================================================================
---
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java
(rev 0)
+++
portal/trunk/component/resources/src/main/java/org/exoplatform/services/resources/LocalePolicy.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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);
+}
Copied:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java
(from rev 3829,
portal/branches/branched-r3776/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java)
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java
(rev 0)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationRequestPhaseLifecycle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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);
+}
Copied:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Phase.java
(from rev 3829,
portal/branches/branched-r3776/component/web/controller/src/main/java/org/exoplatform/web/application/Phase.java)
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Phase.java
(rev 0)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/Phase.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,6 +21,8 @@
import java.util.List;
import java.util.Set;
+import javax.servlet.ServletContext;
+
import org.gatein.wci.WebAppEvent;
import org.gatein.wci.WebAppLifeCycleEvent;
@@ -56,6 +58,7 @@
{
String webApp = event.getWebApp().getServletContext().getContextPath();
removeWebAppSkin(webApp);
+ removeContextAppSkin(event.getWebApp().getServletContext());
}
}
}
@@ -77,6 +80,11 @@
}
}
+ private void removeContextAppSkin(ServletContext servletContext)
+ {
+ service.unregisterServletContext(servletContext);
+ }
+
private void removePortalSkins(String webApp) throws Exception
{
List<SkinKey> portalSkins = SkinDependentManager.getPortalSkins(webApp);
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -57,6 +57,13 @@
resolvers.add(new CompositeResourceResolver(portalContainerName, skins));
}
+ /**
+ * Register a servlet request context
+ * <p>Append a servlet context to the map of contexts if servlet context name is
not existing
+ *
+ * @param servletContext servlet context which want to append
+ * @return
+ */
SimpleResourceContext registerContext(ServletContext servletContext)
{
String key = "/" + servletContext.getServletContextName();
@@ -68,6 +75,25 @@
}
return ctx;
}
+
+ /**
+ * Remove a servlet context from map of contexts
+ *
+ * @param servletContext
+ */
+ public void removeServletContext(ServletContext servletContext)
+ {
+ String key = "/" + servletContext.getServletContextName();
+ SimpleResourceContext ctx = contexts.get(key);
+ if (ctx != null)
+ {
+ contexts.remove(ctx.getContextPath());
+ }
+ else {
+ log.warn("Cannot find servlet context module");
+ return;
+ }
+ }
public Resource resolve(String path)
{
Modified:
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
---
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/component/web/resources/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -799,6 +799,16 @@
{
mainResolver.registerContext(sContext);
}
+
+ /**
+ * unregister a {@link ServletContext} into {@link MainResourceResolver} of {@link
SkinService}
+ *
+ * @param servletContext ServletContext will unregistered
+ */
+ public void unregisterServletContext(ServletContext servletContext)
+ {
+ mainResolver.removeServletContext(servletContext);
+ }
/**
* Clean cache, reload all Skins
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-08-13 17:09:39 UTC (rev 3829)
+++ portal/trunk/pom.xml 2010-08-16 03:50:59 UTC (rev 3830)
@@ -47,7 +47,7 @@
<org.gatein.common.version>2.0.2-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.1-GA</org.gatein.wci.version>
<org.gatein.pc.version>2.1.1-GA</org.gatein.pc.version>
- <org.picketlink.idm>1.1.5.CR02</org.picketlink.idm>
+ <org.picketlink.idm>1.1.5.CR01</org.picketlink.idm>
<org.gatein.wsrp.version>1.1.1-GA</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.3-GA</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
Modified:
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java
===================================================================
---
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/portlet/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardPortlet.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -98,12 +98,4 @@
return false;
}
- /**
- * For now returns null.
- */
- public String getDashboardOwner()
- {
- return null;
- }
-
}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/applicationregistry/webui/component/UIPortletManagement.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -313,17 +313,38 @@
public String getDisplayName()
{
- return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ try
+ {
+ return getMetaValue(MetaInfo.DISPLAY_NAME, name_);
+ }
+ catch (Exception ex)
+ {
+ return "COULD NOT GET DISPLAY NAME OF THE PORTLET";
+ }
}
public String getDescription()
{
- return getMetaValue(MetaInfo.DESCRIPTION, name_);
+ try
+ {
+ return getMetaValue(MetaInfo.DESCRIPTION, name_);
+ }
+ catch (Exception ex)
+ {
+ return "COULD NOT GET DESCRIPTION OF THE PORTLET";
+ }
}
public PreferencesInfo getPortletPreferences()
{
- return portletInfo_.getPreferences();
+ try
+ {
+ return portletInfo_.getPreferences();
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
}
private String getMetaValue(String metaKey, String defaultValue)
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/organization/webui/component/UIUserInfo.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,6 +21,7 @@
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;
@@ -134,7 +135,8 @@
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
if (localeConfig == null)
localeConfig = localeConfigService.getDefaultLocaleConfig();
- uiApp.setLocale(localeConfig.getLocale());
+ PortalRequestContext prqCtx = PortalRequestContext.getCurrentInstance();
+ prqCtx.setLocale(localeConfig.getLocale());
uiApp.setOrientation(localeConfig.getOrientation());
uiApp.localizeNavigations();
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/PortalDragDrop.js 2010-08-16
03:50:59 UTC (rev 3830)
@@ -32,6 +32,10 @@
*/
PortalDragDrop.prototype.init = function(e) {
+ if (eXo.core.DragDrop.dndEvent && eXo.core.DragDrop.dndEvent.clickObject ==
this){
+ return;
+ }
+
if (!e) e = window.event;
if(((e.which) && (e.which == 2 || e.which == 3)) || ((e.button) &&
(e.button == 2))) return;
@@ -194,7 +198,9 @@
this.origDragObjectStyle.setProperties(dndEvent.dragObject.style, false) ;
if(dndEvent.foundTargetObject != null || (dndEvent.backupMouseEvent &&
dndEvent.backupMouseEvent.keyCode != 27)) {
- eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
+ if (dndEvent.foundTargetObject.foundIndex != null) {
+ eXo.portal.PortalDragDrop.doDropCallback(dndEvent) ;
+ }
} else {
if(dndEvent.dragObject.parentNode.nodeName.toLowerCase() == "td") {
dndEvent.dragObject.parentNode.style.width = "auto";
@@ -220,12 +226,6 @@
dndEvent.dragObject.style.width = "auto" ;
};
- DragDrop.cancelCallback = function(dndEvent) {
- if(Browser.browserType == "ie" &&
Browser.findMouseYInClient(dndEvent.backupMouseEvent) < 0) {
- DragDrop.onDrop(dndEvent.backupMouseEvent);
- }
- };
-
var clickObject = this;
var componentBlock = DOMUtil.findAncestorByClass(clickObject,
"UIComponentBlock") ;
@@ -284,7 +284,7 @@
] ;
try {
- dndEvent.lastFoundTargetObject.foundIndex = -1;
+ dndEvent.lastFoundTargetObject.foundIndex = null;
} catch(err) {
}
Modified: portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortal.js 2010-08-16
03:50:59 UTC (rev 3830)
@@ -98,6 +98,56 @@
}
newLayer.parentNode.style.top = -height + "px";
editBlock.style.display = "block";
+
+ //resize width of portlet/container control if IE + LTR align BEGIN
+
+ var uiInfoBar = DOMUtil.findFirstDescendantByClass(editBlock, "div",
"UIInfoBar");
+
+ if( uiInfoBar && (eXo.core.Browser.isIE6() || (eXo.core.Browser.isIE7()
&& eXo.core.I18n.isRT()))){
+ //resize width of portlet/container only one time
+ if(uiInfoBar.style.width == ""){
+ var dragControlArea = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div",
"DragControlArea");
+
+ var portletIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div",
"PortletIcon");
+ var editPortletPropertiesIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar,
"a", "EditPortletPropertiesIcon");
+ var deletePortletIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a",
"DeletePortletIcon");
+
+ var contarnerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "div",
"ContainerIcon");
+ var editContainerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar, "a",
"EditContainerIcon");
+ var deleteContainerIcon = DOMUtil.findFirstDescendantByClass(uiInfoBar,
"a", "DeleteContainerIcon");
+
+ var uiInfoBarWidth = dragControlArea.offsetWidth;
+
+ if(DOMUtil.hasClass(portlet, "UIPortlet")){
+ uiInfoBarWidth += portletIcon.offsetWidth;
+
+ if(editPortletPropertiesIcon){
+ uiInfoBarWidth += editPortletPropertiesIcon.offsetWidth;
+ }
+
+ if(deletePortletIcon){
+ uiInfoBarWidth += deletePortletIcon.offsetWidth;
+ }
+ }
+
+ if(DOMUtil.hasClass(portlet, "UIContainer")){
+ uiInfoBarWidth += contarnerIcon.offsetWidth
+
+ if(editContainerIcon){
+ uiInfoBarWidth += editContainerIcon.offsetWidth;
+ }
+
+ if(deleteContainerIcon){
+ uiInfoBarWidth += deleteContainerIcon.offsetWidth;
+ }
+ }
+
+ uiInfoBar.style.width= uiInfoBarWidth + 35 + "px";
+ }
+
+ }
+ //resize width of portlet/container control if IE + LTR align END
+
} else {
editBlock.style.display = "none";
if(!DOMUtil.hasClass(portlet, "UIPortlet")) {
Modified:
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortalControl.js
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortalControl.js 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/eXoResources/src/main/webapp/javascript/eXo/portal/UIPortalControl.js 2010-08-16
03:50:59 UTC (rev 3830)
@@ -58,21 +58,31 @@
}
};
-UIPortalControl.prototype.onEnterPress = function(e) {
- var e = window.event || e;
- var uiPortalLoginFormAction =
document.getElementById("UIPortalLoginFormAction");
- if(uiPortalLoginFormAction) {
- var code;
- if(!e) e = window.event;
- if(e.keyCode) code = e.keyCode;
- else if (e.which) code = e.which;
- if(code ==13) {
- if(this.t != 13) {
- uiPortalLoginFormAction.onclick() ;
- }
- this.t = code;
- }
- }
+/**
+ * Process enter key press
+ * @param {Event} e this event
+ * @param {String} executeScript javascript command to execute if enter key was pressed
+ */
+UIPortalControl.prototype.onEnterPress = function(e, executeScript) {
+ var e = window.event || e;
+ var code;
+ if(!e) e = window.event;
+ if(e.keyCode) code = e.keyCode;
+ else if (e.which) code = e.which;
+ if(code ==13) {
+ if(this.t != 13) {
+ var uiPortalLoginFormAction =
document.getElementById("UIPortalLoginFormAction");
+ if(uiPortalLoginFormAction) {
+ uiPortalLoginFormAction.onclick() ;
+ }
+ else
+ {
+ if(executeScript)
+ eval(executeScript);
+ }
+ }
+ this.t = code;
+ }
};
/*********** Scroll Manager *************/
Modified:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/Stylesheet.css
===================================================================
---
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/Stylesheet.css 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/Stylesheet.css 2010-08-16
03:50:59 UTC (rev 3830)
@@ -52,7 +52,7 @@
}
.UITrees .Node {
- line-height: 18px;
+ line-height: 19px;
padding-top: 7px;
margin-left: 15px; /* orientation=lt */
margin-right: 15px; /* orientation=rt */
@@ -97,6 +97,15 @@
font-weight: bold;
color: #058ee6;
cursor: pointer;
+}
+
+.UITrees .Node .NullItemIcon {
+ padding-left: 18px; /* orientation=lt */
+ padding-right: 18px; /* orientation=rt */
+ background: url('background/NullItemIcon.gif') no-repeat 6px top; /*
orientation=lt */
+ background: url('background/NullItemIcon-rt.gif') no-repeat 98.5% top; /*
orientation=rt */
+ -webkit-background: url('background/NullItemIcon-rt.gif') no-repeat 98.2% top;
/* orientation=rt */
+ width: 100%; height: auto;
}
/** ################# Icons ###################*/
Modified:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/background/Dotted.gif
===================================================================
(Binary files differ)
Copied:
portal/trunk/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/background/NullItemIcon.gif
(from rev 3829,
portal/branches/branched-r3776/web/eXoResources/src/main/webapp/skin/DefaultSkin/webui/component/UITree/background/NullItemIcon.gif)
===================================================================
(Binary files differ)
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-08-13 17:09:39 UTC (rev
3829)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/web.xml 2010-08-16 03:50:59 UTC (rev
3830)
@@ -1,19 +1,19 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
+<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
Copyright (C) 2009 eXo Platform SAS.
-
+
This is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this software; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -21,9 +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>
+<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,31 +36,33 @@
<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>
</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>
</context-param>
-
+
<!-- ================================================================== -->
<!-- RESOURCE FILTER TO CACHE MERGED JAVASCRIPT AND CSS -->
<!-- ================================================================== -->
+ <filter>
+ <filter-name>LocalizationFilter</filter-name>
+ <filter-class>org.exoplatform.portal.application.localization.LocalizationFilter</filter-class>
+ </filter>
<filter>
<filter-name>GenericFilter</filter-name>
<filter-class>org.exoplatform.web.filter.GenericFilter</filter-class>
</filter>
<filter>
- <filter-name>ResourceRequestFilter</filter-name>
-
<filter-class>org.exoplatform.portal.application.ResourceRequestFilter</filter-class>
+ <filter-name>ResourceRequestFilter</filter-name>
+
<filter-class>org.exoplatform.portal.application.ResourceRequestFilter</filter-class>
</filter>
-
+
<filter>
<filter-name>ThreadLocalSessionProviderInitializedFilter</filter-name>
<filter-class>org.exoplatform.frameworks.jcr.web.ThreadLocalSessionProviderInitializedFilter</filter-class>
- </filter>
+ </filter>
<filter>
<filter-name>SetCurrentIdentityFilter</filter-name>
@@ -66,17 +70,17 @@
</filter>
-
- <filter>
- <filter-name>RestEncodingFilter</filter-name>
-
<filter-class>org.exoplatform.services.rest.servlet.RestEncodingFilter</filter-class>
- <init-param>
- <param-name>REQUEST_ENCODING</param-name>
- <param-value>UTF-8</param-value>
- </init-param>
- </filter>
<filter>
+ <filter-name>RestEncodingFilter</filter-name>
+
<filter-class>org.exoplatform.services.rest.servlet.RestEncodingFilter</filter-class>
+ <init-param>
+ <param-name>REQUEST_ENCODING</param-name>
+ <param-value>UTF-8</param-value>
+ </init-param>
+ </filter>
+
+ <filter>
<filter-name>CacheUserProfileFilter</filter-name>
<filter-class>org.exoplatform.web.CacheUserProfileFilter</filter-class>
</filter>
@@ -101,6 +105,15 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <filter-mapping>
+ <filter-name>LocalizationFilter</filter-name>
+ <url-pattern>/*</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>
@@ -108,29 +121,29 @@
<filter-mapping>
<filter-name>ResourceRequestFilter</filter-name>
- <url-pattern>*.css</url-pattern>
+ <url-pattern>*.css</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>ResourceRequestFilter</filter-name>
- <url-pattern>*.gif</url-pattern>
+ <url-pattern>*.gif</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ResourceRequestFilter</filter-name>
- <url-pattern>*.png</url-pattern>
+ <url-pattern>*.png</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ResourceRequestFilter</filter-name>
- <url-pattern>*.jpg</url-pattern>
+ <url-pattern>*.jpg</url-pattern>
</filter-mapping>
<filter-mapping>
- <filter-name>ResourceRequestFilter</filter-name>
- <url-pattern>/javascript/*</url-pattern>
+ <filter-name>ResourceRequestFilter</filter-name>
+ <url-pattern>/javascript/*</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>SetCurrentIdentityFilter</filter-name>
<url-pattern>/*</url-pattern>
@@ -140,12 +153,12 @@
<filter-name>ThreadLocalSessionProviderInitializedFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>CacheUserProfileFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>RestEncodingFilter</filter-name>
<url-pattern>/rest/*</url-pattern>
@@ -158,36 +171,35 @@
<listener-class>org.exoplatform.web.GenericHttpListener</listener-class>
</listener>
<listener>
-
<listener-class>org.exoplatform.portal.application.PortalSessionListener</listener-class>
+
<listener-class>org.exoplatform.portal.application.PortalSessionListener</listener-class>
</listener>
<listener>
<listener-class>org.exoplatform.services.security.web.JAASConversationStateListener</listener-class>
- </listener>
+ </listener>
<!-- ================================================================== -->
<!-- SERVLET -->
- <!-- ================================================================== -->
+ <!-- ================================================================== -->
<servlet>
- <servlet-name>portal</servlet-name>
-
<servlet-class>org.exoplatform.portal.application.PortalController</servlet-class>
+ <servlet-name>portal</servlet-name>
+
<servlet-class>org.exoplatform.portal.application.PortalController</servlet-class>
<init-param>
- <param-name>webui.configuration</param-name>
- <param-value>app:/WEB-INF/webui-configuration.xml</param-value>
+ <param-name>webui.configuration</param-name>
+ <param-value>app:/WEB-INF/webui-configuration.xml</param-value>
</init-param>
- <load-on-startup>1</load-on-startup>
+ <load-on-startup>1</load-on-startup>
</servlet>
-
+
<servlet>
<servlet-name>RestServer</servlet-name>
- <description>eXo - Platform REST Server</description>
<servlet-class>org.exoplatform.services.rest.servlet.RestServlet</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>
-
+
<servlet>
- <servlet-name>javascript</servlet-name>
-
<servlet-class>org.exoplatform.portal.webui.javascript.JavascriptServlet</servlet-class>
+ <servlet-name>javascript</servlet-name>
+
<servlet-class>org.exoplatform.portal.webui.javascript.JavascriptServlet</servlet-class>
</servlet>
-
+
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>org.exoplatform.frameworks.jcr.web.CommandControllerServlet</servlet-class>
@@ -232,114 +244,114 @@
</servlet-mapping>
- <!-- ================================================================= -->
+ <!-- ================================================================= -->
<servlet-mapping>
- <servlet-name>InitiateLoginServlet</servlet-name>
- <url-pattern>/initiatelogin</url-pattern>
+ <servlet-name>InitiateLoginServlet</servlet-name>
+ <url-pattern>/initiatelogin</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ErrorLoginServlet</servlet-name>
<url-pattern>/errorlogin</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>PortalLoginController</servlet-name>
- <url-pattern>/login</url-pattern>
+ <servlet-name>PortalLoginController</servlet-name>
+ <url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>javascript</servlet-name>
- <url-pattern>/javascript/*</url-pattern>
+ <servlet-name>javascript</servlet-name>
+ <url-pattern>/javascript/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/private/*</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/private/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/public/*</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/public/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/admin/*</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/admin/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/service</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/service</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/upload/*</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/upload/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
- <servlet-name>portal</servlet-name>
- <url-pattern>/download/*</url-pattern>
+ <servlet-name>portal</servlet-name>
+ <url-pattern>/download/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RestServer</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
-
+
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/connector</url-pattern>
- </servlet-mapping>
-
+ </servlet-mapping>
+
<servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
<session-config>
- <session-timeout>30</session-timeout>
+ <session-timeout>30</session-timeout>
</session-config>
<!-- The Welcome File List for IBM WebSphere -->
-
+
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
-
+
<security-constraint>
<web-resource-collection>
- <web-resource-name>user authentication</web-resource-name>
- <url-pattern>/private/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
+ <web-resource-name>user authentication</web-resource-name>
+ <url-pattern>/private/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
- <role-name>users</role-name>
+ <role-name>users</role-name>
</auth-constraint>
<user-data-constraint>
- <transport-guarantee>NONE</transport-guarantee>
+ <transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
- <web-resource-name>admin authentication</web-resource-name>
- <url-pattern>/admin/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
+ <web-resource-name>admin authentication</web-resource-name>
+ <url-pattern>/admin/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
- <role-name>admin</role-name>
+ <role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
- <transport-guarantee>NONE</transport-guarantee>
+ <transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
- <auth-method>FORM</auth-method>
- <realm-name>gatein-domain</realm-name>
+ <auth-method>FORM</auth-method>
+ <realm-name>gatein-domain</realm-name>
<form-login-config>
- <form-login-page>/initiatelogin</form-login-page>
+ <form-login-page>/initiatelogin</form-login-page>
<form-error-page>/errorlogin</form-error-page>
</form-login-config>
</login-config>
<security-role>
- <description>a simple user role</description>
- <role-name>users</role-name>
+ <description>a simple user role</description>
+ <role-name>users</role-name>
</security-role>
<security-role>
<description>the admin role</description>
- <role-name>admin</role-name>
+ <role-name>admin</role-name>
</security-role>
</web-app>
Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-08-13
17:09:39 UTC (rev 3829)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/webui-configuration.xml 2010-08-16
03:50:59 UTC (rev 3830)
@@ -38,6 +38,7 @@
<listener>org.exoplatform.webui.application.MonitorApplicationLifecycle</listener>
<listener>org.exoplatform.portal.application.UserProfileLifecycle</listener>
<listener>org.exoplatform.portal.application.concurrent.PortalConcurrencyMonitorLifecycle</listener>
+
<listener>org.exoplatform.portal.application.localization.LocalizationLifecycle</listener>
</application-lifecycle-listeners>
<events>
Modified:
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/portal/src/main/webapp/groovy/portal/webui/application/UIPortlet.gtmpl 2010-08-16
03:50:59 UTC (rev 3830)
@@ -37,12 +37,14 @@
<div class="FixHeight">
<%
if(hasPermission) {
- try {
- String portletName =
uicomponent.getProducedOfferedPortlet().getInfo().getName();
- print
_ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description."
+ portletName);
- } catch(Exception e){
- print uicomponent.getDisplayName();
- }
+ if(portletTitle == null || portletTitle.trim().length() < 1) {
+ try {
+ String portletName =
uicomponent.getProducedOfferedPortlet().getInfo().getName();
+ print
_ctx.getRequestContext().getApplicationResourceBundle().getString("UIPortlet.description."
+ portletName);
+ } catch(Exception e){
+ print uicomponent.getDisplayName();
+ }
+ } else print portletTitle;
} else print "<div
class='ProtectedContent'>"+_ctx.appRes("UIPortlet.label.protectedContent")+"</div>";
%>
</div>
@@ -60,10 +62,12 @@
if(portalMode != uiPortalApp.CONTAINER_BLOCK_EDIT_MODE && portalMode !=
uiPortalApp.APP_BLOCK_EDIT_MODE) {
if(uicomponent.getShowInfoBar()) {
- String title = uicomponent.getTitle();
- if(title == null || title.trim().length() < 1)
+ String title = portletTitle;
+ if(title == null || title.trim().length() < 1)
+ title = uicomponent.getTitle();
+ if(title == null || title.trim().length() < 1)
title = uicomponent.getDisplayName();
- if(title == null || title.trim().length() < 1)
+ if(title == null || title.trim().length() < 1)
title = portletId;
/*Begin Window Portlet Bar*/
String visibility = "visible";
@@ -288,7 +292,9 @@
String portletIcon = uicomponent.getIcon();
if(portletIcon == null) portletIcon = "PortletIcon";
- String title = uicomponent.getDisplayTitle();
+ String title = portletTitle;
+ if(title == null || title.trim().length() < 1)
+ title = uicomponent.getDisplayTitle();
if(title.length() > 30) title = title.substring(0,27) +
"...";
%>
<div class="PortletIcon $portletIcon"><%=hasPermission
? title : _ctx.appRes("UIPortlet.label.protectedContent")%></div>
Modified: portal/trunk/web/portal/src/main/webapp/groovy/webui/form/UISearchForm.gtmpl
===================================================================
---
portal/trunk/web/portal/src/main/webapp/groovy/webui/form/UISearchForm.gtmpl 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/web/portal/src/main/webapp/groovy/webui/form/UISearchForm.gtmpl 2010-08-16
03:50:59 UTC (rev 3830)
@@ -6,19 +6,21 @@
<div class="MiddleBar">
<div class="UISearchForm">
<%uiform.begin()%>
- <div class="QuickSet">
+ <%String quickSearchlink = uicomponent.event("QuickSearch") ;%>
+ <script type="text/javascript">
+ var executeScript = "<%=quickSearchlink%>";
+ </script>
+ <div class="QuickSet"
onkeypress="eXo.portal.UIPortalControl.onEnterPress(event, executeScript)">
<div
class="SearchTitle"><%=_ctx.appRes("UISearch.label.Search")%>:</div>
<%
QuickSearchInputSet = uiform.getQuickSearchInputSet();
for(field in QuickSearchInputSet.getChildren()) {
uiform.renderField(field)
}
- String quickSearchlink = uicomponent.event("QuickSearch");
%>
<a class="SimpleSearchIcon" href="$quickSearchlink"
title="<%= _ctx.appRes("UISearch.label.QuickSearch") %>">
<span></span>
</a>
-
</div>
<%uiform.end()%>
</div>
Modified: portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UITree.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UITree.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/core/UITree.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -19,6 +19,7 @@
package org.exoplatform.webui.core;
+import org.exoplatform.portal.config.model.PageNode;
import org.exoplatform.util.ReflectionUtil;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
@@ -53,6 +54,11 @@
* The css class name to show the collapse icon
*/
private String colapseIcon = "CollapseIcon";
+
+ /**
+ * The css class name to show the null icon (item has no child)
+ */
+ private String nullItemIcon = "NullItemIcon";
/**
* The css class name to show the selected icon
@@ -265,6 +271,9 @@
iconGroup = selectedIcon;
note = " NodeSelected";
}
+ if(obj instanceof PageNode && ((PageNode)obj).getChildren().size() == 0) {
+ nodeIcon = nullItemIcon;
+ }
if (beanIconField_ != null && beanIconField_.length() > 0)
{
if (getFieldValue(obj, beanIconField_) != null)
@@ -284,11 +293,14 @@
{
builder.append(" <div
class=\"").append(nodeIcon).append("\"
onclick=\"").append(actionLink).append("\">");
}
- else
+ else if (nodeIcon.equals(colapseIcon))
{
builder.append(" <div class=\"").append(nodeIcon).append(
"\"
onclick=\"eXo.portal.UIPortalControl.collapseTree(this)").append("\">");
}
+ else {//Null item
+ builder.append(" <div
class=\"").append(nodeIcon).append("\">");
+ }
if (uiPopupMenu_ == null)
{
builder.append(" <a href=\"javascript:void(0);\"
class=\"NodeIcon ").append(iconGroup).append(note).append(
Modified:
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java
===================================================================
---
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/core/src/main/java/org/exoplatform/webui/form/validator/DateTimeValidator.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -73,17 +73,16 @@
{
// Specify whether or not date/time parsing is to be lenient.
sdf.setLenient(false);
- Date stDate = sdf.parse(s);
- s = stFormat.format(stDate);
+ sdf.parse(s);
}
catch (Exception e)
{
- throw new MessageException(new
ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
+ throw new MessageException(new
ApplicationMessage("DateTimeValidator.msg.Invalid-input", args,
ApplicationMessage.WARNING));
}
if (s.matches(DATETIME_REGEX) && isValidDateTime(s))
return;
- throw new MessageException(new
ApplicationMessage("DateTimeValidator.msg.Invalid-input", args));
+ throw new MessageException(new
ApplicationMessage("DateTimeValidator.msg.Invalid-input", args,
ApplicationMessage.WARNING));
}
private boolean isValidDateTime(String dateTime)
Modified:
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/DashboardParent.java
===================================================================
---
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/DashboardParent.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/DashboardParent.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,11 +21,5 @@
public interface DashboardParent
{
- public static final String ISPRIVATE = "isPrivate";
-
- public static final String OWNER = "owner";
-
- String getDashboardOwner();
-
boolean canEdit();
}
Modified:
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardEditForm.java
===================================================================
---
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardEditForm.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/dashboard/src/main/java/org/exoplatform/dashboard/webui/component/UIDashboardEditForm.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -49,20 +49,13 @@
public UIDashboardEditForm() throws Exception
{
- PortletRequestContext pcontext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance();
- PortletPreferences pref = pcontext.getRequest().getPreferences();
addUIFormInput(new UIFormStringInput(TOTAL_COLUMNS, TOTAL_COLUMNS, null));
- addUIFormInput(new UIFormStringInput(DashboardParent.OWNER, DashboardParent.OWNER,
pref.getValue(
- DashboardParent.OWNER, null)));
- addUIFormInput(new UIFormStringInput(DashboardParent.ISPRIVATE,
DashboardParent.ISPRIVATE, pref.getValue(
- DashboardParent.ISPRIVATE, null)));
}
public static class SaveActionListener extends
EventListener<UIDashboardEditForm>
{
public final void execute(final Event<UIDashboardEditForm> event) throws
Exception
{
-
UIDashboardEditForm uiForm = event.getSource();
UIFormStringInput uiInput = uiForm.getUIStringInput(TOTAL_COLUMNS);
@@ -101,12 +94,6 @@
throw new MessageException(new
ApplicationMessage("NumberFormatValidator.msg.Invalid-number", args));
}
- uiInput = uiForm.getUIStringInput(DashboardParent.ISPRIVATE);
- pref.setValue(DashboardParent.ISPRIVATE, uiInput.getValue());
-
- uiInput = uiForm.getUIStringInput(DashboardParent.OWNER);
- pref.setValue(DashboardParent.OWNER, uiInput.getValue());
-
UIDashboardContainer uiDashboardContainer =
((UIContainer)uiForm.getParent()).getChild(UIDashboard.class).getChild(UIDashboardContainer.class);
uiDashboardContainer.setColumns(totalCols);
Modified: portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml
===================================================================
--- portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-13
17:09:39 UTC (rev 3829)
+++ portal/trunk/webui/portal/src/main/java/conf/portal/configuration.xml 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestContext.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -116,6 +116,8 @@
private Map<String, String[]> parameterMap;
+ private Locale locale = Locale.ENGLISH;
+
public JavascriptManager getJavascriptManager()
{
return jsmanager_;
@@ -169,12 +171,10 @@
// Reconstructing the getPathInfo from the non server decoded values.
String servletPath = URLDecoder.decode(req.getServletPath(), "UTF-8");
String contextPath = URLDecoder.decode(req.getContextPath(), "UTF-8");
- String pathInfo = requestURI_.substring((servletPath + contextPath).length());
+ String pathInfo = "/";
+ if (requestURI_.length() > servletPath.length() + contextPath.length())
+ pathInfo = requestURI_.substring(servletPath.length() + contextPath.length());
- if (pathInfo == null || pathInfo.length() == 0)
- {
- pathInfo = "/";
- }
int colonIndex = pathInfo.indexOf("/", 1);
if (colonIndex < 0)
{
@@ -241,9 +241,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:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalRequestHandler.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -26,6 +26,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.web.application.RequestFailure;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIApplication;
@@ -104,11 +106,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());
@@ -149,4 +157,25 @@
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:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/PortalStateManager.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserProfileLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserProfileLifecycle.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/UserProfileLifecycle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -31,7 +31,7 @@
{
public static final String USER_PROFILE_ATTRIBUTE_NAME =
"PortalUserProfile";
- private final ThreadLocal<UserProfile> currentUserProfile = new
ThreadLocal<UserProfile>();
+ private final static ThreadLocal<UserProfile> currentUserProfile = new
ThreadLocal<UserProfile>();
@SuppressWarnings("unused")
public void onInit(Application app)
@@ -55,15 +55,15 @@
}
}
-
+
currentUserProfile.set(userProfile);
context.setAttribute(this.USER_PROFILE_ATTRIBUTE_NAME, userProfile);
}
-
+
@SuppressWarnings("unused")
public void onFailRequest(Application app, WebuiRequestContext context, RequestFailure
failureType) throws Exception
{
-
+
}
@SuppressWarnings("unused")
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization
(from rev 3829,
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization)
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
===================================================================
---
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -1,142 +0,0 @@
-/*
- * 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.
- *
- * @see NoBrowserLocalePolicyService
- *
- * @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.getLocaleIfSupported(context.getUserProfileLocale());
- if (locale == null)
- locale = getLocaleConfigFromCookie(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();
- for (Locale loc: locales)
- return context.getLocaleIfSupported(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 = getLocaleConfigFromBrowser(context);
-
- return locale;
- }
-
- /**
- * 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();
- for (Locale locale: locales)
- return context.getLocaleIfSupported(locale);
-
- return null;
- }
-
- /**
- * Starter interface method
- */
- public void start()
- {
- }
-
- /**
- * Starter interface method
- */
- public void stop()
- {
- }
-
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java
(from rev 3829,
portal/branches/branched-r3776/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
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/DefaultLocalePolicyService.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -0,0 +1,142 @@
+/*
+ * 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.
+ *
+ * @see NoBrowserLocalePolicyService
+ *
+ * @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.getLocaleIfSupported(context.getUserProfileLocale());
+ if (locale == null)
+ locale = getLocaleConfigFromCookie(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();
+ for (Locale loc: locales)
+ return context.getLocaleIfSupported(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 = getLocaleConfigFromBrowser(context);
+
+ return locale;
+ }
+
+ /**
+ * 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();
+ for (Locale locale: locales)
+ return context.getLocaleIfSupported(locale);
+
+ return null;
+ }
+
+ /**
+ * Starter interface method
+ */
+ public void start()
+ {
+ }
+
+ /**
+ * Starter interface method
+ */
+ public void stop()
+ {
+ }
+
+}
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
===================================================================
---
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -1,97 +0,0 @@
-/*
- * 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);
- }
- }
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
(from rev 3829,
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java)
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/HttpRequestWrapper.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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);
+ }
+ }
+}
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
===================================================================
---
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -1,195 +0,0 @@
-/*
- * 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.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 this dynamic
resources can be localized
- * to keep in synch with the rest of the portal.
- *
- * A concrete example for this 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
- * that LocalizationLifecycle uses.
- *
- * 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.setUserProfileLocale(getUserProfileLocale(container,
req.getRemoteUser()));
- localeCtx.setRemoteUser(req.getRemoteUser());
-
- localeCtx.setPortalLocale(Locale.ENGLISH);
- Locale locale = localePolicy.determineLocale(localeCtx);
- if (!supportedLocales.contains(locale))
- {
- 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
- {
- 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.");
- }
-
- String lang = userProfile == null ? null :
userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
- return (lang != null) ? new Locale(lang) : null;
- }
-
- public void destroy()
- {
- }
-
- public static Locale getCurrentLocale()
- {
- return currentLocale.get();
- }
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
(from rev 3829,
portal/branches/branched-r3776/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
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -0,0 +1,195 @@
+/*
+ * 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.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 this dynamic
resources can be localized
+ * to keep in synch with the rest of the portal.
+ *
+ * A concrete example for this 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
+ * that LocalizationLifecycle uses.
+ *
+ * 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.setUserProfileLocale(getUserProfileLocale(container,
req.getRemoteUser()));
+ localeCtx.setRemoteUser(req.getRemoteUser());
+
+ localeCtx.setPortalLocale(Locale.ENGLISH);
+ Locale locale = localePolicy.determineLocale(localeCtx);
+ if (!supportedLocales.contains(locale))
+ {
+ 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
+ {
+ 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.");
+ }
+
+ String lang = userProfile == null ? null :
userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
+ return (lang != null) ? new Locale(lang) : null;
+ }
+
+ public void destroy()
+ {
+ }
+
+ public static Locale getCurrentLocale()
+ {
+ return currentLocale.get();
+ }
+}
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
===================================================================
---
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -1,314 +0,0 @@
-/*
- * 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.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.web.application.RequestFailure;
-import org.exoplatform.webui.application.WebuiRequestContext;
-
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-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 COOKIE_NAME = "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.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);
- if (!supportedLocales.contains(locale))
- {
- 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();
- if (loc != null && (remembered == null || !loc.equals(remembered)))
- saveLocale(reqCtx, loc);
- }
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onEndRequest
- */
- public void onEndRequest(Application app, WebuiRequestContext context) throws
Exception
- {
- }
-
- /**
- * @see org.exoplatform.web.application.ApplicationLifecycle#onFailRequest
- */
- public void onFailRequest(Application app, WebuiRequestContext context, RequestFailure
failureType) 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) ? new Locale(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 (COOKIE_NAME.equals(cookie.getName()))
- {
- List<Locale> locales = new ArrayList<Locale>();
- locales.add(LocaleContextInfo.getLocale(cookie.getValue()));
- return locales;
- }
- }
- }
- return Collections.emptyList();
- }
-
- private void saveLocale(PortalRequestContext context, Locale loc)
- {
- String user = context.getRemoteUser();
- if (user != null)
- {
- saveLocaleToUserProfile(context, loc, user);
- }
- else
- {
- saveLocaleToCookie(context, loc);
- }
- }
-
- private void saveLocaleToCookie(PortalRequestContext context, Locale loc)
- {
- HttpServletResponse res = context.getResponse();
- Cookie cookie = new Cookie(COOKIE_NAME, 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, loc.getLanguage());
- 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);
- }
- }
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java
(from rev 3829,
portal/branches/branched-r3776/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
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationLifecycle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -0,0 +1,314 @@
+/*
+ * 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.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.web.application.RequestFailure;
+import org.exoplatform.webui.application.WebuiRequestContext;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+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 COOKIE_NAME = "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.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);
+ if (!supportedLocales.contains(locale))
+ {
+ 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();
+ if (loc != null && (remembered == null || !loc.equals(remembered)))
+ saveLocale(reqCtx, loc);
+ }
+ }
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onEndRequest
+ */
+ public void onEndRequest(Application app, WebuiRequestContext context) throws
Exception
+ {
+ }
+
+ /**
+ * @see org.exoplatform.web.application.ApplicationLifecycle#onFailRequest
+ */
+ public void onFailRequest(Application app, WebuiRequestContext context, RequestFailure
failureType) 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) ? new Locale(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 (COOKIE_NAME.equals(cookie.getName()))
+ {
+ List<Locale> locales = new ArrayList<Locale>();
+ locales.add(LocaleContextInfo.getLocale(cookie.getValue()));
+ return locales;
+ }
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ private void saveLocale(PortalRequestContext context, Locale loc)
+ {
+ String user = context.getRemoteUser();
+ if (user != null)
+ {
+ saveLocaleToUserProfile(context, loc, user);
+ }
+ else
+ {
+ saveLocaleToCookie(context, loc);
+ }
+ }
+
+ private void saveLocaleToCookie(PortalRequestContext context, Locale loc)
+ {
+ HttpServletResponse res = context.getResponse();
+ Cookie cookie = new Cookie(COOKIE_NAME, 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, loc.getLanguage());
+ 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);
+ }
+ }
+}
Deleted:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
===================================================================
---
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -1,47 +0,0 @@
-/*
- * 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;
- }
-}
Copied:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
(from rev 3829,
portal/branches/branched-r3776/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java)
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java
(rev 0)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/NoBrowserLocalePolicyService.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -199,7 +199,7 @@
}
Mode mode = renderURL.getMode();
- if (mode != null && !mode.equals(Mode.VIEW))
+ if (mode != null)
{
appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoUserContext.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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,52 @@
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:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIGadget.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,6 +21,7 @@
import org.exoplatform.application.gadget.Gadget;
import org.exoplatform.application.gadget.GadgetRegistryService;
+import org.exoplatform.commons.utils.PropertyManager;
import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.config.DataStorage;
import org.exoplatform.portal.config.model.ApplicationState;
@@ -298,50 +299,24 @@
public boolean isNoCache()
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null) { String prefs = userGadgetStorage.get(username,
- * getApplicationName(), getApplicationInstanceUniqueId(), PREF_NO_CACHE);
- * return prefs.equals("1"); } } catch (Exception e) {} return false;
- */
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public void setNoCache(boolean value)
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
- * userGadgetStorage.save(username, getApplicationName(),
- * getApplicationInstanceUniqueId(), PREF_NO_CACHE, value ? "1" :
"0"); } }
- * catch (Exception e) {}
- */
}
public boolean isDebug()
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null) { String prefs = userGadgetStorage.get(username,
- * getApplicationName(), getApplicationInstanceUniqueId(), PREF_DEBUG);
- * return prefs.equals("1"); } } catch (Exception e) {} return false;
- */
- return true;
+ if(PropertyManager.isDevelopping())
+ return true;
+ return false;
}
public void setDebug(boolean value)
{
- /*
- * try { UserGadgetStorage userGadgetStorage = getGadgetStorage(); String
- * username = Util.getPortalRequestContext().getRemoteUser(); if(username !=
- * null && getGadgetRegistryService().isGadgetDeveloper(username)) {
- * userGadgetStorage.save(username, getApplicationName(),
- * getApplicationInstanceUniqueId(), PREF_DEBUG, value ? "1" :
"0"); } }
- * catch (Exception e) {}
- */
}
public boolean isGadgetDeveloper()
@@ -377,11 +352,7 @@
public void addUserPref(String addedUserPref) throws Exception
{
DataStorage service = getApplicationComponent(DataStorage.class);
- org.exoplatform.portal.pom.spi.gadget.Gadget gadget = service.load(state,
ApplicationType.GADGET);
- if (gadget == null)
- {
- gadget = new org.exoplatform.portal.pom.spi.gadget.Gadget();
- }
+ org.exoplatform.portal.pom.spi.gadget.Gadget gadget = new
org.exoplatform.portal.pom.spi.gadget.Gadget();
//
gadget.addUserPref(addedUserPref);
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletLifecycle.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -186,94 +186,93 @@
RenderInvocation renderInvocation = uicomponent.create(RenderInvocation.class,
prcontext);
- if (uicomponent.getCurrentWindowState() != WindowState.MINIMIZED)
+ String appStatus = uicomponent.getProperties().get("appStatus");
+ if ("Window".equals(uicomponent.getPortletStyle()) &&
!("SHOW".equals(appStatus) || "HIDE".equals(appStatus)))
{
- String appStatus = uicomponent.getProperties().get("appStatus");
- if ("Window".equals(uicomponent.getPortletStyle())
- && !("SHOW".equals(appStatus) ||
"HIDE".equals(appStatus)))
+ markup = Text.create("<span></span>");
+ }
+ else
+ {
+ int portalMode = Util.getUIPortalApplication().getModeState();
+
+ //Check mode of portal, portlet and permission for viewable
+ if ((portalMode == UIPortalApplication.NORMAL_MODE || portalMode ==
UIPortalApplication.APP_VIEW_EDIT_MODE
+ || portalMode == UIPortalApplication.CONTAINER_VIEW_EDIT_MODE ||
uicomponent.getCurrentPortletMode()
+ .equals(PortletMode.EDIT))
+ && uicomponent.hasPermission())
{
- markup = Text.create("<span></span>");
- }
- else
- {
- int portalMode = Util.getUIPortalApplication().getModeState();
-
- //Check mode of portal, portlet and permission for viewable
- if ((portalMode == UIPortalApplication.NORMAL_MODE || portalMode ==
UIPortalApplication.APP_VIEW_EDIT_MODE
- || portalMode == UIPortalApplication.CONTAINER_VIEW_EDIT_MODE ||
uicomponent.getCurrentPortletMode().equals(PortletMode.EDIT))
- && uicomponent.hasPermission())
+ PortletInvocationResponse response =
uicomponent.invoke(renderInvocation);
+ if (response instanceof FragmentResponse)
{
- PortletInvocationResponse response =
uicomponent.invoke(renderInvocation);
- if (response instanceof FragmentResponse)
+ FragmentResponse fragmentResponse = (FragmentResponse) response;
+ switch (fragmentResponse.getType())
{
- FragmentResponse fragmentResponse = (FragmentResponse)response;
- switch (fragmentResponse.getType())
- {
- case FragmentResponse.TYPE_CHARS:
- markup = Text.create(fragmentResponse.getContent());
- break;
- case FragmentResponse.TYPE_BYTES:
- markup = Text.create(fragmentResponse.getBytes(),
Charset.forName("UTF-8"));
- break;
- case FragmentResponse.TYPE_EMPTY:
- markup = Text.create("");
- break;
- }
- portletTitle = fragmentResponse.getTitle();
+ case FragmentResponse.TYPE_CHARS :
+ markup = Text.create(fragmentResponse.getContent());
+ break;
+ case FragmentResponse.TYPE_BYTES :
+ markup = Text.create(fragmentResponse.getBytes(),
Charset.forName("UTF-8"));
+ break;
+ case FragmentResponse.TYPE_EMPTY :
+ markup = Text.create("");
+ break;
+ }
+ portletTitle = fragmentResponse.getTitle();
- // setup portlet properties
- if (fragmentResponse.getProperties() != null)
- {
- //setup transport headers
- if (fragmentResponse.getProperties().getTransportHeaders() != null)
- {
- MultiValuedPropertyMap<String> transportHeaders =
- fragmentResponse.getProperties().getTransportHeaders();
- for (String key : transportHeaders.keySet())
- {
- for (String value : transportHeaders.getValues(key))
- {
- prcontext.getResponse().setHeader(key, value);
- }
- }
- }
-
- //setup up portlet cookies
- if (fragmentResponse.getProperties().getCookies() != null)
- {
- List<Cookie> cookies =
fragmentResponse.getProperties().getCookies();
- for (Cookie cookie : cookies)
- {
- prcontext.getResponse().addCookie(cookie);
- }
- }
+ // setup portlet properties
+ if (fragmentResponse.getProperties() != null)
+ {
+ //setup transport headers
+ if (fragmentResponse.getProperties().getTransportHeaders() != null)
+ {
+ MultiValuedPropertyMap<String> transportHeaders =
fragmentResponse.getProperties()
+ .getTransportHeaders();
+ for (String key : transportHeaders.keySet())
+ {
+ for (String value : transportHeaders.getValues(key))
+ {
+ prcontext.getResponse().setHeader(key, value);
+ }
+ }
+ }
- //setup markup headers
- if (fragmentResponse.getProperties().getMarkupHeaders() != null)
- {
- MultiValuedPropertyMap<Element> markupHeaders =
- fragmentResponse.getProperties().getMarkupHeaders();
+ //setup up portlet cookies
+ if (fragmentResponse.getProperties().getCookies() != null)
+ {
+ List<Cookie> cookies =
fragmentResponse.getProperties().getCookies();
+ for (Cookie cookie : cookies)
+ {
+ prcontext.getResponse().addCookie(cookie);
+ }
+ }
- List<Element> markupElements =
markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
- if (markupElements != null)
- {
- for (Element element : markupElements)
- {
- if ("title".equals(element.getNodeName().toLowerCase())
&& element.getFirstChild() != null)
- {
- String title = element.getFirstChild().getTextContent();
-
prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
- }
- else
- {
- prcontext.addExtraMarkupHeader(element);
- }
- }
- }
- }
- }
+ //setup markup headers
+ if (fragmentResponse.getProperties().getMarkupHeaders() != null)
+ {
+ MultiValuedPropertyMap<Element> markupHeaders =
fragmentResponse.getProperties()
+ .getMarkupHeaders();
+ List<Element> markupElements =
markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
+ if (markupElements != null)
+ {
+ for (Element element : markupElements)
+ {
+ if
("title".equals(element.getNodeName().toLowerCase())
+ && element.getFirstChild() != null)
+ {
+ String title =
element.getFirstChild().getTextContent();
+
prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
+ }
+ else
+ {
+ prcontext.addExtraMarkupHeader(element);
+ }
+ }
+ }
+ }
}
+
+ }
else
{
@@ -306,8 +305,7 @@
}
}
}
- }
- }
+ }
catch (Exception e)
{
PortletContainerException pcException = new PortletContainerException(e);
@@ -325,12 +323,6 @@
}
//
- if (portletTitle == null)
- {
- portletTitle = "Portlet";
- }
-
- //
if (context.useAjax() && !prcontext.getFullRender())
{
if (markup != null)
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UILanguageSelector.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,21 +21,13 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.portal.Constants;
-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;
-import org.exoplatform.services.organization.OrganizationService;
-import org.exoplatform.services.organization.UserProfile;
-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;
@@ -180,18 +172,10 @@
LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
if (localeConfig == null)
localeConfig = localeConfigService.getDefaultLocaleConfig();
- uiApp.setLocale(localeConfig.getLocale());
+ 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)
- {
- UserProfile userProfile =
orgService.getUserProfileHandler().findUserProfileByName(remoteUser);
- userProfile.getUserInfoMap().put(Constants.USER_LANGUAGE, language);
- UserProfileHandler hanlder = orgService.getUserProfileHandler();
- hanlder.saveUserProfile(userProfile, true);
- }
}
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortal.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -238,7 +238,7 @@
uiPageBody.setPageBody(selectedNode_, this);
//Refresh locale
- Locale locale = Util.getUIPortalApplication().getLocale();
+ Locale locale = Util.getPortalRequestContext().getLocale();
localizePageNavigation(navigation, locale);
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/portal/UIPortalComposer.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -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(Constants.USER_LANGUAGE);
@@ -231,7 +231,7 @@
{
if (!portalAppLanguage.equals(userLanguage) &&
!portalAppLanguage.equals(browserLanguage))
{
- uiPortalApp.setLocale(localeConfig.getLocale());
+ prContext.setLocale(localeConfig.getLocale());
//editPortal.refreshNavigation(localeConfig.getLocale());
uiPortalApp.localizeNavigations();
}
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/webui/workspace/UIPortalApplication.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -46,6 +46,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;
@@ -94,8 +95,6 @@
private String nodePath_;
- private Locale locale_ = Locale.ENGLISH;
-
private Orientation orientation_ = Orientation.LT;
final static public String UI_WORKING_WS_ID = "UIWorkingWorkspace";
@@ -144,10 +143,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;
@@ -156,7 +154,6 @@
UserProfile userProfile =
orgService.getUserProfileHandler().findUserProfileByName(user);
if (userProfile != null)
{
- portalLanguage = userProfile.getUserInfoMap().get(Constants.USER_LANGUAGE);
portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
}
else
@@ -165,24 +162,25 @@
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);
@@ -305,14 +303,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;
Modified:
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java
===================================================================
---
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java 2010-08-13
17:09:39 UTC (rev 3829)
+++
portal/trunk/webui/portlet/src/main/java/org/exoplatform/webui/core/UIPortletApplication.java 2010-08-16
03:50:59 UTC (rev 3830)
@@ -21,11 +21,14 @@
import org.exoplatform.webui.application.WebuiApplication;
import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.application.portlet.PortletRequestContext;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
import java.io.Writer;
import java.util.Set;
+import javax.portlet.WindowState;
+
@Serialized
abstract public class UIPortletApplication extends UIApplication
{
@@ -70,7 +73,8 @@
}
/**
- * The default processRender for an UIPortletApplication handles two cases:
+ * The default processRender for an UIPortletApplication does nothing if the current
WindowState in the
+ * render request is MINIMIZED. Otherwise, it handles two cases:
*
* A. Ajax is used
* ---------------
@@ -86,7 +90,15 @@
*/
public void processRender(WebuiApplication app, WebuiRequestContext context) throws
Exception
{
+ //Do nothing if WindowState in the render request is MINIMIZED
+ WindowState currentWindowState =
((PortletRequestContext)context).getRequest().getWindowState();
+ if(currentWindowState == WindowState.MINIMIZED)
+ {
+ return;
+ }
+
WebuiRequestContext pContext =
(WebuiRequestContext)context.getParentAppRequestContext();
+
if (context.useAjax() && !pContext.getFullRender())
{
Writer w = context.getWriter();