Author: [email protected]
Date: Fri Aug 26 15:36:35 2011
New Revision: 1347
Log:
[AMDATUOPENSOCIAL-98] Fixed full screen button by proper implementation of
requestNavigateTo
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/BaseRESTServiceImpl.java
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Modified:
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
==============================================================================
---
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
(original)
+++
trunk/amdatu-opensocial/opensocial-dashboard/src/main/resources/jsp/dashboard.js.jsp
Fri Aug 26 15:36:35 2011
@@ -129,7 +129,7 @@
var metadata = widget.metadata;
if (typeof metadata != 'undefined' && typeof metadata.gadgetUrl !=
'undefined') {
var gadget = shindig.container.createGadget(
- {serviceName: widget.id, specUrl: metadata.gadgetUrl, width:
"100%", secureToken: metadata.secureToken, cssClassGadgetContent:""});
+ {serviceName: widget.id, specUrl: metadata.gadgetUrl, width:
"100%", secureToken: metadata.secureToken, cssClassGadgetContent:"", widget:
widget});
shindig.container.addGadget(gadget);
shindig.container.renderGadget(gadget);
Modified:
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/BaseRESTServiceImpl.java
==============================================================================
---
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/BaseRESTServiceImpl.java
(original)
+++
trunk/amdatu-opensocial/opensocial-gadgetmanagement/src/main/java/org/amdatu/opensocial/gadgetmanagement/service/BaseRESTServiceImpl.java
Fri Aug 26 15:36:35 2011
@@ -104,23 +104,23 @@
return m_userAdmin;
}
- protected Widget getWidget(final HttpServletRequest request, final String
gadgetUrl, final String widgetId)
+ protected Widget getWidget(final HttpServletRequest request, final String
gadgetUrl, final String widgetId)
throws TokenProviderException, InvalidTokenException,
ClassNotFoundException, IOException {
// Load the user preferences for this widget
Map<String, String> userPrefs = null;
if (widgetId != null) {
userPrefs = getUserPreferences(request, widgetId);
}
-
+
Map<String, String> gadgetSpec =
getOpenSocialContainer().getGadgetSpec(request, gadgetUrl, userPrefs);
-
+
Widget widget = new Widget();
-
+
// Set metadata
Metadata metadata = new Metadata();
metadata.setGadgetUrl(gadgetUrl);
widget.setMetadata(metadata);
-
+
if (gadgetSpec != null) {
// Set author, author email and author affiliation
widget.setAuthor(getGadgetSpecValue(gadgetSpec, "author", "unknown
author"));
@@ -160,7 +160,7 @@
return widget;
}
-
+
protected String toAbsoluteUrl(final String url, final HttpServletRequest
request) {
if (url.startsWith("/")) {
// This is a relative URL, convert to absolute URL
@@ -178,31 +178,36 @@
}
}
catch (TokenProviderException e) {}
- catch (InvalidTokenException e) {}
return false;
}
- protected User getCurrentUser(final HttpServletRequest request) throws
TokenProviderException,
- InvalidTokenException {
+ protected User getCurrentUser(final HttpServletRequest request) throws
TokenProviderException {
String token = m_tokenProvider.getTokenFromRequest(request);
if (token != null) {
// Now decrypt to get the username and signature
- Map<String, String> attributes =
m_tokenProvider.verifyToken(token);
- if (attributes != null) {
- String username = attributes.get(TokenProvider.USERNAME);
- Role userRole = m_userAdmin.getRole(username);
- if (userRole != null && userRole.getType() == Role.USER) {
- User user = (User) userRole;
- return user;
+ Map<String, String> attributes;
+ try {
+ attributes = m_tokenProvider.verifyToken(token);
+ if (attributes != null) {
+ String username = attributes.get(TokenProvider.USERNAME);
+ Role userRole = m_userAdmin.getRole(username);
+ if (userRole != null && userRole.getType() == Role.USER) {
+ User user = (User) userRole;
+ return user;
+ }
}
}
+ catch (InvalidTokenException e) {
+ // Ignore the invalid token error, then the user is just not
properly logged in
+ // anymore (i.e. token timeout) and he has to reenter his
password.
+ }
}
return null;
}
-
+
@SuppressWarnings("unchecked")
- protected Map<String, String> getUserPreferences(final HttpServletRequest
request, final String widgetId)
+ protected Map<String, String> getUserPreferences(final HttpServletRequest
request, final String widgetId)
throws ClassNotFoundException, IOException, TokenProviderException,
InvalidTokenException {
User user = getCurrentUser(request);
if (user != null) {
@@ -211,7 +216,7 @@
userPrefsBytes = (byte[]) user.getProperties().get(APP_DATA +
".userprefs." + widgetId);
if (userPrefsBytes != null) {
Map<String, String> userPrefs =
- (Map<String, String>)
ConversionUtil.byteArrayToObject(userPrefsBytes);
+ (Map<String, String>)
ConversionUtil.byteArrayToObject(userPrefsBytes);
return userPrefs;
}
}
Modified:
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
==============================================================================
---
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
(original)
+++
trunk/amdatu-opensocial/opensocial-shindig/src/main/resources/features/shindig.container/shindig-container.js
Fri Aug 26 15:36:35 2011
@@ -223,37 +223,17 @@
* Navigates the page to a new url based on a gadgets requested view and
* parameters.
*/
-shindig.IfrGadgetService.prototype.requestNavigateTo = function(view,
- opt_params) {
+shindig.IfrGadgetService.prototype.requestNavigateTo = function(view,
opt_params) {
var id = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
- var url = shindig.container.gadgetService.getUrlForView(view);
+ var gadget = shindig.container.getGadget(id);
+ var widget = gadget.widget;
- if (opt_params) {
- var paramStr = gadgets.json.stringify(opt_params);
- if (paramStr.length > 0) {
- url += '&appParams=' + encodeURIComponent(paramStr);
- }
- }
-
- if (url && document.location.href.indexOf(url) == -1) {
- document.location.href = url;
- }
-};
+ shindig.container.setView(view);
+ gadget.refresh();
-/**
- * This is a silly implementation that will need to be overriden by almost all
- * real containers.
- * TODO: Find a better default for this function
- *
- * @param {string} view The view name to get the url for.
- */
-shindig.IfrGadgetService.prototype.getUrlForView = function(view) {
+ // In canvas view, we only show 1 widget at a time. So we invoke
openFullScreen on the widget
if (view === 'canvas') {
- return '/canvas';
- } else if (view === 'profile') {
- return '/profile';
- } else {
- return null;
+ widget.openFullscreen();
}
};
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits