Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kayathiri4 committed Oct 4, 2024
1 parent 2256244 commit 04327bd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ default int getCountOfDiscoverableSharedApplications(String filter, String tenan
}

/**
* Check whether the main application has fragment applications.
* Check whether the main application has shared applications.
*
* @param mainApplicationId Main application ID.
* @return True if the main application has fragment applications.
* @throws OrganizationManagementException If an error occurred when checking fragment applications.
* @return True if the main application has shared applications.
* @throws OrganizationManagementException If an error occurred when checking shared applications.
*/
default boolean hasFragmentApps(String mainApplicationId) throws OrganizationManagementException {
default boolean hasSharedApps(String mainApplicationId) throws OrganizationManagementException {

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public int getCountOfDiscoverableSharedApplications(String filter, String tenant
}

@Override
public boolean hasFragmentApps(String mainApplicationId) throws OrganizationManagementException {
public boolean hasSharedApps(String mainApplicationId) throws OrganizationManagementException {

return getOrgApplicationMgtDAO().hasFragments(mainApplicationId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public class SQLConstants {
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1')";

public static final String DELETE_SHARED_APP_LINK = "DELETE FROM SP_SHARED_APP WHERE SHARED_ORG_ID = :" +
public static final String DELETE_SHARED_APP_LINKS_OF_ORG = "DELETE FROM SP_SHARED_APP WHERE SHARED_ORG_ID = :" +
SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_SHARED_ORG_ID + ";";

private SQLConstants() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ List<ApplicationBasicInfo> getDiscoverableSharedApplicationBasicInfo(int limit,
int getCountOfDiscoverableSharedApplications(String filter, String tenantDomain, String rootOrgId)
throws OrganizationManagementException;

default void deleteSharedAppLink(String organizationId) throws OrganizationManagementServerException {
default void deleteSharedAppLinks(String organizationId) throws OrganizationManagementServerException {

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import static org.wso2.carbon.identity.application.mgt.ApplicationMgtUtil.getConsoleAccessUrlFromServerConfig;
import static org.wso2.carbon.identity.application.mgt.ApplicationMgtUtil.getMyAccountAccessUrlFromServerConfig;
import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.IS_FRAGMENT_APP;
import static org.wso2.carbon.identity.organization.management.application.constant.SQLConstants.DELETE_SHARED_APP_LINK;
import static org.wso2.carbon.identity.organization.management.application.constant.SQLConstants.DELETE_SHARED_APP_LINKS_OF_ORG;
import static org.wso2.carbon.identity.organization.management.application.constant.SQLConstants.GET_FILTERED_SHARED_APPLICATIONS;
import static org.wso2.carbon.identity.organization.management.application.constant.SQLConstants.GET_MAIN_APPLICATION;
import static org.wso2.carbon.identity.organization.management.application.constant.SQLConstants.GET_SHARED_APPLICATION;
Expand Down Expand Up @@ -383,11 +383,11 @@ public int getCountOfDiscoverableSharedApplications(String filter, String tenant
}

@Override
public void deleteSharedAppLink(String organizationId) throws OrganizationManagementServerException {
public void deleteSharedAppLinks(String organizationId) throws OrganizationManagementServerException {

NamedJdbcTemplate namedJdbcTemplate = getNewTemplate();
try {
namedJdbcTemplate.executeUpdate(DELETE_SHARED_APP_LINK, preparedStatement -> {
namedJdbcTemplate.executeUpdate(DELETE_SHARED_APP_LINKS_OF_ORG, preparedStatement -> {
preparedStatement.setString(DB_SCHEMA_COLUMN_NAME_SHARED_ORG_ID, organizationId);
});
} catch (DataAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import static org.wso2.carbon.identity.organization.management.application.constant.OrgApplicationMgtConstants.SHARE_WITH_ALL_CHILDREN;
import static org.wso2.carbon.identity.organization.management.application.util.OrgApplicationManagerUtil.setIsAppSharedProperty;
import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.IS_APP_SHARED;
import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ORGANIZATION_ID_PROPERTY;
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.getAuthenticatedUsername;

Expand All @@ -71,9 +70,10 @@ public class OrganizationCreationHandler extends AbstractEventHandler {
public void handleEvent(Event event) throws IdentityEventException {

String eventName = event.getEventName();
Map<String, Object> eventProperties = event.getEventProperties();
String organizationId = (String) eventProperties.get(Constants.EVENT_PROP_ORGANIZATION_ID);

if (Constants.EVENT_POST_ADD_ORGANIZATION.equals(eventName)) {
Map<String, Object> eventProperties = event.getEventProperties();
Organization organization = (Organization) eventProperties.get(Constants.EVENT_PROP_ORGANIZATION);
try {
addSharedApplicationsToOrganization(organization);
Expand All @@ -84,10 +84,7 @@ public void handleEvent(Event event) throws IdentityEventException {
}

if (Constants.EVENT_PRE_DELETE_ORGANIZATION.equals(eventName)) {
Map<String, Object> eventProperties = event.getEventProperties();
String organizationId = (String) eventProperties.get(Constants.EVENT_PROP_ORGANIZATION_ID);
try {
handleSharedAppDeletionForPostDeleteOrganization(event);
handleMainApplicationUpdateForPreDeleteOrganization(organizationId);
} catch (IdentityApplicationManagementException | OrganizationManagementException e) {
throw new IdentityEventException("An error occurred while retrieving main applications of " +
Expand All @@ -97,6 +94,7 @@ public void handleEvent(Event event) throws IdentityEventException {

if (Constants.EVENT_POST_DELETE_ORGANIZATION.equals(eventName)) {
try {
handleSharedAppDeletionForPostDeleteOrganization(organizationId);
handleMainApplicationUpdateForPostDeleteOrganization();
} catch (OrganizationManagementException | IdentityApplicationManagementException e) {
throw new IdentityEventException("An error occurred while updating main application based " +
Expand Down Expand Up @@ -164,16 +162,15 @@ private void addSharedApplicationsToOrganization(Organization organization)
/**
* Handle shared application deletion for post delete organization.
*
* @param event Event.
* @param organizationId ID of the organization.
*/
private void handleSharedAppDeletionForPostDeleteOrganization(Event event)
private void handleSharedAppDeletionForPostDeleteOrganization(String organizationId)
throws OrganizationManagementServerException {

String organizationId = (String) event.getEventProperties().get(ORGANIZATION_ID_PROPERTY);
if (StringUtils.isBlank(organizationId)) {
return;
}
getOrgApplicationMgtDAO().deleteSharedAppLink(organizationId);
getOrgApplicationMgtDAO().deleteSharedAppLinks(organizationId);
}


Expand Down Expand Up @@ -223,7 +220,7 @@ private void handleMainApplicationUpdateForPostDeleteOrganization() throws Ident
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(rootTenantDomain, true);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
for (String mainAppId : mainAppIds) {
boolean hasFragmentsApps = getOrgApplicationManager().hasFragmentApps(mainAppId);
boolean hasFragmentsApps = getOrgApplicationManager().hasSharedApps(mainAppId);
// Since the application doesn't have any shared organizations, isAppShared service provider property
// should be set to false.
if (!hasFragmentsApps) {
Expand Down

0 comments on commit 04327bd

Please sign in to comment.