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 71d414f3c07..a0770582e3f 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 90542d2c58f..1722a420703 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 6c09f147759..319a7dd0495 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 72991467544..fc27224669e 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 b8bfdd1ef46..37e17821ce4 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() +