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);
}
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);
}
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());
}
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);
}
}
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);
}
}
}
Aggregations