Example usage for com.liferay.portal.kernel.portlet WindowStateFactory getWindowState

List of usage examples for com.liferay.portal.kernel.portlet WindowStateFactory getWindowState

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.portlet WindowStateFactory getWindowState.

Prototype

public static WindowState getWindowState(String name) 

Source Link

Usage

From source file:com.liferay.taglib.portlet.ActionURLTag.java

License:Open Source License

public static void doTag(String lifecycle, String windowState, String portletMode, String var, String varImpl,
        Boolean secure, Boolean copyCurrentRenderParameters, Boolean escapeXml, String name, String resourceID,
        String cacheability, long plid, long refererPlid, String portletName, Boolean anchor, Boolean encrypt,
        long doAsGroupId, long doAsUserId, Boolean portletConfiguration, Map<String, String[]> params,
        PageContext pageContext) throws Exception {

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (portletName == null) {
        portletName = _getPortletName(request);
    }/* www .j av a2s.c  o  m*/

    LiferayPortletURL liferayPortletURL = _getLiferayPortletURL(request, plid, portletName, lifecycle);

    if (liferayPortletURL == null) {
        _log.error("Render response is null because this tag is not being "
                + "called within the context of a portlet");

        return;
    }

    if (Validator.isNotNull(windowState)) {
        liferayPortletURL.setWindowState(WindowStateFactory.getWindowState(windowState));
    }

    if (Validator.isNotNull(portletMode)) {
        liferayPortletURL.setPortletMode(PortletModeFactory.getPortletMode(portletMode));
    }

    if (secure != null) {
        liferayPortletURL.setSecure(secure.booleanValue());
    } else {
        liferayPortletURL.setSecure(PortalUtil.isSecure(request));
    }

    if (copyCurrentRenderParameters != null) {
        liferayPortletURL.setCopyCurrentRenderParameters(copyCurrentRenderParameters.booleanValue());
    }

    if (escapeXml != null) {
        liferayPortletURL.setEscapeXml(escapeXml.booleanValue());
    }

    if (lifecycle.equals(PortletRequest.ACTION_PHASE) && Validator.isNotNull(name)) {

        liferayPortletURL.setParameter(ActionRequest.ACTION_NAME, name);
    }

    if (resourceID != null) {
        liferayPortletURL.setResourceID(resourceID);
    }

    if (cacheability != null) {
        liferayPortletURL.setCacheability(cacheability);
    }

    if (refererPlid > LayoutConstants.DEFAULT_PLID) {
        liferayPortletURL.setRefererPlid(refererPlid);
    }

    if (anchor != null) {
        liferayPortletURL.setAnchor(anchor.booleanValue());
    }

    if (encrypt != null) {
        liferayPortletURL.setEncrypt(encrypt.booleanValue());
    }

    if (doAsGroupId > 0) {
        liferayPortletURL.setDoAsGroupId(doAsGroupId);
    }

    if (doAsUserId > 0) {
        liferayPortletURL.setDoAsUserId(doAsUserId);
    }

    if ((portletConfiguration != null) && portletConfiguration.booleanValue()) {

        String returnToFullPageURL = ParamUtil.getString(request, "returnToFullPageURL");
        String portletResource = ParamUtil.getString(request, "portletResource");
        String previewWidth = ParamUtil.getString(request, "previewWidth");

        liferayPortletURL.setParameter("struts_action", "/portlet_configuration/edit_configuration");
        liferayPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
        liferayPortletURL.setParameter("portletResource", portletResource);
        liferayPortletURL.setParameter("previewWidth", previewWidth);
    }

    if (params != null) {
        MapUtil.merge(liferayPortletURL.getParameterMap(), params);

        liferayPortletURL.setParameters(params);
    }

    String portletURLToString = liferayPortletURL.toString();

    if (Validator.isNotNull(var)) {
        pageContext.setAttribute(var, portletURLToString);
    } else if (Validator.isNotNull(varImpl)) {
        pageContext.setAttribute(varImpl, liferayPortletURL);
    } else {
        JspWriter jspWriter = pageContext.getOut();

        jspWriter.write(portletURLToString);
    }
}

From source file:com.liferay.taglib.security.PermissionsURLTag.java

License:Open Source License

