diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java index b7fce45b1a0..26f97f0caf7 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java @@ -961,9 +961,7 @@ public class ApplicationManagerImpl implements ApplicationManager { //Set application categories, tags and unrestricted roles to the application DTO. applicationDTO .setUnrestrictedRoles(visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId)); - applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId)); - applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId)); - applicationDTO.setFavourite(applicationDAO.isFavouriteApp(applicationDTO.getId(), userName, tenantId)); + setApplicationProperties(applicationDTO); if (isFilteringApp(applicationDTO, filter)) { boolean isHideableApp = isHideableApp(applicationDTO.getApplicationReleaseDTOs()); @@ -1586,11 +1584,7 @@ public class ApplicationManagerImpl implements ApplicationManager { return null; } applicationDTO.setApplicationReleaseDTOs(filteredApplicationReleaseDTOs); - - List tags = this.applicationDAO.getAppTags(applicationDTO.getId(), tenantId); - List categories = this.applicationDAO.getAppCategories(applicationDTO.getId(), tenantId); - applicationDTO.setTags(tags); - applicationDTO.setAppCategories(categories); + setApplicationProperties(applicationDTO); List unrestrictedRoles = this.visibilityDAO.getUnrestrictedRoles(applicationDTO.getId(), tenantId); if (!unrestrictedRoles.isEmpty()) { @@ -1630,6 +1624,17 @@ public class ApplicationManagerImpl implements ApplicationManager { } } + /** + * This is useful to set application properties that are mapped in other database tables (I.E: tags and categories) + */ + private void setApplicationProperties(ApplicationDTO applicationDTO) throws ApplicationManagementDAOException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + applicationDTO.setTags(applicationDAO.getAppTags(applicationDTO.getId(), tenantId)); + applicationDTO.setAppCategories(applicationDAO.getAppCategories(applicationDTO.getId(), tenantId)); + applicationDTO.setFavourite(applicationDAO.isFavouriteApp(applicationDTO.getId(), userName, tenantId)); + } + /** * Check whether at least one role is assigned to the given user. *