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

Get discoverable applciations from root and sub organizations #5934

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ private ApplicationInboundTableColumns() {
}
}

/**
* Grouping of constants related to database SP_SHARED_APP table.
*/
public static class ApplicationSPSharedTableColumns {

public static final String SHARED_IDP_ID = "SHARED_IDP_ID";
public static final String OWNER_ORG_ID = "OWNER_ORG_ID";

private ApplicationSPSharedTableColumns() {

}
Comment on lines +220 to +227
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

}

/**
* Enums for error messages.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java#L1242

Added line #L1242 was not covered by tests
}

/**
* Get the parent organization id of the given organization.
*
* @param tenantDomain
* @return parent organization id
* @throws OrganizationManagementServerException
*/
public static String getParentOrgId(String tenantDomain)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the method name and comments as getPrimaryOrgId / getRootOrgId.
Parent org means the immediate org in up, but primary means the root org the tree.

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java#L1255-L1256

Added lines #L1255 - L1256 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@
return null;
}

/**
* Get discoverable applications from root and sub org.
*
Copy link
Contributor

@SujanSanjula96 SujanSanjula96 Sep 16, 2024

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java#L286

Added line #L286 was not covered by tests
}

/**
* Returns basic application information of the application matching given resource Id if discoverable.
*
Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/ApplicationDAO.java#L343

Added line #L343 was not covered by tests
}

/**
* Method that can be run after updating components related to the service provider. Contains post application
* dependency update tasks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5914

Added line #L5914 was not covered by tests
" 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5919-L5920

Added lines #L5919 - L5920 were not covered by tests

// TODO: 11/5/19 : Enforce a max limit
Copy link
Contributor

@SujanSanjula96 SujanSanjula96 Sep 16, 2024

Choose a reason for hiding this comment

The 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5924

Added line #L5924 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5927

Added line #L5927 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5929

Added line #L5929 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5931-L5932

Added lines #L5931 - L5932 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5934

Added line #L5934 was not covered by tests
new NamedPreparedStatement(connection,
getDBQueryForDiscoverableAppsByName(databaseVendorType))) {
statement.setString(1, tenantDomain);
statement.setString(2, filterResolvedForSQL);
statement.setString(3, primaryOrgID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
statement.setString(3, primaryOrgID);
statement.setString(3, primaryOrgID);

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5936-L5941

Added lines #L5936 - L5941 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5943

Added line #L5943 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5945

Added line #L5945 was not covered by tests
}
}
}
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5949-L5950

Added lines #L5949 - L5950 were not covered by tests
" 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5952

Added line #L5952 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5954

Added line #L5954 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5960

Added line #L5960 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5962-L5963

Added lines #L5962 - L5963 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5965

Added line #L5965 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5967-L5971

Added lines #L5967 - L5971 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5973

Added line #L5973 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5975

Added line #L5975 was not covered by tests
}
}
}
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5979-L5980

Added lines #L5979 - L5980 were not covered by tests
" 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5982

Added line #L5982 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5984

Added line #L5984 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5993

Added line #L5993 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5995

Added line #L5995 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5997

Added line #L5997 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L5999

Added line #L5999 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6001

Added line #L6001 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6003

Added line #L6003 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6006

Added line #L6006 was not covered by tests
"DB. Database driver for " + dbVendorType + "could not be identified or not supported.");
}

@Override
public int getCountOfDiscoverableApplications(String filter, String tenantDomain) throws
IdentityApplicationManagementException {
Expand Down Expand Up @@ -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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6052

Added line #L6052 was not covered by tests
+ 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6057

Added line #L6057 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6060-L6062

Added lines #L6060 - L6062 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6064

Added line #L6064 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6067-L6069

Added lines #L6067 - L6069 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6071

Added line #L6071 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6073

Added line #L6073 was not covered by tests
}
}
}
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6077-L6078

Added lines #L6077 - L6078 were not covered by tests
"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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6080

Added line #L6080 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6082

Added line #L6082 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6089

Added line #L6089 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6091

Added line #L6091 was not covered by tests
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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6094-L6095

Added lines #L6094 - L6095 were not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6097-L6099

Added lines #L6097 - L6099 were not covered by tests
}
}
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6102-L6103

Added lines #L6102 - L6103 were not covered by tests
"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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6105

Added line #L6105 was not covered by tests

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6107

Added line #L6107 was not covered by tests
}

@Override
public ApplicationBasicInfo getDiscoverableApplicationBasicInfoByResourceId(String resourceId, String
tenantDomain) throws IdentityApplicationManagementException {
Expand Down Expand Up @@ -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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6390

Added line #L6390 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6392

Added line #L6392 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6394

Added line #L6394 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6396

Added line #L6396 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6398

Added line #L6398 was not covered by tests
} 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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6400

Added line #L6400 was not covered by tests
}

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

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L6403

Added line #L6403 was not covered by tests
"DB. Database driver for " + dbVendorType + "could not be identified or not supported.");

}

private String getDBVendorSpecificDiscoverableAppRetrievalQuery(String dbVendorType) throws
IdentityApplicationManagementException {

Expand Down
Loading
Loading