Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve Discoverable Applications info for Sub-Org #392

Merged
merged 10 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.wso2.carbon.identity.organization.management.application;

import org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo;
import org.wso2.carbon.identity.application.common.model.ServiceProvider;
import org.wso2.carbon.identity.organization.management.application.model.SharedApplication;
import org.wso2.carbon.identity.organization.management.service.exception.NotImplementedException;
Expand Down Expand Up @@ -176,4 +177,39 @@ default Map<String, String> getChildAppIds(String parentAppId, String parentOrgI

throw new NotImplementedException("getChildAppIds method is not implemented in " + this.getClass().getName());
}

/**
* Get the discoverable shared application basic info.
*
* @param limit Maximum no of applications to be returned in the result set (optional).
* @param offset Zero based index of the first application to be returned in the result set (optional).
* @param filter Filter to search for applications (optional).
* @param sortOrder Sort order, ascending or descending (optional).
* @param sortBy Attribute to sort from (optional).
* @param tenantDomain Tenant domain.
* @return List of DiscoverableApplicationBasicInfo of applications matching the given criteria.
* @throws OrganizationManagementException If an error occurred when retrieving the discoverable applications.
*/
default List<ApplicationBasicInfo> getDiscoverableSharedApplicationBasicInfo(int limit, int offset, String filter,
String sortOrder,
String sortBy, String tenantDomain)
throws OrganizationManagementException {

return null;
}

