Merge branch 'application-mgt-new' into 'application-mgt-new'

Improve and refactor APPM source

See merge request entgra/carbon-device-mgt!137
feature/appm-store/pbac
Dharmakeerthi Lasantha 6 years ago
commit 48c87384f1

@ -232,7 +232,7 @@ public interface ApplicationManager {
void validateBinaryArtifact(Attachment binaryFile) throws RequestValidatingException; void validateBinaryArtifact(Attachment binaryFile) throws RequestValidatingException;
void addAplicationCategories(List<String> categories) throws ApplicationManagementException; void addApplicationCategories(List<String> categories) throws ApplicationManagementException;
List<Tag> getRegisteredTags() throws ApplicationManagementException; List<Tag> getRegisteredTags() throws ApplicationManagementException;

@ -276,14 +276,14 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
+ "AP_APP_REVIEW.USERNAME AS USERNAME, " + "AP_APP_REVIEW.USERNAME AS USERNAME, "
+ "AP_APP_REVIEW.ROOT_PARENT_ID AS ROOT_PARENT_ID, " + "AP_APP_REVIEW.ROOT_PARENT_ID AS ROOT_PARENT_ID, "
+ "AP_APP_REVIEW.IMMEDIATE_PARENT_ID AS IMMEDIATE_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.UUID AS UUID, "
+ "AP_APP_RELEASE.VERSION AS VERSION " + "AP_APP_RELEASE.VERSION AS VERSION "
+ "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " + "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID "
+ "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND " + "WHERE AP_APP_REVIEW.AP_APP_RELEASE_ID = ? AND "
+ "AP_APP_REVIEW.ROOT_PARENT_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 = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
+ "LIMIT ? OFFSET ?"; + "LIMIT ? OFFSET ?";
try (PreparedStatement statement = conn.prepareStatement(sql)) { try (PreparedStatement statement = conn.prepareStatement(sql)) {
@ -331,7 +331,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
+ "AP_APP_RELEASE.VERSION AS VERSION " + "AP_APP_RELEASE.VERSION AS VERSION "
+ "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " + "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 " ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.TENANT_ID = ? " + "AP_APP_REVIEW.TENANT_ID = ? "
@ -387,7 +387,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
+ "AP_APP_RELEASE.VERSION AS VERSION " + "AP_APP_RELEASE.VERSION AS VERSION "
+ "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON " + "FROM AP_APP_REVIEW INNER JOIN AP_APP_RELEASE ON "
+ "AP_APP_REVIEW.AP_APP_RELEASE_ID = AP_APP_RELEASE.ID " + "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 " ") AND AP_APP_REVIEW.ROOT_PARENT_ID = ? AND "
+ "AP_APP_REVIEW.ACTIVE_REVIEW = true AND " + "AP_APP_REVIEW.ACTIVE_REVIEW = true AND "
+ "AP_APP_REVIEW.USERNAME = ? AND " + "AP_APP_REVIEW.USERNAME = ? AND "
@ -517,7 +517,6 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO {
for (String uuid : uuids) { for (String uuid : uuids) {
ps.setObject(index++, uuid); ps.setObject(index++, uuid);
} }
ps.setInt(index++, tenantId);
ps.setInt(index, tenantId); ps.setInt(index, tenantId);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {

@ -1582,7 +1582,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
} }
@Override @Override
public void addAplicationCategories(List<String> categories) throws ApplicationManagementException { public void addApplicationCategories(List<String> categories) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();

@ -85,7 +85,7 @@ public class ApplicationManagementServiceComponent {
ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance();
applicationManager applicationManager
.addAplicationCategories(ConfigurationManager.getInstance().getConfiguration().getAppCategories()); .addApplicationCategories(ConfigurationManager.getInstance().getConfiguration().getAppCategories());
DataHolder.getInstance().setApplicationManager(applicationManager); DataHolder.getInstance().setApplicationManager(applicationManager);
bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null); bundleContext.registerService(ApplicationManager.class.getName(), applicationManager, null);

@ -203,7 +203,7 @@ public class ApplicationManagementTest extends BaseTestCase {
categories.add("Test Category"); categories.add("Test Category");
categories.add("Test Category2"); categories.add("Test Category2");
ApplicationManager manager = new ApplicationManagerImpl(); ApplicationManager manager = new ApplicationManagerImpl();
manager.addAplicationCategories(categories); manager.addApplicationCategories(categories);
} }

Loading…
Cancel
Save