-
Notifications
You must be signed in to change notification settings - Fork 541
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
Get discoverable applciations from root and sub organizations #5934
Changes from 4 commits
887d67e
3da0e50
2131144
c0fd487
d8a3354
043197b
31474ff
9325bf3
0a332c5
8b82553
c5cf416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,10 @@ | |
import org.wso2.carbon.identity.core.URLBuilderException; | ||
import org.wso2.carbon.identity.core.util.IdentityTenantUtil; | ||
import org.wso2.carbon.identity.core.util.IdentityUtil; | ||
import org.wso2.carbon.identity.organization.management.service.OrganizationManagerImpl; | ||
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.util.OrganizationManagementUtil; | ||
import org.wso2.carbon.user.api.Tenant; | ||
import org.wso2.carbon.user.api.UserStoreException; | ||
import org.wso2.carbon.user.api.UserStoreManager; | ||
|
@@ -1225,4 +1228,31 @@ | |
|
||
return Boolean.parseBoolean(IdentityUtil.getProperty(TRUSTED_APP_CONSENT_REQUIRED_PROPERTY)); | ||
} | ||
|
||
/** | ||
* check the given tenant is a sub org | ||
asha15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @param tenantDomain | ||
* @return true if the tenant is a sub org | ||
asha15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @throws OrganizationManagementException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Complete the exception description. |
||
*/ | ||
public static boolean isSubOrg(String tenantDomain) | ||
throws OrganizationManagementException { | ||
|
||
return OrganizationManagementUtil.isOrganization(tenantDomain); | ||
Check warning on line 1242 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java#L1242
|
||
} | ||
|
||
/** | ||
* Get the parent organization id of the given organization. | ||
* | ||
* @param tenantDomain | ||
* @return parent organization id | ||
* @throws OrganizationManagementServerException | ||
*/ | ||
public static String getParentOrgId(String tenantDomain) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the method name and comments as getPrimaryOrgId / getRootOrgId. |
||
throws OrganizationManagementServerException { | ||
|
||
OrganizationManagerImpl organizationManager = new OrganizationManagerImpl(); | ||
return organizationManager.getPrimaryOrganizationId(tenantDomain); | ||
Check warning on line 1256 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java#L1255-L1256
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,6 +273,19 @@ | |
return null; | ||
} | ||
|
||
/** | ||
* Get discoverable applications from root and sub org. | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. params are missing in the java doc comment |
||
* @throws IdentityApplicationManagementException Error when obtaining discoverable applications. | ||
*/ | ||
default List<ApplicationBasicInfo> getDiscoverableAppsInfoFromRootAndSubOrg(int limit, int offset, String filter, | ||
String sortOrder, String sortBy, String | ||
tenantDomain, String primaryOrgID) | ||
Comment on lines
+281
to
+283
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this correctly formatted? |
||
throws IdentityApplicationManagementException { | ||
|
||
return null; | ||
Check warning on line 286 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java#L286
|
||
} | ||
|
||
/** | ||
* Returns basic application information of the application matching given resource Id if discoverable. | ||
* | ||
|
@@ -315,6 +328,21 @@ | |
return 0; | ||
} | ||
|
||
/** | ||
* Returns the count of discoverable applications from root and sub org. | ||
* | ||
* @param filter Filter to search for applications (optional). | ||
* @param tenantDomain Tenant domain | ||
* @param primaryOrgId Primary organization ID | ||
asha15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @return Count of discoverable applications. | ||
* @throws IdentityApplicationManagementException | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. complete the exception description |
||
*/ | ||
default int getCountOfDiscoverableAppsFromRootAndSubOrg(String filter, String tenantDomain, String primaryOrgId) | ||
throws IdentityApplicationManagementException { | ||
|
||
return 0; | ||
Check warning on line 343 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java#L343
|
||
} | ||
|
||
/** | ||
* Method that can be run after updating components related to the service provider. Contains post application | ||
* dependency update tasks. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5904,6 +5904,109 @@ | |||||
return Collections.unmodifiableList(applicationBasicInfoList); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public List<ApplicationBasicInfo> getDiscoverableAppsInfoFromRootAndSubOrg(int limit, int offset, String filter, | ||||||
String sortOrder, String sortBy, | ||||||
String tenantDomain, String primaryOrgID) | ||||||
throws IdentityApplicationManagementException { | ||||||
|
||||||
if (log.isDebugEnabled()) { | ||||||
log.debug("Retrieving application basic information of discoverable applications for limit: " + limit + | ||||||
Check warning on line 5914 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5914
|
||||||
" offset: " + offset + " filter: " + filter + " sortOrder: " + sortOrder + " sortBy: " + sortBy + | ||||||
" in tenantDomain: " + tenantDomain); | ||||||
} | ||||||
|
||||||
validateForUnImplementedSortingAttributes(sortOrder, sortBy); | ||||||
validateAttributesForPagination(offset, limit); | ||||||
Check warning on line 5920 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5919-L5920
|
||||||
|
||||||
// TODO: 11/5/19 : Enforce a max limit | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 11/5/19 is a date it seems and shall we update that |
||||||
if (StringUtils.isBlank(filter) || ASTERISK.equals(filter)) { | ||||||
return getDiscoverableAppsInfoFromRootAndSubOrg(limit, offset, tenantDomain, primaryOrgID); | ||||||
Check warning on line 5924 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5924
|
||||||
} | ||||||
|
||||||
String filterResolvedForSQL = resolveSQLFilter(filter); | ||||||
Check warning on line 5927 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5927
|
||||||
|
||||||
List<ApplicationBasicInfo> applicationBasicInfoList = new ArrayList<>(); | ||||||
Check warning on line 5929 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5929
|
||||||
|
||||||
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) { | ||||||
String databaseVendorType = connection.getMetaData().getDatabaseProductName(); | ||||||
Check warning on line 5932 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5931-L5932
|
||||||
|
||||||
try (NamedPreparedStatement statement = | ||||||
Check warning on line 5934 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5934
|
||||||
new NamedPreparedStatement(connection, | ||||||
getDBQueryForDiscoverableAppsByName(databaseVendorType))) { | ||||||
statement.setString(1, tenantDomain); | ||||||
statement.setString(2, filterResolvedForSQL); | ||||||
statement.setString(3, primaryOrgID); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
statement.setInt(4, offset); | ||||||
statement.setInt(5, limit); | ||||||
Check warning on line 5941 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5936-L5941
|
||||||
|
||||||
try (ResultSet resultSet = statement.executeQuery()) { | ||||||
Check warning on line 5943 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5943
|
||||||
while (resultSet.next()) { | ||||||
applicationBasicInfoList.add(buildApplicationBasicInfo(resultSet)); | ||||||
Check warning on line 5945 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5945
|
||||||
} | ||||||
} | ||||||
} | ||||||
} catch (SQLException e) { | ||||||
throw new IdentityApplicationManagementServerException("Error while getting application basic information" + | ||||||
Check warning on line 5950 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5949-L5950
|
||||||
" for discoverable applications in tenantDomain: " + tenantDomain, e); | ||||||
} | ||||||
Check warning on line 5952 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5952
|
||||||
|
||||||
return Collections.unmodifiableList(applicationBasicInfoList); | ||||||
Check warning on line 5954 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5954
|
||||||
} | ||||||
|
||||||
private List<ApplicationBasicInfo> getDiscoverableAppsInfoFromRootAndSubOrg(int limit, int offset, String | ||||||
tenantDomain, String primaryOrgId) throws IdentityApplicationManagementException { | ||||||
|
||||||
List<ApplicationBasicInfo> applicationBasicInfoList = new ArrayList<>(); | ||||||
Check warning on line 5960 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5960
|
||||||
|
||||||
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) { | ||||||
String databaseVendorType = connection.getMetaData().getDatabaseProductName(); | ||||||
Check warning on line 5963 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5962-L5963
|
||||||
|
||||||
try (NamedPreparedStatement statement = | ||||||
Check warning on line 5965 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5965
|
||||||
new NamedPreparedStatement(connection, | ||||||
getVendorSpecificDiscoverableAppsQueryForRootAndSubOrg(databaseVendorType))) { | ||||||
statement.setString(1, tenantDomain); | ||||||
statement.setString(2, primaryOrgId); | ||||||
statement.setInt(3, offset); | ||||||
statement.setInt(4, limit); | ||||||
Check warning on line 5971 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5967-L5971
|
||||||
|
||||||
try (ResultSet resultSet = statement.executeQuery()) { | ||||||
Check warning on line 5973 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5973
|
||||||
while (resultSet.next()) { | ||||||
applicationBasicInfoList.add(buildApplicationBasicInfo(resultSet)); | ||||||
Check warning on line 5975 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5975
|
||||||
} | ||||||
} | ||||||
} | ||||||
} catch (SQLException e) { | ||||||
throw new IdentityApplicationManagementServerException("Error while getting application basic information" + | ||||||
Check warning on line 5980 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5979-L5980
|
||||||
" for discoverable applications in tenantDomain: " + tenantDomain, e); | ||||||
} | ||||||
Check warning on line 5982 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5982
|
||||||
|
||||||
return Collections.unmodifiableList(applicationBasicInfoList); | ||||||
Check warning on line 5984 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5984
|
||||||
} | ||||||
|
||||||
private String getVendorSpecificDiscoverableAppsQueryForRootAndSubOrg(String dbVendorType) throws | ||||||
IdentityApplicationManagementException { | ||||||
|
||||||
if ("MySQL".equals(dbVendorType) | ||||||
|| "MariaDB".equals(dbVendorType) | ||||||
|| "H2".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_MYSQL; | ||||||
Check warning on line 5993 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5993
|
||||||
} else if ("Oracle".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_ORACLE; | ||||||
Check warning on line 5995 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5995
|
||||||
} else if ("Microsoft SQL Server".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_MSSQL; | ||||||
Check warning on line 5997 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5997
|
||||||
} else if ("PostgreSQL".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_POSTGRES; | ||||||
Check warning on line 5999 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5999
|
||||||
} else if (dbVendorType != null && dbVendorType.contains("DB2")) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_DB2; | ||||||
Check warning on line 6001 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6001
|
||||||
} else if ("INFORMIX".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_INFORMIX; | ||||||
Check warning on line 6003 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6003
|
||||||
} | ||||||
|
||||||
throw new IdentityApplicationManagementException("Error while loading discoverable applications from " + | ||||||
Check warning on line 6006 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6006
|
||||||
"DB. Database driver for " + dbVendorType + "could not be identified or not supported."); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public int getCountOfDiscoverableApplications(String filter, String tenantDomain) throws | ||||||
IdentityApplicationManagementException { | ||||||
|
@@ -5941,6 +6044,69 @@ | |||||
return count; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public int getCountOfDiscoverableAppsFromRootAndSubOrg(String filter, String tenantDomain, String primaryOrgId) | ||||||
throws IdentityApplicationManagementException { | ||||||
|
||||||
if (log.isDebugEnabled()) { | ||||||
log.debug("Getting count of discoverable applications matching filter: " + filter + " in tenantDomain: " | ||||||
Check warning on line 6052 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6052
|
||||||
+ tenantDomain); | ||||||
} | ||||||
|
||||||
if (StringUtils.isBlank(filter) || ASTERISK.equals(filter)) { | ||||||
return getCountOfDiscoverableAppsFromRootAndSubOrg(tenantDomain, primaryOrgId); | ||||||
Check warning on line 6057 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6057
|
||||||
} | ||||||
|
||||||
int count = 0; | ||||||
String filterResolvedForSQL = resolveSQLFilter(filter); | ||||||
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) { | ||||||
Check warning on line 6062 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6060-L6062
|
||||||
|
||||||
try (NamedPreparedStatement statement = | ||||||
Check warning on line 6064 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6064
|
||||||
new NamedPreparedStatement(connection, ApplicationMgtDBQueries | ||||||
.LOAD_DISCOVERABLE_APP_COUNT_FROM_ROOT_AND_SUBORG_BY_APP_NAME)) { | ||||||
statement.setString(1, tenantDomain); | ||||||
statement.setString(2, filterResolvedForSQL); | ||||||
statement.setString(3, primaryOrgId); | ||||||
Check warning on line 6069 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6067-L6069
|
||||||
|
||||||
try (ResultSet resultSet = statement.executeQuery()) { | ||||||
Check warning on line 6071 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6071
|
||||||
if (resultSet.next()) { | ||||||
count = resultSet.getInt(1); | ||||||
Check warning on line 6073 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6073
|
||||||
} | ||||||
} | ||||||
} | ||||||
} catch (SQLException e) { | ||||||
throw new IdentityApplicationManagementServerException("Error while getting count of discoverable " + | ||||||
Check warning on line 6078 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6077-L6078
|
||||||
"applications matching filter:" + filter + " in tenantDomain: " + tenantDomain, e); | ||||||
} | ||||||
Check warning on line 6080 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6080
|
||||||
|
||||||
return count; | ||||||
Check warning on line 6082 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6082
|
||||||
} | ||||||
|
||||||
private int getCountOfDiscoverableAppsFromRootAndSubOrg(String tenantDomain, String primaryOrgId) | ||||||
throws IdentityApplicationManagementException { | ||||||
|
||||||
int count; | ||||||
try (Connection connection = IdentityDatabaseUtil.getDBConnection(false)) { | ||||||
Check warning on line 6089 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6089
|
||||||
|
||||||
try (NamedPreparedStatement statement = | ||||||
Check warning on line 6091 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6091
|
||||||
new NamedPreparedStatement(connection, | ||||||
ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APP_COUNT_BY_ROOT_AND_SUBORG)) { | ||||||
statement.setString(1, tenantDomain); | ||||||
statement.setString(2, primaryOrgId); | ||||||
Check warning on line 6095 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6094-L6095
|
||||||
|
||||||
try (ResultSet resultSet = statement.executeQuery()) { | ||||||
resultSet.next(); | ||||||
count = resultSet.getInt(1); | ||||||
Check warning on line 6099 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6097-L6099
|
||||||
} | ||||||
} | ||||||
} catch (SQLException e) { | ||||||
throw new IdentityApplicationManagementServerException("Error while getting count of discoverable " + | ||||||
Check warning on line 6103 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6102-L6103
|
||||||
"applications in tenantDomain: " + tenantDomain, e); | ||||||
} | ||||||
Check warning on line 6105 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6105
|
||||||
|
||||||
return count; | ||||||
Check warning on line 6107 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6107
|
||||||
} | ||||||
|
||||||
@Override | ||||||
public ApplicationBasicInfo getDiscoverableApplicationBasicInfoByResourceId(String resourceId, String | ||||||
tenantDomain) throws IdentityApplicationManagementException { | ||||||
|
@@ -6215,6 +6381,30 @@ | |||||
"DB. Database driver for " + dbVendorType + "could not be identified or not supported."); | ||||||
} | ||||||
|
||||||
private String getDBQueryForDiscoverableAppsByName(String dbVendorType) throws | ||||||
IdentityApplicationManagementException { | ||||||
|
||||||
if ("MySQL".equals(dbVendorType) | ||||||
|| "MariaDB".equals(dbVendorType) | ||||||
|| "H2".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_MYSQL; | ||||||
Check warning on line 6390 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6390
|
||||||
} else if ("Oracle".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_ORACLE; | ||||||
Check warning on line 6392 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6392
|
||||||
} else if ("Microsoft SQL Server".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_MSSQL; | ||||||
Check warning on line 6394 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6394
|
||||||
} else if ("PostgreSQL".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_POSTGRES; | ||||||
Check warning on line 6396 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6396
|
||||||
} else if (dbVendorType != null && dbVendorType.contains("DB2")) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_DB2; | ||||||
Check warning on line 6398 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6398
|
||||||
} else if ("INFORMIX".equals(dbVendorType)) { | ||||||
return ApplicationMgtDBQueries.LOAD_DISCOVERABLE_APPS_FROM_ROOT_AND_SUBORG_BY_APP_NAME_INFORMIX; | ||||||
Check warning on line 6400 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6400
|
||||||
} | ||||||
|
||||||
throw new IdentityApplicationManagementException("Error while loading discoverable applications from " + | ||||||
Check warning on line 6403 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java Codecov / codecov/patchcomponents/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6403
|
||||||
"DB. Database driver for " + dbVendorType + "could not be identified or not supported."); | ||||||
|
||||||
} | ||||||
|
||||||
private String getDBVendorSpecificDiscoverableAppRetrievalQuery(String dbVendorType) throws | ||||||
IdentityApplicationManagementException { | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since SP_SHARED_APP table related queries are not managed in framework, it is not recommended to redefine column names of SP_SHARED_APP here.
Hope you can't even use import the constants from other repo due to cyclic dependencies.
Can't we take an approach like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we define the constants in the organization-mgt-core repo and use that instead of moving the logic to the organization management repo?. Was this comment or any other concern lead to move the logic. @asha15
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I restructured the code in a way we don't need this constant anymore. However having SP_SHARED_APP related queries in framework repo will give maintainability issues. that's why we moved it to organization management repo.