/**
* Get the count of discoverable shared applications.
*
* @param filter Filter to search for applications (optional).
* @param tenantDomain Tenant domain.
* @return Count of discoverable applications matching given filter.
* @throws OrganizationManagementException If an error occurred when retrieving the count of
* discoverable applications.
*/
default int getCountOfDiscoverableSharedApplications(String filter, String tenantDomain)
throws OrganizationManagementException {

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants;
import org.wso2.carbon.identity.application.common.IdentityApplicationManagementException;
import org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo;
import org.wso2.carbon.identity.application.common.model.AuthenticationStep;
import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.IdentityProvider;
Expand Down Expand Up @@ -709,6 +710,25 @@ public Map<String, String> getChildAppIds(String parentAppId, String parentOrgId
return Collections.emptyMap();
}

@Override
public List<ApplicationBasicInfo> getDiscoverableSharedApplicationBasicInfo(int limit, int offset, String filter,
String sortOrder, String sortBy,
String tenantDomain)
throws OrganizationManagementException {

String rootOrgId = getOrganizationManager().getPrimaryOrganizationId(tenantDomain);
return getOrgApplicationMgtDAO().getDiscoverableSharedApplicationBasicInfo(limit, offset, filter, sortOrder,
sortBy, tenantDomain, rootOrgId);
}

@Override
public int getCountOfDiscoverableSharedApplications(String filter, String tenantDomain)
throws OrganizationManagementException {

String rootOrgId = getOrganizationManager().getPrimaryOrganizationId(tenantDomain);
return getOrgApplicationMgtDAO().getCountOfDiscoverableSharedApplications(filter, tenantDomain, rootOrgId);
}

/**
* Returns whether the given application is a main application.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,109 @@ public class SQLConstants {
SQLPlaceholders.DB_SCHEMA_COLUMN_NAME_OWNER_ORG_ID + "; AND SHARED_ORG_ID IN (" +
SQLPlaceholders.SHARED_ORG_ID_LIST_PLACEHOLDER + ")";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_MYSQL =
asha15 marked this conversation as resolved.
Show resolved Hide resolved
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') " +
"ORDER BY ID DESC LIMIT ?, ?";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_POSTGRES =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') " +
"ORDER BY ID DESC OFFSET ? LIMIT ?";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_ORACLE =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') " +
"BETWEEN ? AND ? ORDER BY ID DESC";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_MSSQL =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') " +
"ORDER BY ID DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_INFORMIX =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') " +
"ORDER BY ID DESC SKIP ? LIMIT ?";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_AND_APP_NAME_MYSQL =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1') ORDER BY ID DESC LIMIT ?, ?";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_AND_APP_NAME_POSTGRESL =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1') ORDER BY ID DESC OFFSET ? LIMIT ?";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_AND_APP_NAME_ORACLE =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1') BETWEEN ? AND ? ORDER BY ID DESC";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_AND_APP_NAME_MSSQL =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1') ORDER BY ID DESC OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";

public static final String LOAD_DISCOVERABLE_SHARED_APPS_BY_TENANT_AND_APP_NAME_INFORMIX =
"SELECT sa_shared.ID, sa_shared.APP_NAME, sa_shared.DESCRIPTION, sa_shared.UUID, sa_shared.IMAGE_URL, " +
"CASE WHEN sa_shared.ACCESS_URL IS NOT NULL THEN sa_shared.ACCESS_URL ELSE sa_main.ACCESS_URL END AS " +
"ACCESS_URL, sa_shared.USERNAME, sa_shared.USER_STORE, sa_shared.TENANT_ID FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1') ORDER BY ID DESC SKIP ? LIMIT ?";

public static final String LOAD_DISCOVERABLE_SHARED_APP_COUNT_BY_TENANT =
"SELECT COUNT(sa_shared.UUID) FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR sa_shared.IS_DISCOVERABLE = '1') ";

public static final String LOAD_DISCOVERABLE_SHARED_APP_COUNT_BY_APP_NAME_AND_TENANT =
"SELECT COUNT(sa_shared.UUID) FROM SP_SHARED_APP ssa " +
"JOIN SP_APP sa_main ON ssa.MAIN_APP_ID = sa_main.UUID " +
"JOIN SP_APP sa_shared ON ssa.SHARED_APP_ID = sa_shared.UUID WHERE ssa.SHARED_ORG_ID = ? AND " +
"sa_shared.APP_NAME LIKE ? AND ssa.OWNER_ORG_ID = ? AND (sa_main.IS_DISCOVERABLE = '1' OR " +
"sa_shared.IS_DISCOVERABLE = '1')";

private SQLConstants() {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.wso2.carbon.identity.organization.management.application.dao;

import org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo;
import org.wso2.carbon.identity.organization.management.application.model.MainApplicationDO;
import org.wso2.carbon.identity.organization.management.application.model.SharedApplicationDO;
import org.wso2.carbon.identity.organization.management.service.exception.NotImplementedException;
Expand Down Expand Up @@ -138,4 +139,36 @@ default List<SharedApplicationDO> getSharedApplications(String mainAppId, String
throw new NotImplementedException(
"getSharedApplications method is not implemented in " + this.getClass().getName());
}

/**
* Returns the basic information of the discoverable shared applications
*
* @param limit Maximum no of applications to be returned in the result set (optional).
* @param offset Zero based index of the first application to be returned in the result set (optional).
* @param filter Filter to search for applications (optional).
* @param sortOrder Sort order, ascending or descending (optional).
* @param sortBy Attribute to sort from (optional).
* @param tenantDomain Tenant domain.
* @param rootOrgId Root organization ID.
* @return List of DiscoverableApplicationBasicInfo of applications matching the given criteria.
* @throws OrganizationManagementException The server exception is thrown in a failure when retrieving the
* discoverable applications.
*/
List<ApplicationBasicInfo> getDiscoverableSharedApplicationBasicInfo(int limit, int offset, String filter,
String sortOrder, String sortBy,
String tenantDomain, String rootOrgId)
throws OrganizationManagementException;

/**
* Returns the count of discoverable shared applications matching given filter.
*
* @param filter Filter to search for applications (optional).
* @param tenantDomain Tenant domain.
* @param rootOrgId Root organization ID.
* @return Count of discoverable applications matching given filter.
* @throws OrganizationManagementException The server exception is thrown in a failure when retrieving the
* discoverable applications count.
*/
int getCountOfDiscoverableSharedApplications(String filter, String tenantDomain, String rootOrgId)
throws OrganizationManagementException;
}
Loading
Loading