From 853d095706b2d7bda2f7304cd65a528e0ee780be Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sat, 29 Sep 2018 12:03:11 +0530 Subject: [PATCH] conflict fixes --- .../services/ApplicationStorageManager.java | 2 +- .../application/mgt/core/dao/common/Util.java | 22 +++++++++---------- .../GenericApplicationReleaseDAOImpl.java | 22 +++---------------- .../mgt/core/impl/ApplicationManagerImpl.java | 5 ++--- .../impl/ApplicationStorageManagerImpl.java | 3 ++- 5 files changed, 19 insertions(+), 35 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/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java index 71d414f3c0..a0770582e3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java @@ -52,7 +52,7 @@ public interface ApplicationStorageManager { * @param screenshots Input Streams of screenshots * @throws ResourceManagementException Resource Management Exception. */ - void updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFile, + ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFile, InputStream bannerFile, List screenshots) throws ResourceManagementException, 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/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index 90542d2c58..1722a42070 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -139,17 +139,17 @@ public class Util { application.setDeviceTypeId(rs.getInt("DEVICE_TYPE_ID")); } -// Tag tag = new Tag(); -// tag.setTagName(rs.getString("APP_TAG")); -// UnrestrictedRole unrestrictedRole = new UnrestrictedRole(); -// unrestrictedRole.setRole(rs.getString("ROLE")); -// if (application.getTags() != null && application.getTags().contains(tag)) { -// application.getTags().add(tag); -// } -// if (application.getUnrestrictedRoles() != null && application.getUnrestrictedRoles() -// .contains(unrestrictedRole)) { -// application.getUnrestrictedRoles().add(unrestrictedRole); -// } + Tag tag = new Tag(); + tag.setTagName(rs.getString("APP_TAG")); + UnrestrictedRole unrestrictedRole = new UnrestrictedRole(); + unrestrictedRole.setRole(rs.getString("ROLE")); + if (application.getTags() != null && application.getTags().contains(tag)) { + application.getTags().add(tag); + } + if (application.getUnrestrictedRoles() != null && application.getUnrestrictedRoles() + .contains(unrestrictedRole)) { + application.getUnrestrictedRoles().add(unrestrictedRole); + } iteration++; } } 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/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 6c09f14775..319a7dd049 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -254,8 +254,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE, AR.APP_PRICE," + " AR.STORED_LOCATION, AR.ICON_LOCATION, AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR" + ".SC_2_LOCATION AS SCREEN_SHOT_2, AR.SC_3_LOCATION AS SCREEN_SHOT_3, AR.APP_HASH_VALUE AS HASH_VALUE, " - + "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.CREATED_BY, AR.CREATED_AT, " - + "AR.PUBLISHED_BY, AR.PUBLISHED_AT, AR.STARS, AR.RATING FROM AP_APP_RELEASE AS " + + "AR.SHARED_WITH_ALL_TENANTS AS SHARED, AR.APP_META_INFO, AR.RATING FROM AP_APP_RELEASE AS " + "AR where AR.TENANT_ID = ? AND AR.AP_APP_ID=(SELECT AP_APP_ID" + " FROM AP_APP_LIFECYCLE_STATE WHERE AP_APP_ID = ? AND CURRENT_STATE = ? AND TENANT_ID = ?);"; @@ -269,23 +268,8 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements resultSet = statement.executeQuery(); while (resultSet.next()) { - ApplicationRelease applicationRelease = new ApplicationRelease(); - applicationRelease.setId(resultSet.getInt("RELEASE_ID")); - applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION")); - applicationRelease.setUuid(resultSet.getString("UUID")); - applicationRelease.setReleaseType(resultSet.getString("RELEASE_TYPE")); - applicationRelease.setPrice(resultSet.getDouble("APP_PRICE")); - applicationRelease.setAppStoredLoc(resultSet.getString("STORED_LOCATION")); - applicationRelease.setIconLoc(resultSet.getString("ICON_LOCATION")); - applicationRelease.setBannerLoc(resultSet.getString("BANNER_LOCATION")); - applicationRelease.setScreenshotLoc1(resultSet.getString("SCREEN_SHOT_1")); - applicationRelease.setScreenshotLoc2(resultSet.getString("SCREEN_SHOT_2")); - applicationRelease.setScreenshotLoc3(resultSet.getString("SCREEN_SHOT_3")); - applicationRelease.setAppHashValue(resultSet.getString("HASH_VALUE")); - applicationRelease.setIsSharedWithAllTenants(resultSet.getInt("SHARED")); - applicationRelease.setMetaData(resultSet.getString("APP_META_INFO")); - applicationRelease.setRating(resultSet.getDouble("RATING")); - applicationReleases.add(applicationRelease); + ApplicationRelease appRelease = constructApplicationRelease(resultSet); + applicationReleases.add(appRelease); } return applicationReleases; } catch (DBConnectionException e) { 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 7299146754..fc27224669 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 @@ -733,10 +733,9 @@ public class ApplicationManagerImpl implements ApplicationManager { if (applicationRelease == null) { throw new NotFoundException("No App release associated with the app Id " + appId + "and UUID "+ uuid); } - applicationStorageManager + ApplicationRelease updatedRelease = applicationStorageManager .updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments); - updateRelease(appId, applicationRelease); - return applicationRelease; + return updateRelease(appId, updatedRelease); } finally { ConnectionManagerUtil.closeDBConnection(); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index b8bfdd1ef4..37e17821ce 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -133,7 +133,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public void updateImageArtifacts(ApplicationRelease applicationRelease, InputStream + public ApplicationRelease updateImageArtifacts(ApplicationRelease applicationRelease, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ResourceManagementException { @@ -164,6 +164,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager count++; } } + return applicationRelease; } catch (ApplicationStorageManagementException e) { throw new ApplicationStorageManagementException("Application Storage exception while trying to" + " update the screen-shot count for the application Release " + applicationRelease.getUuid() +