Example usage for com.liferay.portal.kernel.portlet LiferayPortletURL getLifecycle

List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletURL getLifecycle

Introduction

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

Prototype

public String getLifecycle();

Source Link

Document

Returns the portlet lifecycle of this URL's target portlet.

Usage

From source file:com.liferay.alloy.mvc.AlloyFriendlyURLMapper.java

License:Open Source License

@Override
public String buildPath(LiferayPortletURL liferayPortletURL) {
    Map<String, String> routeParameters = new HashMap<String, String>();

    buildRouteParameters(liferayPortletURL, routeParameters);

    // Populate method parameter based on the portlet lifecycle

    String lifecycle = liferayPortletURL.getLifecycle();

    if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
        routeParameters.put("method", HttpMethods.POST);
    } else {// w  w w . ja  v a 2  s  . c o  m
        routeParameters.put("method", HttpMethods.GET);
    }

    // Map URL with router

    String friendlyURLPath = router.parametersToUrl(routeParameters);

    if (friendlyURLPath == null) {
        return null;
    }

    // Remove mapped parameters from URL

    addParametersIncludedInPath(liferayPortletURL, routeParameters);

    // Remove method

    int pos = friendlyURLPath.indexOf(CharPool.SLASH);

    if (pos != -1) {
        friendlyURLPath = friendlyURLPath.substring(pos);
    } else {
        friendlyURLPath = StringPool.BLANK;
    }

    // Add mapping

    friendlyURLPath = StringPool.SLASH.concat(getMapping()).concat(friendlyURLPath);

    return friendlyURLPath;
}

From source file:com.liferay.portlet.PortletURLUtil.java

License:Open Source License

public static PortletURL clone(PortletURL portletURL, MimeResponse mimeResponse) throws PortletException {

    LiferayPortletURL liferayPortletURL = (LiferayPortletURL) portletURL;

    return clone(liferayPortletURL, liferayPortletURL.getLifecycle(), mimeResponse);
}