Search in sources :

Example 46 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay 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 47 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class BaseConfigurationAction method doProcessAction.

protected void doProcessAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    Layout layout = themeDisplay.getLayout();
    JSONObject userPrefsJSONObject = JSONFactoryUtil.createJSONObject();
    Map<String, UserPref> userPrefs = getUserPrefs(portletConfig, actionRequest);
    for (UserPref userPref : userPrefs.values()) {
        String name = userPref.getName();
        String value = ParamUtil.getString(actionRequest, name);
        userPrefsJSONObject.put(name, value);
    }
    String namespace = ShindigUtil.getPortletResourceNamespace(actionRequest, themeDisplay);
    String columnName = ShindigUtil.getColumnUserPrefs(namespace, themeDisplay);
    ExpandoValueServiceUtil.addValue(themeDisplay.getCompanyId(), Layout.class.getName(), ShindigUtil.getTableOpenSocial(), columnName, layout.getPlid(), userPrefsJSONObject.toString());
    String portletResource = ParamUtil.getString(actionRequest, "portletResource");
    SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);
    SessionMessages.add(actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) Layout(com.liferay.portal.model.Layout) UserPref(org.apache.shindig.gadgets.spec.UserPref) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 48 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class ConfigurationActionImpl method getGadget.

@Override
protected Gadget getGadget(PortletConfig portletConfig, PortletRequest portletRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String portletResource = ParamUtil.getString(portletRequest, "portletResource");
    return ShindigUtil.getGadget(portletResource, themeDisplay.getCompanyId());
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 49 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class BaseGadgetPortlet method checkExpando.

protected void checkExpando(RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
    ExpandoTable expandoTable = ExpandoTableLocalServiceUtil.getTable(themeDisplay.getCompanyId(), Layout.class.getName(), ShindigUtil.getTableOpenSocial());
    String namespace = renderResponse.getNamespace();
    String columnName = ShindigUtil.getColumnUserPrefs(namespace, themeDisplay);
    ExpandoColumn expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), columnName);
    if (expandoColumn == null) {
        expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), columnName, ExpandoColumnConstants.STRING);
        Map<Long, String[]> roleIdsToActionIds = new HashMap<Long, String[]>();
        Role guestRole = RoleLocalServiceUtil.getRole(expandoColumn.getCompanyId(), RoleConstants.GUEST);
        roleIdsToActionIds.put(guestRole.getRoleId(), new String[] { ActionKeys.VIEW });
        Role userRole = RoleLocalServiceUtil.getRole(expandoColumn.getCompanyId(), RoleConstants.USER);
        roleIdsToActionIds.put(userRole.getRoleId(), new String[] { ActionKeys.UPDATE, ActionKeys.VIEW });
        ResourcePermissionLocalServiceUtil.setResourcePermissions(expandoColumn.getCompanyId(), ExpandoColumn.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(expandoColumn.getColumnId()), roleIdsToActionIds);
    }
}
Also used : Role(com.liferay.portal.model.Role) ExpandoTable(com.liferay.portlet.expando.model.ExpandoTable) Layout(com.liferay.portal.model.Layout) HashMap(java.util.HashMap) ExpandoColumn(com.liferay.portlet.expando.model.ExpandoColumn) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 50 with ThemeDisplay

use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.

the class ShindigUtil method updateOAuthConsumers.

public static void updateOAuthConsumers(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long[] oAuthConsumerIds = ParamUtil.getLongValues(actionRequest, "oAuthConsumerId");
    String gadgetKey = ParamUtil.getString(actionRequest, "gadgetKey");
    String[] serviceNames = ParamUtil.getParameterValues(actionRequest, "serviceName");
    String[] consumerKeys = ParamUtil.getParameterValues(actionRequest, "consumerKey");
    String[] consumerSecrets = ParamUtil.getParameterValues(actionRequest, "consumerSecret");
    String[] keyTypes = ParamUtil.getParameterValues(actionRequest, "keyType");
    if ((serviceNames.length == 0) && (keyTypes.length != 0)) {
        serviceNames = new String[] { StringPool.BLANK };
    }
    for (int i = 0; i < serviceNames.length; i++) {
        String consumerKey = (String) ArrayUtil.getValue(consumerKeys, i);
        String consumerSecret = (String) ArrayUtil.getValue(consumerSecrets, i);
        if (Validator.isNull(consumerKey)) {
            consumerKey = StringPool.BLANK;
        }
        if (Validator.isNull(consumerSecret)) {
            consumerSecret = StringPool.BLANK;
        }
        if (oAuthConsumerIds[i] <= 0) {
            OAuthConsumerLocalServiceUtil.addOAuthConsumer(themeDisplay.getCompanyId(), gadgetKey, serviceNames[i], consumerKey, consumerSecret, keyTypes[i]);
        } else {
            OAuthConsumerLocalServiceUtil.updateOAuthConsumer(oAuthConsumerIds[i], consumerKey, consumerSecret, keyTypes[i], StringPool.BLANK, StringPool.BLANK);
        }
    }
}
Also used : ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Aggregations

ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)63 PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)10 ServiceContext (com.liferay.portal.service.ServiceContext)7 JSONObject (com.liferay.portal.kernel.json.JSONObject)6 PortletURL (javax.portlet.PortletURL)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 User (com.liferay.portal.model.User)5 Gadget (com.liferay.opensocial.model.Gadget)4 SystemException (com.liferay.portal.kernel.exception.SystemException)4 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)4 PortletConfig (javax.portlet.PortletConfig)4 KBArticle (com.liferay.knowledgebase.model.KBArticle)3 KBFolder (com.liferay.knowledgebase.model.KBFolder)3 Role (com.liferay.portal.model.Role)3 HashMap (java.util.HashMap)3 LiferayPortletURL (com.liferay.portal.kernel.portlet.LiferayPortletURL)2 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 Folder (com.liferay.portal.kernel.repository.model.Folder)2 Layout (com.liferay.portal.model.Layout)2 SocialActivity (com.liferay.portlet.social.model.SocialActivity)2