Search in sources :

Example 36 with JSONObject

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);
}
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 37 with 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);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ServiceContext(com.liferay.portal.service.ServiceContext) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry)

Example 38 with 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);
}
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 39 with JSONObject

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;
    }
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) JSONObject(com.liferay.portal.kernel.json.JSONObject)

Example 40 with JSONObject

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());
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject)

Aggregations

JSONObject (com.liferay.portal.kernel.json.JSONObject)54 JSONArray (com.liferay.portal.kernel.json.JSONArray)13 IOException (java.io.IOException)10 TException (org.apache.thrift.TException)9 PrintWriter (java.io.PrintWriter)7 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)5 ServiceContext (com.liferay.portal.service.ServiceContext)5 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)5 PortalException (com.liferay.portal.kernel.exception.PortalException)4 JSONException (com.liferay.portal.kernel.json.JSONException)4 Folder (com.liferay.portal.kernel.repository.model.Folder)4 Date (java.util.Date)4 CveSearchService (org.eclipse.sw360.datahandler.thrift.cvesearch.CveSearchService)4 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)4 User (org.eclipse.sw360.datahandler.thrift.users.User)4 JSONFactoryUtil.createJSONObject (com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject)3 Role (com.liferay.portal.kernel.model.Role)3 User (com.liferay.portal.kernel.model.User)3 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)3 User (com.liferay.portal.model.User)3