use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class EditorPortlet method updateGadget.
@Override
public void updateGadget(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
long groupId = themeDisplay.getScopeGroupId();
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
if (cmd.equals(Constants.ADD)) {
GadgetPermission.check(permissionChecker, groupId, ActionKeys.PUBLISH_GADGET);
Gadget gadget = doAddGadget(actionRequest, actionResponse);
String publishGadgetRedirect = ParamUtil.getString(actionRequest, "publishGadgetRedirect");
boolean unpublishPermission = GadgetPermission.contains(permissionChecker, groupId, gadget.getGadgetId(), ActionKeys.DELETE);
publishGadgetRedirect = HttpUtil.addParameter(publishGadgetRedirect, "unpublishPermission", unpublishPermission);
publishGadgetRedirect = HttpUtil.addParameter(publishGadgetRedirect, "gadgetId", gadget.getGadgetId());
actionResponse.sendRedirect(publishGadgetRedirect);
} else {
long gadgetId = ParamUtil.getLong(actionRequest, "gadgetId");
GadgetPermission.check(permissionChecker, groupId, gadgetId, ActionKeys.UPDATE);
doUpdateGadget(actionRequest, actionResponse);
}
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class EditorPortlet method serveGetFolderChildren.
protected void serveGetFolderChildren(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
long repositoryId = ParamUtil.getLong(resourceRequest, "repositoryId");
long folderId = ParamUtil.getLong(resourceRequest, "folderId");
List<Folder> folders = DLAppServiceUtil.getFolders(repositoryId, folderId);
folders = ListUtil.sort(folders, new RepositoryModelNameComparator(true));
JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
for (Folder folder : folders) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("entryId", folder.getFolderId());
jsonObject.put("label", folder.getName());
jsonObject.put("leaf", false);
jsonObject.put("type", "editor");
jsonArray.put(jsonObject);
}
boolean getFileEntries = ParamUtil.getBoolean(resourceRequest, "getFileEntries");
if (getFileEntries) {
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folderId);
fileEntries = ListUtil.sort(fileEntries, new RepositoryModelNameComparator(true));
for (FileEntry fileEntry : fileEntries) {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
jsonObject.put("entryId", fileEntry.getFileEntryId());
String portalURL = PortalUtil.getPortalURL(themeDisplay);
String fileEntryURL = ShindigUtil.getFileEntryURL(portalURL, fileEntry.getFileEntryId());
jsonObject.put("fileEntryURL", fileEntryURL);
long gadgetId = 0;
try {
Gadget gadget = GadgetLocalServiceUtil.getGadget(themeDisplay.getCompanyId(), fileEntryURL);
gadgetId = gadget.getGadgetId();
} catch (Exception e) {
}
jsonObject.put("gadgetId", gadgetId);
jsonObject.put("label", fileEntry.getTitle());
jsonObject.put("leaf", true);
JSONObject jsonPermissions = JSONFactoryUtil.createJSONObject();
if (gadgetId > 0) {
boolean unpublishPermission = GadgetPermission.contains(permissionChecker, themeDisplay.getScopeGroupId(), gadgetId, ActionKeys.DELETE);
jsonPermissions.put("unpublishPermission", unpublishPermission);
}
jsonObject.put("permissions", jsonPermissions);
jsonObject.put("type", "editor");
jsonArray.put(jsonObject);
}
}
writeJSON(resourceRequest, resourceResponse, jsonArray);
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class BaseGadgetPortlet method doRender.
protected void doRender(RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
checkExpando(renderRequest, renderResponse);
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletDisplay.getId());
Gadget gadget = getGadget(renderRequest);
if (gadget == null) {
return;
}
GadgetSpec gadgetSpec = ShindigUtil.getGadgetSpec(gadget.getUrl());
overrideConfiguration(gadgetSpec, portlet, portletDisplay);
renderRequest.setAttribute(WebKeys.GADGET, gadget);
String view = getView(renderRequest, gadgetSpec);
renderRequest.setAttribute(WebKeys.VIEW, view);
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class GadgetPortlet method getGadget.
@Override
protected Gadget getGadget(RenderRequest renderRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletConfig portletConfig = getPortletConfig();
return ShindigUtil.getGadget(portletConfig.getPortletName(), themeDisplay.getCompanyId());
}
use of com.liferay.portal.theme.ThemeDisplay in project liferay-ide by liferay.
the class EditDiscussionAction method updateMessage.
protected MBMessage updateMessage(ActionRequest actionRequest) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
String className = ParamUtil.getString(actionRequest, "className");
long classPK = ParamUtil.getLong(actionRequest, "classPK");
String permissionClassName = ParamUtil.getString(actionRequest, "permissionClassName");
long permissionClassPK = ParamUtil.getLong(actionRequest, "permissionClassPK");
long permissionOwnerId = ParamUtil.getLong(actionRequest, "permissionOwnerId");
long messageId = ParamUtil.getLong(actionRequest, "messageId");
long threadId = ParamUtil.getLong(actionRequest, "threadId");
long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId");
String subject = ParamUtil.getString(actionRequest, "subject");
String body = ParamUtil.getString(actionRequest, "body");
ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest);
MBMessage message = null;
if (messageId <= 0) {
// Add message
User user = null;
if (themeDisplay.isSignedIn()) {
user = themeDisplay.getUser();
} else {
String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
user = UserLocalServiceUtil.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);
if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {
return null;
}
}
String name = PrincipalThreadLocal.getName();
PrincipalThreadLocal.setName(user.getUserId());
try {
message = MBMessageServiceUtil.addDiscussionMessage(serviceContext.getScopeGroupId(), className, classPK, permissionClassName, permissionClassPK, permissionOwnerId, threadId, parentMessageId, subject, body, serviceContext);
} finally {
PrincipalThreadLocal.setName(name);
}
} else {
// Update message
message = MBMessageServiceUtil.updateDiscussionMessage(className, classPK, permissionClassName, permissionClassPK, permissionOwnerId, messageId, subject, body, serviceContext);
}
// Subscription
boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe");
if (subscribe) {
SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK);
}
return message;
}
Aggregations