public static Organization addSite(Organization organization) throws Exception { return OrganizationLocalServiceUtil.updateOrganization( organization.getCompanyId(), organization.getOrganizationId(), organization.getParentOrganizationId(), organization.getName(), organization.getType(), organization.getRegionId(), organization.getCountryId(), organization.getStatusId(), organization.getComments(), false, null, true, null); }
public static void getRole(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long roleId = ParamUtil.getLong(request, "roleId"); Role role = null; Group group = (Group) request.getAttribute(WebKeys.GROUP); if ((group != null) && group.isOrganization()) { long organizationId = group.getOrganizationId(); while (organizationId != OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID) { Organization organization = OrganizationLocalServiceUtil.getOrganization(organizationId); long organizationGroupId = organization.getGroupId(); if (GroupPermissionUtil.contains( permissionChecker, organizationGroupId, ActionKeys.ASSIGN_USER_ROLES) || OrganizationPermissionUtil.contains( permissionChecker, organizationId, ActionKeys.ASSIGN_USER_ROLES) || UserGroupRoleLocalServiceUtil.hasUserGroupRole( themeDisplay.getUserId(), organizationGroupId, RoleConstants.ORGANIZATION_ADMINISTRATOR, true) || UserGroupRoleLocalServiceUtil.hasUserGroupRole( themeDisplay.getUserId(), organizationGroupId, RoleConstants.ORGANIZATION_OWNER, true)) { if (roleId > 0) { role = RoleLocalServiceUtil.getRole(roleId); } break; } organizationId = organization.getParentOrganizationId(); } if ((roleId > 0) && (role == null)) { role = RoleServiceUtil.getRole(roleId); } } else if ((group != null) && group.isRegularSite()) { if (GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.ASSIGN_USER_ROLES) || UserGroupRoleLocalServiceUtil.hasUserGroupRole( themeDisplay.getUserId(), group.getGroupId(), RoleConstants.SITE_ADMINISTRATOR, true) || UserGroupRoleLocalServiceUtil.hasUserGroupRole( themeDisplay.getUserId(), group.getGroupId(), RoleConstants.SITE_OWNER, true)) { if (roleId > 0) { role = RoleLocalServiceUtil.getRole(roleId); } } else { if (roleId > 0) { role = RoleServiceUtil.getRole(roleId); } } } else { if (roleId > 0) { role = RoleServiceUtil.getRole(roleId); } } request.setAttribute(WebKeys.ROLE, role); }