use of org.apache.shindig.gadgets.spec.ModulePrefs in project liferay-ide by liferay.
the class GadgetLocalServiceImpl method addGadget.
public Gadget addGadget(long companyId, String url, String portletCategoryNames, ServiceContext serviceContext) throws PortalException, SystemException {
Date now = new Date();
validate(companyId, url, portletCategoryNames);
long gadgetId = counterLocalService.increment();
Gadget gadget = gadgetPersistence.create(gadgetId);
gadget.setUuid(serviceContext.getUuid());
gadget.setCompanyId(companyId);
gadget.setCreateDate(now);
gadget.setModifiedDate(now);
GadgetSpec gadgetSpec = null;
try {
gadgetSpec = ShindigUtil.getGadgetSpec(url);
} catch (Exception e) {
throw new GadgetURLException(e);
}
ModulePrefs modulePrefs = gadgetSpec.getModulePrefs();
gadget.setName(modulePrefs.getTitle());
gadget.setUrl(url);
gadget.setPortletCategoryNames(portletCategoryNames);
gadgetPersistence.update(gadget);
gadgetLocalService.initGadget(gadget.getUuid(), companyId, gadgetId, gadget.getName(), gadget.getPortletCategoryNames());
return gadget;
}
use of org.apache.shindig.gadgets.spec.ModulePrefs in project liferay-ide by liferay.
the class ShindigUtil method getOAuthServices.
public static Map<String, OAuthService> getOAuthServices(String url) throws Exception {
GadgetSpec gadgetSpec = getGadgetSpec(url);
ModulePrefs modulePrefs = gadgetSpec.getModulePrefs();
if (modulePrefs == null) {
return null;
}
OAuthSpec oAuthSpec = modulePrefs.getOAuthSpec();
if (oAuthSpec == null) {
return null;
}
return oAuthSpec.getServices();
}
use of org.apache.shindig.gadgets.spec.ModulePrefs in project liferay-ide by liferay.
the class EditorPortlet method serveGetRenderParameters.
protected void serveGetRenderParameters(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
String fileEntryURL = ParamUtil.getString(resourceRequest, "fileEntryURL");
GadgetSpec gadgetSpec = ShindigUtil.getGadgetSpec(fileEntryURL, true, true);
ModulePrefs modulePrefs = gadgetSpec.getModulePrefs();
jsonObject.put("height", modulePrefs.getHeight());
long moduleId = ShindigUtil.getModuleId(resourceResponse.getNamespace());
jsonObject.put("moduleId", moduleId);
Map<String, Feature> features = modulePrefs.getFeatures();
boolean requiresPubsub = features.containsKey("pubsub-2");
jsonObject.put("requiresPubsub", requiresPubsub);
boolean scrolling = modulePrefs.getScrolling();
jsonObject.put("scrolling", scrolling);
String ownerId = ShindigUtil.getOwnerId(themeDisplay.getLayout());
String portalURL = PortalUtil.getPortalURL(themeDisplay);
String currentURL = PortalUtil.getCurrentURL(resourceRequest);
String secureToken = ShindigUtil.createSecurityToken(ownerId, themeDisplay.getUserId(), fileEntryURL, portalURL, fileEntryURL, moduleId, currentURL);
jsonObject.put("secureToken", secureToken);
jsonObject.put("specUrl", fileEntryURL);
writeJSON(resourceRequest, resourceResponse, jsonObject);
}
use of org.apache.shindig.gadgets.spec.ModulePrefs in project liferay-ide by liferay.
the class ShindigUtil method getGadget.
public static com.liferay.opensocial.model.Gadget getGadget(PortletPreferences portletPreferences) throws Exception {
String url = portletPreferences.getValue("url", StringPool.BLANK);
if (Validator.isNull(url)) {
return null;
}
com.liferay.opensocial.model.Gadget gadget = new GadgetImpl();
GadgetSpec gadgetSpec = null;
try {
gadgetSpec = ShindigUtil.getGadgetSpec(url);
} catch (Exception e) {
throw new GadgetURLException(e);
}
ModulePrefs modulePrefs = gadgetSpec.getModulePrefs();
gadget.setName(modulePrefs.getTitle());
gadget.setUrl(url);
return gadget;
}
Aggregations