Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Oct 24, 2023
1 parent 3da2b8e commit 5a692da
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void shareOrganizationUser(String orgId, String associatedUserId, String associa
throws OrganizationManagementException;

/**
* UnShare all the shared users for the given user.
* Unshare all the shared users for the given user.
*
* @param associatedUserId The ID of the associated user.
* @param associatedOrgId The ID of the organization where the user is managed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public class SQLConstants {
public static final String GET_ORGANIZATION_USER_ASSOCIATION_FOR_ROOT_USER_IN_ORG = "SELECT UM_USER_ID, " +
"UM_ORG_ID, UM_ASSOCIATED_USER_ID, UM_ASSOCIATED_ORG_ID FROM UM_ORG_USER_ASSOCIATION " +
"WHERE UM_ASSOCIATED_USER_ID = ? AND UM_ORG_ID = ?";

public static final String GET_ORGANIZATION_USER_ASSOCIATIONS_FOR_SHARED_USER = "SELECT UM_USER_ID, UM_ORG_ID, " +
"UM_ASSOCIATED_USER_ID, UM_ASSOCIATED_ORG_ID FROM UM_ORG_USER_ASSOCIATION " +
"UM_ASSOCIATED_USER_ID, UM_ASSOCIATED_ORG_ID FROM UM_ORG_USER_ASSOCIATION " +
"WHERE UM_USER_ID = ? AND UM_ORG_ID = ?";
/**
* SQL placeholders related to organization user sharing SQL operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void activate(ComponentContext componentContext) {
new SharedUserOperationEventListener(), null);
bundleContext.registerService(AbstractEventHandler.class.getName(),
new SharingOrganizationCreatorUserEventHandler(), null);
LOG.info("Shared Organization User Listener activated successfully.");
LOG.info("OrganizationUserSharingServiceComponent activated successfully.");
}

@Reference(
Expand Down Expand Up @@ -89,7 +89,6 @@ protected void setOrganizationManagementService(OrganizationManager organization

OrganizationUserSharingDataHolder.getInstance().setOrganizationManager(organizationManager);
LOG.debug("Set Organization Management Service");

}

protected void unsetOrganizationManagementService(OrganizationManager organizationManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.wso2.carbon.identity.organization.management.role.management.service.models.User;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.identity.organization.management.service.model.Organization;
import org.wso2.carbon.identity.organization.management.service.util.OrganizationManagementUtil;

import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -40,7 +41,6 @@
import static org.wso2.carbon.identity.organization.management.role.management.service.constant.RoleManagementConstants.ORG_ADMINISTRATOR_ROLE;
import static org.wso2.carbon.identity.organization.management.role.management.service.constant.RoleManagementConstants.ORG_CREATOR_ROLE;
import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.SUPER_ORG_ID;
import static org.wso2.carbon.identity.organization.management.service.util.Utils.isSubOrganization;

/**
* The event handler for sharing the organization creator to the child organization.
Expand All @@ -60,9 +60,9 @@ public void handleEvent(Event event) throws IdentityEventException {
String orgId = organization.getId();

try {
int organizationDepth = OrganizationUserSharingDataHolder.getInstance().getOrganizationManager()
.getOrganizationDepthInHierarchy(orgId);
if (!isSubOrganization(organizationDepth)) {
String tenantDomain = OrganizationUserSharingDataHolder.getInstance().getOrganizationManager()
.resolveTenantDomain(orgId);
if (!OrganizationManagementUtil.isOrganization(tenantDomain)) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,9 @@ public List<String> getUserOrganizationPermissions(String userId, String organiz
permissions.addAll(groupAssignedRoles);
}

} catch (UserStoreException | DataAccessException e) {
} catch (UserStoreException | DataAccessException | OrganizationManagementException e) {
throw handleServerException(ERROR_CODE_ERROR_RETRIEVING_ORGANIZATION_PERMISSIONS, e, organizationId,
userId);
} catch (OrganizationManagementException e) {
throw new RuntimeException(e);
}

return permissions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
import org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementServerException;
import org.wso2.carbon.identity.organization.management.service.model.Organization;
import org.wso2.carbon.identity.organization.management.tenant.association.internal.TenantAssociationDataHolder;
import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
Expand Down Expand Up @@ -75,11 +74,9 @@ public void onTenantCreate(TenantInfoBean tenantInfo) {
organization.setType(OrganizationManagementConstants.OrganizationTypes.TENANT.name());
getOrganizationManager().addRootOrganization(tenant.getId(), organization);
}
} catch (UserStoreException | OrganizationManagementServerException e) {
} catch (UserStoreException | OrganizationManagementException e) {
String error = "Error occurred while adding user-tenant association for the tenant id: " + tenantId;
LOG.error(error, e);
} catch (OrganizationManagementException e) {
throw new RuntimeException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ public enum ErrorMessage {
ERROR_CODE_ACCEPT_INVITATION("10024",
"Unable to accept the invitation.",
"Could not accept the invitation for the user %s."),
ERROR_CODE_CONSTRUCT_REDIRECT_URL("10029",
ERROR_CODE_CONSTRUCT_REDIRECT_URL("10025",
"Unable to construct the redirect URL.",
"Unable to construct the redirect URL for invitation acceptance."),
ERROR_CODE_GET_USER_STORE_MANAGER("10031",
ERROR_CODE_GET_USER_STORE_MANAGER("10026",
"Unable to get the user store manager.",
"Unable to get the user store manager for the tenant."),
ERROR_CODE_GET_TENANT_FROM_ORG("10032",
ERROR_CODE_GET_TENANT_FROM_ORG("10027",
"Unable to get the tenant domain.",
"Unable to get the tenant domain for the organization %s."),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ protected void setOrganizationUserSharingService(OrganizationUserSharingService

UserInvitationMgtDataHolder.getInstance().setOrganizationUserSharingService(organizationUserSharingService);
LOG.debug("Set organization user association service.");

}

protected void unsetOrganizationUserAssociationService(
Expand Down

0 comments on commit 5a692da

Please sign in to comment.