From f130351a1512f1743b8f9ef4278b37f374859446 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Tue, 18 Jun 2019 01:04:28 +0530 Subject: [PATCH] Improve and refactor APPM source --- .../mgt/common/services/ApplicationManager.java | 2 +- .../mgt/core/dao/impl/review/ReviewDAOImpl.java | 9 ++++----- .../mgt/core/impl/ApplicationManagerImpl.java | 2 +- .../internal/ApplicationManagementServiceComponent.java | 2 +- .../management/ApplicationManagementTest.java | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index e40d28e89c..3bbf1762f2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -232,7 +232,7 @@ public interface ApplicationManager { void validateBinaryArtifact(Attachment binaryFile) throws RequestValidatingException; - void addAplicationCategories(List categories) throws ApplicationManagementException; + void addApplicationCategories(List categories) throws ApplicationManagementException; List getRegisteredTags() throws ApplicationManagementException; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java index a06ddfd9c8..e1864ecfbb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java @@ -276,14 +276,14 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { + "AP_APP_REVIEW.USERNAME AS USERNAME, " + "AP_APP_REVIEW.ROOT_PARENT_ID AS ROOT_PARENT_ID, " + "AP_APP_REVIEW.IMMEDIATE_PARENT_ID AS IMMEDIATE_PARENT_ID, " - + "AP_APP_REVIEW.RATING AS RATING " + + "AP_APP_REVIEW.RATING AS RATING, " + "AP_APP_RELEASE.UUID AS UUID, " + "AP_APP_RELEASE.VERSION AS VERSION " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND " + "AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " - + "AP_APP_REVIEW.ACTIVE_REVIEW = true " + + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.TENANT_ID = ? " + "LIMIT ? OFFSET ?"; try (PreparedStatement statement = conn.prepareStatement(sql)) { @@ -331,7 +331,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { + "AP_APP_RELEASE.VERSION AS VERSION " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " - + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID (", + + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID IN (", ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.TENANT_ID = ? " @@ -387,7 +387,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { + "AP_APP_RELEASE.VERSION AS VERSION " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " - + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID (", + + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID IN (", ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.USERNAME = ? AND " @@ -517,7 +517,6 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { for (String uuid : uuids) { ps.setObject(index++, uuid); } - ps.setInt(index++, tenantId); ps.setInt(index, tenantId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index eb4bbf8260..3bd1708a74 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1582,7 +1582,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void addAplicationCategories(List categories) throws ApplicationManagementException { + public void addApplicationCategories(List categories) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.beginDBTransaction(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java index 15810529f9..54a511e573 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -85,7 +85,7 @@ public class ApplicationManagementServiceComponent { ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); applicationManager - .addAplicationCategories(ConfigurationManager.getInstance().getConfiguration().getAppCategories()); + .addApplicationCategories(ConfigurationManager.getInstance().getConfiguration().getAppCategories()); DataHolder.getInstance().setApplicationManager(applicationManager); bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java index 1f002a74b1..04607486a7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/java/org.wso2.carbon.device.application.mgt.core/management/ApplicationManagementTest.java @@ -203,7 +203,7 @@ public class ApplicationManagementTest extends BaseTestCase { categories.add("Test Category"); categories.add("Test Category2"); ApplicationManager manager = new ApplicationManagerImpl(); - manager.addAplicationCategories(categories); + manager.addApplicationCategories(categories); }