Search in sources :

Example 1 with GadgetSpec

use of org.apache.shindig.gadgets.spec.GadgetSpec 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;
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) Gadget(com.liferay.opensocial.model.Gadget) ModulePrefs(org.apache.shindig.gadgets.spec.ModulePrefs) DuplicateGadgetURLException(com.liferay.opensocial.DuplicateGadgetURLException) GadgetURLException(com.liferay.opensocial.GadgetURLException) Date(java.util.Date) DuplicateGadgetURLException(com.liferay.opensocial.DuplicateGadgetURLException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) GadgetPortletCategoryNamesException(com.liferay.opensocial.GadgetPortletCategoryNamesException) NoSuchGadgetException(com.liferay.opensocial.NoSuchGadgetException) GadgetURLException(com.liferay.opensocial.GadgetURLException)

Example 2 with GadgetSpec

use of org.apache.shindig.gadgets.spec.GadgetSpec in project liferay-ide by liferay.

the class BaseGadgetPortlet method doRender.

protected void doRender(RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    checkExpando(renderRequest, renderResponse);
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
    Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletDisplay.getId());
    Gadget gadget = getGadget(renderRequest);
    if (gadget == null) {
        return;
    }
    GadgetSpec gadgetSpec = ShindigUtil.getGadgetSpec(gadget.getUrl());
    overrideConfiguration(gadgetSpec, portlet, portletDisplay);
    renderRequest.setAttribute(WebKeys.GADGET, gadget);
    String view = getView(renderRequest, gadgetSpec);
    renderRequest.setAttribute(WebKeys.VIEW, view);
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) Gadget(com.liferay.opensocial.model.Gadget) Portlet(com.liferay.portal.model.Portlet) MVCPortlet(com.liferay.util.bridges.mvc.MVCPortlet) PortletDisplay(com.liferay.portal.theme.PortletDisplay) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 3 with GadgetSpec

use of org.apache.shindig.gadgets.spec.GadgetSpec 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();
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) OAuthSpec(org.apache.shindig.gadgets.spec.OAuthSpec) ModulePrefs(org.apache.shindig.gadgets.spec.ModulePrefs)

Example 4 with GadgetSpec

use of org.apache.shindig.gadgets.spec.GadgetSpec 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);
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) JSONObject(com.liferay.portal.kernel.json.JSONObject) ModulePrefs(org.apache.shindig.gadgets.spec.ModulePrefs) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) Feature(org.apache.shindig.gadgets.spec.Feature)

Example 5 with GadgetSpec

use of org.apache.shindig.gadgets.spec.GadgetSpec in project liferay-ide by liferay.

the class BaseConfigurationAction method getUserPrefs.

protected Map<String, UserPref> getUserPrefs(PortletConfig portletConfig, PortletRequest portletRequest) throws Exception {
    Gadget gadget = getGadget(portletConfig, portletRequest);
    GadgetSpec gadgetSpec = ShindigUtil.getGadgetSpec(gadget.getUrl());
    return gadgetSpec.getUserPrefs();
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) Gadget(com.liferay.opensocial.model.Gadget)

Aggregations

GadgetSpec (org.apache.shindig.gadgets.spec.GadgetSpec)6 ModulePrefs (org.apache.shindig.gadgets.spec.ModulePrefs)4 Gadget (com.liferay.opensocial.model.Gadget)3 GadgetURLException (com.liferay.opensocial.GadgetURLException)2 PortalException (com.liferay.portal.kernel.exception.PortalException)2 SystemException (com.liferay.portal.kernel.exception.SystemException)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2 DuplicateGadgetURLException (com.liferay.opensocial.DuplicateGadgetURLException)1 GadgetPortletCategoryNamesException (com.liferay.opensocial.GadgetPortletCategoryNamesException)1 NoSuchGadgetException (com.liferay.opensocial.NoSuchGadgetException)1 GadgetImpl (com.liferay.opensocial.model.impl.GadgetImpl)1 JSONObject (com.liferay.portal.kernel.json.JSONObject)1 Portlet (com.liferay.portal.model.Portlet)1 PortletDisplay (com.liferay.portal.theme.PortletDisplay)1 MVCPortlet (com.liferay.util.bridges.mvc.MVCPortlet)1 Date (java.util.Date)1 ProcessingException (org.apache.shindig.gadgets.process.ProcessingException)1 Feature (org.apache.shindig.gadgets.spec.Feature)1 OAuthSpec (org.apache.shindig.gadgets.spec.OAuthSpec)1