Merge from 1.5 branch: NIHVIVO-3977 Incorporate improvements in OpenSocial for 1.5.1. Also, make shinding_orng_tables.sql re-runnable.
This commit is contained in:
parent
b9cd04f0fa
commit
e0a255c8b2
9 changed files with 443 additions and 351 deletions
|
@ -37,7 +37,7 @@ public class GadgetSpec {
|
|||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
String sqlCommand = "select page, viewer_req, owner_req, view, closed_width, open_width, start_closed, chromeId, display_order from orng_app_views where appId = "
|
||||
String sqlCommand = "select page, viewer_req, owner_req, view, chromeId, opt_params, display_order from orng_app_views where appId = "
|
||||
+ appId;
|
||||
conn = ds.getConnection();
|
||||
stmt = conn.createStatement();
|
||||
|
@ -47,9 +47,8 @@ public class GadgetSpec {
|
|||
rset.getString(1),
|
||||
new GadgetViewRequirements(rset.getString(1), rset
|
||||
.getString(2), rset.getString(3), rset
|
||||
.getString(4), rset.getInt(5), rset
|
||||
.getInt(6), rset.getBoolean(7), rset
|
||||
.getString(8), rset.getInt(9)));
|
||||
.getString(4), rset.getString(5), rset
|
||||
.getString(6), rset.getInt(7)));
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
|
|
|
@ -4,31 +4,24 @@ public class GadgetViewRequirements {
|
|||
private char viewerReq; // U for User or null for no requirement
|
||||
private char ownerReq; // R for Registered or null for no requirement
|
||||
private String view;
|
||||
private int closedWidth;
|
||||
private int openWidth;
|
||||
private boolean startClosed;
|
||||
private String chromeId;
|
||||
private String optParams;
|
||||
private int display_order;
|
||||
|
||||
public GadgetViewRequirements(char viewerReq, char ownerReq,
|
||||
String view, int closedWidth, int openWidth, boolean startClosed,
|
||||
String chromeId, int display_order) {
|
||||
String view, String chromeId, String optParams, int display_order) {
|
||||
this.viewerReq = viewerReq;
|
||||
this.ownerReq = ownerReq;
|
||||
this.view = view;
|
||||
this.closedWidth = closedWidth;
|
||||
this.openWidth = openWidth;
|
||||
this.startClosed = startClosed;
|
||||
this.chromeId = chromeId;
|
||||
this.optParams = optParams;
|
||||
this.display_order = display_order;
|
||||
}
|
||||
|
||||
public GadgetViewRequirements(String page, String viewerReq,
|
||||
String ownerReq, String view, int closedWidth, int openWidth,
|
||||
boolean startClosed, String chromeId, int display_order) {
|
||||
String ownerReq, String view, String chromeId, String optParams, int display_order) {
|
||||
this(viewerReq != null ? viewerReq.charAt(0) : ' ',
|
||||
ownerReq != null ? ownerReq.charAt(0) : ' ', view, closedWidth,
|
||||
openWidth, startClosed, chromeId, display_order);
|
||||
ownerReq != null ? ownerReq.charAt(0) : ' ', view, chromeId, optParams, display_order);
|
||||
}
|
||||
|
||||
public char getViewerReq() {
|
||||
|
@ -43,22 +36,14 @@ public class GadgetViewRequirements {
|
|||
return view;
|
||||
}
|
||||
|
||||
public int getClosedWidth() {
|
||||
return closedWidth;
|
||||
}
|
||||
|
||||
public int getOpenWidth() {
|
||||
return openWidth;
|
||||
}
|
||||
|
||||
public boolean getStartClosed() {
|
||||
return startClosed;
|
||||
}
|
||||
|
||||
public String getChromeId() {
|
||||
return chromeId;
|
||||
}
|
||||
|
||||
public String getOptParams() {
|
||||
return optParams != null && optParams.trim().length() > 0 ? optParams : "{}";
|
||||
}
|
||||
|
||||
int getDisplayOrder() {
|
||||
return display_order;
|
||||
}
|
||||
|
|
|
@ -353,15 +353,13 @@ public class OpenSocialManager {
|
|||
public String getGadgetJavascript() {
|
||||
String lineSeparator = System.getProperty("line.separator");
|
||||
String gadgetScriptText = "var my = {};" + lineSeparator
|
||||
+ "my.gadgetSpec = function(appId, name, url, secureToken, view, closed_width, open_width, start_closed, chrome_id, visible_scope) {"
|
||||
+ "my.gadgetSpec = function(appId, name, url, secureToken, view, chrome_id, opt_params, visible_scope) {"
|
||||
+ lineSeparator + "this.appId = appId;" + lineSeparator
|
||||
+ "this.name = name;" + lineSeparator + "this.url = url;"
|
||||
+ lineSeparator + "this.secureToken = secureToken;"
|
||||
+ lineSeparator + "this.view = view || 'default';"
|
||||
+ lineSeparator + "this.closed_width = closed_width;"
|
||||
+ lineSeparator + "this.open_width = open_width;"
|
||||
+ lineSeparator + "this.start_closed = start_closed;"
|
||||
+ lineSeparator + "this.chrome_id = chrome_id;" + lineSeparator
|
||||
+ lineSeparator + "this.chrome_id = chrome_id;"
|
||||
+ lineSeparator + "this.opt_params = opt_params;" + lineSeparator
|
||||
+ "this.visible_scope = visible_scope;" + lineSeparator + "};"
|
||||
+ lineSeparator + "my.pubsubData = {};" + lineSeparator;
|
||||
for (String key : getPubsubData().keySet()) {
|
||||
|
@ -377,10 +375,7 @@ public class OpenSocialManager {
|
|||
gadgetScriptText += "new my.gadgetSpec(" + gadget.getAppId() + ",'"
|
||||
+ gadget.getName() + "','" + gadget.getGadgetURL() + "','"
|
||||
+ gadget.getSecurityToken() + "','" + gadget.getView()
|
||||
+ "'," + gadget.getClosedWidth() + ","
|
||||
+ gadget.getOpenWidth() + ","
|
||||
+ (gadget.getStartClosed() ? "1" : "0") + ",'"
|
||||
+ gadget.getChromeId() + "','"
|
||||
+ "','" + gadget.getChromeId() + "'," + gadget.getOptParams() + ",'"
|
||||
+ gadget.getGadgetSpec().getVisibleScope() + "'), ";
|
||||
}
|
||||
gadgetScriptText = gadgetScriptText.substring(0,
|
||||
|
|
|
@ -73,23 +73,6 @@ public class PreparedGadget implements Comparable<PreparedGadget> {
|
|||
}
|
||||
}
|
||||
|
||||
public int getOpenWidth() {
|
||||
GadgetViewRequirements reqs = getGadgetViewRequirements();
|
||||
return reqs != null ? reqs.getOpenWidth() : 0;
|
||||
}
|
||||
|
||||
public int getClosedWidth() {
|
||||
GadgetViewRequirements reqs = getGadgetViewRequirements();
|
||||
return reqs != null ? reqs.getClosedWidth() : 0;
|
||||
}
|
||||
|
||||
public boolean getStartClosed() {
|
||||
GadgetViewRequirements reqs = getGadgetViewRequirements();
|
||||
// if the page specific reqs are present, honor those. Otherwise defaut
|
||||
// to true for regular gadgets, false for sandbox gadgets
|
||||
return reqs != null ? reqs.getStartClosed() : !gadgetSpec.fromSandbox();
|
||||
}
|
||||
|
||||
public String getChromeId() {
|
||||
GadgetViewRequirements reqs = getGadgetViewRequirements();
|
||||
if (reqs != null) {
|
||||
|
@ -112,6 +95,11 @@ public class PreparedGadget implements Comparable<PreparedGadget> {
|
|||
}
|
||||
}
|
||||
|
||||
public String getOptParams() {
|
||||
GadgetViewRequirements reqs = getGadgetViewRequirements();
|
||||
return reqs != null ? reqs.getOptParams() : "{}";
|
||||
}
|
||||
|
||||
public String getCanvasURL() throws UnsupportedEncodingException {
|
||||
return "~/gadget?appId=" + getAppId() + "&Person="
|
||||
+ URLEncoder.encode(helper.getOwnerId(), "UTF-8");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue