Author: chris.laprun(a)jboss.com
Date: 2008-07-07 11:58:11 -0400 (Mon, 07 Jul 2008)
New Revision: 11318
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPValidator.java
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
Log:
- Encapsulated access to default locales and MIME types and return copies on WSRPConstants
to prevent client-side modification.
- Encapsulated validation mode handling in WSRPValidator class.
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestProducerBehavior.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -60,7 +60,7 @@
PortletDescription portletDesc = new PortletDescription();
portletDesc.setPortletHandle(portletHandle);
portletDesc.setMarkupTypes(new MarkupType[]{new MarkupType("text/html",
new String[]{WSRPConstants.VIEW_MODE},
- new String[]{WSRPConstants.NORMAL_WINDOW_STATE}, WSRPConstants.DEFAULT_LOCALES,
null)});
+ new String[]{WSRPConstants.NORMAL_WINDOW_STATE},
WSRPConstants.getDefaultLocales(), null)});
String suffixString = suffix == null ? "" : suffix;
portletDesc.setDescription(ServiceObjectFactory.createLocalizedString(ServiceObjectFactory.SAMPLE_DESCRIPTION
+ suffixString));
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/framework/TestWSRPProducerImpl.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -65,6 +65,7 @@
import org.jboss.portal.wsrp.core.UnsupportedMimeTypeFault;
import org.jboss.portal.wsrp.core.UnsupportedModeFault;
import org.jboss.portal.wsrp.core.UnsupportedWindowStateFault;
+import org.jboss.portal.wsrp.producer.WSRPValidator;
import org.jboss.portal.wsrp.producer.config.ProducerConfiguration;
import org.jboss.portal.wsrp.producer.config.ProducerRegistrationRequirements;
@@ -283,6 +284,6 @@
public void setUseStrictMode(boolean strict)
{
- throw new UnsupportedOperationException("setUseStrictMode not
implemented");
+ WSRPValidator.setStrict(strict);
}
}
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/test/wsrp/v1/consumer/behaviors/interop/LiferayServiceDescriptionBehavior.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -0,0 +1,72 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.test.wsrp.v1.consumer.behaviors.interop;
+
+import org.jboss.portal.test.wsrp.framework.ServiceDescriptionBehavior;
+import org.jboss.portal.wsrp.core.LocalizedString;
+import org.jboss.portal.wsrp.core.PortletDescription;
+
+import java.util.Set;
+
+/**
+ * Liferay behavior as exhibited at
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162201#...
+ *
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class LiferayServiceDescriptionBehavior extends ServiceDescriptionBehavior
+{
+ public LiferayServiceDescriptionBehavior()
+ {
+ /*
+ <portletHandle>98</portletHandle>
+<markupTypes>
+ <mimeType>text/html</mimeType>
+ <modes>wsrp:view</modes>
+ <windowStates>wsrp:normal</windowStates>
+ <windowStates>wsrp:minimized</windowStates>
+ <windowStates>wsrp:maximized</windowStates>
+ <locales>en_US</locales>
+</markupTypes>
+<groupID>98</groupID>
+<shortTitle lang='English'>
+ <value>javax.portlet.short-title.98</value>
+</shortTitle>
+<title lang='English'>
+ <value>Software Catalog</value>
+</title>
+ */
+ PortletDescription pd = createPortletDescription("98", null);
+ pd.getMarkupTypes()[0].getLocales()[0] = "en_US";
+ LocalizedString locString = pd.getShortTitle();
+ pd.setGroupID("98");
+ String lang = "English";
+ locString.setLang(lang);
+ locString.setValue("javax.portlet.short-title.98");
+ locString = pd.getTitle();
+ locString.setLang(lang);
+ locString.setValue("Software Catalog");
+
+ serviceDescription.setOfferedPortlets(new PortletDescription[]{pd});
+ }
+}
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPConstants.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -116,20 +116,8 @@
// WSRP Defaults
****************************************************************************************************
/** Default character set used to generate markup. */
- public static final String DEFAULT_CHARACTER_SET = "UTF-8";
+ public static final String DEFAULT_CHARACTER_SET = "UTF-8";
- /** Default locales. */
- public static final String[] DEFAULT_LOCALES;
-
- static
- {
- String defaultLocale = WSRPUtils.toString(Locale.getDefault());
- DEFAULT_LOCALES = new String[]{defaultLocale, "en"};
- }
-
- /** Default MIME types. */
- public static final String[] DEFAULT_MIME_TYPES = new
String[]{"text/html"};
-
// Registration data related
****************************************************************************************
/** Default consumer name if none has been provided in the WSRP descriptor
(*-wsrp.xml) */
@@ -182,4 +170,17 @@
private WSRPConstants()
{
}
+
+ // init default locale at loading time as it is slow
+ private static String defaultLocale = WSRPUtils.toString(Locale.getDefault());
+
+ public static String[] getDefaultLocales()
+ {
+ return new String[]{defaultLocale, "en"}; // return copy to prevent
modifications by client code
+ }
+
+ public static String[] getDefaultMimeTypes()
+ {
+ return new String[]{"text/html"}; // return copy to prevent modifications
by client code
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPTypeFactory.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -288,14 +288,14 @@
}
/**
- * Same as createMarkupParams(false, {@link WSRPConstants#DEFAULT_LOCALES}, {@link
WSRPConstants#DEFAULT_MIME_TYPES},
+ * Same as createMarkupParams(false, {@link WSRPConstants#getDefaultLocales()}, {@link
WSRPConstants#getDefaultMimeTypes()},
* {@link WSRPConstants#VIEW_MODE}, {@link WSRPConstants#NORMAL_WINDOW_STATE})
*
* @return
*/
public static MarkupParams createDefaultMarkupParams()
{
- return createMarkupParams(false, WSRPConstants.DEFAULT_LOCALES,
WSRPConstants.DEFAULT_MIME_TYPES,
+ return createMarkupParams(false, WSRPConstants.getDefaultLocales(),
WSRPConstants.getDefaultMimeTypes(),
WSRPConstants.VIEW_MODE, WSRPConstants.NORMAL_WINDOW_STATE);
}
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -710,7 +710,7 @@
//todo: might need to implement customization of default service description
GetServiceDescription gsd = WSRPTypeFactory.createGetServiceDescription();
- gsd.setDesiredLocales(WSRPConstants.DEFAULT_LOCALES);
+ gsd.setDesiredLocales(WSRPConstants.getDefaultLocales());
if (asUnregistred)
{
return gsd;
Modified:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-07-07
15:56:08 UTC (rev 11317)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPProducerImpl.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -33,13 +33,10 @@
import org.jboss.portal.registration.Registration;
import org.jboss.portal.registration.RegistrationLocal;
import org.jboss.portal.registration.RegistrationManager;
-import org.jboss.portal.registration.RegistrationUtils;
import org.jboss.portal.wsrp.ResponseDebugFactory;
import org.jboss.portal.wsrp.WSRPConstants;
import org.jboss.portal.wsrp.WSRPExceptionFactory;
-import org.jboss.portal.wsrp.WSRPPortletURL;
import org.jboss.portal.wsrp.WSRPProducer;
-import org.jboss.portal.wsrp.WSRPUtils;
import org.jboss.portal.wsrp.core.AccessDeniedFault;
import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
import org.jboss.portal.wsrp.core.ClonePortlet;
@@ -124,7 +121,7 @@
private CookieProtocol requiresInitCookie = CookieProtocol.none;
/** Supported locales. */
- private String[] supportedLocales = WSRPConstants.DEFAULT_LOCALES;
+ private String[] supportedLocales = WSRPConstants.getDefaultLocales();
private ProducerConfigurationService configurationService;
@@ -273,9 +270,7 @@
public void setUseStrictMode(boolean strict)
{
- RegistrationUtils.setStrict(strict);
- WSRPUtils.setStrict(strict);
- WSRPPortletURL.setStrict(strict);
+ WSRPValidator.setStrict(strict);
}
protected void startService() throws Exception
Added:
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPValidator.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPValidator.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/producer/WSRPValidator.java 2008-07-07
15:58:11 UTC (rev 11318)
@@ -0,0 +1,49 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+package org.jboss.portal.wsrp.producer;
+
+import org.jboss.portal.registration.RegistrationUtils;
+import org.jboss.portal.wsrp.WSRPPortletURL;
+import org.jboss.portal.wsrp.WSRPUtils;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class WSRPValidator
+{
+ private static boolean strict = true;
+
+ public static void setStrict(boolean strictMode)
+ {
+ strict = strictMode;
+ RegistrationUtils.setStrict(strict);
+ WSRPUtils.setStrict(strict);
+ WSRPPortletURL.setStrict(strict);
+ }
+
+ public static boolean isStrict()
+ {
+ return strict;
+ }
+}