public static void doTag(String redirect, String modelResource, String modelResourceDescription,
        String resourcePrimKey, String windowState, String var, int[] roleTypes, PageContext pageContext)
        throws Exception {

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    Layout layout = themeDisplay.getLayout();

    if (Validator.isNull(redirect)
            && (Validator.isNull(windowState) || !windowState.equals(LiferayWindowState.POP_UP.toString()))) {

        redirect = PortalUtil.getCurrentURL(request);
    }/*from  ww w  .j a  v  a2 s  . c o  m*/

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.PORTLET_CONFIGURATION,
            layout.getPlid(), PortletRequest.RENDER_PHASE);

    if (Validator.isNotNull(windowState)) {
        portletURL.setWindowState(WindowStateFactory.getWindowState(windowState));
    } else if (themeDisplay.isStatePopUp()) {
        portletURL.setWindowState(LiferayWindowState.POP_UP);
    } else {
        portletURL.setWindowState(WindowState.MAXIMIZED);
    }

    portletURL.setParameter("struts_action", "/portlet_configuration/edit_permissions");

    if (Validator.isNotNull(redirect)) {
        portletURL.setParameter("redirect", redirect);

        if (!themeDisplay.isStateMaximized()) {
            portletURL.setParameter("returnToFullPageURL", redirect);
        }
    }

    portletURL.setParameter("portletResource", portletDisplay.getId());
    portletURL.setParameter("modelResource", modelResource);
    portletURL.setParameter("modelResourceDescription", modelResourceDescription);
    portletURL.setParameter("resourcePrimKey", resourcePrimKey);

    if (roleTypes != null) {
        portletURL.setParameter("roleTypes", StringUtil.merge(roleTypes));
    }

    String portletURLToString = portletURL.toString();

    if (Validator.isNotNull(var)) {
        pageContext.setAttribute(var, portletURLToString);
    } else {
        JspWriter jspWriter = pageContext.getOut();

        jspWriter.write(portletURLToString);
    }
}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void updateNotificationStatusConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, WindowStateException {

    long notificationConfigId = ParamUtil.getLong(actionRequest,
            NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID);
    String dossierNextStatus = ParamUtil.getString(actionRequest,
            NotificationStatusConfigDisplayTerms.DOSSIER_NEXT_STATUS);
    boolean isSendNotification = ParamUtil.getBoolean(actionRequest,
            NotificationStatusConfigDisplayTerms.IS_SEND_NOTIFICATION, false);

    String currentURL = ParamUtil.getString(actionRequest, WebKeys.CURRENT_URL);

    String backURL = ParamUtil.getString(actionRequest, WebKeys.BACK_URL);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    NotificationStatusConfig notificationConfig = null;

    try {/*from  w ww  .j  a  v a  2 s  .c  om*/

        try {
            notificationConfig = NotificationStatusConfigLocalServiceUtil
                    .fetchNotificationStatusConfig(notificationConfigId);

            notificationConfig = NotificationStatusConfigLocalServiceUtil
                    .getByDossierNextStatus(dossierNextStatus);
        } catch (SystemException e) {

        }

        if (Validator.isNull(notificationConfig)) {

            notificationConfig = NotificationStatusConfigLocalServiceUtil.createNotificationStatusConfig(
                    CounterLocalServiceUtil.increment(NotificationStatusConfig.class.getName()));

            notificationConfig.setCompanyId(themeDisplay.getCompanyId());
            notificationConfig.setGroupId(themeDisplay.getScopeGroupId());
            notificationConfig.setUserId(themeDisplay.getUserId());
            notificationConfig.setCreateDate(new Date());
            notificationConfig.setModifiedDate(new Date());

            notificationConfig.setDossierNextStatus(dossierNextStatus);
            notificationConfig.setIsSendNotification(isSendNotification);

            NotificationStatusConfigLocalServiceUtil.addNotificationStatusConfig(notificationConfig);
            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_ADD_SUCESS);

        } else {

            notificationConfig.setCompanyId(themeDisplay.getCompanyId());
            notificationConfig.setGroupId(themeDisplay.getScopeGroupId());
            notificationConfig.setUserId(themeDisplay.getUserId());
            notificationConfig.setModifiedDate(new Date());

            notificationConfig.setDossierNextStatus(dossierNextStatus);
            notificationConfig.setIsSendNotification(isSendNotification);

            NotificationStatusConfigLocalServiceUtil.updateNotificationStatusConfig(notificationConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_UPDATE_SUCESS);

        }

    } catch (Exception e) {
        _log.error(e);
        SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_STATUS_SYSTEM_EXCEPTION_OCCURRED);
    } finally {

        PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),
                (String) actionRequest.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(),
                PortletRequest.RENDER_PHASE);
        redirectURL.setParameter(NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID,
                String.valueOf(notificationConfig.getNotiStatusConfigId()));
        WindowState state = WindowStateFactory.getWindowState(LiferayWindowState.POP_UP.toString());
        redirectURL.setWindowState(state);

        redirectURL.setParameter("mvcPath",
                "/html/portlets/notificationmgt/backoffice/status/notification_status_config_edit.jsp");
        actionResponse.sendRedirect(redirectURL.toString());

    }

}

