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 2011/05/04 19:58:47 UTC
svn commit: r1099544 - in /incubator/wookie/trunk/src/org/apache/wookie:
controller/WidgetInstancesController.java helpers/SharedDataHelper.java
Author: scottbw
Date: Wed May 4 17:58:47 2011
New Revision: 1099544
URL: http://svn.apache.org/viewvc?rev=1099544&view=rev
Log:
Fixed a big problem with the solution to WOOKIE-206 I committed earlier, which is that the new SharedDataHelper wasn't being used in the WidgetInstancesController - causing duplicate widget instances.
Modified:
incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java
incubator/wookie/trunk/src/org/apache/wookie/helpers/SharedDataHelper.java
Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java?rev=1099544&r1=1099543&r2=1099544&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetInstancesController.java Wed May 4 17:58:47 2011
@@ -184,9 +184,11 @@ public class WidgetInstancesController e
public static void doGetWidget(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String userId = request.getParameter("userid"); //$NON-NLS-1$
- String sharedDataKey = request.getParameter("shareddatakey"); //$NON-NLS-1$
+ String sharedDataKey = request.getParameter("shareddatakey"); //$NON-NLS-1$
+ String apiKey = request.getParameter("api_key"); //$NON-NLS-1$
String serviceType = request.getParameter("servicetype"); //$NON-NLS-1$
String widgetId = request.getParameter("widgetid"); //$NON-NLS-1$
+ sharedDataKey = SharedDataHelper.getInternalSharedDataKey(apiKey, widgetId, sharedDataKey);
HttpSession session = request.getSession(true);
Messages localizedMessages = LocaleHandler.localizeMessages(request);
@@ -207,7 +209,6 @@ public class WidgetInstancesController e
// Widget exists
if(instance==null){
- String apiKey = request.getParameter("api_key"); //$NON-NLS-1$
instance = WidgetInstanceFactory.getWidgetFactory(session, localizedMessages).newInstance(apiKey, userId, sharedDataKey, serviceType, widgetId, locale);
response.setStatus(HttpServletResponse.SC_CREATED);
} else {
@@ -340,6 +341,7 @@ public class WidgetInstancesController e
String userId = URLDecoder.decode(request.getParameter("userid"), "UTF-8"); //$NON-NLS-1$
String sharedDataKey = request.getParameter("shareddatakey"); //$NON-NLS-1$;
String widgetId = request.getParameter("widgetid");
+ sharedDataKey = SharedDataHelper.getInternalSharedDataKey(apiKey, widgetId, sharedDataKey);
if (widgetId != null){
widgetId = URLDecoder.decode(widgetId, "UTF-8"); //$NON-NLS-1$
_logger.debug("Looking for widget instance with widgetid of " + widgetId);
Modified: incubator/wookie/trunk/src/org/apache/wookie/helpers/SharedDataHelper.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/SharedDataHelper.java?rev=1099544&r1=1099543&r2=1099544&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/SharedDataHelper.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/SharedDataHelper.java Wed May 4 17:58:47 2011
@@ -40,6 +40,11 @@ public class SharedDataHelper {
return String.valueOf(key.hashCode());
}
+ public static String getInternalSharedDataKey(String apiKey, String widgetUri, String sharedDataKey){
+ String key = sharedDataKey + ":" + apiKey + ":" + widgetUri;
+ return String.valueOf(key.hashCode());
+ }
+
public static ISharedData[] findSharedData(IWidgetInstance instance){
String sharedDataKey = SharedDataHelper.getInternalSharedDataKey(instance);
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();