use of com.liferay.portal.kernel.json.JSONObject 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.kernel.json.JSONObject in project liferay-ide by liferay.
the class EditorPortlet method serveUpdateFileEntryContent.
protected void serveUpdateFileEntryContent(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
String content = ParamUtil.getString(resourceRequest, "content");
byte[] bytes = content.getBytes(StringPool.UTF8);
ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
DLAppServiceUtil.updateFileEntry(fileEntryId, fileEntry.getTitle(), resourceRequest.getContentType(), fileEntry.getTitle(), fileEntry.getDescription(), StringPool.BLANK, false, bytes, serviceContext);
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
writeJSON(resourceRequest, resourceResponse, jsonObject);
}
use of com.liferay.portal.kernel.json.JSONObject 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.kernel.json.JSONObject in project liferay-ide by liferay.
the class SerializerUtil method getBeanProperty.
protected static String getBeanProperty(Object bean, String fieldName) {
Object value = BeanPropertiesUtil.getObject(bean, fieldName);
if (value == null) {
return null;
}
if (fieldName.equals("location")) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
copyProperties(value, jsonObject, _ADDRESS_FIELDS);
return jsonObject.toString();
} else {
return (String) value;
}
}
use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.
the class KnowledgeBaseUtil method setPreferredKBFolderURLTitle.
public static void setPreferredKBFolderURLTitle(PortalPreferences portalPreferences, String contentRootPrefix, String value) throws JSONException {
String preferredKBFolderURLTitle = portalPreferences.getValue(PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle", "{}");
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(preferredKBFolderURLTitle);
jsonObject.put(contentRootPrefix, value);
portalPreferences.setValue(PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle", jsonObject.toString());
}
Aggregations