Example usage for com.liferay.portal.kernel.messaging.proxy ProxyModeThreadLocal setForceSync

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

Introduction

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

Prototype

@Deprecated
public static void setForceSync(boolean forceSync) 

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  ww w  .  j a v  a 2  s . co  m*/

    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;/*from w w  w.j  a  v a2s .  c o  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. ja  va2 s  .c  o  m
}

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);
    }// w  w w  .  j av a  2  s  .  c o  m
}