You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2012/10/09 16:23:38 UTC
svn commit: r1396044 - in /incubator/wookie/trunk/src/org/apache/wookie:
controller/WidgetsController.java helpers/WidgetFactory.java
Author: scottbw
Date: Tue Oct 9 14:23:38 2012
New Revision: 1396044
URL: http://svn.apache.org/viewvc?rev=1396044&view=rev
Log:
Added improved handling of updates for widgets with no identifier, reusing any previously-issued identifier. Note that one consequence is that widget identifiers are not updated on PUT. Note also this only applies when using the REST API, where there is a resource parameter for the widget ID. See WOOKIE-383.
Modified:
incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java
incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java
Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java?rev=1396044&r1=1396043&r2=1396044&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java Tue Oct 9 14:23:38 2012
@@ -255,13 +255,23 @@ public class WidgetsController extends C
//
W3CWidgetFactory fac = W3CWidgetFactoryUtils.createW3CWidgetFactory(getServletContext(), properties, localizedMessages);
W3CWidget widgetModel = fac.parse(zipFile);
+
+ String widgetId = widgetModel.getIdentifier();
+
+ //
+ // If we have a generated ID and resourceId, use the resourceId to override the generated widget identifier. This is a fix for WOOKIE-383
+ //
+ if (widgetModel.getIdentifier().startsWith("http://incubator.apache.org/wookie/generated/") && resourceId != null){
+ widgetId = resourceId;
+ }
+
new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
//
// Check if the widget model corresponds to an existing installed widget
//
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
- if (persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null) {
+ if (persistenceManager.findWidgetByGuid(widgetId) == null) {
//
// A new widget was created, so return 201
@@ -277,7 +287,7 @@ public class WidgetsController extends C
// Widget already exists, so update the widget metadata and configuration details
// and return 200
//
- WidgetFactory.update(widgetModel,persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()), true, zipFile);
+ WidgetFactory.update(widgetModel,persistenceManager.findWidgetByGuid(widgetId), true, zipFile);
returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new File(fac.getUnzippedWidgetDirectory(), "config.xml"), getWookieServerURL(request, "").toString(), true), response);
return false;
Modified: incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java?rev=1396044&r1=1396043&r2=1396044&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java Tue Oct 9 14:23:38 2012
@@ -307,7 +307,12 @@ public class WidgetFactory {
widget.setDir(model.getDir());
widget.setLang(model.getLang());
widget.setDefaultLocale(model.getDefaultLocale());
- widget.setIdentifier(model.getIdentifier());
+
+ //
+ // Don't override the identifier - see WOOKIE-383
+ //
+ //widget.setIdentifier(model.getIdentifier());
+
widget.setHeight(model.getHeight());
widget.setWidth(model.getWidth());
widget.setVersion(model.getVersion());