Search in sources :

Example 1 with ThemeDisplay

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();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WindowStateException(javax.portlet.WindowStateException) FileVersion(com.liferay.portal.kernel.repository.model.FileVersion) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 2 with ThemeDisplay

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);
}
Also used : User(com.liferay.portal.kernel.model.User) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay)

Example 3 with ThemeDisplay

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);
}
Also used : User(com.liferay.portal.kernel.model.User) ThemeDisplay(com.liferay.portal.kernel.theme.ThemeDisplay)

Aggregations

ThemeDisplay (com.liferay.portal.kernel.theme.ThemeDisplay)3 User (com.liferay.portal.kernel.model.User)2 PortalException (com.liferay.portal.kernel.exception.PortalException)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 FileVersion (com.liferay.portal.kernel.repository.model.FileVersion)1 PortletURL (javax.portlet.PortletURL)1 WindowStateException (javax.portlet.WindowStateException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1