return buf.toString();
}
public String getIframeUrl(Gadget gadget) {
GadgetContext context = gadget.getContext();
GadgetSpec spec = gadget.getSpec();
String url = context.getUrl().toString();
View view = gadget.getCurrentView();
View.ContentType type;
type = (view == null) ? View.ContentType.HTML : view.getType();
UriBuilder uri;
switch (type) {
case URL:
uri = new UriBuilder(view.getHref());
break;
case HTML:
case HTML_SANITIZED:
default:
Uri iframeBaseUri = iframeBaseUris.get(context.getContainer());
uri = iframeBaseUri != null ? new UriBuilder(iframeBaseUri) : new UriBuilder();
String host = lockedDomainService.getLockedDomainForGadget(gadget, context.getContainer());
if (host != null) {
uri.setAuthority(host);
}
break;
}
uri.addQueryParameter("container", context.getContainer());
if (context.getModuleId() != 0) {
uri.addQueryParameter("mid", Integer.toString(context.getModuleId()));
}
if (context.getIgnoreCache()) {
uri.addQueryParameter("nocache", "1");
} else {
uri.addQueryParameter("v", spec.getChecksum());
}
uri.addQueryParameter("lang", context.getLocale().getLanguage());
uri.addQueryParameter("country", context.getLocale().getCountry());
uri.addQueryParameter("view", context.getView());