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

Conversation

asha15
Copy link
Contributor

@asha15 asha15 commented Sep 12, 2024

Proposed changes in this pull request

currently we're retrieving the discoverable application only from the reverent tenant. However when it comes to sub organization the application should be fetched against root org and sub organization.

Tested with H2 DB.

When should this PR be merged

[Please describe any preconditions that need to be addressed before we
can merge this pull request.]

Follow up actions

[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly?

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place? There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
  • If this is a new feature or a significant change to an existing feature? has the manual testing spreadsheet been updated with instructions for manual testing?

Security

  • Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • Are all UI and API inputs run through forms or serializers?
  • Are all external inputs validated and sanitized appropriately?
  • Does all branching logic have a default case?
  • Does this solution handle outliers and edge cases gracefully?
  • Are all external communications secured and restricted to SSL?

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 0% with 120 lines in your changes missing coverage. Please review.

Project coverage is 21.05%. Comparing base (647776b) to head (c0fd487).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...y/application/mgt/dao/impl/ApplicationDAOImpl.java 0.00% 99 Missing ⚠️
...ernal/impl/DiscoverableApplicationManagerImpl.java 0.00% 14 Missing ⚠️
...n/identity/application/mgt/ApplicationMgtUtil.java 0.00% 3 Missing ⚠️
...n/identity/application/mgt/dao/ApplicationDAO.java 0.00% 2 Missing ⚠️
...cation/mgt/dao/impl/CacheBackedApplicationDAO.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5934      +/-   ##
============================================
- Coverage     21.07%   21.05%   -0.02%     
  Complexity     5626     5626              
============================================
  Files          1561     1561              
  Lines         99201    99298      +97     
  Branches      15188    15201      +13     
============================================
+ Hits          20904    20905       +1     
- Misses        75276    75374      +98     
+ Partials       3021     3019       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

*
* @param tenantDomain
* @return true if the tenant is a sub org
* @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.

return appDAO.getDiscoverableApplicationBasicInfo(limit, offset, filter, sortOrder, sortBy, tenantDomain);
try {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
if (ApplicationMgtUtil.isSubOrg(tenantDomain)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wny requirement to wrap this OrganizationManagementUtil.isOrganization(tenantDomain) with using an another util function?
Since the OrganizationManagementException is also handled here, we can directly use OrganizationManagementUtil.isOrganization(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.

Comment on lines +281 to +283
default List<ApplicationBasicInfo> getDiscoverableAppsInfoFromRootAndSubOrg(int limit, int offset, String filter,
String sortOrder, String sortBy, String
tenantDomain, String primaryOrgID)
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?

* @param tenantDomain Tenant domain
* @param primaryOrgId Primary organization ID
* @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

Comment on lines +220 to +227
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() {

}
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.

asha15 and others added 7 commits September 15, 2024 20:52
…n.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationMgtUtil.java

Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
…n.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/internal/impl/DiscoverableApplicationManagerImpl.java

Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
Co-authored-by: Anuradha Karunarathna <anuradha199528@gmail.com>
@@ -273,6 +273,19 @@ default List<ApplicationBasicInfo> getDiscoverableApplicationBasicInfo(int limit
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

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);

validateForUnImplementedSortingAttributes(sortOrder, sortBy);
validateAttributesForPagination(offset, limit);

// 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

@asha15
Copy link
Contributor Author

asha15 commented Sep 17, 2024

Closing the PR as the improvement has been moved to wso2-extensions/identity-organization-management#392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants