use of com.liferay.portal.kernel.theme.ThemeDisplay in project liferay-blade-samples by liferay.
the class BladeActionConfigurationIcon method getURL.
public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {
HttpServletRequest servletRequest = _portal.getHttpServletRequest(portletRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
FileEntry fileEntry = _retrieveFile(servletRequest);
PortletURL portletURL = PortletURLFactoryUtil.create(servletRequest, "blade_document_action_portlet_BladeDocumentActionPortlet", themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
String fileName = fileEntry.getFileName();
String mimeType = fileEntry.getMimeType();
String version = fileEntry.getVersion();
String createdDate = String.valueOf(fileEntry.getCreateDate());
String createdUserName = fileEntry.getUserName();
String statusLabel = null;
try {
FileVersion fileVersion = fileEntry.getLatestFileVersion();
int status = fileVersion.getStatus();
statusLabel = WorkflowConstants.getStatusLabel(status);
} catch (PortalException pe) {
_log.log(LogService.LOG_ERROR, pe.getMessage(), pe);
}
portletURL.setParameter("fileName", fileName);
portletURL.setParameter("mimeType", mimeType);
portletURL.setParameter("version", version);
portletURL.setParameter("statusLabel", statusLabel);
portletURL.setParameter("createdDate", createdDate);
portletURL.setParameter("createdUserName", createdUserName);
try {
portletURL.setWindowState(LiferayWindowState.POP_UP);
} catch (WindowStateException wse) {
_log.log(LogService.LOG_ERROR, wse.getMessage(), wse);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("javascript:Liferay.Util.openWindow(");
stringBuilder.append("{dialog: {cache: false,width:800,modal: true},");
stringBuilder.append("title: 'basic information',id: ");
stringBuilder.append("'testPopupIdUnique',uri: '");
stringBuilder.append(portletURL.toString() + "'});");
return stringBuilder.toString();
}
use of com.liferay.portal.kernel.theme.ThemeDisplay in project liferay-blade-samples by liferay.
the class BladePortletAction method render.
@Override
public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
_log.log(LogService.LOG_INFO, "BladePortletAction - render");
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
User loggedinUser = themeDisplay.getUser();
if (loggedinUser != null) {
loggedinUser.setLastName("BLADE");
loggedinUser.setGreeting("Hello," + loggedinUser.getFirstName() + " from BLADE!");
_userLocalService.updateUser(loggedinUser);
}
return originalStrutsPortletAction.render(originalStrutsPortletAction, portletConfig, renderRequest, renderResponse);
}
use of com.liferay.portal.kernel.theme.ThemeDisplay in project liferay-blade-samples by liferay.
the class BladePortletAction method processAction.
@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_log.log(LogService.LOG_INFO, "BladePortletAction - processAction");
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
User loggedinUser = themeDisplay.getUser();
if (loggedinUser != null) {
_log.log(LogService.LOG_INFO, "Logging in with user:[" + loggedinUser.getFirstName() + " " + loggedinUser.getLastName() + "]");
_log.log(LogService.LOG_INFO, "Logged in user: Current Greetings[" + loggedinUser.getGreeting() + "]");
}
originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest, actionResponse);
}
Aggregations