incubator-wookie-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scot...@apache.org
Subject svn commit: r833374 - in /incubator/wookie/trunk: scripts/derby/ scripts/mysql/ src/org/apache/wookie/beans/ src/org/apache/wookie/helpers/ src/org/apache/wookie/manager/impl/ src/org/apache/wookie/manifestmodel/ src/org/apache/wookie/manifestmodel/impl/
Date Fri, 06 Nov 2009 12:24:17 GMT
Author: scottbw
Date: Fri Nov  6 12:24:16 2009
New Revision: 833374

URL: http://svn.apache.org/viewvc?rev=833374&view=rev
Log:
Fix for WOOKIE-55 adding the "widget-short-name" field to the Widget database, and WidgetShortName
to Widget class, and added support in the upload process and also in any XML representations
returned from the REST API. Also fixed a conformance error with repetitions of name elements
in a locale being appended in the manifest parser.

Modified:
    incubator/wookie/trunk/scripts/derby/widgetdb.sql
    incubator/wookie/trunk/scripts/mysql/widgetdb.sql
    incubator/wookie/trunk/src/org/apache/wookie/beans/Widget.java
    incubator/wookie/trunk/src/org/apache/wookie/beans/schema.hbm.xml
    incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.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/WidgetManifestModel.java

Modified: incubator/wookie/trunk/scripts/derby/widgetdb.sql
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/scripts/derby/widgetdb.sql?rev=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/scripts/derby/widgetdb.sql (original)
+++ incubator/wookie/trunk/scripts/derby/widgetdb.sql Fri Nov  6 12:24:16 2009
@@ -1,4 +1,4 @@
-INSERT INTO Widget VALUES (1,'Unsupported widget widget','This widget is a placeholder for
when no corresponding widget is found for a given type','Paul Sharples','/wookie/shared/images/defaultwidget.png','/wookie/wservices/www.tencompetence.org/widgets/default/notsupported/index.htm','http://www.tencompetence.org/widgets/default/notsupported',350,500,'f','v1.0'),(2,'Default
chat widget','This widget provides a simple chat or Instant messaging facility','Paul Sharples','/wookie/shared/images/chat.png','/wookie/wservices/www.tencompetence.org/widgets/default/chat/index.htm','http://www.tencompetence.org/widgets/default/chat',358,500,'f','v1.0'),(3,'Default
discussion/forum widget','This widget provides a threaded discussion forum facility','Paul
Sharples','/wookie/shared/images/forum.png','/wookie/wservices/www.tencompetence.org/widgets/default/forum/index.htm','http://www.tencompetence.org/widgets/default/forum',350,520,'t','v1.0'),(4,'Default
vote widget','This widget provi
 des a voting facility','Paul Sharples','/wookie/shared/images/vote.png','/wookie/wservices/www.tencompetence.org/widgets/default/vote/index.htm','http://www.tencompetence.org/widgets/default/vote',350,500,'f','v1.0'),(5,'Natter','A
simple chat widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/natter/icon.png','/wookie/wservices/www.getwookie.org/widgets/natter/index.htm','http://www.getwookie.org/widgets/natter',383,255,'F','v1.0'),(6,'Weather','A
simple weather widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/weather/icon.png','/wookie/wservices/www.getwookie.org/widgets/weather/index.htm','http://www.getwookie.org/widgets/weather',125,125,'F','v1.0');
+INSERT INTO Widget VALUES (1,'Unsupported widget widget','','This widget is a placeholder
for when no corresponding widget is found for a given type','Paul Sharples','/wookie/shared/images/defaultwidget.png','/wookie/wservices/www.tencompetence.org/widgets/default/notsupported/index.htm','http://www.tencompetence.org/widgets/default/notsupported',350,500,'f','v1.0'),(2,'Default
chat widget','','This widget provides a simple chat or Instant messaging facility','Paul Sharples','/wookie/shared/images/chat.png','/wookie/wservices/www.tencompetence.org/widgets/default/chat/index.htm','http://www.tencompetence.org/widgets/default/chat',358,500,'f','v1.0'),(3,'Default
discussion/forum widget','','This widget provides a threaded discussion forum facility','Paul
Sharples','/wookie/shared/images/forum.png','/wookie/wservices/www.tencompetence.org/widgets/default/forum/index.htm','http://www.tencompetence.org/widgets/default/forum',350,520,'t','v1.0'),(4,'Default
vote widget','','This 
 widget provides a voting facility','Paul Sharples','/wookie/shared/images/vote.png','/wookie/wservices/www.tencompetence.org/widgets/default/vote/index.htm','http://www.tencompetence.org/widgets/default/vote',350,500,'f','v1.0'),(5,'Natter','','A
simple chat widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/natter/icon.png','/wookie/wservices/www.getwookie.org/widgets/natter/index.htm','http://www.getwookie.org/widgets/natter',383,255,'F','v1.0'),(6,'Weather','','A
simple weather widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/weather/icon.png','/wookie/wservices/www.getwookie.org/widgets/weather/index.htm','http://www.getwookie.org/widgets/weather',125,125,'F','v1.0');
 INSERT INTO WidgetDefault VALUES ('unsupported',1),('chat',2),('discussion',3),('forum',3),('vote',4),('natter',5),('weather',6);
 INSERT INTO WidgetService VALUES (1,'unsupported'),(2,'chat'),(3,'discussion'),(4,'forum'),(5,'vote'),(6,'natter'),(7,'weather');
 INSERT INTO WidgetType VALUES (1,1,'unsupported'),(2,2,'chat'),(3,3,'forum'),(4,3,'discussion'),(5,4,'vote'),(6,5,'natter'),(7,6,'weather');

Modified: incubator/wookie/trunk/scripts/mysql/widgetdb.sql
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/scripts/mysql/widgetdb.sql?rev=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/scripts/mysql/widgetdb.sql (original)
+++ incubator/wookie/trunk/scripts/mysql/widgetdb.sql Fri Nov  6 12:24:16 2009
@@ -5,6 +5,7 @@
 CREATE TABLE `Widget` (
   `id` int(11) NOT NULL auto_increment,
   `widget_title` varchar(255) default NULL,
+  `widget_short_name` varchar(255) default NULL,
   `url` varchar(255) default NULL,
   `height` int(11) default NULL,
   `width` int(11) default NULL,
@@ -167,7 +168,7 @@
 );
 
 
-INSERT INTO `Widget` VALUES (1,'Unsupported widget widget','/wookie/wservices/www.tencompetence.org/widgets/default/notsupported/index.htm',350,500,'f','http://www.tencompetence.org/widgets/default/notsupported','This
widget is a placeholder for when no corresponding widget is found for a given type','Paul
Sharples','/wookie/shared/images/defaultwidget.png', 'v1.0'),(2,'Default chat widget','/wookie/wservices/www.tencompetence.org/widgets/default/chat/index.htm',358,500,'f','http://www.tencompetence.org/widgets/default/chat','This
widget provides a simple chat or Instant messaging facility','Paul Sharples','/wookie/shared/images/chat.png',
'v1.0'),(3,'Default discussion/forum widget','/wookie/wservices/www.tencompetence.org/widgets/default/forum/index.htm',350,520,'t','http://www.tencompetence.org/widgets/default/forum','This
widget provides a threaded discussion forum facility','Paul Sharples','/wookie/shared/images/forum.png',
'v1.0'),(4,'Default vote widget','/wookie/wser
 vices/www.tencompetence.org/widgets/default/vote/index.htm',350,500,'f','http://www.tencompetence.org/widgets/default/vote','This
widget provides a voting facility','Paul Sharples','/wookie/shared/images/vote.png', 'v1.0'),(5,'Natter','/wookie/wservices/www.getwookie.org/widgets/natter/index.htm',383,255,'F','http://www.getwookie.org/widgets/natter','A
simple chat widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/natter/icon.png',
'v1.0'),(6,'Weather','/wookie/wservices/www.getwookie.org/widgets/weather/index.htm',125,125,'F','http://www.getwookie.org/widgets/weather','A
simple weather widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/weather/icon.png',
'v1.0');
+INSERT INTO `Widget` VALUES (1,'Unsupported widget widget','','/wookie/wservices/www.tencompetence.org/widgets/default/notsupported/index.htm',350,500,'f','http://www.tencompetence.org/widgets/default/notsupported','This
widget is a placeholder for when no corresponding widget is found for a given type','Paul
Sharples','/wookie/shared/images/defaultwidget.png', 'v1.0'),(2,'Default chat widget','','/wookie/wservices/www.tencompetence.org/widgets/default/chat/index.htm',358,500,'f','http://www.tencompetence.org/widgets/default/chat','This
widget provides a simple chat or Instant messaging facility','Paul Sharples','/wookie/shared/images/chat.png',
'v1.0'),(3,'Default discussion/forum widget','','/wookie/wservices/www.tencompetence.org/widgets/default/forum/index.htm',350,520,'t','http://www.tencompetence.org/widgets/default/forum','This
widget provides a threaded discussion forum facility','Paul Sharples','/wookie/shared/images/forum.png',
'v1.0'),(4,'Default vote widget','','
 /wookie/wservices/www.tencompetence.org/widgets/default/vote/index.htm',350,500,'f','http://www.tencompetence.org/widgets/default/vote','This
widget provides a voting facility','Paul Sharples','/wookie/shared/images/vote.png', 'v1.0'),(5,'Natter','','/wookie/wservices/www.getwookie.org/widgets/natter/index.htm',383,255,'F','http://www.getwookie.org/widgets/natter','A
simple chat widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/natter/icon.png',
'v1.0'),(6,'Weather','','/wookie/wservices/www.getwookie.org/widgets/weather/index.htm',125,125,'F','http://www.getwookie.org/widgets/weather','A
simple weather widget','Scott Wilson','/wookie/wservices/www.getwookie.org/widgets/weather/icon.png',
'v1.0');
 INSERT INTO `WidgetDefault` VALUES ('unsupported',1),('chat',2),('discussion',3),('forum',3),('vote',4),('natter',5),('weather',6);
 INSERT INTO `WidgetService` VALUES (1,'unsupported'),(2,'chat'),(3,'discussion'),(4,'forum'),(5,'vote'),(6,'natter'),(7,'weather');
 INSERT INTO `WidgetType` VALUES (1,1,'unsupported'),(2,2,'chat'),(3,3,'forum'),(4,3,'discussion'),(5,4,'vote'),(6,5,'natter'),(7,6,'weather');

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/Widget.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/Widget.java?rev=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/Widget.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/Widget.java Fri Nov  6 12:24:16 2009
@@ -34,6 +34,7 @@
 	private static final long serialVersionUID = 1L;
 	
 	private String widgetTitle;
+	private String widgetShortName;
 	private String widgetDescription;
 	private String widgetAuthor;
 	private String widgetIconLocation;
@@ -113,7 +114,15 @@
 		this.widgetTitle = widgetTitle;
 	}
 
+	public String getWidgetShortName() {
+		return widgetShortName;
+	}
+
 
+	public void setWidgetShortName(String name) {
+		this.widgetShortName = name;
+	}
+	
 	public String getWidgetDescription() {
 		return widgetDescription;
 	}
@@ -187,7 +196,7 @@
 	 */
 	public static Widget[] findByType(String typeToSearch) {
 		final IDBManager dbManager = DBManagerFactory.getDBManager();			
-		String sqlQuery = "SELECT widget.id, widget.widget_title, widget_description, widget_author,
widget_icon_location, widget.url, widget.maximize, widget.guid, " +
+		String sqlQuery = "SELECT widget.id, widget.widget_title,  widget.widget_short_name, widget_description,
widget_author, widget_icon_location, widget.url, widget.maximize, widget.guid, " +
 								"widget.height, widget.width, widget_version, widgettype.widget_context "
 						+ "FROM Widget widget, WidgetType widgettype "
 						+ "WHERE widget.id = widgettype.widget_id "
@@ -200,7 +209,7 @@
 	
 	public static Widget findDefaultByType(String typeToSearch) {
 		final IDBManager dbManager = DBManagerFactory.getDBManager();
-		String sqlQuery = "SELECT widget.id, widget.widget_title, widget_version, widget_description,
widget_author, widget_icon_location, widget.url, widget.height, widget.width, widget.maximize,
widget.guid " //$NON-NLS-1$
+		String sqlQuery = "SELECT widget.id, widget.widget_title, widget.widget_short_name, widget_version,
widget_description, widget_author, widget_icon_location, widget.url, widget.height, widget.width,
widget.maximize, widget.guid " //$NON-NLS-1$
 			+ "FROM Widget widget, WidgetDefault widgetdefault " //$NON-NLS-1$
 			+ "WHERE widget.id = widgetdefault.widgetId " //$NON-NLS-1$
 			+ "AND widgetdefault.widgetContext='" + typeToSearch + "'";		 //$NON-NLS-1$ //$NON-NLS-2$

Modified: incubator/wookie/trunk/src/org/apache/wookie/beans/schema.hbm.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/beans/schema.hbm.xml?rev=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/beans/schema.hbm.xml (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/beans/schema.hbm.xml Fri Nov  6 12:24:16
2009
@@ -11,6 +11,7 @@
 			<generator class="increment" />
 		</id>
 		<property name="widgetTitle" column="widget_title" type="string" />
+		<property name="widgetShortName" column="widget_short_name" type="string" />
 		<property name="widgetDescription" column="widget_description" type="string" />
 		<property name="widgetAuthor" column="widget_author" type="string" />
 		<property name="widgetIconLocation" column="widget_icon_location" type="string" />

Modified: incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java?rev=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetHelper.java Fri Nov  6 12:24:16
2009
@@ -70,7 +70,7 @@
 		URL urlWidgetIcon = null;
 		out += "\t<widget id=\""+widget.getId()+"\" identifier=\"" + widget.getGuid() + "\"
version=\""
 				+ widget.getVersion() + "\">\n";
-		out += "\t\t<title>" + widget.getWidgetTitle() + "</title>\n";
+		out += "\t\t<title short=\""+widget.getWidgetShortName()+"\">" + widget.getWidgetTitle()
+ "</title>\n";
 		out += "\t\t<description>" + widget.getWidgetDescription()
 				+ "</description>\n";
 		String iconPath = widget.getWidgetIconLocation();

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=833374&r1=833373&r2=833374&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 Fri
Nov  6 12:24:16 2009
@@ -84,6 +84,7 @@
 		Widget widget;
 		widget = new Widget();												
 		widget.setWidgetTitle(model.getLocalName("en"));
+		widget.setWidgetShortName(model.getLocalShortName("en"));
 		widget.setWidgetDescription(model.getLocalDescription("en"));
 		widget.setWidgetAuthor(model.getAuthor());
 		widget.setWidgetIconLocation(model.getFirstIconPath());

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=833374&r1=833373&r2=833374&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/manifestmodel/IManifestModel.java Fri Nov
 6 12:24:16 2009
@@ -34,6 +34,8 @@
 
 	public String getLocalName(String locale);
 	
+	public String getLocalShortName(String locale);
+	
 	public List<INameEntity> getNames();
 
 	public String getLocalDescription(String locale);

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=833374&r1=833373&r2=833374&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
Fri Nov  6 12:24:16 2009
@@ -17,6 +17,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wookie.exceptions.BadManifestException;
 import org.apache.wookie.manifestmodel.IAccessEntity;
@@ -116,13 +117,24 @@
 	}
 	
 	public String getLocalName(String locale){
-		String nonlocalizedvalue = null;
+		INameEntity name = getLocalNameEntity(locale);
+		if (name != null) return name.getName();
+		return IW3CXMLConfiguration.UNKNOWN;
+	}
+	
+	public String getLocalShortName(String locale){
+		INameEntity name = getLocalNameEntity(locale);
+		if (name != null) return name.getShort();
+		return IW3CXMLConfiguration.UNKNOWN;		
+	}
+	
+	private INameEntity getLocalNameEntity(String locale){
+		INameEntity nonLocalized = 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 (name.getLanguage().equals(locale)) return name;
+			if (name.getLanguage().equals("")) nonLocalized = name;
 		}
-		if (nonlocalizedvalue == null) return IW3CXMLConfiguration.UNKNOWN;
-		return nonlocalizedvalue;
+		return nonLocalized;
 	}
 	
 	public String getLocalDescription(String locale){
@@ -252,8 +264,12 @@
 			if(tag.equals(IW3CXMLConfiguration.NAME_ELEMENT)) {				
 				INameEntity aName = new NameEntity();
 				aName.fromXML(child);				
-				// add it to our list
-				fNamesList.add(aName);
+				// add it to our list only if its not a repetition of an
+				// existing name for the locale
+				boolean exists = false;
+				for (INameEntity name: fNamesList.toArray(new INameEntity[fNamesList.size()]))
+					if (StringUtils.equals(name.getLanguage(), aName.getLanguage())) exists = true;
+				if (!exists) fNamesList.add(aName);
 			}
 			
 			// DESCRIPTION IS OPTIONAL multiple on xml:lang



Mime
View raw message