incubator-wookie-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scot...@apache.org
Subject svn commit: r832940 - in /incubator/wookie/trunk: src-tests/org/apache/wookie/tests/ src/org/apache/wookie/ src/org/apache/wookie/manager/impl/ src/org/apache/wookie/manifestmodel/ src/org/apache/wookie/manifestmodel/impl/ src/org/apache/wookie/util/
Date Thu, 05 Nov 2009 00:48:45 GMT
Author: scottbw
Date: Thu Nov  5 00:48:44 2009
New Revision: 832940

URL: http://svn.apache.org/viewvc?rev=832940&view=rev
Log:
Fix for issue WOOKIE-54 affecting processing of widgets using unicode whitespace characters;
also fixed issues relating to non-localized elements and repeat elements. Overall this changeset
should fix about 12 or so conformance errors.

Added:
    incubator/wookie/trunk/src/org/apache/wookie/util/UnicodeUtils.java
Modified:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/W3CTest.java
    incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java
    incubator/wookie/trunk/src/org/apache/wookie/manager/impl/WidgetAdminManager.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AccessEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AuthorEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/DescriptionEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/IconEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/LicenseEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/NameEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/PreferenceEntity.java
    incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java

Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/W3CTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/W3CTest.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/W3CTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/W3CTest.java Thu Nov  5 00:48:44
2009
@@ -108,13 +108,13 @@
 			IManifestModel model = WidgetManifestUtils.dealWithManifest(BASIC_MANIFEST,null);
 			assertNotNull(model);
 			assertEquals("http://www.getwookie.org/widgets/WP3/natter", model.getIdentifier());
-			assertEquals("Natter", model.getFirstName());
+			assertEquals("Natter", model.getLocalName("en"));
 			assertEquals(255, model.getWidth());
 			assertEquals(383, model.getHeight());
 			assertEquals("Icon.png", model.getFirstIconPath());
 			assertEquals("Scott Wilson", model.getAuthor());
 			assertEquals("1.0", model.getVersion());	
-			assertEquals("basic chat widget", model.getFirstDescription());
+			assertEquals("basic chat widget", model.getLocalDescription("en"));
 			assertEquals("application", model.getViewModes());	
 		} 
 		catch (JDOMException ex) {
@@ -134,7 +134,7 @@
 			IManifestModel model = WidgetManifestUtils.dealWithManifest(FEATURES_MANIFEST, null);
 			assertNotNull(model);
 			assertEquals("http://www.getwookie.org/example", model.getIdentifier());
-			assertEquals("Example Test Widget", model.getFirstName());			
+			assertEquals("Example Test Widget", model.getLocalName("en"));			
 			assertEquals(2, model.getNames().size());
 			assertEquals("es", model.getDescriptions().get(1).getLanguage());
 			

Modified: incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/WidgetAdminServlet.java Thu Nov  5 00:48:44
2009
@@ -493,7 +493,7 @@
 					if(!manager.doesWidgetAlreadyExistInSystem(manifestIdentifier)){									
 						int dbkey = manager.addNewWidget(widgetModel, new String[]{});
 						// widget added
-						session.setAttribute("message_value", "'"+ widgetModel.getFirstName() +"' - " + localizedMessages.getString("WidgetAdminServlet.19"));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+						session.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " +
localizedMessages.getString("WidgetAdminServlet.19")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
 						retrieveServices(session, manager);
 						session.setAttribute("hasValidated", Boolean.valueOf(true));																	 //$NON-NLS-1$
 						session.setAttribute("dbkey", dbkey); //$NON-NLS-1$
@@ -503,7 +503,7 @@
 					else{
 						// TODO - call the manager to update required resources
 						// widget updated
-						session.setAttribute("message_value", "'"+ widgetModel.getFirstName() +"' - " + localizedMessages.getString("WidgetAdminServlet.20"));
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+						session.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " +
localizedMessages.getString("WidgetAdminServlet.20")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
 					}						
 				}
 				else{

Modified: incubator/wookie/trunk/src/org/apache/wookie/manager/impl/WidgetAdminManager.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manager/impl/WidgetAdminManager.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manager/impl/WidgetAdminManager.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manager/impl/WidgetAdminManager.java Thu
Nov  5 00:48:44 2009
@@ -83,8 +83,8 @@
 		int newWidgetIdx = -1;			
 		Widget widget;
 		widget = new Widget();												
-		widget.setWidgetTitle(model.getFirstName());
-		widget.setWidgetDescription(model.getFirstDescription());
+		widget.setWidgetTitle(model.getLocalName("en"));
+		widget.setWidgetDescription(model.getLocalDescription("en"));
 		widget.setWidgetAuthor(model.getAuthor());
 		widget.setWidgetIconLocation(model.getFirstIconPath());
 		widget.setUrl(model.getContent().getSrc());

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java Thu Nov
 5 00:48:44 2009
@@ -32,11 +32,11 @@
 
 	public void updateIconPaths(String path);
 
-	public String getFirstName();
+	public String getLocalName(String locale);
 	
 	public List<INameEntity> getNames();
 
-	public String getFirstDescription();
+	public String getLocalDescription(String locale);
 
 	public int getHeight();
 

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AccessEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AccessEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AccessEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AccessEntity.java Thu
Nov  5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.IAccessEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -56,13 +57,10 @@
 	}
 	
 	public void fromXML(Element element) {		
-		fUri = element.getAttributeValue(IW3CXMLConfiguration.URI_ATTRIBUTE);
+		fUri = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.URI_ATTRIBUTE));
 		//TODO this is required, but may need to be checked
