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