From source file:org.opencps.notificationmgt.portlet.NotificationPortlet.java

License:Open Source License

public void updateNotificationEventConfig(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, WindowStateException {

    long notiEventConfigId = ParamUtil.getLong(actionRequest,
            NotificationEventConfigDisplayTerms.NOTICE_EVENT_CONFIG_ID);

    long notiStatusConfigId = ParamUtil.getLong(actionRequest,
            NotificationStatusConfigDisplayTerms.NOTICE_CONFIG_ID);

    boolean active = ParamUtil.getBoolean(actionRequest, NotificationEventConfigDisplayTerms.ACTIVE, false);

    String eventName = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.EVENT_NAME);
    String description = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.DESCRIPTION);
    String pattern = ParamUtil.getString(actionRequest, NotificationEventConfigDisplayTerms.PATTERN);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    NotificationEventConfig notiEventConfig = null;

    try {/* w  w  w.j av a2  s  .com*/

        try {
            notiEventConfig = NotificationEventConfigLocalServiceUtil
                    .fetchNotificationEventConfig(notiEventConfigId);

        } catch (SystemException e) {

        }

        if (Validator.isNotNull(notiEventConfig)) {

            notiEventConfig.setCompanyId(themeDisplay.getCompanyId());
            notiEventConfig.setGroupId(themeDisplay.getScopeGroupId());
            notiEventConfig.setUserId(themeDisplay.getUserId());
            notiEventConfig.setModifiedDate(new Date());

            notiEventConfig.setNotiStatusConfigId(notiStatusConfigId);
            notiEventConfig.setEventName(eventName);
            notiEventConfig.setDescription(description);
            notiEventConfig.setActive(active);
            notiEventConfig.setPattern(pattern);

            NotificationEventConfigLocalServiceUtil.updateNotificationEventConfig(notiEventConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_UPDATE_SUCESS);

        } else {

            notiEventConfig = NotificationEventConfigLocalServiceUtil.createNotificationEventConfig(
                    CounterLocalServiceUtil.increment(NotificationEventConfig.class.getName()));

            notiEventConfig.setCompanyId(themeDisplay.getCompanyId());
            notiEventConfig.setGroupId(themeDisplay.getScopeGroupId());
            notiEventConfig.setUserId(themeDisplay.getUserId());
            notiEventConfig.setCreateDate(new Date());
            notiEventConfig.setModifiedDate(new Date());

            notiEventConfig.setNotiStatusConfigId(notiStatusConfigId);
            notiEventConfig.setEventName(eventName);
            notiEventConfig.setDescription(description);
            notiEventConfig.setActive(active);
            notiEventConfig.setPattern(pattern);

            NotificationEventConfigLocalServiceUtil.addNotificationEventConfig(notiEventConfig);

            SessionMessages.add(actionRequest, MessageKeys.NOTIFICATION_EVENT_ADD_SUCESS);
        }
    } catch (Exception e) {
        _log.error(e);
    } finally {

        PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),
                (String) actionRequest.getAttribute(WebKeys.PORTLET_ID), themeDisplay.getLayout().getPlid(),
                PortletRequest.RENDER_PHASE);
        redirectURL.setParameter(NotificationEventConfigDisplayTerms.NOTICE_EVENT_CONFIG_ID,
                String.valueOf(notiEventConfig.getNotiEventConfigId()));
        WindowState state = WindowStateFactory.getWindowState(LiferayWindowState.POP_UP.toString());
        redirectURL.setWindowState(state);

        redirectURL.setParameter("mvcPath",
                "/html/portlets/notificationmgt/backoffice/event/notification_event_config_edit.jsp");
        actionResponse.sendRedirect(redirectURL.toString());

    }

}