Example usage for com.liferay.portal.kernel.portlet DynamicActionRequest DynamicActionRequest

List of usage examples for com.liferay.portal.kernel.portlet DynamicActionRequest DynamicActionRequest

Introduction

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

Prototype

public DynamicActionRequest(ActionRequest actionRequest) 

Source Link

Usage

From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java

License:Open Source License

private ActionRequest _wrapActionRequest(ActionRequest actionRequest) throws Exception {

    DynamicActionRequest dynamicActionRequest = new DynamicActionRequest(actionRequest);

    long prefixId = getListTypeId(actionRequest, "prefixValue", ListTypeConstants.CONTACT_PREFIX);

    dynamicActionRequest.setParameter("prefixId", String.valueOf(prefixId));

    long suffixId = getListTypeId(actionRequest, "suffixValue", ListTypeConstants.CONTACT_SUFFIX);

    dynamicActionRequest.setParameter("suffixId", String.valueOf(suffixId));

    return dynamicActionRequest;
}

From source file:com.liferay.so.hook.action.EditUserAction.java

License:Open Source License

protected void updateUser(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    updateProjectsEntries(actionRequest, actionResponse);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    if (!cmd.equals(Constants.UPDATE)) {
        originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);

        return;/*from   w w  w.  ja  v  a2 s .  c  o  m*/
    }

    DynamicActionRequest dynamicActionRequest = new DynamicActionRequest(actionRequest);

    User user = PortalUtil.getSelectedUser(actionRequest);

    Role role = RoleLocalServiceUtil.fetchRole(user.getCompanyId(), RoleConstants.SOCIAL_OFFICE_USER);

    if (role == null) {
        originalStrutsPortletAction.processAction(portletConfig, dynamicActionRequest, actionResponse);

        return;
    }

    long[] roleIds = getLongArray(actionRequest, "rolesSearchContainerPrimaryKeys");

    boolean newSocialOfficeUser = ArrayUtil.contains(roleIds, role.getRoleId());

    List<Role> roles = user.getRoles();

    if (newSocialOfficeUser && !roles.contains(role)) {
        LayoutSetPrototype publicLayoutSetPrototype = LayoutSetPrototypeUtil.fetchLayoutSetPrototype(
                user.getCompanyId(), SocialOfficeConstants.LAYOUT_SET_PROTOTYPE_KEY_USER_PUBLIC);

        if (publicLayoutSetPrototype != null) {
            dynamicActionRequest.setParameter("publicLayoutSetPrototypeId",
                    String.valueOf(publicLayoutSetPrototype.getLayoutSetPrototypeId()));
            dynamicActionRequest.setParameter("publicLayoutSetPrototypeLinkEnabled", Boolean.TRUE.toString());
        }

        LayoutSetPrototype privateLayoutSetPrototype = LayoutSetPrototypeUtil.fetchLayoutSetPrototype(
                user.getCompanyId(), SocialOfficeConstants.LAYOUT_SET_PROTOTYPE_KEY_USER_PRIVATE);

        if (privateLayoutSetPrototype != null) {
            dynamicActionRequest.setParameter("privateLayoutSetPrototypeId",
                    String.valueOf(privateLayoutSetPrototype.getLayoutSetPrototypeId()));
            dynamicActionRequest.setParameter("privateLayoutSetPrototypeLinkEnabled", Boolean.TRUE.toString());
        }
    } else if (!newSocialOfficeUser && roles.contains(role)) {
        dynamicActionRequest.setParameter("publicLayoutSetPrototypeId", StringPool.BLANK);
        dynamicActionRequest.setParameter("publicLayoutSetPrototypeLinkEnabled", Boolean.FALSE.toString());
        dynamicActionRequest.setParameter("privateLayoutSetPrototypeId", StringPool.BLANK);
        dynamicActionRequest.setParameter("privateLayoutSetPrototypeLinkEnabled", Boolean.FALSE.toString());
    }

    originalStrutsPortletAction.processAction(portletConfig, dynamicActionRequest, actionResponse);
}