Return-Path: Delivered-To: apmail-incubator-wookie-dev-archive@minotaur.apache.org Received: (qmail 89953 invoked from network); 16 Jun 2010 22:09:59 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Jun 2010 22:09:59 -0000 Received: (qmail 9373 invoked by uid 500); 16 Jun 2010 22:09:59 -0000 Delivered-To: apmail-incubator-wookie-dev-archive@incubator.apache.org Received: (qmail 9308 invoked by uid 500); 16 Jun 2010 22:09:59 -0000 Mailing-List: contact wookie-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wookie-dev@incubator.apache.org Delivered-To: mailing list wookie-dev@incubator.apache.org Received: (qmail 9300 invoked by uid 99); 16 Jun 2010 22:09:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 22:09:59 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [216.200.145.38] (HELO omta0105.mta.everyone.net) (216.200.145.38) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jun 2010 22:09:51 +0000 Received: from dm0224.mta.everyone.net (sj1-slb03-gw2 [172.16.1.96]) by omta0105.mta.everyone.net (Postfix) with ESMTP id 5DEB0732750 for ; Wed, 16 Jun 2010 15:09:28 -0700 (PDT) X-Eon-Dm: dm0224 Received: by dm0224.mta.everyone.net (EON-AUTHRELAY2 - 426dd405) id dm0224.4c1184be.2f20a3 for ; Wed, 16 Jun 2010 15:09:22 -0700 X-Eon-Sig: AQLYMZZMGUuSqrF2ogIAAAAB,8ba261a96d63a97741d4d82e2d9df7b3 Message-ID: <4C194BA0.8070306@wispertel.net> Date: Wed, 16 Jun 2010 16:09:36 -0600 From: Randy Watler User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: wookie-dev@incubator.apache.org Subject: Re: svn commit: r955407 - in /incubator/wookie/branches/pluggablepersistence: parser/java/src/org/apache/wookie/w3c/util/ src/org/apache/wookie/beans/ src/org/apache/wookie/controller/ src/org/apache/wookie/helpers/ src/org/apache/wookie/util/opensocial/ References: <20100616214503.BDAA223888D7@eris.apache.org> In-Reply-To: <20100616214503.BDAA223888D7@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Scott: Phew... that was unexpected! I was just trying to save some marshaling to/from arrays there, (now I feel like an idiot). What configurations have the parser loaded in a different classloader? Randy scottbw@apache.org wrote: > Author: scottbw > Date: Wed Jun 16 21:45:03 2010 > New Revision: 955407 > > URL: http://svn.apache.org/viewvc?rev=955407&view=rev > Log: > [in PP branch] replaced calls for localization using collections with arrays; this is because the parser may be loaded with a different classloader, and so cannot appropriately cast the return arrays from the supplied collection. > > Modified: > incubator/wookie/branches/pluggablepersistence/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java > incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/beans/IWidget.java > incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/controller/WidgetInstancesController.java > incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/helpers/WidgetHelper.java > incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/util/opensocial/OpenSocialUtils.java > > Modified: incubator/wookie/branches/pluggablepersistence/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java > URL: http://svn.apache.org/viewvc/incubator/wookie/branches/pluggablepersistence/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java?rev=955407&r1=955406&r2=955407&view=diff > ============================================================================== > --- incubator/wookie/branches/pluggablepersistence/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java (original) > +++ incubator/wookie/branches/pluggablepersistence/parser/java/src/org/apache/wookie/w3c/util/LocalizationUtils.java Wed Jun 16 21:45:03 2010 > @@ -49,20 +49,6 @@ public class LocalizationUtils { > } > > /** > - * Returns the first (best) match for an element given the set of locales, or null > - * if there are no suitable elements. > - * @param elements collection > - * @param locales > - * @return an ILocalizedElement, or null if there are no valid entries > - */ > - public static ILocalizedElement getLocalizedElement(Collection elements, String[] locales){ > - if (elements == null) return null; > - ILocalizedElement[] elementsArray = processElementsByLocales(elements,locales); > - if (elementsArray.length == 0) return null; > - return elementsArray[0]; > - } > - > - /** > * Filters and sorts a list of localized elements using the given locale list; only localized elements > * are returned unless no appropriate localized elements are found, in which case nonlocalized elements > * are returned > @@ -79,23 +65,6 @@ public class LocalizationUtils { > } > > /** > - * Filters and sorts a list of localized elements using the given locale list; only localized elements > - * are returned unless no appropriate localized elements are found, in which case nonlocalized elements > - * are returned > - * > - * @param elements collection > - * @param locales > - * @return the sorted and filtered set of elements > - */ > - public static ILocalizedElement[] processElementsByLocales(Collection elements,String[] locales){ > - if (elements == null) return null; > - List localesList = getProcessedLocaleList(locales); > - ILocalizedElement[] elementsArray = elements.toArray(new ILocalizedElement[elements.size()]); > - Arrays.sort(elementsArray, new LocaleComparator(localesList)); > - return filter(elementsArray,localesList); > - } > - > - /** > * Sorts an array of localized elements using default locales (*). This places > * any localized elements first, then any unlocalized elements > * @return > > Modified: incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/beans/IWidget.java > URL: http://svn.apache.org/viewvc/incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/beans/IWidget.java?rev=955407&r1=955406&r2=955407&view=diff > ============================================================================== > --- incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/beans/IWidget.java (original) > +++ incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/beans/IWidget.java Wed Jun 16 21:45:03 2010 > @@ -332,7 +332,8 @@ public interface IWidget extends IBean > */ > public static String getWidgetTitle(IWidget widget, String locale) > { > - IName name = (IName)LocalizationUtils.getLocalizedElement(widget.getNames(), new String[]{locale}); > + IName[] names = widget.getNames().toArray(new IName[widget.getNames().size()]); > + IName name = (IName)LocalizationUtils.getLocalizedElement(names, new String[]{locale}); > return ((name != null) ? name.getName() : IW3CXMLConfiguration.UNKNOWN); > } > > @@ -345,7 +346,8 @@ public interface IWidget extends IBean > */ > public static String getWidgetDescription(IWidget widget, String locale) > { > - IDescription description = (IDescription)LocalizationUtils.getLocalizedElement(widget.getDescriptions(), new String[]{locale}); > + IDescription[] descriptions = widget.getDescriptions().toArray(new IDescription[widget.getDescriptions().size()]); > + IDescription description = (IDescription)LocalizationUtils.getLocalizedElement(descriptions, new String[]{locale}); > return ((description != null) ? description.getContent() : null); > } > > @@ -358,7 +360,8 @@ public interface IWidget extends IBean > */ > public static String getWidgetShortName(IWidget widget, String locale) > { > - IName name = (IName)LocalizationUtils.getLocalizedElement(widget.getNames(), new String[]{locale}); > + IName[] names = widget.getNames().toArray(new IName[widget.getNames().size()]); > + IName name = (IName)LocalizationUtils.getLocalizedElement(names, new String[]{locale}); > return ((name != null) ? name.getShortName() : IW3CXMLConfiguration.UNKNOWN); > } > > @@ -411,7 +414,8 @@ public interface IWidget extends IBean > */ > public static String getUrl(IWidget widget, String locale) > { > - IStartFile startFile = (IStartFile)LocalizationUtils.getLocalizedElement(widget.getStartFiles(), new String[]{locale}); > + IStartFile[] startFiles = widget.getStartFiles().toArray(new IStartFile[widget.getStartFiles().size()]); > + IStartFile startFile = (IStartFile)LocalizationUtils.getLocalizedElement(startFiles, new String[]{locale}); > return ((startFile != null) ? startFile.getUrl() : null); > } > > @@ -424,7 +428,8 @@ public interface IWidget extends IBean > */ > public static String getWidgetIconLocation(IWidget widget, String locale) > { > - IWidgetIcon icon = (IWidgetIcon)LocalizationUtils.getLocalizedElement(widget.getWidgetIcons(), new String[]{locale}); > + IWidgetIcon[] icons = widget.getWidgetIcons().toArray(new IWidgetIcon[widget.getWidgetIcons().size()]); > + IWidgetIcon icon = (IWidgetIcon)LocalizationUtils.getLocalizedElement(icons, new String[]{locale}); > return ((icon != null) ? icon.getSrc() : null); > } > } > > Modified: incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/controller/WidgetInstancesController.java > URL: http://svn.apache.org/viewvc/incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/controller/WidgetInstancesController.java?rev=955407&r1=955406&r2=955407&view=diff > ============================================================================== > --- incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/controller/WidgetInstancesController.java (original) > +++ incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/controller/WidgetInstancesController.java Wed Jun 16 21:45:03 2010 > @@ -305,7 +305,7 @@ public class WidgetInstancesController e > protected static String getUrl(HttpServletRequest request, IWidgetInstance instance) throws IOException{ > String url = ""; > > - Collection startFiles = instance.getWidget().getStartFiles(); > + IStartFile[] startFiles = instance.getWidget().getStartFiles().toArray(new IStartFile[instance.getWidget().getStartFiles().size()]); > IStartFile sf = (IStartFile) LocalizationUtils.getLocalizedElement(startFiles, new String[]{instance.getLang()}); > // Try default locale if no appropriate localization found > if (sf == null) sf = (IStartFile) LocalizationUtils.getLocalizedElement(startFiles, null); > > Modified: incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/helpers/WidgetHelper.java > URL: http://svn.apache.org/viewvc/incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/helpers/WidgetHelper.java?rev=955407&r1=955406&r2=955407&view=diff > ============================================================================== > --- incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/helpers/WidgetHelper.java (original) > +++ incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/helpers/WidgetHelper.java Wed Jun 16 21:45:03 2010 > @@ -115,7 +115,8 @@ public class WidgetHelper { > > private static String getLicenses(IWidget widget, String[] locales){ > String out = ""; > - ILicense[] licenses = (ILicense[])LocalizationUtils.processElementsByLocales(widget.getLicenses(), locales); > + ILicense[] licenses = widget.getLicenses().toArray(new ILicense[widget.getLicenses().size()]); > + licenses = (ILicense[])LocalizationUtils.processElementsByLocales(licenses, locales); > for (ILicense license: licenses){ > out +="\t\t if (license.getLang()!=null) out+=" xml:lang=\""+license.getLang()+"\""; > @@ -135,7 +136,8 @@ public class WidgetHelper { > } > > private static String getName(IWidget widget, String[] locales){ > - IName name = (IName)LocalizationUtils.getLocalizedElement(widget.getNames(),locales); > + IName[] names = widget.getNames().toArray(new IName[widget.getNames().size()]); > + IName name = (IName)LocalizationUtils.getLocalizedElement(names,locales); > String shortName = null; > String longName = null; > if (name != null) { > @@ -152,7 +154,8 @@ public class WidgetHelper { > } > > private static String getDescription(IWidget widget, String[] locales){ > - IDescription desc = (IDescription)LocalizationUtils.getLocalizedElement(widget.getDescriptions(), locales); > + IDescription[] descriptions = widget.getDescriptions().toArray(new IDescription[widget.getDescriptions().size()]); > + IDescription desc = (IDescription)LocalizationUtils.getLocalizedElement(descriptions, locales); > String out = "\t\t if (desc!= null && desc.getDir()!=null) out+=" dir=\""+desc.getDir()+"\""; > out += ">"; > @@ -174,7 +177,7 @@ public class WidgetHelper { > String out = ""; > IWidgetIcon[] icons; > if (locales != null && locales.length != 0){ > - icons = (IWidgetIcon[])LocalizationUtils.processElementsByLocales(widget.getWidgetIcons(), locales); > + icons = (IWidgetIcon[])LocalizationUtils.processElementsByLocales(widget.getWidgetIcons().toArray(new IWidgetIcon[widget.getWidgetIcons().size()]), locales); > } else { > icons = widget.getWidgetIcons().toArray(new IWidgetIcon[widget.getWidgetIcons().size()]); > } > > Modified: incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/util/opensocial/OpenSocialUtils.java > URL: http://svn.apache.org/viewvc/incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/util/opensocial/OpenSocialUtils.java?rev=955407&r1=955406&r2=955407&view=diff > ============================================================================== > --- incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/util/opensocial/OpenSocialUtils.java (original) > +++ incubator/wookie/branches/pluggablepersistence/src/org/apache/wookie/util/opensocial/OpenSocialUtils.java Wed Jun 16 21:45:03 2010 > @@ -127,8 +127,8 @@ public class OpenSocialUtils { > } > > private static String getUrl(IWidgetInstance instance){ > - Collection files = instance.getWidget().getStartFiles(); > - IStartFile start = (IStartFile) LocalizationUtils.getLocalizedElement(files, new String[]{"en"}); > + IStartFile[] startFiles = instance.getWidget().getStartFiles().toArray(new IStartFile[instance.getWidget().getStartFiles().size()]); > + IStartFile start = (IStartFile) LocalizationUtils.getLocalizedElement(startFiles, new String[]{"en"}); > return start.getUrl(); > } > > > > >