From a372e424433a0fa12fa92ed65cb157a578cd2a06 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 12 Jul 2019 14:07:08 +0530 Subject: [PATCH] Improve APPM logic --- .../services/ApplicationStorageManager.java | 2 +- .../mgt/core/impl/ApplicationManagerImpl.java | 39 +++++++++++-------- .../impl/ApplicationStorageManagerImpl.java | 2 +- .../mgt/core/impl/AppmDataHandlerImpl.java | 2 +- 4 files changed, 25 insertions(+), 20 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 5e86145584..d2e44b6cfd 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 @@ -88,5 +88,5 @@ public interface ApplicationStorageManager { * @return {@link InputStream} * @throws ApplicationStorageManagementException throws if an error occurs when accessing the file. */ - InputStream getFileSttream(String path) throws ApplicationStorageManagementException; + InputStream getFileStream(String path) throws ApplicationStorageManagementException; } 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 e2647cef16..4536fc9c29 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 @@ -583,12 +583,14 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg, e); } catch (UserStoreException e) { - throw new ApplicationManagementException( - "User-store exception while checking whether the user " + userName + " of tenant " + tenantId - + " has the publisher permission", e); + String msg = "User-store exception while checking whether the user " + userName + " of tenant " + tenantId + + " has the publisher permission"; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { - throw new ApplicationManagementException( - "DAO exception while getting applications for the user " + userName + " of tenant " + tenantId, e); + String msg = "DAO exception while getting applications for the user " + userName + " of tenant " + tenantId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -792,23 +794,26 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.commitDBTransaction(); return applicationRelease; } catch (TransactionManagementException e) { - throw new ApplicationManagementException( - "Error occurred while staring application release creating transaction for application Id: " - + applicationId, e); + String msg = "Error occurred while staring application release creating transaction for application Id: " + + applicationId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (DBConnectionException e) { - throw new ApplicationManagementException( - "Error occurred while adding application release into IoTS app management ApplicationDTO id of the " - + "application release: " + applicationId, e); - + String msg = "Error occurred while adding application release into IoTS app management ApplicationDTO id of" + + " the application release: " + applicationId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException( - "Error occurred while adding new application release lifecycle state to the application release: " - + applicationId, e); + String msg = "Error occurred while adding new application release lifecycle state to the application" + + " release: " + applicationId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException( - "Error occurred while adding new application release for application " + applicationId, e); + String msg = "Error occurred while adding new application release for application " + applicationId; + log.error(msg); + throw new ApplicationManagementException(msg, e); } 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 243fd1bc75..1142a02452 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 @@ -212,7 +212,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public InputStream getFileSttream (String path) throws ApplicationStorageManagementException { + public InputStream getFileStream(String path) throws ApplicationStorageManagementException { String filePath = storagePath + path; try { return StorageManagementUtil.getInputStream(filePath); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java index d480dde109..56d81a4b6c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java @@ -80,7 +80,7 @@ public class AppmDataHandlerImpl implements AppmDataHandler { throw new NotFoundException(msg); } artifactPath = appReleaseHashValue + Constants.FORWARD_SLASH + artifactName; - InputStream inputStream = applicationStorageManager.getFileSttream(artifactPath); + InputStream inputStream = applicationStorageManager.getFileStream(artifactPath); if (inputStream == null) { String msg = "Couldn't file the file in the file system. File path: " + artifactPath; log.error(msg);