-		if(fUri == null){
-			fUri = "";
-		}
-		String subDomains = element.getAttributeValue(IW3CXMLConfiguration.SUBDOMAINS_ATTRIBUTE);
-		if(subDomains == null){
+		String subDomains = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.SUBDOMAINS_ATTRIBUTE));
+		if(subDomains.equals("")){
 			fSubDomains = false;
 		}
 		else{

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AuthorEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AuthorEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AuthorEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/AuthorEntity.java Thu
Nov  5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.IAuthorEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -69,19 +70,9 @@
 	}
 	
 	public void fromXML(Element element) {
-		fAuthorName = element.getText();		
-		if(fAuthorName == null){					
-			fAuthorName = "";
-		}
-		fHref = element.getAttributeValue(IW3CXMLConfiguration.HREF_ATTRIBUTE);
-		if(fHref == null){
-			fHref = "";
-		}				
-		fEmail = element.getAttributeValue(IW3CXMLConfiguration.EMAIL_ATTRIBUTE);
-		if(fEmail == null){
-			fEmail = "";
-		}
-		
+		fAuthorName = UnicodeUtils.normalizeWhitespace(element.getText());		
+		fHref = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.HREF_ATTRIBUTE));
		
+		fEmail = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.EMAIL_ATTRIBUTE));
 	}
 
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ContentEntity.java Thu
Nov  5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.IContentEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -69,20 +70,17 @@
 	}
 	
 	public void fromXML(Element element) {				
-		fSrc = element.getAttributeValue(IW3CXMLConfiguration.SOURCE_ATTRIBUTE);
-		if(fSrc == null){
-			fSrc = IW3CXMLConfiguration.DEFAULT_SRC_PAGE;
-		}
+		fSrc = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.SOURCE_ATTRIBUTE));
 		// just in case it's there, but they leave it empty
-		if(fSrc == ""){
+		if(fSrc.equals("")){
 			fSrc = IW3CXMLConfiguration.DEFAULT_SRC_PAGE;
 		}
-		fCharSet = element.getAttributeValue(IW3CXMLConfiguration.CHARSET_ATTRIBUTE);
-		if(fCharSet == null){
+		fCharSet = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.CHARSET_ATTRIBUTE));
+		if(fSrc.equals("")){
 			fCharSet = IW3CXMLConfiguration.DEFAULT_CHARSET;
 		}
