Search in sources :

Example 31 with JSONObject

use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.

the class LiferayActivityService method getExternalActivity.

protected Activity getExternalActivity(SocialActivity socialActivity) throws Exception {
    Activity activity = new ActivityImpl(String.valueOf(socialActivity.getClassPK()), String.valueOf(socialActivity.getUserId()));
    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(socialActivity.getExtraData());
    SerializerUtil.copyProperties(extraDataJSONObject, activity, _ACTIVITY_FIELDS);
    return activity;
}
Also used : ActivityImpl(org.apache.shindig.social.core.model.ActivityImpl) JSONObject(com.liferay.portal.kernel.json.JSONObject) SocialActivity(com.liferay.portlet.social.model.SocialActivity) Activity(org.apache.shindig.social.opensocial.model.Activity)

Example 32 with JSONObject

use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.

the class EditorPortlet method serveGetFileEntryContent.

protected void serveGetFileEntryContent(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    String content = StringUtil.read(fileEntry.getContentStream());
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    jsonObject.put("content", content);
    writeJSON(resourceRequest, resourceResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry)

Example 33 with JSONObject

use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.

the class EditorPortlet method serveException.

protected void serveException(Exception exception, ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException {
    JSONObject jsonError = JSONFactoryUtil.createJSONObject();
    jsonError.put("message", exception.getLocalizedMessage());
    jsonError.put("name", exception.getClass().getSimpleName());
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    jsonObject.put("error", jsonError);
    writeJSON(resourceRequest, resourceResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject)

Example 34 with JSONObject

use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.

the class EditorPortlet method serveAddFileEntry.

protected void serveAddFileEntry(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long folderId = ParamUtil.getLong(resourceRequest, "folderId");
    Folder folder = DLAppServiceUtil.getFolder(folderId);
    String fileEntryTitle = ParamUtil.getString(resourceRequest, "fileEntryTitle");
    String content = ParamUtil.getString(resourceRequest, "content");
    byte[] bytes = content.getBytes(StringPool.UTF8);
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setAttribute("sourceFileName", fileEntryTitle);
    serviceContext.setScopeGroupId(folder.getGroupId());
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(folder.getRepositoryId(), folderId, fileEntryTitle, resourceRequest.getContentType(), fileEntryTitle, StringPool.BLANK, StringPool.BLANK, bytes, serviceContext);
    jsonObject.put("fileEntryId", fileEntry.getFileEntryId());
    String portalURL = PortalUtil.getPortalURL(themeDisplay);
    String fileEntryURL = ShindigUtil.getFileEntryURL(portalURL, fileEntry.getFileEntryId());
    jsonObject.put("fileEntryURL", fileEntryURL);
    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) Folder(com.liferay.portal.kernel.repository.model.Folder) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 35 with JSONObject

use of com.liferay.portal.kernel.json.JSONObject in project liferay-ide by liferay.

the class EditorPortlet method serveUpdateFileEntryTitle.

protected void serveUpdateFileEntryTitle(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    String fileEntryTitle = ParamUtil.getString(resourceRequest, "fileEntryTitle");
    byte[] bytes = null;
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    DLAppServiceUtil.updateFileEntry(fileEntryId, fileEntryTitle, resourceRequest.getContentType(), fileEntryTitle, 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)

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