Example usage for com.liferay.portal.kernel.messaging.proxy ProxyModeThreadLocalCloseable ProxyModeThreadLocalCloseable

List of usage examples for com.liferay.portal.kernel.messaging.proxy ProxyModeThreadLocalCloseable ProxyModeThreadLocalCloseable

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.messaging.proxy ProxyModeThreadLocalCloseable ProxyModeThreadLocalCloseable.

Prototype

public ProxyModeThreadLocalCloseable() 

Source Link

Usage

From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java

License:Open Source License

public void editRoleAssignments(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long roleId = ParamUtil.getLong(actionRequest, "roleId");

    Role role = _roleLocalService.getRole(roleId);

    String roleName = role.getName();

    if (roleName.equals(RoleConstants.OWNER)) {
        throw new RoleAssignmentException(roleName);
    }/*from   w ww  . ja  va2s.com*/

    long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L);
    long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L);

    if (!ArrayUtil.isEmpty(addUserIds) || !ArrayUtil.isEmpty(removeUserIds)) {

        try (ProxyModeThreadLocalCloseable proxyModeThreadLocalCloseable = new ProxyModeThreadLocalCloseable()) {

            ProxyModeThreadLocal.setForceSync(true);

            _userService.addRoleUsers(roleId, addUserIds);
            _userService.unsetRoleUsers(roleId, removeUserIds);
        }
    }

    long[] addGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "addGroupIds"), 0L);
    long[] removeGroupIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeGroupIds"), 0L);

    if (!ArrayUtil.isEmpty(addGroupIds) || !ArrayUtil.isEmpty(removeGroupIds)) {

        _groupService.addRoleGroups(roleId, addGroupIds);
        _groupService.unsetRoleGroups(roleId, removeGroupIds);
    }
}

From source file:com.liferay.user.groups.admin.web.internal.portlet.UserGroupsAdminPortlet.java

License:Open Source License

public void editUserGroup(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long userGroupId = ParamUtil.getLong(actionRequest, "userGroupId");

    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(UserGroup.class.getName(), actionRequest);

    UserGroup userGroup = null;//w  w w  .  j a v a 2s . co m

    try (ProxyModeThreadLocalCloseable proxyModeThreadLocalCloseable = new ProxyModeThreadLocalCloseable()) {

        ProxyModeThreadLocal.setForceSync(true);

        if (userGroupId <= 0) {

            // Add user group

            userGroup = _userGroupService.addUserGroup(name, description, serviceContext);
        } else {

            // Update user group

            userGroup = _userGroupService.updateUserGroup(userGroupId, name, description, serviceContext);
        }
    }

    // Layout set prototypes

    long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId");
    long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId");
    boolean publicLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "publicLayoutSetPrototypeLinkEnabled");
    boolean privateLayoutSetPrototypeLinkEnabled = ParamUtil.getBoolean(actionRequest,
            "privateLayoutSetPrototypeLinkEnabled");

    if ((privateLayoutSetPrototypeId > 0) || (publicLayoutSetPrototypeId > 0)) {

        SitesUtil.updateLayoutSetPrototypesLinks(userGroup.getGroup(), publicLayoutSetPrototypeId,
                privateLayoutSetPrototypeId, publicLayoutSetPrototypeLinkEnabled,
                privateLayoutSetPrototypeLinkEnabled);
    }
}

From source file:com.liferay.user.groups.admin.web.internal.portlet.UserGroupsAdminPortlet.java

License:Open Source License

public void editUserGroupAssignments(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

    long userGroupId = ParamUtil.getLong(actionRequest, "userGroupId");

    long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L);
    long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L);

    try (ProxyModeThreadLocalCloseable proxyModeThreadLocalCloseable = new ProxyModeThreadLocalCloseable()) {

        ProxyModeThreadLocal.setForceSync(true);

        _userService.addUserGroupUsers(userGroupId, addUserIds);
        _userService.unsetUserGroupUsers(userGroupId, removeUserIds);
    }//from   w  w  w  .  j  a  va2s  .  c om
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditOrganizationAssignmentsMVCActionCommand.java

License:Open Source License

protected void updateOrganizationUsers(ActionRequest actionRequest) throws Exception {

    long organizationId = ParamUtil.getLong(actionRequest, "organizationId");

    long[] addUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "addUserIds"), 0L);
    long[] removeUserIds = StringUtil.split(ParamUtil.getString(actionRequest, "removeUserIds"), 0L);

    try (ProxyModeThreadLocalCloseable proxyModeThreadLocalCloseable = new ProxyModeThreadLocalCloseable()) {

        ProxyModeThreadLocal.setForceSync(true);

        _userService.addOrganizationUsers(organizationId, addUserIds);
        _userService.unsetOrganizationUsers(organizationId, removeUserIds);
    }/*from  w  ww.j  a  va2  s. co m*/
}