-		fType = element.getAttributeValue(IW3CXMLConfiguration.TYPE_ATTRIBUTE);
-		if(fType == null){
+		fType = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.TYPE_ATTRIBUTE));
+		if(fSrc.equals("")){
 			fType = IW3CXMLConfiguration.DEFAULT_MEDIA_TYPE;
 		}	
 	}	

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/DescriptionEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/DescriptionEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/DescriptionEntity.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/DescriptionEntity.java
Thu Nov  5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.IDescriptionEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 import org.jdom.Namespace;
 /**
@@ -59,14 +60,8 @@
 	}
 	
 	public void fromXML(Element element) {
-		fDescription = element.getText();
-		if(fDescription == null){					
-			fDescription = "";
-		}
-		fLanguage = element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE, Namespace.XML_NAMESPACE);
-		if(fLanguage == null){
-			fLanguage = IW3CXMLConfiguration.DEFAULT_LANG;
-		}
+		fDescription = UnicodeUtils.normalizeWhitespace(element.getText());
+		fLanguage = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE,
Namespace.XML_NAMESPACE));
 	}
 
 

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/FeatureEntity.java Thu
Nov  5 00:48:44 2009
@@ -21,6 +21,7 @@
 import org.apache.wookie.manifestmodel.IFeatureEntity;
 import org.apache.wookie.manifestmodel.IParamEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -89,12 +90,12 @@
 	}
 	
 	public void fromXML(Element element) throws BadManifestException {
-		fName = element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE);
-		if(fName == null || fName == ""){
+		fName = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE));
+		if(fName == null || fName.equals("")){
 			throw new BadManifestException("A Feature is defined in the manifest, but its name attribute
is empty.");
 		}
-		String isRequired = element.getAttributeValue(IW3CXMLConfiguration.REQUIRED_ATTRIBUTE);
-		if(isRequired == null){
+		String isRequired = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.REQUIRED_ATTRIBUTE));
+		if(isRequired.equals("")){
 			fRequired = true;
 		}
 		else{

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/IconEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/IconEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/IconEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/IconEntity.java Thu Nov
 5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.IIconEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -65,26 +66,31 @@
 	
 	public void fromXML(Element element) {		
 		// src is required
-		fSrc = element.getAttributeValue(IW3CXMLConfiguration.SOURCE_ATTRIBUTE);
+		fSrc = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.SOURCE_ATTRIBUTE));
 		// TODO - do we test that this file exists?
-		if(fSrc==null){
-			fSrc="";
-		}
 		// height is optional
-		String tempHeight = element.getAttributeValue(IW3CXMLConfiguration.HEIGHT_ATTRIBUTE);
-		if(tempHeight == null){
+		String tempHeight = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.HEIGHT_ATTRIBUTE));
+		if(tempHeight.equals("")){
 			fHeight = IW3CXMLConfiguration.DEFAULT_HEIGHT_SMALL;
 		}
 		else{
-			fHeight = Integer.valueOf(tempHeight);
+			try {
+				fHeight = Integer.valueOf(tempHeight);
+			} catch (NumberFormatException e) {
+				fHeight = IW3CXMLConfiguration.DEFAULT_HEIGHT_SMALL;
+			}
 		}
 		// width is optional
-		String tempWidth = element.getAttributeValue(IW3CXMLConfiguration.WIDTH_ATTRIBUTE);
-		if(tempWidth == null){
+		String tempWidth = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.WIDTH_ATTRIBUTE));
+		if(tempWidth.equals("")){
 			fWidth = IW3CXMLConfiguration.DEFAULT_WIDTH_SMALL;
 		}
 		else{
-			fWidth = Integer.valueOf(tempWidth);
+			try {
+				fWidth = Integer.valueOf(tempWidth);
+			} catch (NumberFormatException e) {
+				fWidth = IW3CXMLConfiguration.DEFAULT_WIDTH_SMALL;
+			}
 		}	
 	}
 

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/LicenseEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/LicenseEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/LicenseEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/LicenseEntity.java Thu
Nov  5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.ILicenseEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 import org.jdom.Namespace;
 /**
@@ -70,17 +71,10 @@
 	}
 	
 	public void fromXML(Element element) {
-		fLicenseText = element.getText();
-
-		if(fLicenseText == null){					
-			fLicenseText = "";
-		}
-		fHref = element.getAttributeValue(IW3CXMLConfiguration.HREF_ATTRIBUTE);
-		if(fHref == null){
-			fHref = "";
-		}				
-		fLanguage = element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE, Namespace.XML_NAMESPACE);
-		if(fLanguage == null){
+		fLicenseText = UnicodeUtils.normalizeWhitespace(element.getText());
+		fHref = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.HREF_ATTRIBUTE));
			
+		fLanguage = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE,
Namespace.XML_NAMESPACE));
+		if(fLanguage.equals("")){
 			fLanguage = IW3CXMLConfiguration.DEFAULT_LANG;
 		}		
 	}

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/NameEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/NameEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/NameEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/NameEntity.java Thu Nov
 5 00:48:44 2009
@@ -16,6 +16,7 @@
 
 import org.apache.wookie.manifestmodel.INameEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 import org.jdom.Namespace;
 /**
@@ -70,22 +71,12 @@
 	}
 	
 	public void fromXML(Element element) {				
-		fName = element.getText();		
 		// Get the text value of name
-		if(fName == null){					
-			fName = "";
-		}		
+		fName = UnicodeUtils.normalizeWhitespace(element.getText());
 		// Get the xml:lang attribute (if exists)
-		fLanguage = element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE, Namespace.XML_NAMESPACE);
-		if(fLanguage == null){
-			fLanguage = IW3CXMLConfiguration.DEFAULT_LANG;
-		}
+		fLanguage = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE,
Namespace.XML_NAMESPACE));
 		// Get the short attribute (if exists)
-		fShort = element.getAttributeValue(IW3CXMLConfiguration.SHORT_ATTRIBUTE);
-		if(fShort == null){
-			fShort = "";
-		}
+		fShort = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.SHORT_ATTRIBUTE));
 	}
 
-
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/ParamEntity.java Thu Nov
 5 00:48:44 2009
@@ -17,6 +17,7 @@
 import org.apache.wookie.exceptions.BadManifestException;
 import org.apache.wookie.manifestmodel.IParamEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -59,16 +60,8 @@
 	}
 	
 	public void fromXML(Element element) throws BadManifestException {
-		// Name
-		fName = element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE);
-		if(fName == null){
-			fName = "";
-		}
-		// Value
-		fValue = element.getAttributeValue(IW3CXMLConfiguration.VALUE_ATTRIBUTE);
-		if(fValue == null){
-			fValue = "";
-		}
+		fName = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.NAME_ATTRIBUTE));
+		fValue = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.VALUE_ATTRIBUTE));
 	}	
 
 }

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/PreferenceEntity.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/PreferenceEntity.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/PreferenceEntity.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/PreferenceEntity.java
Thu Nov  5 00:48:44 2009
@@ -17,6 +17,7 @@
 import org.apache.wookie.exceptions.BadManifestException;
 import org.apache.wookie.manifestmodel.IPreferenceEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 /**
  * @author Paul Sharples
@@ -45,8 +46,8 @@
 	
 	public void fromXML(Element element) throws BadManifestException {
 		super.fromXML(element);
-		String isReadOnly = element.getAttributeValue(IW3CXMLConfiguration.READONLY_ATTRIBUTE);
-		if(isReadOnly == null){
+		String isReadOnly = UnicodeUtils.normalizeSpaces(element.getAttributeValue(IW3CXMLConfiguration.READONLY_ATTRIBUTE));
+		if(isReadOnly.equals("")){
 			fReadOnly = false;
 		}
 		else{

Modified: incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java?rev=832940&r1=832939&r2=832940&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/impl/WidgetManifestModel.java
Thu Nov  5 00:48:44 2009
@@ -31,6 +31,7 @@
 import org.apache.wookie.manifestmodel.IPreferenceEntity;
 import org.apache.wookie.manifestmodel.IW3CXMLConfiguration;
 import org.apache.wookie.util.RandomGUID;
+import org.apache.wookie.util.UnicodeUtils;
 import org.jdom.Element;
 import org.jdom.Namespace;
 /**
@@ -114,22 +115,24 @@
 		return fNamesList;
 	}
 	
-	public String getFirstName(){
-		if(fNamesList.size() > 0){
-			return fNamesList.get(0).getName();
-		}
-		else {
-			return IW3CXMLConfiguration.UNKNOWN;
-		}
-	}
-	
-	public String getFirstDescription(){
-		if(fDescriptionsList.size() > 0){
-			return fDescriptionsList.get(0).getDescription();
-		}
-		else {
-			return IW3CXMLConfiguration.UNKNOWN;
+	public String getLocalName(String locale){
+		String nonlocalizedvalue = null;
+		for (INameEntity name:fNamesList.toArray(new INameEntity[fNamesList.size()])){
+			if (name.getLanguage().equals(locale)) return name.getName();
+			if (name.getLanguage().equals("")) nonlocalizedvalue = name.getName();
+		}
+		if (nonlocalizedvalue == null) return IW3CXMLConfiguration.UNKNOWN;
+		return nonlocalizedvalue;
+	}
+	
+	public String getLocalDescription(String locale){
+		String nonlocalizedvalue = "";
+		for (IDescriptionEntity desc:fDescriptionsList.toArray(new IDescriptionEntity[fDescriptionsList.size()])){
+			if (desc.getLanguage().equals(locale)) return desc.getDescription();
+			if (desc.getLanguage().equals("")) nonlocalizedvalue = desc.getDescription();
 		}
+		if (nonlocalizedvalue == null) return IW3CXMLConfiguration.UNKNOWN;
+		return nonlocalizedvalue;	
 	}
 	
 	public List<IIconEntity> getIconsList() {
@@ -196,12 +199,17 @@
 			//give up & generate one
 			RandomGUID r = new RandomGUID();
 			fIdentifier = "generated-uid-" + r.toString();
+		} else {
+			//normalize spaces
+			fIdentifier = UnicodeUtils.normalizeSpaces(fIdentifier);
 		}
 		// VERSION IS OPTIONAL		
 		fVersion = element.getAttributeValue(IW3CXMLConfiguration.VERSION_ATTRIBUTE);
 		if(fVersion == null){
 			// give up 
 			fVersion = IW3CXMLConfiguration.DEFAULT_WIDGET_VERSION;
+		} else {
+			fVersion = UnicodeUtils.normalizeSpaces(fVersion);
 		}
 		// HEIGHT IS OPTIONAL		
 		String height  = element.getAttributeValue(IW3CXMLConfiguration.HEIGHT_ATTRIBUTE);
@@ -225,6 +233,8 @@
 		fViewModes = element.getAttributeValue(IW3CXMLConfiguration.MODE_ATTRIBUTE);
 		if(fViewModes == null){
 			fViewModes = IW3CXMLConfiguration.DEFAULT_VIEWMODE;
+		} else {
+			fViewModes = UnicodeUtils.normalizeSpaces(fViewModes);
 		}
 		// xml:lang optional
 		fLang = element.getAttributeValue(IW3CXMLConfiguration.LANG_ATTRIBUTE, Namespace.XML_NAMESPACE);
@@ -254,8 +264,8 @@
 				fDescriptionsList.add(aDescription);
 			}
 			
-			// AUTHOR IS OPTIONAL - can only be one
-			if(tag.equals(IW3CXMLConfiguration.AUTHOR_ELEMENT)) {
+			// AUTHOR IS OPTIONAL - can only be one, ignore subsequent repetitions
+			if(tag.equals(IW3CXMLConfiguration.AUTHOR_ELEMENT) && fAuthor == null) {
 				fAuthor = new AuthorEntity();
 				fAuthor.fromXML(child);
 			}		

Added: incubator/wookie/trunk/src/org/apache/wookie/util/UnicodeUtils.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/UnicodeUtils.java?rev=832940&view=auto
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/UnicodeUtils.java (added)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/UnicodeUtils.java Thu Nov  5 00:48:44
2009
@@ -0,0 +1,67 @@
+package org.apache.wookie.util;
+
+import org.apache.commons.lang.CharSetUtils;
+import org.apache.commons.lang.StringUtils;
+
+/*
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A utility class for sanitizing unicode strings in accordance with the rules for 
+ * handling normalized text content and attributes set out in the W3C Widgets
+ * specification
+ */
+public class UnicodeUtils {
+	
+	/**
+	 * Normalizes all whitespace and space characters in the given string to 
+	 * U+0020, then collapses multiple adjacent spaces to a single space, and
+	 * removes any leading and trailing spaces. If the input string is null,
+	 * the method returns an empty string ("")
+	 * @param in the string to normalize
+	 * @return the normalized string
+	 */
+	public static String normalizeWhitespace(String in){
+		return normalize(in, true);
+	}
+	
+	/**
+	 * Normalizes all space characters in the given string to 
+	 * U+0020, then collapses multiple adjacent spaces to a single space, and
+	 * removes any leading and trailing spaces. If the input string is null,
+	 * the method returns an empty string ("")
+	 * @param in the string to normalize
+	 * @return the normalized string
+	 */
+	public static String normalizeSpaces(String in){
+		return normalize(in, false);
+	}
+	
+	private static String normalize(String in, boolean includeWhitespace){
+		if (in == null) return "";
+		String out = "";
+		for (int x=0;x<in.length();x++){
+			String s = in.substring(x, x+1);
+			char ch = s.charAt(0);
+			if (Character.isSpaceChar(ch) || (Character.isWhitespace(ch) && includeWhitespace)){
+				s = " ";
+			}
+			out = out + s;
+		}
+		out = CharSetUtils.squeeze(out, " ");
+		out = StringUtils.strip(out);
+		return out;
+	}
+
+}



Mime
View raw message