From 7907a1c5ffc53908ddedbb731a68f8d0bafaa501 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 5 May 2022 00:44:31 +0530 Subject: [PATCH 01/15] Add tenant whitelabeling api Make whitelabel favion and logo api public Refactor whitelabeling feature in separate classes --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.addons/pom.xml | 2 +- .../io.entgra.application.mgt.api/pom.xml | 2 +- .../io.entgra.application.mgt.common/pom.xml | 2 +- .../common/services/ApplicationManager.java | 2 +- .../services/ApplicationStorageManager.java | 11 + .../wrapper/CustomAppReleaseWrapper.java | 2 +- .../common/wrapper/EntAppReleaseWrapper.java | 2 +- .../wrapper/PublicAppReleaseWrapper.java | 2 +- .../common/wrapper/WebAppReleaseWrapper.java | 2 +- .../io.entgra.application.mgt.core/pom.xml | 2 +- .../mgt/core/config/Artifacts.java | 2 +- .../mgt/core/impl/ApplicationManagerImpl.java | 37 ++- .../impl/ApplicationStorageManagerImpl.java | 32 +- .../core/impl/SPApplicationManagerImpl.java | 5 +- .../core/util/ApplicationManagementUtil.java | 4 +- .../mgt/core/StorageManagementUtilTest.java | 9 +- .../management/ApplicationManagementTest.java | 5 +- .../pom.xml | 2 +- .../ApplicationManagementPublisherAPI.java | 2 +- ...ApplicationManagementPublisherAPIImpl.java | 2 +- .../pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.api/pom.xml | 2 +- .../jaxrs/service/api/MetadataService.java | 1 + .../jaxrs/service/api/WhiteLabelService.java | 289 ++++++++++++++++ .../service/impl/MetadataServiceImpl.java | 25 ++ .../service/impl/WhiteLabelServiceImpl.java | 172 ++++++++++ .../impl/util/RequestValidationUtil.java | 110 ++++++ .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 24 ++ .../src/main/webapp/WEB-INF/cxf-servlet.xml | 2 + .../src/main/webapp/WEB-INF/web.xml | 2 + .../org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../carbon/device}/mgt/common/Base64File.java | 2 +- .../common/exceptions/NotFoundException.java | 35 ++ .../mgt/MetadataManagementService.java | 1 - .../metadata/mgt/WhiteLabelArtifactPath.java | 49 +++ .../common/metadata/mgt/WhiteLabelImage.java | 38 +++ .../mgt/WhiteLabelImageRequestPayload.java | 53 +++ .../mgt/WhiteLabelManagementService.java | 49 +++ .../common/metadata/mgt/WhiteLabelTheme.java | 49 +++ .../mgt/WhiteLabelThemeCreateRequest.java | 49 +++ .../org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../exception/StorageManagementException.java | 32 ++ .../device/mgt/core/common/util/FileUtil.java | 15 +- .../device/mgt/core/common/util/HttpUtil.java | 13 + .../common}/util/StorageManagementUtil.java | 46 +-- .../core/config/DeviceManagementConfig.java | 11 + .../whitelabel/MetaDataConfiguration.java | 18 + .../whitelabel/WhiteLabelConfiguration.java | 28 ++ .../tenant/whitelabel/WhiteLabelImages.java | 49 +++ .../internal/DeviceManagementDataHolder.java | 21 ++ .../DeviceManagementServiceComponent.java | 14 + .../mgt/MetadataManagementServiceImpl.java | 3 +- .../mgt/WhiteLabelManagementServiceImpl.java | 313 ++++++++++++++++++ .../mgt/dao/util/MetadataConstants.java | 22 ++ .../mgt/util/WhiteLabelStorageUtil.java | 162 +++++++++ .../core/util/DeviceMgtTenantMgtListener.java | 6 + .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.common/pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../src/main/resources/conf/mdm-ui-config.xml | 2 + .../repository/conf/mdm-ui-config.xml.j2 | 2 + .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 4 +- 150 files changed, 1852 insertions(+), 178 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java rename components/{application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application => device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device}/mgt/common/Base64File.java (96%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelArtifactPath.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java rename components/{application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core => device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common}/util/StorageManagementUtil.java (67%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/dao/util/MetadataConstants.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml index cec4dcfb01..fe91905214 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml index 471ef03864..5b519b30d4 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml index 6a9eb109dd..46f2116b2b 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index 6df5c58fde..c27ad6278b 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 1cdf1d717f..82eafa0136 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 9e6e0ee3dc..270b13d80e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index 604d3b430f..b0699d43b8 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index 4c1066a271..f4ee8cdd9b 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml index 104da8bfb2..af203bd025 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml @@ -5,7 +5,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 673610f363..9f27c44e1e 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index d72878e226..14b0fe0f36 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml index 5f3bf1396a..d113cfd633 100644 --- a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml @@ -20,7 +20,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.api/pom.xml index c5a06e5afd..4fb755bab0 100644 --- a/components/application-mgt/io.entgra.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.application.mgt.common/pom.xml index 2b0a0f8606..c18db9cdd1 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationManager.java index 82e78096b1..dcc63be3b3 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationManager.java @@ -17,7 +17,7 @@ package io.entgra.application.mgt.common.services; import io.entgra.application.mgt.common.ApplicationType; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.entgra.application.mgt.common.dto.ApplicationDTO; import io.entgra.application.mgt.common.exception.ResourceManagementException; import org.apache.cxf.jaxrs.ext.multipart.Attachment; diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationStorageManager.java index 39be94cc3d..9c8ffb0654 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/services/ApplicationStorageManager.java @@ -22,6 +22,7 @@ import io.entgra.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.application.mgt.common.exception.ApplicationStorageManagementException; import io.entgra.application.mgt.common.exception.RequestValidatingException; import io.entgra.application.mgt.common.exception.ResourceManagementException; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; import java.io.InputStream; import java.util.List; @@ -121,4 +122,14 @@ public interface ApplicationStorageManager { * @throws ApplicationStorageManagementException throws if an error occurs when accessing the file. */ InputStream getFileStream(String deviceType, String tenantDomain) throws ApplicationStorageManagementException; + + /** + * Useful to generate MD5 string of {@link InputStream} + * + * @param inputStream {@link InputStream} + * @return md5 string of provided input stream + * + * @throws StorageManagementException if errors while generating md5 string + */ + String getMD5(InputStream inputStream) throws StorageManagementException; } diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/CustomAppReleaseWrapper.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/CustomAppReleaseWrapper.java index 566e67d5d5..e2d49c5dcb 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/CustomAppReleaseWrapper.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/CustomAppReleaseWrapper.java @@ -16,7 +16,7 @@ */ package io.entgra.application.mgt.common.wrapper; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/EntAppReleaseWrapper.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/EntAppReleaseWrapper.java index 6fdb22dc80..e73f948a1e 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/EntAppReleaseWrapper.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/EntAppReleaseWrapper.java @@ -16,7 +16,7 @@ */ package io.entgra.application.mgt.common.wrapper; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/PublicAppReleaseWrapper.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/PublicAppReleaseWrapper.java index 3fdbdab0b4..011f083753 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/PublicAppReleaseWrapper.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/PublicAppReleaseWrapper.java @@ -16,7 +16,7 @@ */ package io.entgra.application.mgt.common.wrapper; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/WebAppReleaseWrapper.java b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/WebAppReleaseWrapper.java index 3d0a343c74..41fed3a76b 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/WebAppReleaseWrapper.java +++ b/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/wrapper/WebAppReleaseWrapper.java @@ -16,7 +16,7 @@ */ package io.entgra.application.mgt.common.wrapper; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/components/application-mgt/io.entgra.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.application.mgt.core/pom.xml index a29e450988..81b0cd151d 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/config/Artifacts.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/config/Artifacts.java index 8e745c77eb..43721fbe37 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/config/Artifacts.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/config/Artifacts.java @@ -28,7 +28,7 @@ public class Artifacts { private String imageLocation; private String binaryLocation; - @XmlElement(name = "ImageLocation", required = true) + @XmlElement(name = "ImageLocationType", required = true) public String getImageLocation() { return imageLocation; } diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java index b7fce45b1a..58e0ebfc90 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java @@ -17,7 +17,7 @@ package io.entgra.application.mgt.core.impl; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.entgra.application.mgt.core.dao.SPApplicationDAO; import io.entgra.application.mgt.core.util.ApplicationManagementUtil; import org.apache.commons.codec.digest.DigestUtils; @@ -86,7 +86,8 @@ import io.entgra.application.mgt.core.internal.DataHolder; import io.entgra.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.application.mgt.core.util.ConnectionManagerUtil; import io.entgra.application.mgt.core.util.Constants; -import io.entgra.application.mgt.core.util.StorageManagementUtil; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; +import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -600,14 +601,15 @@ public class ApplicationManagerImpl implements ApplicationManager { */ private String generateMD5OfApp(ApplicationArtifact applicationArtifact, byte[] content) throws ApplicationManagementException { try { - String md5OfApp = StorageManagementUtil.getMD5(new ByteArrayInputStream(content)); + ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); + String md5OfApp = applicationStorageManager.getMD5(new ByteArrayInputStream(content)); if (md5OfApp == null) { String msg = "Error occurred while generating md5sum value of " + applicationArtifact.getInstallerName(); log.error(msg); throw new ApplicationManagementException(msg); } return md5OfApp; - } catch( ApplicationStorageManagementException e) { + } catch(StorageManagementException e) { String msg = "Error occurred while generating md5sum value of " + applicationArtifact.getInstallerName(); log.error(msg); throw new ApplicationManagementException(msg, e); @@ -689,7 +691,7 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new ApplicationManagementException(msg); } - String md5OfApp = StorageManagementUtil.getMD5(new ByteArrayInputStream(content)); + String md5OfApp = applicationStorageManager.getMD5(new ByteArrayInputStream(content)); if (md5OfApp == null) { String msg = "Error occurred while md5sum value retrieving process: application UUID " + applicationReleaseDTO.getUuid(); @@ -708,6 +710,11 @@ public class ApplicationManagerImpl implements ApplicationManager { applicationStorageManager .uploadReleaseArtifact(applicationReleaseDTO, deviceType, binaryDuplicate, tenantId); } + } catch (StorageManagementException e) { + String msg = "Error occurred while md5sum value retrieving process: application UUID " + + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); } catch (DBConnectionException e) { String msg = "Error occurred when getting database connection for verifying app release data."; log.error(msg, e); @@ -752,7 +759,7 @@ public class ApplicationManagerImpl implements ApplicationManager { byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream()); try (ByteArrayInputStream binaryClone = new ByteArrayInputStream(content)) { - String md5OfApp = StorageManagementUtil.getMD5(binaryClone); + String md5OfApp = applicationStorageManager.getMD5(binaryClone); if (md5OfApp == null) { String msg = "Error occurred while retrieving md5sum value from the binary file for application " @@ -818,6 +825,11 @@ public class ApplicationManagerImpl implements ApplicationManager { } } } + } catch (StorageManagementException e) { + String msg = "Error occurred while retrieving md5sum value from the binary file for application " + + "release UUID " + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); } catch (IOException e) { String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact .getInstallerName(); @@ -2157,9 +2169,9 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.closeDBConnection(); } } - + public ApplicationRelease changeLifecycleState(ApplicationReleaseDTO applicationReleaseDTO, LifecycleChanger lifecycleChanger) throws ApplicationManagementException { - + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); if (lifecycleChanger == null || StringUtils.isEmpty(lifecycleChanger.getAction())) { @@ -2167,7 +2179,7 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg); throw new BadRequestException(msg); } - + try{ if (lifecycleStateManager .isValidStateChange(applicationReleaseDTO.getCurrentState(), lifecycleChanger.getAction(), userName, @@ -3249,7 +3261,7 @@ public class ApplicationManagerImpl implements ApplicationManager { try { byte[] content = IOUtils.toByteArray(applicationArtifact.getInstallerStream()); try (ByteArrayInputStream binaryClone = new ByteArrayInputStream(content)) { - String md5OfApp = StorageManagementUtil.getMD5(binaryClone); + String md5OfApp = applicationStorageManager.getMD5(binaryClone); if (md5OfApp == null) { String msg = "Error occurred while retrieving md5sum value from the binary file for " + "application release UUID " + applicationReleaseDTO.get().getUuid(); @@ -3295,6 +3307,11 @@ public class ApplicationManagerImpl implements ApplicationManager { } } } + } catch (StorageManagementException e) { + String msg = "Error occurred while retrieving md5sum value from the binary file for " + + "application release UUID " + applicationReleaseDTO.get().getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg); } catch (IOException e) { String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact.getInstallerName(); diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 91e3f4579b..a99d759d46 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. @@ -19,6 +18,7 @@ package io.entgra.application.mgt.core.impl; import com.dd.plist.NSDictionary; import net.dongliu.apk.parser.bean.ApkMeta; +import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -31,12 +31,13 @@ import io.entgra.application.mgt.common.services.ApplicationStorageManager; import io.entgra.application.mgt.core.exception.ParsingException; import io.entgra.application.mgt.core.util.ArtifactsParser; import io.entgra.application.mgt.core.util.Constants; -import io.entgra.application.mgt.core.util.StorageManagementUtil; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; +import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; import java.io.*; import java.util.List; -import static io.entgra.application.mgt.core.util.StorageManagementUtil.saveFile; +import static org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil.saveFile; /** * This class contains the default concrete implementation of ApplicationStorage Management. @@ -112,6 +113,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager + applicationReleaseDTO.getUuid(); log.error(msg, e); throw new ApplicationStorageManagementException(msg, e); + } catch (StorageManagementException e) { + String msg = "Error occurred while uploading image artifacts" + + applicationReleaseDTO.getUuid(); + log.error(msg, e); + throw new ResourceManagementException(msg, e); } } @@ -159,6 +165,11 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager + applicationReleaseDTO.getUuid(); log.error(msg, e); throw new ResourceManagementException( msg, e); + } catch (StorageManagementException e) { + String msg = "Error occurred while uploading image artifacts" + + applicationReleaseDTO.getUuid(); + log.error(msg, e); + throw new ResourceManagementException(msg, e); } } @@ -286,4 +297,17 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager throw new ApplicationStorageManagementException(msg); } } + + @Override + public String getMD5(InputStream inputStream) throws StorageManagementException { + String md5; + try { + md5 = DigestUtils.md5Hex(inputStream); + } catch (IOException e) { + String msg = "IO Exception occurred while trying to get the md5sum value of application"; + log.error(msg, e); + throw new StorageManagementException(msg, e); + } + return md5; + } } diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/SPApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/SPApplicationManagerImpl.java index 8382f428b5..bd0afe85a6 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/SPApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/SPApplicationManagerImpl.java @@ -49,6 +49,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.validator.routines.UrlValidator; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.common.util.HttpUtil; import java.util.ArrayList; import java.util.List; @@ -327,9 +328,7 @@ public class SPApplicationManagerImpl implements SPApplicationManager { * @throws BadRequestException if url is invalid */ private void validateIdentityServerUrl(String url) throws BadRequestException { - String[] schemes = {"http","https"}; - UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS); - if (!urlValidator.isValid(url)) { + if (!HttpUtil.isHttpUrlValid(url)) { String msg = "Identity server url is not a valid url"; log.error(msg); throw new BadRequestException(msg); diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/ApplicationManagementUtil.java index f0ef6c4b29..bb7d65eced 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/ApplicationManagementUtil.java @@ -18,13 +18,11 @@ package io.entgra.application.mgt.core.util; import io.entgra.application.mgt.common.ApplicationArtifact; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.entgra.application.mgt.common.FileDataHolder; import io.entgra.application.mgt.common.dto.ApplicationDTO; -import io.entgra.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.application.mgt.common.exception.ApplicationManagementException; import io.entgra.application.mgt.common.exception.RequestValidatingException; -import io.entgra.application.mgt.common.exception.ResourceManagementException; import io.entgra.application.mgt.common.services.SPApplicationManager; import io.entgra.application.mgt.common.wrapper.ApplicationWrapper; import io.entgra.application.mgt.common.wrapper.CustomAppReleaseWrapper; diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/StorageManagementUtilTest.java b/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/StorageManagementUtilTest.java index 08644a5fab..afbe689b97 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/StorageManagementUtilTest.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/StorageManagementUtilTest.java @@ -23,7 +23,8 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import io.entgra.application.mgt.common.exception.ResourceManagementException; -import io.entgra.application.mgt.core.util.StorageManagementUtil; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; +import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; import java.io.File; import java.io.FileInputStream; @@ -47,14 +48,14 @@ public class StorageManagementUtilTest { public void testCreateArtifactDirectory() { try { StorageManagementUtil.createArtifactDirectory(TEMP_FOLDER); - } catch (ResourceManagementException e) { + } catch (StorageManagementException e) { e.printStackTrace(); Assert.fail("Directory creation failed."); } } @Test - public void testSaveFile() throws IOException, ResourceManagementException { + public void testSaveFile() throws IOException, ResourceManagementException, StorageManagementException { StorageManagementUtil.createArtifactDirectory(TEMP_FOLDER); InputStream apk = new FileInputStream(APK_FILE); StorageManagementUtil.saveFile(apk, TEMP_FOLDER + APK_FILE_NAME); @@ -65,7 +66,7 @@ public class StorageManagementUtilTest { } @AfterMethod - public void deleteFileTest() throws IOException, ResourceManagementException { + public void deleteFileTest() throws IOException, StorageManagementException { File file = new File(TEMP_FOLDER); StorageManagementUtil.delete(file); if (file.exists()) { diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/management/ApplicationManagementTest.java b/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/management/ApplicationManagementTest.java index baccaed999..8ab3915a28 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/management/ApplicationManagementTest.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/test/java/io/entgra/application/mgt/core/management/ApplicationManagementTest.java @@ -42,19 +42,16 @@ import io.entgra.application.mgt.core.impl.ApplicationManagerImpl; import io.entgra.application.mgt.core.internal.DataHolder; import io.entgra.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.Base64File; import org.wso2.carbon.device.mgt.core.common.util.FileUtil; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeVersion; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class ApplicationManagementTest extends BaseTestCase { diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml index 2c15d1522d..e1d4400d79 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java b/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java index 5abce176c6..505285d82d 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/ApplicationManagementPublisherAPI.java @@ -17,7 +17,7 @@ */ package io.entgra.application.mgt.publisher.api.services; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java index 078af292d9..04b4b50771 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/src/main/java/io/entgra/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java @@ -18,7 +18,7 @@ package io.entgra.application.mgt.publisher.api.services.impl; import io.entgra.application.mgt.common.ApplicationArtifact; import io.entgra.application.mgt.common.ApplicationList; -import io.entgra.application.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.Base64File; import io.entgra.application.mgt.common.Filter; import io.entgra.application.mgt.common.LifecycleChanger; import io.entgra.application.mgt.common.exception.ResourceManagementException; diff --git a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml index 362f84188a..4adb35bdf3 100644 --- a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index c24bb9ee77..6215076220 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index c8ef6490f3..7f468c0d95 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index 492567040a..c0228dd450 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index 499770d3f3..ab7d21fe47 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -38,7 +38,7 @@ org.wso2.carbon.devicemgt certificate-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index d17941ce53..d5816dac40 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index f531a7985d..5488bf8a1a 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index c76a9d0642..15904f573b 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 24fc4c8325..779b6f0dc8 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index ed0615a965..c8c38d83b2 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 30c92b6283..4657158241 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 780f4308e1..867a524d3c 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index 110c755d04..e1645847c7 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index ae70a2d2ed..74a8f7cd34 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 6aea2a873a..1bb61cc59a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/MetadataService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/MetadataService.java index 446944729b..55aeafeec0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/MetadataService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/MetadataService.java @@ -33,6 +33,7 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java new file mode 100644 index 0000000000..647e894521 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java @@ -0,0 +1,289 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.jaxrs.service.api; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; +import io.swagger.annotations.ResponseHeader; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; +import org.apache.axis2.transport.http.HTTPConstants; +import org.wso2.carbon.apimgt.annotations.api.Scope; +import org.wso2.carbon.apimgt.annotations.api.Scopes; +import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; +import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; +import org.wso2.carbon.device.mgt.jaxrs.util.Constants; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +/** + * Metadata related REST-API implementation. + */ +@SwaggerDefinition( + info = @Info( + version = "1.0.0", + title = "Whitelabel Service", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = "name", value = "WhiteLabelManagement"), + @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/whitelabel"), + }) + } + ), + tags = { + @Tag(name = "device_management") + } +) +@Scopes( + scopes = { + @Scope( + name = "View Whitelabel", + description = "View whitelabel details", + key = "perm:whitelabel:view", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/whitelabel/view"} + ), + @Scope( + name = "Update Whitelabel", + description = "Updating whitelabel", + key = "perm:whitelabel:update", + roles = {"Internal/devicemgt-user"}, + permissions = {"/device-mgt/whitelabel/update"} + ), + } +) +@Api(value = "Whitelabel Management") +@Path("/whitelabel") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface WhiteLabelService { + + @GET + @Path("/favicon") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation( + produces = MediaType.APPLICATION_OCTET_STREAM, + httpMethod = HTTPConstants.HEADER_GET, + value = "Get whitelabel favicon", + notes = "Get whitelabel favicon for the tenant of the logged in user", + tags = "Tenant Metadata Management" + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved white label favicon.", + response = Metadata.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while getting white label artifact.", + response = ErrorResponse.class) + }) + Response getWhiteLabelFavicon(); + + @GET + @Path("/logo") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation( + produces = MediaType.APPLICATION_OCTET_STREAM, + httpMethod = HTTPConstants.HEADER_GET, + value = "Get whitelabel logo", + notes = "Get whitelabel logo for the tenant of the logged in user", + tags = "Tenant Metadata Management" + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved white label logo.", + response = Metadata.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while getting white label artifact.", + response = ErrorResponse.class) + }) + Response getWhiteLabelLogo(); + + @PUT + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Create whitelabel for tenant", + notes = "Create whitelabel for the tenant of the logged in user", + tags = "Tenant Metadata Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully created white label theme.", + response = Metadata.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while creating white label theme.", + response = ErrorResponse.class) + }) + Response createWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest); + + @GET + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Get whitelabel for tenant", + notes = "Get whitelabel for the tenant of the logged in user", + tags = "Tenant Metadata Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:view") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched white label theme.", + response = Metadata.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while fetching white label theme.", + response = ErrorResponse.class) + }) + Response getWhiteLabelTheme(); + + @PUT + @Path("/reset") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HTTPConstants.HEADER_POST, + value = "Reset whitelabel for tenant", + notes = "Reset whitelabel to default for the tenant of the logged in user", + tags = "Tenant Metadata Management", + extensions = { + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:whitelabel:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched white label theme.", + response = Metadata.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource was last modified.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 500, + message = "Internal Server Error. " + + "\n Server error occurred while deleting white label theme.", + response = ErrorResponse.class) + }) + Response resetWhiteLabel(); +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java index 5a484bfa0c..64d182bf67 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/MetadataServiceImpl.java @@ -18,20 +18,27 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.PaginationRequest; import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; import org.wso2.carbon.device.mgt.jaxrs.service.api.MetadataService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.List; import javax.ws.rs.Consumes; @@ -147,4 +154,22 @@ public class MetadataServiceImpl implements MetadataService { } } + /** + * Useful to send files as application/octet-stream responses + */ + private Response sendFileStream(byte[] content) throws IOException { + try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { + Response.ResponseBuilder response = Response + .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); + response.status(Response.Status.OK); +// response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + response.header("Content-Length", content.length); + return response.build(); + } catch (IOException e) { + String msg = "Error occurred while creating input stream from buffer array. "; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java new file mode 100644 index 0000000000..bdc4c748f8 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.jaxrs.service.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; +import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; +import org.wso2.carbon.device.mgt.jaxrs.service.api.MetadataService; +import org.wso2.carbon.device.mgt.jaxrs.service.api.WhiteLabelService; +import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; +import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.List; + +/** + * This is the service class for metadata management. + */ +@Path("/whitelabel") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class WhiteLabelServiceImpl implements WhiteLabelService { + + private static final Log log = LogFactory.getLog(WhiteLabelServiceImpl.class); + + @GET + @Override + @Path("/favicon") + public Response getWhiteLabelFavicon() { + try { + byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(); + return sendFileStream(fileContent); + } catch (NotFoundException e) { + String msg = "Couldn't find such a whitelabel artifact."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating whitelabel for tenant"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (IOException e) { + String msg = "Error occurred while getting the byte array of the artifact file. "; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @GET + @Override + @Path("/logo") + public Response getWhiteLabelLogo() { + try { + byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(); + return sendFileStream(fileContent); + } catch (NotFoundException e) { + String msg = "Couldn't find such a whitelabel artifact."; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating whitelabel for tenant"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (IOException e) { + String msg = "Error occurred while getting the byte array of the artifact file. "; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @PUT + @Override + public Response createWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { + RequestValidationUtil.validateWhiteLabelTheme(whiteLabelThemeCreateRequest); + try { + WhiteLabelTheme createdWhiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().updateWhiteLabelTheme(whiteLabelThemeCreateRequest); + return Response.status(Response.Status.CREATED).entity(createdWhiteLabelTheme).build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while creating whitelabel for tenant"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @GET + @Override + public Response getWhiteLabelTheme() { + try { + WhiteLabelTheme whiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelTheme(); + return Response.status(Response.Status.CREATED).entity(whiteLabelTheme).build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while deleting whitelabel for tenant"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } catch (NotFoundException e) { + String msg = "Not white label theme configured for this tenant"; + log.error(msg, e); + return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); + } + } + + @PUT + @Override + @Path("/reset") + public Response resetWhiteLabel() { + try { + DeviceMgtAPIUtils.getWhiteLabelManagementService().resetToDefaultWhiteLabelTheme(); + return Response.status(Response.Status.CREATED).entity("White label theme deleted successfully.").build(); + } catch (MetadataManagementException e) { + String msg = "Error occurred while resetting whitelabel for tenant"; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + /** + * Useful to send files as application/octet-stream responses + */ + private Response sendFileStream(byte[] content) throws IOException { + try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { + Response.ResponseBuilder response = Response + .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); + response.status(Response.Status.OK); +// response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + response.header("Content-Length", content.length); + return response.build(); + } catch (IOException e) { + String msg = "Error occurred while creating input stream from buffer array. "; + log.error(msg, e); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 1308dfa970..d71373c2df 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -18,10 +18,14 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.impl.util; +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.EnumUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; +import org.wso2.carbon.device.mgt.common.Base64File; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.FeatureManager; @@ -31,8 +35,12 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImage; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayload; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; +import org.wso2.carbon.device.mgt.core.common.util.HttpUtil; import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; @@ -654,6 +662,108 @@ public class RequestValidationUtil { } } + public static void validateWhiteLabelArtifactDownloadRequest(String whiteLabelImage) { + if (!EnumUtils.isValidEnum(WhiteLabelImage.ImageName.class, whiteLabelImage)) { + String msg = "Invalid white label image requested. Image: " + whiteLabelImage; + log.error(msg); + throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST) + .setMessage(msg).build()); + + } + } + + public static void validateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { + if (whiteLabelThemeCreateRequest.getFavicon() == null) { + String msg = "Favicon is required to whitelabel"; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + if (whiteLabelThemeCreateRequest.getLogo() == null) { + String msg = "Logo is required to whitelabel"; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + if (whiteLabelThemeCreateRequest.getFooterText() == null) { + String msg = "Footer text is required to whitelabel"; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + try { + validateWhiteLabelImage(whiteLabelThemeCreateRequest.getFavicon()); + validateWhiteLabelImage(whiteLabelThemeCreateRequest.getLogo()); + } catch (InputValidationException e) { + String msg = "Payload contains invalid base64 files"; + log.error(msg); + throw e; + } + } + + /** + * Validate if {@link WhiteLabelImageRequestPayload} contains mandatory fields. + */ + private static void validateWhiteLabelImage(WhiteLabelImageRequestPayload whiteLabelImage) { + if (whiteLabelImage.getImageType() == null) { + String msg = "Invalid payload found with the request. White label imageType cannot be null."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.BASE64) { + try { + Base64File image = new Gson().fromJson(whiteLabelImage.getImage(), Base64File.class); + validateBase64File(image); + } catch (JsonSyntaxException e) { + String msg = "Invalid image payload found with the request. Image object does not represent a Base64 File. " + + "Hence verify the request payload object."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + return; + } + if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.URL) { + try { + String imageUrl = new Gson().fromJson(whiteLabelImage.getImage(), String.class); + if (!HttpUtil.isHttpUrlValid(imageUrl)) { + String msg = "Invalid image url provided for white label image."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + } catch (JsonSyntaxException e) { + String msg = "Invalid payload found with the request. Hence verify the request payload object."; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + } + } + + /** + * Validate if {@link Base64File} contains mandatory fields. + */ + private static void validateBase64File(Base64File base64File) { + if (base64File.getBase64String() == null || base64File.getName() == null) { + String msg = "Base64File doesn't contain required properties. name and base64String properties " + + "are required fields for base64file type"; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } + } + /** * Validate if the metaData and metaKey values are non empty & in proper format. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index 8861833f5a..c14649b334 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -74,6 +74,7 @@ import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.report.mgt.ReportManagementService; @@ -173,6 +174,7 @@ public class DeviceMgtAPIUtils { // private static IntegrationClientService integrationClientService; private static MetadataManagementService metadataManagementService; + private static WhiteLabelManagementService whiteLabelManagementService; private static OTPManagementService otpManagementService; private static volatile SubscriptionManager subscriptionManager; @@ -510,6 +512,28 @@ public class DeviceMgtAPIUtils { return notificationManagementService; } + /** + * Initializing and accessing method for WhiteLabelManagementService. + * + * @return WhiteLabelManagementService instance + * @throws IllegalStateException if whiteLabelManagementService cannot be initialized + */ + public static WhiteLabelManagementService getWhiteLabelManagementService() { + if (whiteLabelManagementService == null) { + synchronized (DeviceMgtAPIUtils.class) { + if (whiteLabelManagementService == null) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + whiteLabelManagementService = (WhiteLabelManagementService) ctx.getOSGiService( + WhiteLabelManagementService.class, null); + if (whiteLabelManagementService == null) { + throw new IllegalStateException("Metadata Management service not initialized."); + } + } + } + } + return whiteLabelManagementService; + } + /** * Initializing and accessing method for MetadataManagementService. * diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index efce569c42..9db350e267 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -49,6 +49,7 @@ + @@ -99,6 +100,7 @@ + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml index fffbfbdb24..f5282af6a8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml @@ -49,6 +49,8 @@ nonSecuredEndPoints /api/device-mgt/v1.0/users/validate + /api/device-mgt/v1.0/whitelabel/favicon + /api/device-mgt/v1.0/whitelabel/logo diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 8c83847a2a..0a8dde45f3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/Base64File.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Base64File.java similarity index 96% rename from components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/Base64File.java rename to components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Base64File.java index ef1f1d3204..0ec7e800d9 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/src/main/java/io/entgra/application/mgt/common/Base64File.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Base64File.java @@ -16,7 +16,7 @@ * under the License. */ -package io.entgra.application.mgt.common; +package org.wso2.carbon.device.mgt.common; public class Base64File { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java new file mode 100644 index 0000000000..2e59a81bbe --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java @@ -0,0 +1,35 @@ +package org.wso2.carbon.device.mgt.common.exceptions; + + +/* + * Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * This exception will be thrown when the requested application or platform not found. + */ +public class NotFoundException extends Exception { + + public NotFoundException(String message, Throwable throwable) { + super(message, throwable); + } + + public NotFoundException(String message) { + super(message); + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/MetadataManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/MetadataManagementService.java index 060492f620..4765fc047d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/MetadataManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/MetadataManagementService.java @@ -23,7 +23,6 @@ import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; - import java.util.List; /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelArtifactPath.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelArtifactPath.java new file mode 100644 index 0000000000..7cf6368808 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelArtifactPath.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +public class WhiteLabelArtifactPath { + private String faviconPath; + private String logoPath; + + public WhiteLabelArtifactPath() { + + } + + public WhiteLabelArtifactPath(String faviconPath, String logoPath) { + this.faviconPath = faviconPath; + this.logoPath = logoPath; + } + + public String getFaviconPath() { + return faviconPath; + } + + public void setFaviconPath(String faviconPath) { + this.faviconPath = faviconPath; + } + + public String getLogoPath() { + return logoPath; + } + + public void setLogoPath(String logoPath) { + this.logoPath = logoPath; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java new file mode 100644 index 0000000000..70003b6e60 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java @@ -0,0 +1,38 @@ +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +public class WhiteLabelImage { + private ImageLocationType imageLocationType; + private String imageLocation; + + public ImageLocationType getImageLocationType() { + return imageLocationType; + } + + public void setImageLocationType(ImageLocationType imageLocationType) { + this.imageLocationType = imageLocationType; + } + + public String getImageLocation() { + return imageLocation; + } + + public void setImageLocation(String imageLocation) { + this.imageLocation = imageLocation; + } + + public enum ImageName { + FAVICON, + LOGO; + + @Override + public String toString() { + return name().toLowerCase(); + } + } + + public enum ImageLocationType { + URL, + CUSTOM_FILE, + DEFAULT_FILE + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java new file mode 100644 index 0000000000..718c9a7924 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java @@ -0,0 +1,53 @@ +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import org.wso2.carbon.device.mgt.common.Base64File; + +public class WhiteLabelImageRequestPayload { + private ImageType imageType; + private JsonElement image; + + public ImageType getImageType() { + return imageType; + } + + public void setImageType(ImageType imageType) { + this.imageType = imageType; + } + + public JsonElement getImage() { + return image; + } + + public Base64File getImageAsBase64File() { + if (imageType != ImageType.BASE64) { + throw new IllegalStateException("Cannot convert image with Image type of " + imageType + " to base64."); + } + return new Gson().fromJson(image, Base64File.class); + } + + public String getImageAsUrl() { + if (imageType != ImageType.URL) { + throw new IllegalStateException("Cannot convert image with Image type of " + imageType + " to image url string."); + } + return new Gson().fromJson(image, String.class); + } + + public void setImage(JsonElement image) { + this.image = image; + } + + public enum ImageType { + URL, + BASE64; + + public WhiteLabelImage.ImageLocationType getDTOImageLocationType() { + if (this == URL) { + return WhiteLabelImage.ImageLocationType.URL; + } + return WhiteLabelImage.ImageLocationType.CUSTOM_FILE; + } + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java new file mode 100644 index 0000000000..649ad471c7 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; + +import java.io.IOException; +import java.util.List; + +/** + * Defines the contract of MetadataManagementService. + */ +public interface WhiteLabelManagementService { + + byte[] getWhiteLabelFavicon() throws + MetadataManagementException, NotFoundException, IOException; + byte[] getWhiteLabelLogo() throws + MetadataManagementException, NotFoundException, IOException; + + void addDefaultWhiteLabelThemeIfNotExist() throws MetadataManagementException; + + void resetToDefaultWhiteLabelTheme() throws MetadataManagementException; + + WhiteLabelTheme updateWhiteLabelTheme(WhiteLabelThemeCreateRequest createWhiteLabelTheme) + throws MetadataManagementException; + + WhiteLabelTheme getWhiteLabelTheme() throws MetadataManagementException, NotFoundException; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java new file mode 100644 index 0000000000..6eaa8b4d05 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +public class WhiteLabelTheme { + private WhiteLabelImage faviconImage; + private WhiteLabelImage logoImage; + private String footerText; + + public String getFooterText() { + return footerText; + } + + public void setFooterText(String footerText) { + this.footerText = footerText; + } + + public WhiteLabelImage getFaviconImage() { + return faviconImage; + } + + public void setFaviconImage(WhiteLabelImage faviconImage) { + this.faviconImage = faviconImage; + } + + public WhiteLabelImage getLogoImage() { + return logoImage; + } + + public void setLogoImage(WhiteLabelImage logoImage) { + this.logoImage = logoImage; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java new file mode 100644 index 0000000000..5e5e6f0d32 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.common.metadata.mgt; + +public class WhiteLabelThemeCreateRequest { + private WhiteLabelImageRequestPayload favicon; + private WhiteLabelImageRequestPayload logo; + private String footerText; + + public WhiteLabelImageRequestPayload getFavicon() { + return favicon; + } + + public void setFavicon(WhiteLabelImageRequestPayload favicon) { + this.favicon = favicon; + } + + public WhiteLabelImageRequestPayload getLogo() { + return logo; + } + + public void setLogo(WhiteLabelImageRequestPayload logo) { + this.logo = logo; + } + + public String getFooterText() { + return footerText; + } + + public void setFooterText(String footerText) { + this.footerText = footerText; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 2c7bb44969..8007415ca7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java new file mode 100644 index 0000000000..dada3c2818 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/exception/StorageManagementException.java @@ -0,0 +1,32 @@ +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.common.exception; + +/** + * Represents the exception thrown during storing and retrieving the artifacts. + */ +public class StorageManagementException extends Exception { + public StorageManagementException(String message, Throwable ex) { + super(message, ex); + } + + public StorageManagementException(String message) { + super(message); + } +} + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java index 9626c8198f..60d1538af9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java @@ -19,6 +19,8 @@ package org.wso2.carbon.device.mgt.core.common.util; import org.apache.commons.io.FileUtils; +import org.wso2.carbon.device.mgt.common.Base64File; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -54,7 +56,7 @@ public class FileUtil { } /** - * Useful to convert input stream to base64 string + * Useful to convert file to base64 string * * @param file stream to be converted * @return base64 string of the provided input stream @@ -64,6 +66,17 @@ public class FileUtil { return Base64.getEncoder().encodeToString(fileContent); } + /** + * Useful to convert {@link File} to {@link Base64File} + * + * @param file to be converted + * @return {@link Base64File} of the provided input stream + */ + public static Base64File fileToBase64File(File file) throws IOException { + String base64String = fileToBase64String(file); + return new Base64File(file.getName(), base64String); + } + /** * This generates file name with a suffix depending on the duplicate name count, useful when saving * files with the same name diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/HttpUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/HttpUtil.java index afd8ad5f44..84b895be37 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/HttpUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/HttpUtil.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.core.common.util; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; +import org.apache.commons.validator.routines.UrlValidator; import org.apache.http.HttpResponse; import org.apache.http.entity.ContentType; import org.apache.http.util.EntityUtils; @@ -234,4 +235,16 @@ public class HttpUtil { ContentType contentType = ContentType.getOrDefault(response.getEntity()); return contentType.getMimeType(); } + + /** + * Validate http url (For example make sure it uses http/https protocol) + * + * @param url url to be checked if valid + * @return if provided http url is valid + */ + public static boolean isHttpUrlValid(String url) { + String[] schemes = {"http","https"}; + UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_LOCAL_URLS); + return urlValidator.isValid(url); + } } diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/StorageManagementUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/StorageManagementUtil.java similarity index 67% rename from components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/StorageManagementUtil.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/StorageManagementUtil.java index f0819dbd80..9766a7a393 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/util/StorageManagementUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/StorageManagementUtil.java @@ -16,16 +16,12 @@ * under the License. */ -package io.entgra.application.mgt.core.util; +package org.wso2.carbon.device.mgt.core.common.util; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import io.entgra.application.mgt.common.ImageArtifact; -import io.entgra.application.mgt.common.exception.ApplicationStorageManagementException; -import io.entgra.application.mgt.common.exception.ResourceManagementException; +import org.wso2.carbon.device.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; import java.io.File; import java.io.FileInputStream; @@ -47,14 +43,13 @@ public class StorageManagementUtil { * This method is responsible for creating artifact parent directories in the given path. * * @param artifactDirectoryPath Path for the artifact directory. - * @throws ResourceManagementException Resource Management Exception. */ - public static void createArtifactDirectory(String artifactDirectoryPath) throws ResourceManagementException { + public static void createArtifactDirectory(String artifactDirectoryPath) throws StorageManagementException { File artifactDirectory = new File(artifactDirectoryPath); if (!artifactDirectory.exists() && !artifactDirectory.mkdirs()) { - throw new ResourceManagementException( - "Cannot create directories in the path to save the application related artifacts"); + throw new StorageManagementException( + "Cannot create directories in the path: " + artifactDirectoryPath); } } @@ -103,20 +98,13 @@ public class StorageManagementUtil { } /** - * To create {@link ImageArtifact}. + * To save a bas64 string of a file in a given location. * - * @param imageFile Image File. - * @param imageArtifactPath Path of the image artifact file. - * @return Image Artifact. - * @throws IOException IO Exception. + * @param base64File {@link Base64File} of the file. */ - public static ImageArtifact createImageArtifact(File imageFile, String imageArtifactPath) throws IOException { - ImageArtifact imageArtifact = new ImageArtifact(); - imageArtifact.setName(imageFile.getName()); - imageArtifact.setType(Files.probeContentType(imageFile.toPath())); - byte[] imageBytes = IOUtils.toByteArray(new FileInputStream(imageArtifactPath)); - imageArtifact.setEncodedImage(Base64.encodeBase64URLSafeString(imageBytes)); - return imageArtifact; + public static void saveFile(Base64File base64File, String path) throws IOException { + InputStream inputStream = FileUtil.base64ToInputStream(base64File.getBase64String()); + saveFile(inputStream, path); } /*** @@ -138,16 +126,4 @@ public class StorageManagementUtil { throw new IOException(msg, e); } } - - public static String getMD5(InputStream binaryFile) throws ApplicationStorageManagementException { - String md5; - try { - md5 = DigestUtils.md5Hex(binaryFile); - } catch (IOException e) { - String msg = "IO Exception occurred while trying to get the md5sum value of application"; - log.error(msg, e); - throw new ApplicationStorageManagementException(msg, e); - } - return md5; - } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index ebdfa35bfc..37358e31ca 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -25,6 +25,7 @@ import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguratio import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.GeoFenceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration; +import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration; import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations; @@ -68,6 +69,7 @@ public final class DeviceManagementConfig { private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration; private DefaultRoles defaultRoles; private OperationTimeoutConfiguration operationTimeoutConfiguration; + private MetaDataConfiguration metaDataConfiguration; @XmlElement(name = "ManagementRepository", required = true) public DeviceManagementConfigRepository getDeviceManagementConfigRepository() { @@ -254,5 +256,14 @@ public final class DeviceManagementConfig { public void setOperationTimeoutConfiguration(OperationTimeoutConfiguration operationTimeoutConfiguration) { this.operationTimeoutConfiguration = operationTimeoutConfiguration; } + + @XmlElement(name = "MetaDataConfiguration", required = true) + public MetaDataConfiguration getMetaDataConfiguration() { + return metaDataConfiguration; + } + + public void setMetaDataConfiguration(MetaDataConfiguration metaDataConfiguration) { + this.metaDataConfiguration = metaDataConfiguration; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java new file mode 100644 index 0000000000..859baf1979 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java @@ -0,0 +1,18 @@ +package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "MetaDataConfiguration") +public class MetaDataConfiguration { + private WhiteLabelConfiguration whiteLabelConfiguration; + + @XmlElement(name = "WhiteLabelConfiguration", required = true) + public WhiteLabelConfiguration getWhiteLabelConfiguration() { + return whiteLabelConfiguration; + } + + public void setWhiteLabelConfiguration(WhiteLabelConfiguration whiteLabelConfiguration) { + this.whiteLabelConfiguration = whiteLabelConfiguration; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java new file mode 100644 index 0000000000..0d544bedbf --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java @@ -0,0 +1,28 @@ +package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "WhiteLabelConfiguration") +public class WhiteLabelConfiguration { + private String footerText; + private WhiteLabelImages whiteLabelImages; + + @XmlElement(name = "FooterText", required = true) + public String getFooterText() { + return footerText; + } + + public void setFooterText(String footerText) { + this.footerText = footerText; + } + + @XmlElement(name = "WhiteLabelImages", required = true) + public WhiteLabelImages getWhiteLabelImages() { + return whiteLabelImages; + } + + public void setWhiteLabelImages(WhiteLabelImages whiteLabelImages) { + this.whiteLabelImages = whiteLabelImages; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java new file mode 100644 index 0000000000..4a6039944e --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java @@ -0,0 +1,49 @@ +package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "WhiteLabelImages") +public class WhiteLabelImages { + + private String storagePath; + private String defaultImagesLocation; + private String defaultFaviconName; + private String defaultLogoName; + + @XmlElement(name = "StoragePath", required = true) + public String getStoragePath() { + return storagePath; + } + + public void setStoragePath(String storagePath) { + this.storagePath = storagePath; + } + + @XmlElement(name = "DefaultFaviconName", required = true) + public String getDefaultFaviconName() { + return defaultFaviconName; + } + + public void setDefaultFaviconName(String defaultFaviconName) { + this.defaultFaviconName = defaultFaviconName; + } + + @XmlElement(name = "DefaultLogoName", required = true) + public String getDefaultLogoName() { + return defaultLogoName; + } + + public void setDefaultLogoName(String defaultLogoName) { + this.defaultLogoName = defaultLogoName; + } + + @XmlElement(name = "DefaultImagesLocation", required = true) + public String getDefaultImagesLocation() { + return defaultImagesLocation; + } + + public void setDefaultImagesLocation(String defaultImagesLocation) { + this.defaultImagesLocation = defaultImagesLocation; + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java index 5cb1a1c9ab..e3bf6981b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementDataHolder.java @@ -26,6 +26,8 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization import org.wso2.carbon.device.mgt.common.event.config.EventConfigurationProviderService; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; +import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; import org.wso2.carbon.device.mgt.common.spi.DeviceTypeGeneratorService; import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig; @@ -34,6 +36,7 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManag import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceTypeServiceIdentifier; import org.wso2.carbon.device.mgt.core.geo.task.GeoFenceEventOperationManager; +import org.wso2.carbon.device.mgt.core.metadata.mgt.MetadataManagementServiceImpl; import org.wso2.carbon.device.mgt.core.operation.timeout.task.OperationTimeoutTaskManagerService; import org.wso2.carbon.device.mgt.core.privacy.PrivacyComplianceProvider; import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository; @@ -83,6 +86,8 @@ public class DeviceManagementDataHolder { private GeoFenceEventOperationManager geoFenceEventOperationManager; private ExecutorService eventConfigExecutors; private OperationTimeoutTaskManagerService operationTimeoutTaskManagerService; + private MetadataManagementService metadataManagementService; + private WhiteLabelManagementService whiteLabelManagementService; private final Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap( new HashMap<>()); @@ -349,4 +354,20 @@ public class DeviceManagementDataHolder { OperationTimeoutTaskManagerService operationTimeoutTaskManagerService) { this.operationTimeoutTaskManagerService = operationTimeoutTaskManagerService; } + + public MetadataManagementService getMetadataManagementService() { + return metadataManagementService; + } + + public void setMetadataManagementService(MetadataManagementService metadataManagementService) { + this.metadataManagementService = metadataManagementService; + } + + public WhiteLabelManagementService getWhiteLabelManagementService() { + return whiteLabelManagementService; + } + + public void setWhiteLabelManagementService(WhiteLabelManagementService whiteLabelManagementService) { + this.whiteLabelManagementService = whiteLabelManagementService; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index 4c031163aa..faed94f6d1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementService; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; @@ -58,6 +59,7 @@ import org.wso2.carbon.device.mgt.core.device.details.mgt.impl.DeviceInformation import org.wso2.carbon.device.mgt.core.event.config.EventConfigurationProviderServiceImpl; import org.wso2.carbon.device.mgt.core.geo.service.GeoLocationProviderServiceImpl; import org.wso2.carbon.device.mgt.core.metadata.mgt.MetadataManagementServiceImpl; +import org.wso2.carbon.device.mgt.core.metadata.mgt.WhiteLabelManagementServiceImpl; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.NotificationManagementServiceImpl; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; @@ -349,8 +351,20 @@ public class DeviceManagementServiceComponent { /* Registering Metadata Service */ MetadataManagementService metadataManagementService = new MetadataManagementServiceImpl(); + DeviceManagementDataHolder.getInstance().setMetadataManagementService(metadataManagementService); bundleContext.registerService(MetadataManagementService.class.getName(), metadataManagementService, null); + /* Registering Whitelabel Service */ + WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); + DeviceManagementDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); + try { + whiteLabelManagementService.addDefaultWhiteLabelThemeIfNotExist(); + } catch (Throwable e) { + log.error("Error occurred while adding default tenant white label theme", e); + + } + bundleContext.registerService(WhiteLabelManagementService.class.getName(), whiteLabelManagementService, null); + /* Registering Event Configuration Service */ EventConfigurationProviderService eventConfigurationService = new EventConfigurationProviderServiceImpl(); DeviceManagementDataHolder.getInstance().setEventConfigurationProviderService(eventConfigurationService); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java index 7d7fd1d7c0..2cdf4d7ad4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/MetadataManagementServiceImpl.java @@ -33,7 +33,6 @@ import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataDAO; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; - import java.sql.SQLException; import java.util.List; @@ -44,7 +43,7 @@ public class MetadataManagementServiceImpl implements MetadataManagementService private static final Log log = LogFactory.getLog(MetadataManagementServiceImpl.class); - private MetadataDAO metadataDAO; + private final MetadataDAO metadataDAO; public MetadataManagementServiceImpl() { this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java new file mode 100644 index 0000000000..8646168824 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.metadata.mgt; + +import com.google.gson.Gson; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; +import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; +import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImage; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayload; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; +import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.WhiteLabelConfiguration; +import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; +import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataDAO; +import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; +import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.util.MetadataConstants; +import org.wso2.carbon.device.mgt.core.metadata.mgt.util.WhiteLabelStorageUtil; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.SQLException; + +/** + * This class implements the MetadataManagementService. + */ +public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementService { + + private static final Log log = LogFactory.getLog(WhiteLabelManagementServiceImpl.class); + + private final MetadataDAO metadataDAO; + + public WhiteLabelManagementServiceImpl() { + this.metadataDAO = MetadataManagementDAOFactory.getMetadataDAO(); + } + + @Override + public byte[] getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException, IOException { + WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); + return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + } + + @Override + public byte[] getWhiteLabelLogo() throws MetadataManagementException, NotFoundException, IOException { + WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); + return getImageContent(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); + } + + private byte[] getImageContent(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws + IOException, MetadataManagementException, NotFoundException { + if (image.getImageLocationType() == WhiteLabelImage.ImageLocationType.URL) { + return getImageStreamFromUrl(image.getImageLocation()); + } + InputStream fileStream = WhiteLabelStorageUtil.getWhiteLabelImageStream(image, imageName); + return IOUtils.toByteArray(fileStream); + } + + private byte[] getImageStreamFromUrl(String url) throws IOException, NotFoundException { + try(CloseableHttpClient client = HttpClients.createDefault()) { + HttpGet imageGetRequest = new HttpGet(url); + HttpResponse response = client.execute(imageGetRequest); + InputStream imageStream = response.getEntity().getContent(); + if (imageStream == null) { + String msg = "Failed to retrieve the image from url: " + url; + log.error(msg); + throw new NotFoundException(msg); + } + return IOUtils.toByteArray(imageStream); + } + } + + + @Override + public void addDefaultWhiteLabelThemeIfNotExist() throws MetadataManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + try { + MetadataManagementDAOFactory.beginTransaction(); + if (!metadataDAO.isExist(tenantId, MetadataConstants.WHITELABEL_META_KEY)) { + WhiteLabelTheme whiteLabelTheme = getDefaultWhiteLabelTheme(); + Metadata metadata = constructWhiteLabelThemeMetadata(whiteLabelTheme); + metadataDAO.addMetadata(tenantId, metadata); + if (log.isDebugEnabled()) { + log.debug("White label metadata entry has inserted successfully"); + } + } + MetadataManagementDAOFactory.commitTransaction(); + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + String msg = "Error occurred while inserting default whitelabel metadata entry."; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } + + } + + @Override + public void resetToDefaultWhiteLabelTheme() throws MetadataManagementException { + WhiteLabelTheme whiteLabelTheme = getDefaultWhiteLabelTheme(); + Metadata metadata = constructWhiteLabelThemeMetadata(whiteLabelTheme); + DeviceManagementDataHolder.getInstance().getMetadataManagementService().updateMetadata(metadata); + } + + private WhiteLabelTheme getDefaultWhiteLabelTheme() { + String footerText = getDefaultFooterText(); + WhiteLabelImage favicon = constructDefaultFaviconImage(); + WhiteLabelImage logo = constructDefaultLogoImage(); + WhiteLabelTheme defaultTheme = new WhiteLabelTheme(); + defaultTheme.setFooterText(footerText); + defaultTheme.setLogoImage(logo); + defaultTheme.setFaviconImage(favicon); + return defaultTheme; + } + + private String getDefaultFooterText() { + MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getMetaDataConfiguration(); + WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); + return whiteLabelConfiguration.getFooterText(); + } + + private WhiteLabelImage constructDefaultFaviconImage() { + MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getMetaDataConfiguration(); + WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); + WhiteLabelImage favicon = new WhiteLabelImage(); + favicon.setImageLocation(whiteLabelConfiguration.getWhiteLabelImages().getDefaultFaviconName()); + setDefaultWhiteLabelImageCommonProperties(favicon); + return favicon; + } + + private WhiteLabelImage constructDefaultLogoImage() { + MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getMetaDataConfiguration(); + WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); + WhiteLabelImage logo = new WhiteLabelImage(); + logo.setImageLocation(whiteLabelConfiguration.getWhiteLabelImages().getDefaultLogoName()); + setDefaultWhiteLabelImageCommonProperties(logo); + return logo; + } + + private void setDefaultWhiteLabelImageCommonProperties(WhiteLabelImage image) { + image.setImageLocationType(WhiteLabelImage.ImageLocationType.DEFAULT_FILE); + } + + @Override + public WhiteLabelTheme updateWhiteLabelTheme(WhiteLabelThemeCreateRequest createWhiteLabelTheme) + throws MetadataManagementException { + if (log.isDebugEnabled()) { + log.debug("Creating Metadata : [" + createWhiteLabelTheme.toString() + "]"); + } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + File existingFaviconImage = null; + File existingLogoImage = null; + try { + WhiteLabelTheme theme = getWhiteLabelTheme(); + if (theme.getFaviconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { + existingFaviconImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + } + if (theme.getFaviconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { + existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + } + storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getFavicon(), WhiteLabelImage.ImageName.FAVICON, tenantId); + storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getLogo(), WhiteLabelImage.ImageName.LOGO, tenantId); + WhiteLabelTheme whiteLabelTheme = constructWhiteLabelTheme(createWhiteLabelTheme); + Metadata metadataWhiteLabelTheme = constructWhiteLabelThemeMetadata(whiteLabelTheme); + + MetadataManagementDAOFactory.beginTransaction(); + metadataDAO.updateMetadata(tenantId, metadataWhiteLabelTheme); + MetadataManagementDAOFactory.commitTransaction(); + if (log.isDebugEnabled()) { + log.debug("Metadata entry created successfully. " + createWhiteLabelTheme.toString()); + } + return whiteLabelTheme; + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); + String msg = "Error occurred while creating the metadata entry. " + createWhiteLabelTheme.toString(); + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new MetadataManagementException("Error occurred while creating metadata record", e); + } catch (NotFoundException e) { + String msg = "Error occurred while retrieving existing white label theme"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } + } + + private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, int tenantId) + throws MetadataManagementException { + WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId); + if (existingFavicon != null) { + WhiteLabelStorageUtil.storeWhiteLabelImage(existingFavicon, WhiteLabelImage.ImageName.FAVICON, tenantId); + } + if (existingLogo != null) { + WhiteLabelStorageUtil.storeWhiteLabelImage(existingLogo, WhiteLabelImage.ImageName.LOGO, tenantId); + } + } + + private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage, + WhiteLabelImage.ImageName imageName, int tenantId) + throws MetadataManagementException { + if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.BASE64) { + Base64File imageBase64 = new Gson().fromJson(whiteLabelImage.getImage(), Base64File.class); + WhiteLabelStorageUtil.updateWhiteLabelImage(imageBase64, imageName, tenantId); + } + } + + private WhiteLabelTheme constructWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { + WhiteLabelTheme whiteLabelTheme = new WhiteLabelTheme(); + WhiteLabelImageRequestPayload faviconPayload = whiteLabelThemeCreateRequest.getFavicon(); + WhiteLabelImageRequestPayload logoPayload = whiteLabelThemeCreateRequest.getLogo(); + WhiteLabelImage faviconImage = constructWhiteLabelImageDTO(faviconPayload); + WhiteLabelImage logoImage = constructWhiteLabelImageDTO(logoPayload); + whiteLabelTheme.setFaviconImage(faviconImage); + whiteLabelTheme.setLogoImage(logoImage); + whiteLabelTheme.setFooterText(whiteLabelThemeCreateRequest.getFooterText()); + return whiteLabelTheme; + } + + private WhiteLabelImage constructWhiteLabelImageDTO(WhiteLabelImageRequestPayload image) { + WhiteLabelImage imageResponse = new WhiteLabelImage(); + WhiteLabelImage.ImageLocationType imageLocationType = image.getImageType().getDTOImageLocationType(); + imageResponse.setImageLocationType(imageLocationType); + String imageLocation; + if (image.getImageType() == WhiteLabelImageRequestPayload.ImageType.BASE64) { + Base64File imageBase64 = image.getImageAsBase64File(); + imageLocation = imageBase64.getName(); + } else { + imageLocation = image.getImageAsUrl(); + } + imageResponse.setImageLocation(imageLocation); + return imageResponse; + } + + private Metadata constructWhiteLabelThemeMetadata(WhiteLabelTheme whiteLabelTheme) { + String whiteLabelThemeJsonString = new Gson().toJson(whiteLabelTheme); + Metadata metadata = new Metadata(); + metadata.setMetaKey(MetadataConstants.WHITELABEL_META_KEY); + metadata.setMetaValue(whiteLabelThemeJsonString); + return metadata; + } + + @Override + public WhiteLabelTheme getWhiteLabelTheme() throws MetadataManagementException, NotFoundException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + if (log.isDebugEnabled()) { + log.debug("Retrieving whitelabel theme for tenant: " + tenantId); + } + try { + MetadataManagementDAOFactory.openConnection(); + Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.WHITELABEL_META_KEY); + if (metadata == null) { + String msg = "Whitelabel theme not found for tenant: " + tenantId; + log.debug(msg); + throw new NotFoundException(msg); + } + return new Gson().fromJson(metadata.getMetaValue(), WhiteLabelTheme.class); + } catch (MetadataManagementDAOException e) { + String msg = "Error occurred while retrieving white label theme for tenant:" + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (SQLException e) { + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } finally { + MetadataManagementDAOFactory.closeConnection(); + } + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/dao/util/MetadataConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/dao/util/MetadataConstants.java new file mode 100644 index 0000000000..19d7cf59bd --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/dao/util/MetadataConstants.java @@ -0,0 +1,22 @@ +/* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.metadata.mgt.dao.util; + +public class MetadataConstants { + public static final String WHITELABEL_META_KEY = "whitelabel"; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java new file mode 100644 index 0000000000..ac9f705a85 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -0,0 +1,162 @@ +/* Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.core.metadata.mgt.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; +import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; +import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImage; +import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; +import org.wso2.carbon.device.mgt.core.common.util.FileUtil; +import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * This class contains the default concrete implementation of ApplicationStorage Management. + */ +public class WhiteLabelStorageUtil { + private static final Log log = LogFactory.getLog(WhiteLabelStorageUtil.class); + private static final MetaDataConfiguration metadataConfig; + private static final String STORAGE_PATH; + + static { + metadataConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().getMetaDataConfiguration(); + if (metadataConfig == null) { + throw new RuntimeException("Meta configuration is not found in cdm-config.xml"); + } + STORAGE_PATH = metadataConfig.getWhiteLabelConfiguration().getWhiteLabelImages().getStoragePath(); + } + + public static void storeWhiteLabelImage(Base64File image, WhiteLabelImage.ImageName imageName, int tenantId) + throws MetadataManagementException { + String storedLocation; + + try { + String imageStoringBaseDirPath = STORAGE_PATH + File.separator + tenantId; + StorageManagementUtil.createArtifactDirectory(imageStoringBaseDirPath); + String storingDir = imageStoringBaseDirPath + File.separator + imageName; + StorageManagementUtil.createArtifactDirectory(storingDir); + storedLocation = storingDir + File.separator + image.getName(); + StorageManagementUtil.saveFile(image, storedLocation); + } catch (IOException e) { + String msg = "IO Exception occurred while saving whitelabel artifacts for the tenant " + tenantId; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (StorageManagementException e) { + String msg = "Error occurred while uploading white label image artifacts"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } + } + + public static void storeWhiteLabelImage(File file, WhiteLabelImage.ImageName imageName, int tenantId) throws + MetadataManagementException { + try { + storeWhiteLabelImage(FileUtil.fileToBase64File(file), imageName, tenantId); + } catch (IOException e) { + String msg = "Error occurred when converting provided File object to Base64File class"; + log.error(msg); + throw new MetadataManagementException(msg, e); + } + } + + + public static void updateWhiteLabelImage(Base64File image, WhiteLabelImage.ImageName imageName, int tenantId) + throws MetadataManagementException { + deleteWhiteLabelImageIfExists(imageName, tenantId); + storeWhiteLabelImage(image, imageName, tenantId); + } + + public static File getWhiteLabelImageFile(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) + throws MetadataManagementException, NotFoundException { + String fullPathToImage = getPathToImage(image, imageName); + return new File(fullPathToImage); + } + + public static InputStream getWhiteLabelImageStream(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) + throws MetadataManagementException, NotFoundException { + String fullPathToFile = getPathToImage(image, imageName); + try { + InputStream imageStream = StorageManagementUtil.getInputStream(fullPathToFile); + if (imageStream == null) { + String msg = "Failed to get the " + imageName + " image with the file name: " + fullPathToFile; + log.error(msg); + throw new NotFoundException(msg); + } + return imageStream; + } catch (IOException e) { + String msg = "Error occurred when accessing the file in file path: " + fullPathToFile; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } + } + + private static String getPathToImage(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) + throws MetadataManagementException { + WhiteLabelImage.ImageLocationType imageLocationType = image.getImageLocationType(); + if (imageLocationType == WhiteLabelImage.ImageLocationType.URL) { + String msg = "White label images of URL type is not stored, hence it doesn't have a path in file system."; + log.error(msg); + throw new MetadataManagementException(msg); + } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String fileName = image.getImageLocation(); + String filePath = String.valueOf(tenantId); + if (imageLocationType == WhiteLabelImage.ImageLocationType.DEFAULT_FILE) { + filePath = metadataConfig.getWhiteLabelConfiguration().getWhiteLabelImages().getDefaultImagesLocation(); + } + return STORAGE_PATH + File.separator + filePath + File.separator + imageName + File.separator + fileName; + } + + /*** + * This method is responsible to delete artifact file which is located in the artifact path. + */ + public static void deleteWhiteLabelImageIfExists(WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { + String artifactPath = STORAGE_PATH + File.separator + tenantId + File.separator + imageName; + File artifact = new File(artifactPath); + if (artifact.exists()) { + try { + StorageManagementUtil.delete(artifact); + } catch (IOException e) { + throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e); + } + } + } + + /*** + * This method is responsible to delete artifact file which is located in the artifact path. + */ + public static void deleteWhiteLabelImageForTenantIfExists(int tenantId) throws MetadataManagementException { + String artifactPath = STORAGE_PATH + File.separator + tenantId; + File artifact = new File(artifactPath); + if (artifact.exists()) { + try { + StorageManagementUtil.delete(artifact); + } catch (IOException e) { + throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e); + } + } + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java index 5e0e0cff93..872648881d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagementException; import org.wso2.carbon.device.mgt.common.roles.config.Role; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; @@ -68,6 +69,11 @@ public class DeviceMgtTenantMgtListener implements TenantMgtListener { PrivilegedCarbonContext.endTenantFlow(); } } + try { + DeviceManagementDataHolder.getInstance().getMetadataManagementService().addDefaultWhiteLabelThemeIfNotExist(); + } catch (MetadataManagementException e) { + log.error("Error occurred while adding default white label theme to created tenant.", e); + } } @Override diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 6c22827666..254a0e06e5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index f2f79a482c..168e99f485 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 8676d01aef..5e9565dd27 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index e0d871e8be..d842f020d9 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heartbeat-management - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 00ef627558..00dcc3a169 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index 5eb633afe4..c1b6a61b47 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index eb3e1e1a14..1fe7630665 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index 25fb1f9193..bea3ed30cd 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 72c88ac3e1..6397a558a0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 309fd2171c..0c4862a266 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index cf1c7f9b34..8126f754c9 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index cae20ffbd5..a7b2a911c0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 77b9973826..487e942816 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index f8b0169bbe..fc04203754 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index a5824da02e..49b0d1b4d3 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index 81e2e59fb1..b5ade0b0c3 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index 545f74e108..408abff878 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml index 49f84d1800..786ca943c1 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml index 20ce4ea49d..7ce23d075e 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 0bb3f68fc0..7037b73e5c 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index 1ca37a8705..d4f5d22e05 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 65b87e96a2..1e3917a86e 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index c9e81a7326..c073d222ea 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index d617e96461..e773a44ec6 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml index bed5b34afc..76e69e798e 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml index 1ff3f9b7b9..d50ddc46a4 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index c838305151..74d6ec9eca 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index eefeef9bfc..8f657bc162 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index b91b252459..2be4052a59 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml index 921d92cc0d..3560c4f748 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml @@ -23,7 +23,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 3b232e73b4..4452caf2a8 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index ea046da07c..43dedeed4a 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml index 492d585483..1278909489 100644 --- a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml index 2e492a4406..ad2482c694 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 7bd8b97a3c..6a53d9fa88 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index 45ba9da0e0..a9ea4dfba2 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index 2a9b601a7e..dcc3615536 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index 1fb02d23f4..b5f340e61c 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index c8c6642101..662c4325af 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index 4c2c79eaa5..c6d3b7a856 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index 253db555c4..b2d0d3b153 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 4b280f00e5..16c161caf7 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 67c3051d6a..9f34db1a96 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index dd847c9f24..27a6c0f30e 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index 61a4a27dde..a513e38e58 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index 3f381205f6..ee84b3e83b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index a78088e2f8..6420e924c8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 8c0d7bed76..cfcbfcbc78 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -194,6 +194,8 @@ perm:android:upgrade-firmware perm:android:send-notification perm:geo-service:geo-fence + perm:whitelabel:view + perm:whitelabel:update perm:metadata:view perm:metadata:create perm:metadata:update diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 index 292234023c..612cbc4d3d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/mdm-ui-config.xml.j2 @@ -206,6 +206,8 @@ perm:android:upgrade-firmware perm:android:send-notification perm:geo-service:geo-fence + perm:whitelabel:view + perm:whitelabel:update perm:metadata:view perm:metadata:create perm:metadata:update diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index 6816cc71f5..af1a3b165f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,7 +4,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 6a89749b3e..874edaca48 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 5dd7af0f42..9e03680471 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 330a8a0f00..65ab4f8708 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index 6f971c06e8..69639f2688 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heart-beat-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 3356963a63..96d6215000 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 1e58aec7c3..06427c4750 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt jwt-client-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index a0459c1b18..1bcc6e4c9d 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index 2700187e56..612783f39f 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index 2efb0f9cd0..d2dfee4663 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index 9f1c95a2dd..dfa2a8ebe9 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index d046e692e9..c4880eab25 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index 283b56eebf..be7df6c6be 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml index e5fc66ba9c..efb91751ba 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml index fbc892d47c..c09e4d3d27 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index cb55c3bba0..e8a77b147a 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml index e597c04fd8..22b6229db0 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index b91bded19d..bd06e13b89 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 71c04123dd..679ea4dad0 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 5636ba26b0..27fe3146c0 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 8603b65f94..5ae11399c5 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -2076,7 +2076,7 @@ 1.2.11.wso2v10 - 5.0.7-SNAPSHOT + 5.0.6-SNAPSHOT 4.7.35 From 1d84adbb4f7504aea34ac5baf61319366ac2b767 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 19 May 2022 22:12:42 +0530 Subject: [PATCH 02/15] Add java doc comment Fix adding default white label on tenant create Add whitelabel logo and favicon apis as non secured endpoints Fix License --- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/analytics-mgt/grafana-mgt/pom.xml | 2 +- components/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/apimgt-extensions/pom.xml | 2 +- .../io.entgra.application.mgt.addons/pom.xml | 2 +- .../io.entgra.application.mgt.api/pom.xml | 2 +- .../io.entgra.application.mgt.common/pom.xml | 2 +- .../io.entgra.application.mgt.core/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.device.mgt.api/pom.xml | 2 +- .../jaxrs/service/api/WhiteLabelService.java | 10 +-- .../service/impl/WhiteLabelServiceImpl.java | 35 ++------- .../src/main/webapp/WEB-INF/web.xml | 4 +- .../org.wso2.carbon.device.mgt.common/pom.xml | 2 +- .../mgt/WhiteLabelManagementService.java | 47 ++++++++---- .../org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../DeviceManagementServiceComponent.java | 5 +- .../mgt/WhiteLabelManagementServiceImpl.java | 71 ++++++++++++++++--- .../mgt/util/WhiteLabelStorageUtil.java | 48 +++++++++++-- .../core/util/DeviceMgtTenantMgtListener.java | 3 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- components/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/identity-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.common/pom.xml | 2 +- .../org.wso2.carbon.policy.mgt.core/pom.xml | 2 +- components/policy-mgt/pom.xml | 2 +- .../org.wso2.carbon.email.sender.core/pom.xml | 2 +- components/transport-mgt/email-sender/pom.xml | 2 +- components/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- components/transport-mgt/sms-handler/pom.xml | 2 +- .../io.entgra.ui.request.interceptor/pom.xml | 2 +- components/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../webapp-authenticator-framework/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/analytics-mgt/grafana-mgt/pom.xml | 2 +- features/analytics-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/apimgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/application-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/certificate-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt-extensions/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/device-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/heartbeat-management/pom.xml | 2 +- .../pom.xml | 2 +- features/jwt-client/pom.xml | 2 +- .../pom.xml | 2 +- features/policy-mgt/pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/email-sender/pom.xml | 2 +- features/transport-mgt/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- features/transport-mgt/sms-handler/pom.xml | 2 +- .../pom.xml | 2 +- features/ui-request-interceptor/pom.xml | 2 +- .../pom.xml | 2 +- .../webapp-authenticator-framework/pom.xml | 2 +- pom.xml | 4 +- 109 files changed, 257 insertions(+), 170 deletions(-) diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml index fe91905214..cec4dcfb01 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml index 5b519b30d4..471ef03864 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml index 46f2116b2b..6a9eb109dd 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index c27ad6278b..6df5c58fde 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index 82eafa0136..1cdf1d717f 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml index 270b13d80e..9e6e0ee3dc 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml index b0699d43b8..604d3b430f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml index f4ee8cdd9b..4c1066a271 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml index af203bd025..104da8bfb2 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/pom.xml @@ -5,7 +5,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml index 9f27c44e1e..673610f363 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 14b0fe0f36..d72878e226 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml index d113cfd633..5f3bf1396a 100644 --- a/components/application-mgt/io.entgra.application.mgt.addons/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.addons/pom.xml @@ -20,7 +20,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.api/pom.xml index 4fb755bab0..c5a06e5afd 100644 --- a/components/application-mgt/io.entgra.application.mgt.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.application.mgt.common/pom.xml index c18db9cdd1..2b0a0f8606 100644 --- a/components/application-mgt/io.entgra.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.application.mgt.core/pom.xml index 81b0cd151d..a29e450988 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt application-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml index e1d4400d79..2c15d1522d 100644 --- a/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.publisher.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml index 4adb35bdf3..362f84188a 100644 --- a/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml +++ b/components/application-mgt/io.entgra.application.mgt.store.api/pom.xml @@ -22,7 +22,7 @@ application-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 6215076220..c24bb9ee77 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml index 7f468c0d95..c8ef6490f3 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml index c0228dd450..492567040a 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/pom.xml @@ -22,7 +22,7 @@ certificate-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml index ab7d21fe47..499770d3f3 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.core/pom.xml @@ -38,7 +38,7 @@ org.wso2.carbon.devicemgt certificate-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml index d5816dac40..d17941ce53 100644 --- a/components/certificate-mgt/pom.xml +++ b/components/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml index 5488bf8a1a..f531a7985d 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml index 15904f573b..c76a9d0642 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.pull.notification/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml index 779b6f0dc8..24fc4c8325 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml index c8c38d83b2..ed0615a965 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml index 4657158241..30c92b6283 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml index 867a524d3c..780f4308e1 100644 --- a/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml +++ b/components/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp/pom.xml @@ -22,7 +22,7 @@ device-mgt-extensions org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml index e1645847c7..110c755d04 100644 --- a/components/device-mgt-extensions/pom.xml +++ b/components/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml index 74a8f7cd34..ae70a2d2ed 100644 --- a/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml +++ b/components/device-mgt/io.entgra.carbon.device.mgt.config.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml index 1bb61cc59a..6aea2a873a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java index 647e894521..8545bebcd9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.Extension; @@ -35,18 +34,12 @@ import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; -import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; - import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -107,7 +100,6 @@ public interface WhiteLabelService { @ApiResponse( code = 200, message = "OK. \n Successfully retrieved white label favicon.", - response = Metadata.class, responseHeaders = { @ResponseHeader( name = "Content-Type", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java index bdc4c748f8..a0380f7032 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -20,37 +20,22 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.PaginationRequest; -import org.wso2.carbon.device.mgt.common.PaginationResult; -import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; -import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; -import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; -import org.wso2.carbon.device.mgt.common.metadata.mgt.MetadataManagementService; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; -import org.wso2.carbon.device.mgt.jaxrs.beans.MetadataList; -import org.wso2.carbon.device.mgt.jaxrs.service.api.MetadataService; import org.wso2.carbon.device.mgt.jaxrs.service.api.WhiteLabelService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; - import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.util.List; /** * This is the service class for metadata management. @@ -70,15 +55,11 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(); return sendFileStream(fileContent); } catch (NotFoundException e) { - String msg = "Couldn't find such a whitelabel artifact."; + String msg = "Favicon not found this tenant."; log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { - String msg = "Error occurred while creating whitelabel for tenant"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (IOException e) { - String msg = "Error occurred while getting the byte array of the artifact file. "; + String msg = "Error occurred while getting favicon"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } @@ -92,15 +73,11 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(); return sendFileStream(fileContent); } catch (NotFoundException e) { - String msg = "Couldn't find such a whitelabel artifact."; + String msg = "Logo not found for this tenant."; log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { - String msg = "Error occurred while creating whitelabel for tenant"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } catch (IOException e) { - String msg = "Error occurred while getting the byte array of the artifact file. "; + String msg = "Error occurred while getting logo"; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } @@ -154,7 +131,7 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { /** * Useful to send files as application/octet-stream responses */ - private Response sendFileStream(byte[] content) throws IOException { + private Response sendFileStream(byte[] content) { try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { Response.ResponseBuilder response = Response .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml index f5282af6a8..5cc5c012ff 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/web.xml @@ -48,8 +48,8 @@ nonSecuredEndPoints - /api/device-mgt/v1.0/users/validate - /api/device-mgt/v1.0/whitelabel/favicon + /api/device-mgt/v1.0/users/validate, + /api/device-mgt/v1.0/whitelabel/favicon, /api/device-mgt/v1.0/whitelabel/logo diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml index 0a8dde45f3..8c83847a2a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/pom.xml @@ -21,7 +21,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java index 649ad471c7..0c84ee2ea0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -17,33 +17,56 @@ */ package org.wso2.carbon.device.mgt.common.metadata.mgt; - -import org.wso2.carbon.device.mgt.common.PaginationRequest; -import org.wso2.carbon.device.mgt.common.PaginationResult; -import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyAlreadyExistsException; -import org.wso2.carbon.device.mgt.common.exceptions.MetadataKeyNotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; - import java.io.IOException; -import java.util.List; /** - * Defines the contract of MetadataManagementService. + * Defines the contract of WhiteLabelManagementService. */ public interface WhiteLabelManagementService { + /** + * Use to get byte content of favicon whitelabel image + * @return byte content of favicon + * @throws MetadataManagementException if error occurred while retrieving favicon + * @throws NotFoundException if favicon is not found + */ byte[] getWhiteLabelFavicon() throws - MetadataManagementException, NotFoundException, IOException; + MetadataManagementException, NotFoundException; + + /** + * Use to get byte content of logo whitelabel image + * @return byte content of logo + * @throws MetadataManagementException if error occurred while retrieving logo + * @throws NotFoundException if logo is not found + */ byte[] getWhiteLabelLogo() throws - MetadataManagementException, NotFoundException, IOException; + MetadataManagementException, NotFoundException; - void addDefaultWhiteLabelThemeIfNotExist() throws MetadataManagementException; + /** + * This method is useful to create & persist default white label theme for provided tenant if + * it doesn't exist already + * @throws MetadataManagementException if error while adding default white label theme + */ + void addDefaultWhiteLabelThemeIfNotExist(int tenantId) throws MetadataManagementException; + /** + * This method is useful to reset existing white label to default whitelabel + * @throws MetadataManagementException if error while resetting default white label theme + */ void resetToDefaultWhiteLabelTheme() throws MetadataManagementException; + /** + * This method is useful to update existing white label theme + * @throws MetadataManagementException if error while updating existing white label theme + */ WhiteLabelTheme updateWhiteLabelTheme(WhiteLabelThemeCreateRequest createWhiteLabelTheme) throws MetadataManagementException; + /** + * This method is useful to get existing white label theme + * @throws MetadataManagementException if error while getting existing white label theme + */ WhiteLabelTheme getWhiteLabelTheme() throws MetadataManagementException, NotFoundException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index 8007415ca7..2c7bb44969 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java index faed94f6d1..b29e5b911c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; @@ -291,6 +292,8 @@ public class DeviceManagementServiceComponent { if (log.isDebugEnabled()) { log.debug("Registering OSGi service DeviceManagementProviderServiceImpl"); } + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + /* Registering Tenants Observer */ BundleContext bundleContext = componentContext.getBundleContext(); TenantCreateObserver listener = new TenantCreateObserver(); @@ -358,7 +361,7 @@ public class DeviceManagementServiceComponent { WhiteLabelManagementService whiteLabelManagementService = new WhiteLabelManagementServiceImpl(); DeviceManagementDataHolder.getInstance().setWhiteLabelManagementService(whiteLabelManagementService); try { - whiteLabelManagementService.addDefaultWhiteLabelThemeIfNotExist(); + whiteLabelManagementService.addDefaultWhiteLabelThemeIfNotExist(tenantId); } catch (Throwable e) { log.error("Error occurred while adding default tenant white label theme", e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 8646168824..e0596fe997 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -66,17 +66,33 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } @Override - public byte[] getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException, IOException { - WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); - return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + public byte[] getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException { + try { + WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); + return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + + } catch (IOException e) { + String msg = "Error occurred while getting byte content of favicon"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } } @Override - public byte[] getWhiteLabelLogo() throws MetadataManagementException, NotFoundException, IOException { - WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); - return getImageContent(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); + public byte[] getWhiteLabelLogo() throws MetadataManagementException, NotFoundException { + try { + WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); + return getImageContent(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); + } catch (IOException e) { + String msg = "Error occurred while getting byte content of logo"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } } + /** + * Useful to get white label image file byte content for provided {@link WhiteLabelImage.ImageName} + */ private byte[] getImageContent(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws IOException, MetadataManagementException, NotFoundException { if (image.getImageLocationType() == WhiteLabelImage.ImageLocationType.URL) { @@ -86,6 +102,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return IOUtils.toByteArray(fileStream); } + /** + * Useful to get white label image file byte content from provided url + */ private byte[] getImageStreamFromUrl(String url) throws IOException, NotFoundException { try(CloseableHttpClient client = HttpClients.createDefault()) { HttpGet imageGetRequest = new HttpGet(url); @@ -102,8 +121,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ @Override - public void addDefaultWhiteLabelThemeIfNotExist() throws MetadataManagementException { - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + public void addDefaultWhiteLabelThemeIfNotExist(int tenantId) throws MetadataManagementException { try { MetadataManagementDAOFactory.beginTransaction(); if (!metadataDAO.isExist(tenantId, MetadataConstants.WHITELABEL_META_KEY)) { @@ -137,6 +155,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ DeviceManagementDataHolder.getInstance().getMetadataManagementService().updateMetadata(metadata); } + /** + * Construct and return default whitelabel detail bean {@link WhiteLabelImage} + */ private WhiteLabelTheme getDefaultWhiteLabelTheme() { String footerText = getDefaultFooterText(); WhiteLabelImage favicon = constructDefaultFaviconImage(); @@ -148,6 +169,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return defaultTheme; } + /** + * Get default whitelabel label footer from config + */ private String getDefaultFooterText() { MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig().getMetaDataConfiguration(); @@ -175,6 +199,10 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return logo; } + /** + * This is useful to set common properties such as DEFAULT_FILE type for {@link WhiteLabelImage.ImageLocationType} + * for default white label image bean{@link WhiteLabelImage} + */ private void setDefaultWhiteLabelImageCommonProperties(WhiteLabelImage image) { image.setImageLocationType(WhiteLabelImage.ImageLocationType.DEFAULT_FILE); } @@ -228,6 +256,15 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } } + /** + * This is method is useful to restore provided existing white label images (i.e: favicon/logo). + * For example if any exception occurred white updating/deleting white label, this method can be used to + * restore the existing images in any case. Note that the existing images should be first loaded so that + * those can be passed to this method in order to restore. + * + * @param existingFavicon existing favicon image file + * @param existingLogo existing logo image file + */ private void restoreWhiteLabelImages(File existingFavicon, File existingLogo, int tenantId) throws MetadataManagementException { WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId); @@ -239,6 +276,13 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } } + /** + * This handles storing provided white label image if required. + * For example if the provided white label image is of URL type it doesn't need to be stored + * + * @param whiteLabelImage image to be stored + * @param imageName (i.e: FAVICON) + */ private void storeWhiteLabelImageIfRequired(WhiteLabelImageRequestPayload whiteLabelImage, WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { @@ -248,6 +292,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } } + /** + * Generate {@link WhiteLabelTheme} from provided {@link WhiteLabelThemeCreateRequest} + */ private WhiteLabelTheme constructWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { WhiteLabelTheme whiteLabelTheme = new WhiteLabelTheme(); WhiteLabelImageRequestPayload faviconPayload = whiteLabelThemeCreateRequest.getFavicon(); @@ -260,6 +307,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return whiteLabelTheme; } + /** + * Generate {@link WhiteLabelImage} from provided {@link WhiteLabelImageRequestPayload} + */ private WhiteLabelImage constructWhiteLabelImageDTO(WhiteLabelImageRequestPayload image) { WhiteLabelImage imageResponse = new WhiteLabelImage(); WhiteLabelImage.ImageLocationType imageLocationType = image.getImageType().getDTOImageLocationType(); @@ -275,6 +325,9 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return imageResponse; } + /** + * Generate {@link Metadata} from provided {@link WhiteLabelImage} + */ private Metadata constructWhiteLabelThemeMetadata(WhiteLabelTheme whiteLabelTheme) { String whiteLabelThemeJsonString = new Gson().toJson(whiteLabelTheme); Metadata metadata = new Metadata(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index ac9f705a85..553b53a459 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -49,10 +49,15 @@ public class WhiteLabelStorageUtil { STORAGE_PATH = metadataConfig.getWhiteLabelConfiguration().getWhiteLabelImages().getStoragePath(); } + /** + * Store provided white label {@link Base64File} image + * + * @param image base64 image file + * @param imageName {@link WhiteLabelImage.ImageName} (i.e FAVICON) + */ public static void storeWhiteLabelImage(Base64File image, WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { String storedLocation; - try { String imageStoringBaseDirPath = STORAGE_PATH + File.separator + tenantId; StorageManagementUtil.createArtifactDirectory(imageStoringBaseDirPath); @@ -71,10 +76,16 @@ public class WhiteLabelStorageUtil { } } - public static void storeWhiteLabelImage(File file, WhiteLabelImage.ImageName imageName, int tenantId) throws + /** + * Store provided white label {@link File} image + * + * @param image white label file + * @param imageName {@link WhiteLabelImage.ImageName} (i.e FAVICON) + */ + public static void storeWhiteLabelImage(File image, WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { try { - storeWhiteLabelImage(FileUtil.fileToBase64File(file), imageName, tenantId); + storeWhiteLabelImage(FileUtil.fileToBase64File(image), imageName, tenantId); } catch (IOException e) { String msg = "Error occurred when converting provided File object to Base64File class"; log.error(msg); @@ -83,18 +94,38 @@ public class WhiteLabelStorageUtil { } + /** + * Update white label image for provided tenant + * + * @param image {@link Base64File} white label file + * @param imageName (i.e: FAVICON) + */ public static void updateWhiteLabelImage(Base64File image, WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { deleteWhiteLabelImageIfExists(imageName, tenantId); storeWhiteLabelImage(image, imageName, tenantId); } + /** + * Use to get a given {@link WhiteLabelImage.ImageName (i.e: LOGO)} white label image File + * + * @param image detail bean + * @param imageName (i.e: LOGO) + * @return white label image file {@link File} + */ public static File getWhiteLabelImageFile(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws MetadataManagementException, NotFoundException { String fullPathToImage = getPathToImage(image, imageName); return new File(fullPathToImage); } + /** + * Useful to get the given {@link WhiteLabelImage.ImageName (i.e: LOGO)} white label image InputStream + * + * @param image - white label image detail bean + * @param imageName (i.e: LOGO) + * @return white label image input stream + */ public static InputStream getWhiteLabelImageStream(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws MetadataManagementException, NotFoundException { String fullPathToFile = getPathToImage(image, imageName); @@ -113,6 +144,13 @@ public class WhiteLabelStorageUtil { } } + /** + * Construct the path to white label image in the file system and return + * + * @param image - white label image detail bean + * @param imageName (i.e: LOGO) + * @return Full path to white label image in the system + */ private static String getPathToImage(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws MetadataManagementException { WhiteLabelImage.ImageLocationType imageLocationType = image.getImageLocationType(); @@ -131,7 +169,7 @@ public class WhiteLabelStorageUtil { } /*** - * This method is responsible to delete artifact file which is located in the artifact path. + * This method is responsible to delete provided white label image file which if exist */ public static void deleteWhiteLabelImageIfExists(WhiteLabelImage.ImageName imageName, int tenantId) throws MetadataManagementException { String artifactPath = STORAGE_PATH + File.separator + tenantId + File.separator + imageName; @@ -146,7 +184,7 @@ public class WhiteLabelStorageUtil { } /*** - * This method is responsible to delete artifact file which is located in the artifact path. + * This method is responsible to delete all white label images for provided tenant */ public static void deleteWhiteLabelImageForTenantIfExists(int tenantId) throws MetadataManagementException { String artifactPath = STORAGE_PATH + File.separator + tenantId; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java index 872648881d..79f58e82a1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceMgtTenantMgtListener.java @@ -70,7 +70,8 @@ public class DeviceMgtTenantMgtListener implements TenantMgtListener { } } try { - DeviceManagementDataHolder.getInstance().getMetadataManagementService().addDefaultWhiteLabelThemeIfNotExist(); + DeviceManagementDataHolder.getInstance().getWhiteLabelManagementService(). + addDefaultWhiteLabelThemeIfNotExist(tenantInfoBean.getTenantId()); } catch (MetadataManagementException e) { log.error("Error occurred while adding default white label theme to created tenant.", e); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml index 254a0e06e5..6c22827666 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/pom.xml @@ -22,7 +22,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml index 168e99f485..f2f79a482c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.url.printer/pom.xml @@ -23,7 +23,7 @@ device-mgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml index 5e9565dd27..8676d01aef 100644 --- a/components/device-mgt/pom.xml +++ b/components/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml index d842f020d9..e0d871e8be 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heartbeat-management - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml index 00dcc3a169..00ef627558 100644 --- a/components/heartbeat-management/pom.xml +++ b/components/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml index c1b6a61b47..5eb633afe4 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml index 1fe7630665..eb3e1e1a14 100644 --- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml +++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt identity-extensions - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml index bea3ed30cd..25fb1f9193 100644 --- a/components/identity-extensions/pom.xml +++ b/components/identity-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml index 6397a558a0..72c88ac3e1 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml index 0c4862a266..309fd2171c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.information.point/pom.xml @@ -3,7 +3,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 8126f754c9..cf1c7f9b34 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index a7b2a911c0..cae20ffbd5 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt policy-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml index 487e942816..77b9973826 100644 --- a/components/policy-mgt/pom.xml +++ b/components/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml index fc04203754..f8b0169bbe 100644 --- a/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml +++ b/components/transport-mgt/email-sender/org.wso2.carbon.email.sender.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml index 49b0d1b4d3..a5824da02e 100644 --- a/components/transport-mgt/email-sender/pom.xml +++ b/components/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml index b5ade0b0c3..81e2e59fb1 100644 --- a/components/transport-mgt/pom.xml +++ b/components/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml index 408abff878..545f74e108 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml index 786ca943c1..49f84d1800 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.common/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml index 7ce23d075e..20ce4ea49d 100644 --- a/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml +++ b/components/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.core/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml index 7037b73e5c..0bb3f68fc0 100644 --- a/components/transport-mgt/sms-handler/pom.xml +++ b/components/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml index d4f5d22e05..1ca37a8705 100644 --- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml +++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor io.entgra.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT 4.0.0 diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml index 1e3917a86e..65b87e96a2 100644 --- a/components/ui-request-interceptor/pom.xml +++ b/components/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index c073d222ea..c9e81a7326 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml index e773a44ec6..d617e96461 100644 --- a/components/webapp-authenticator-framework/pom.xml +++ b/components/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml index 76e69e798e..bed5b34afc 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml index d50ddc46a4..1ff3f9b7b9 100644 --- a/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml +++ b/features/analytics-mgt/grafana-mgt/io.entgra.analytics.mgt.grafana.proxy.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt grafana-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml index 74d6ec9eca..c838305151 100644 --- a/features/analytics-mgt/grafana-mgt/pom.xml +++ b/features/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt analytics-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml index 8f657bc162..eefeef9bfc 100644 --- a/features/analytics-mgt/pom.xml +++ b/features/analytics-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml index 2be4052a59..b91b252459 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml index 3560c4f748..921d92cc0d 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.feature/pom.xml @@ -23,7 +23,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml index 4452caf2a8..3b232e73b4 100644 --- a/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml +++ b/features/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher.feature/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt apimgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml index 43dedeed4a..ea046da07c 100644 --- a/features/apimgt-extensions/pom.xml +++ b/features/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml index 1278909489..492d585483 100644 --- a/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml index ad2482c694..2e492a4406 100644 --- a/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/io.entgra.application.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt application-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 6a53d9fa88..7bd8b97a3c 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml index a9ea4dfba2..45ba9da0e0 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml index dcc3615536..2a9b601a7e 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml index b5f340e61c..1fb02d23f4 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt certificate-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml index 662c4325af..c8c6642101 100644 --- a/features/certificate-mgt/pom.xml +++ b/features/certificate-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml index c6d3b7a856..4c2c79eaa5 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.device.type.deployer.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml index b2d0d3b153..253db555c4 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml index 16c161caf7..4b280f00e5 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml index 9f34db1a96..67c3051d6a 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml index 27a6c0f30e..dd847c9f24 100644 --- a/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml +++ b/features/device-mgt-extensions/org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-extensions-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml index a513e38e58..61a4a27dde 100644 --- a/features/device-mgt-extensions/pom.xml +++ b/features/device-mgt-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml index ee84b3e83b..3f381205f6 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml index 6420e924c8..a78088e2f8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml index af1a3b165f..6816cc71f5 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.extensions.feature/pom.xml @@ -4,7 +4,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml index 874edaca48..6a89749b3e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml index 9e03680471..5dd7af0f42 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt device-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml index 65ab4f8708..330a8a0f00 100644 --- a/features/device-mgt/pom.xml +++ b/features/device-mgt/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml index 69639f2688..6f971c06e8 100644 --- a/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml +++ b/features/heartbeat-management/io.entgra.server.heart.beat.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt heart-beat-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml index 96d6215000..3356963a63 100644 --- a/features/heartbeat-management/pom.xml +++ b/features/heartbeat-management/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml index 06427c4750..1e58aec7c3 100644 --- a/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml +++ b/features/jwt-client/org.wso2.carbon.identity.jwt.client.extension.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt jwt-client-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml index 1bcc6e4c9d..a0459c1b18 100644 --- a/features/jwt-client/pom.xml +++ b/features/jwt-client/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml index 612783f39f..2700187e56 100644 --- a/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml +++ b/features/policy-mgt/org.wso2.carbon.policy.mgt.server.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt policy-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml index d2dfee4663..2efb0f9cd0 100644 --- a/features/policy-mgt/pom.xml +++ b/features/policy-mgt/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml index dfa2a8ebe9..9f1c95a2dd 100644 --- a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml +++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt email-sender-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/email-sender/pom.xml b/features/transport-mgt/email-sender/pom.xml index c4880eab25..d046e692e9 100644 --- a/features/transport-mgt/email-sender/pom.xml +++ b/features/transport-mgt/email-sender/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/pom.xml b/features/transport-mgt/pom.xml index be7df6c6be..283b56eebf 100644 --- a/features/transport-mgt/pom.xml +++ b/features/transport-mgt/pom.xml @@ -3,7 +3,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml index efb91751ba..e5fc66ba9c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.api.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml index c09e4d3d27..fbc892d47c 100644 --- a/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml +++ b/features/transport-mgt/sms-handler/io.entgra.transport.mgt.sms.handler.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt sms-handler-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/transport-mgt/sms-handler/pom.xml b/features/transport-mgt/sms-handler/pom.xml index e8a77b147a..cb55c3bba0 100644 --- a/features/transport-mgt/sms-handler/pom.xml +++ b/features/transport-mgt/sms-handler/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt transport-mgt-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml index 22b6229db0..e597c04fd8 100644 --- a/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml +++ b/features/ui-request-interceptor/io.entgra.ui.request.interceptor.feature/pom.xml @@ -21,7 +21,7 @@ ui-request-interceptor-feature io.entgra.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT 4.0.0 diff --git a/features/ui-request-interceptor/pom.xml b/features/ui-request-interceptor/pom.xml index bd06e13b89..b91bded19d 100644 --- a/features/ui-request-interceptor/pom.xml +++ b/features/ui-request-interceptor/pom.xml @@ -21,7 +21,7 @@ carbon-devicemgt org.wso2.carbon.devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml index 679ea4dad0..71c04123dd 100644 --- a/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml +++ b/features/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework.server.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt webapp-authenticator-framework-feature - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/features/webapp-authenticator-framework/pom.xml b/features/webapp-authenticator-framework/pom.xml index 27fe3146c0..5636ba26b0 100644 --- a/features/webapp-authenticator-framework/pom.xml +++ b/features/webapp-authenticator-framework/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 5ae11399c5..8603b65f94 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt carbon-devicemgt pom - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT WSO2 Carbon - Device Management - Parent http://wso2.org WSO2 Connected Device Manager Components @@ -2076,7 +2076,7 @@ 1.2.11.wso2v10 - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT 4.7.35 From 1559af96606377f1216099e1259b19ac17dd68d9 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 24 May 2022 20:59:21 +0530 Subject: [PATCH 03/15] Adress feedback Add missing licenses --- .../mgt/core/impl/ApplicationManagerImpl.java | 15 +++++---- .../impl/ApplicationStorageManagerImpl.java | 3 +- .../service/impl/WhiteLabelServiceImpl.java | 1 - .../impl/util/RequestValidationUtil.java | 31 +++++++++---------- .../mgt/jaxrs/util/DeviceMgtAPIUtils.java | 2 +- .../common/exceptions/NotFoundException.java | 5 ++- .../common/metadata/mgt/WhiteLabelImage.java | 18 +++++++++++ .../mgt/WhiteLabelImageRequestPayload.java | 18 +++++++++++ .../mgt/WhiteLabelManagementService.java | 2 +- .../whitelabel/MetaDataConfiguration.java | 18 +++++++++++ .../whitelabel/WhiteLabelConfiguration.java | 18 +++++++++++ .../tenant/whitelabel/WhiteLabelImages.java | 18 +++++++++++ .../mgt/WhiteLabelManagementServiceImpl.java | 11 ++++++- .../mgt/util/WhiteLabelStorageUtil.java | 10 ++++-- 14 files changed, 135 insertions(+), 35 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java index 58e0ebfc90..23237e54c8 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java @@ -87,7 +87,6 @@ import io.entgra.application.mgt.core.lifecycle.LifecycleStateManager; import io.entgra.application.mgt.core.util.ConnectionManagerUtil; import io.entgra.application.mgt.core.util.Constants; import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementException; -import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -611,7 +610,7 @@ public class ApplicationManagerImpl implements ApplicationManager { return md5OfApp; } catch(StorageManagementException e) { String msg = "Error occurred while generating md5sum value of " + applicationArtifact.getInstallerName(); - log.error(msg); + log.error(msg, e); throw new ApplicationManagementException(msg, e); } } @@ -713,8 +712,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (StorageManagementException e) { String msg = "Error occurred while md5sum value retrieving process: application UUID " + applicationReleaseDTO.getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); + log.error(msg, e); + throw new ApplicationStorageManagementException(msg, e); } catch (DBConnectionException e) { String msg = "Error occurred when getting database connection for verifying app release data."; log.error(msg, e); @@ -828,8 +827,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (StorageManagementException e) { String msg = "Error occurred while retrieving md5sum value from the binary file for application " + "release UUID " + applicationReleaseDTO.getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); + log.error(msg, e); + throw new ApplicationStorageManagementException(msg, e); } catch (IOException e) { String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact .getInstallerName(); @@ -3310,8 +3309,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (StorageManagementException e) { String msg = "Error occurred while retrieving md5sum value from the binary file for " + "application release UUID " + applicationReleaseDTO.get().getUuid(); - log.error(msg); - throw new ApplicationStorageManagementException(msg); + log.error(msg, e); + throw new ApplicationStorageManagementException(msg, e); } catch (IOException e) { String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact.getInstallerName(); diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java index a99d759d46..c9965d4f06 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -1,4 +1,5 @@ -/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * +/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java index a0380f7032..0946ccb454 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -136,7 +136,6 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { Response.ResponseBuilder response = Response .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); response.status(Response.Status.OK); -// response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\""); response.header("Content-Length", content.length); return response.build(); } catch (IOException e) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index d71373c2df..03c49ecb9d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -662,17 +662,11 @@ public class RequestValidationUtil { } } - public static void validateWhiteLabelArtifactDownloadRequest(String whiteLabelImage) { - if (!EnumUtils.isValidEnum(WhiteLabelImage.ImageName.class, whiteLabelImage)) { - String msg = "Invalid white label image requested. Image: " + whiteLabelImage; - log.error(msg); - throw new InputValidationException(new ErrorResponse.ErrorResponseBuilder() - .setCode(HttpStatus.SC_BAD_REQUEST) - .setMessage(msg).build()); - - } - } - + /** + * Check if whitelabel theme create request contains valid payload and all required payload + * + * @param whiteLabelThemeCreateRequest {@link WhiteLabelThemeCreateRequest} + */ public static void validateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { if (whiteLabelThemeCreateRequest.getFavicon() == null) { String msg = "Favicon is required to whitelabel"; @@ -700,7 +694,7 @@ public class RequestValidationUtil { validateWhiteLabelImage(whiteLabelThemeCreateRequest.getLogo()); } catch (InputValidationException e) { String msg = "Payload contains invalid base64 files"; - log.error(msg); + log.error(msg, e); throw e; } } @@ -723,14 +717,13 @@ public class RequestValidationUtil { } catch (JsonSyntaxException e) { String msg = "Invalid image payload found with the request. Image object does not represent a Base64 File. " + "Hence verify the request payload object."; - log.error(msg); + log.error(msg, e); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } - return; } - if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.URL) { + else if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.URL) { try { String imageUrl = new Gson().fromJson(whiteLabelImage.getImage(), String.class); if (!HttpUtil.isHttpUrlValid(imageUrl)) { @@ -742,11 +735,17 @@ public class RequestValidationUtil { } } catch (JsonSyntaxException e) { String msg = "Invalid payload found with the request. Hence verify the request payload object."; - log.error(msg); + log.error(msg, e); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } + } else { + String msg = "Invalid payload found with the request. Unknown white label imageType " + whiteLabelImage.getImageType(); + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java index c14649b334..4f8b41cdab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java @@ -526,7 +526,7 @@ public class DeviceMgtAPIUtils { whiteLabelManagementService = (WhiteLabelManagementService) ctx.getOSGiService( WhiteLabelManagementService.class, null); if (whiteLabelManagementService == null) { - throw new IllegalStateException("Metadata Management service not initialized."); + throw new IllegalStateException("Whitelabel Management service not initialized."); } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java index 2e59a81bbe..6a8287db01 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/exceptions/NotFoundException.java @@ -1,6 +1,3 @@ -package org.wso2.carbon.device.mgt.common.exceptions; - - /* * Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. * @@ -19,6 +16,8 @@ package org.wso2.carbon.device.mgt.common.exceptions; * under the License. */ +package org.wso2.carbon.device.mgt.common.exceptions; + /** * This exception will be thrown when the requested application or platform not found. */ diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java index 70003b6e60..ba9e6f82f2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImage.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.common.metadata.mgt; public class WhiteLabelImage { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java index 718c9a7924..e78e85b240 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelImageRequestPayload.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2022, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.common.metadata.mgt; import com.google.gson.Gson; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java index 0c84ee2ea0..e1536b8059 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java @@ -17,9 +17,9 @@ */ package org.wso2.carbon.device.mgt.common.metadata.mgt; + import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; -import java.io.IOException; /** * Defines the contract of WhiteLabelManagementService. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java index 859baf1979..ae95b17e0d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; import javax.xml.bind.annotation.XmlElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java index 0d544bedbf..6b51f0e170 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; import javax.xml.bind.annotation.XmlElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java index 4a6039944e..cb8efe884d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; import javax.xml.bind.annotation.XmlElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index e0596fe997..76fda9f697 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -70,7 +70,6 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ try { WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); - } catch (IOException e) { String msg = "Error occurred while getting byte content of favicon"; log.error(msg, e); @@ -179,6 +178,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return whiteLabelConfiguration.getFooterText(); } + /** + * This is useful to construct and get the default favicon whitelabel image + * + * @return {@link WhiteLabelImage} + */ private WhiteLabelImage constructDefaultFaviconImage() { MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig().getMetaDataConfiguration(); @@ -189,6 +193,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ return favicon; } + /** + * This is useful to construct and get the default logo whitelabel image + * + * @return {@link WhiteLabelImage} + */ private WhiteLabelImage constructDefaultLogoImage() { MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig().getMetaDataConfiguration(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index 553b53a459..d18678ec91 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -88,7 +88,7 @@ public class WhiteLabelStorageUtil { storeWhiteLabelImage(FileUtil.fileToBase64File(image), imageName, tenantId); } catch (IOException e) { String msg = "Error occurred when converting provided File object to Base64File class"; - log.error(msg); + log.error(msg, e); throw new MetadataManagementException(msg, e); } } @@ -178,7 +178,9 @@ public class WhiteLabelStorageUtil { try { StorageManagementUtil.delete(artifact); } catch (IOException e) { - throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e); + String msg = "Error occurred while deleting whitelabel artifacts"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); } } } @@ -193,7 +195,9 @@ public class WhiteLabelStorageUtil { try { StorageManagementUtil.delete(artifact); } catch (IOException e) { - throw new MetadataManagementException("Error occurred while deleting whitelabel artifacts", e); + String msg = "Error occurred while deleting whitelabel artifacts"; + log.error(msg, e); + throw new MetadataManagementException(msg, e); } } } From ed9ec69509584a41b1dc7a82387482bf7781de9c Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 24 May 2022 21:10:49 +0530 Subject: [PATCH 04/15] Move metadata and whitelabel config classes to metadata.mgt package --- .../carbon/device/mgt/core/config/DeviceManagementConfig.java | 2 +- .../whitelabel => metadata/mgt}/MetaDataConfiguration.java | 4 +++- .../mgt}/whitelabel/WhiteLabelConfiguration.java | 2 +- .../{tenant => metadata/mgt}/whitelabel/WhiteLabelImages.java | 2 +- .../core/metadata/mgt/WhiteLabelManagementServiceImpl.java | 4 ++-- .../mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{tenant/whitelabel => metadata/mgt}/MetaDataConfiguration.java (89%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{tenant => metadata/mgt}/whitelabel/WhiteLabelConfiguration.java (95%) rename components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/{tenant => metadata/mgt}/whitelabel/WhiteLabelImages.java (96%) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java index 37358e31ca..2fb085c0ec 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/DeviceManagementConfig.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguratio import org.wso2.carbon.device.mgt.core.config.cache.DeviceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.cache.GeoFenceCacheConfiguration; import org.wso2.carbon.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration; -import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; +import org.wso2.carbon.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; import org.wso2.carbon.device.mgt.core.event.config.EventOperationTaskConfiguration; import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration; import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java similarity index 89% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java index ae95b17e0d..4f929ea030 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/MetaDataConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java @@ -16,7 +16,9 @@ * under the License. */ -package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; +package org.wso2.carbon.device.mgt.core.config.metadata.mgt; + +import org.wso2.carbon.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java similarity index 95% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java index 6b51f0e170..cac694eb2e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; +package org.wso2.carbon.device.mgt.core.config.metadata.mgt.whitelabel; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelImages.java similarity index 96% rename from components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java rename to components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelImages.java index cb8efe884d..69ea8fa1d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/tenant/whitelabel/WhiteLabelImages.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelImages.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.core.config.tenant.whitelabel; +package org.wso2.carbon.device.mgt.core.config.metadata.mgt.whitelabel; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 76fda9f697..b9ea1091bf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -38,8 +38,8 @@ import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementServic import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; -import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.WhiteLabelConfiguration; +import org.wso2.carbon.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; +import org.wso2.carbon.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataDAO; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOException; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index d18678ec91..26e2b23ce1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -28,7 +28,7 @@ import org.wso2.carbon.device.mgt.core.common.exception.StorageManagementExcepti import org.wso2.carbon.device.mgt.core.common.util.FileUtil; import org.wso2.carbon.device.mgt.core.common.util.StorageManagementUtil; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; -import org.wso2.carbon.device.mgt.core.config.tenant.whitelabel.MetaDataConfiguration; +import org.wso2.carbon.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; import java.io.File; import java.io.IOException; import java.io.InputStream; From 5677e1e3fe7b85c417f043e510657d6bb16b00cc Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 24 May 2022 21:13:26 +0530 Subject: [PATCH 05/15] Better feedback message/log if favicon/logo white label images not found --- .../mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java index 0946ccb454..901885985d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -55,7 +55,8 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(); return sendFileStream(fileContent); } catch (NotFoundException e) { - String msg = "Favicon not found this tenant."; + String msg = "Favicon white label image cannot be found in the system. Updating the whitelabel theme might" + + "help restore it"; log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { @@ -73,7 +74,8 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(); return sendFileStream(fileContent); } catch (NotFoundException e) { - String msg = "Logo not found for this tenant."; + String msg = "Logo white label image cannot be found in the system. Updating the whitelabel theme might" + + "help restore it"; log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (MetadataManagementException e) { From 768950bbb1b23e5fce2a0e47a2e5eec1a1fa416f Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Wed, 25 May 2022 21:38:03 +0530 Subject: [PATCH 06/15] Add whitelabel metadata configuration to cdm-config --- .../src/main/resources/conf/cdm-config.xml | 18 ++++++++++++++++++ .../repository/conf/cdm-config.xml.j2 | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 50e3afd824..2636456d80 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -178,6 +178,24 @@ + + + + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.0.0 | © 2022 + , All Rights Reserved. + + + repository/resources/whitelabel + favicon.png + logo.svg + default + + + + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 28b00241af..1370def31b 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -311,6 +311,23 @@ + + + + <a href='https://entgra.io' target='_blank'> + Entgra + </a> + IoT Server 5.0.0 | © 2022 + , All Rights Reserved. + + + repository/resources/whitelabel + favicon.png + logo.svg + default + + + From 460675fcadb1e137fc046b58aa3fc358f876aab6 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 26 May 2022 03:35:57 +0530 Subject: [PATCH 07/15] Fix favicon/logo response content type --- .../jaxrs/service/api/WhiteLabelService.java | 4 -- .../service/impl/WhiteLabelServiceImpl.java | 19 ++--- .../device/mgt/common/FileResponse.java | 70 +++++++++++++++++++ .../mgt/WhiteLabelManagementService.java | 5 +- .../device/mgt/core/common/util/FileUtil.java | 18 ++++- .../mgt/WhiteLabelManagementServiceImpl.java | 45 ++++++++---- 6 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java index 8545bebcd9..68313eb878 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java @@ -87,9 +87,7 @@ public interface WhiteLabelService { @GET @Path("/favicon") - @Produces(MediaType.APPLICATION_OCTET_STREAM) @ApiOperation( - produces = MediaType.APPLICATION_OCTET_STREAM, httpMethod = HTTPConstants.HEADER_GET, value = "Get whitelabel favicon", notes = "Get whitelabel favicon for the tenant of the logged in user", @@ -123,9 +121,7 @@ public interface WhiteLabelService { @GET @Path("/logo") - @Produces(MediaType.APPLICATION_OCTET_STREAM) @ApiOperation( - produces = MediaType.APPLICATION_OCTET_STREAM, httpMethod = HTTPConstants.HEADER_GET, value = "Get whitelabel logo", notes = "Get whitelabel logo for the tenant of the logged in user", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java index 901885985d..69cb3d9ea7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.FileResponse; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; @@ -52,8 +53,8 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { @Path("/favicon") public Response getWhiteLabelFavicon() { try { - byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(); - return sendFileStream(fileContent); + FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(); + return sendFileStream(fileResponse); } catch (NotFoundException e) { String msg = "Favicon white label image cannot be found in the system. Updating the whitelabel theme might" + "help restore it"; @@ -71,8 +72,8 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { @Path("/logo") public Response getWhiteLabelLogo() { try { - byte[] fileContent = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(); - return sendFileStream(fileContent); + FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(); + return sendFileStream(fileResponse); } catch (NotFoundException e) { String msg = "Logo white label image cannot be found in the system. Updating the whitelabel theme might" + "help restore it"; @@ -131,14 +132,14 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { } /** - * Useful to send files as application/octet-stream responses + * Useful to send file responses */ - private Response sendFileStream(byte[] content) { - try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(content)) { + private Response sendFileStream(FileResponse fileResponse) { + try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(fileResponse.getFileContent())) { Response.ResponseBuilder response = Response - .ok(binaryDuplicate, MediaType.APPLICATION_OCTET_STREAM); + .ok(binaryDuplicate, fileResponse.getMimeType()); response.status(Response.Status.OK); - response.header("Content-Length", content.length); + response.header("Content-Length", fileResponse.getFileContent().length); return response.build(); } catch (IOException e) { String msg = "Error occurred while creating input stream from buffer array. "; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java new file mode 100644 index 0000000000..d2b29e34b9 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2022, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. + * + * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.device.mgt.common; + +public class FileResponse { + private byte[] fileContent; + private String mimeType; + + private String name; + + public byte[] getFileContent() { + return fileContent; + } + + public void setFileContent(byte[] fileContent) { + this.fileContent = fileContent; + } + + public String getMimeType() { + return mimeType; + } + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + public enum ImageExtension { + SVG() { + @Override + public String mimeType() { + return "image/svg+xml"; + } + }, + PNG, + JPG, + JPEG, + GIF; + + public String mimeType() { + return "application/octet-stream"; + } + + public static String mimeTypeOf(String extension) { + ImageExtension imageExtension = ImageExtension.valueOf(extension.toUpperCase()); + return imageExtension.mimeType(); + } + + @Override + public String toString() { + return this.name().toLowerCase(); + } + + } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java index e1536b8059..68a630a19f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelManagementService.java @@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.common.metadata.mgt; +import org.wso2.carbon.device.mgt.common.FileResponse; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; @@ -32,7 +33,7 @@ public interface WhiteLabelManagementService { * @throws MetadataManagementException if error occurred while retrieving favicon * @throws NotFoundException if favicon is not found */ - byte[] getWhiteLabelFavicon() throws + FileResponse getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException; /** @@ -41,7 +42,7 @@ public interface WhiteLabelManagementService { * @throws MetadataManagementException if error occurred while retrieving logo * @throws NotFoundException if logo is not found */ - byte[] getWhiteLabelLogo() throws + FileResponse getWhiteLabelLogo() throws MetadataManagementException, NotFoundException; /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java index 60d1538af9..269e6b7957 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/common/util/FileUtil.java @@ -88,7 +88,7 @@ public class FileUtil { String suffix = generateDuplicateFileNameSuffix(fileNameCount); String fileNameWithoutExtension = extractFileNameWithoutExtension(fileName); String fileNameWithSuffix = fileNameWithoutExtension + suffix; - fileNameWithSuffix = fileNameWithSuffix + '.' + extractFileExtension(fileName); + fileNameWithSuffix = fileNameWithSuffix + '.' + extractFileExtensionFileName(fileName); return fileNameWithSuffix; } @@ -111,13 +111,27 @@ public class FileUtil { return suffix; } + /** + * Use to extract file extension from file path + * + * @param filePath path of the file + * @return extension of the file + */ + public static String extractFileExtensionFromFilePath(String filePath) { + File file = new File(filePath); + return extractFileExtensionFileName(file.getName()); + } + /** * Use to extract file extension from file name * * @param fileName name of the file * @return extension of the file */ - private static String extractFileExtension(String fileName) { + public static String extractFileExtensionFileName(String fileName) { + if (!fileName.contains(".")) { + return ""; + } return fileName.substring(fileName.lastIndexOf('.') + 1); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index b9ea1091bf..6dfbda673b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -28,6 +28,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.FileResponse; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; import org.wso2.carbon.device.mgt.common.exceptions.TransactionManagementException; @@ -37,6 +38,8 @@ import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayl import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; +import org.wso2.carbon.device.mgt.core.common.util.FileUtil; +import org.wso2.carbon.device.mgt.core.common.util.HttpUtil; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; import org.wso2.carbon.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; @@ -46,7 +49,6 @@ import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOExc import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.MetadataManagementDAOFactory; import org.wso2.carbon.device.mgt.core.metadata.mgt.dao.util.MetadataConstants; import org.wso2.carbon.device.mgt.core.metadata.mgt.util.WhiteLabelStorageUtil; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -66,10 +68,10 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } @Override - public byte[] getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException { + public FileResponse getWhiteLabelFavicon() throws MetadataManagementException, NotFoundException { try { WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); - return getImageContent(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + return getImageFileResponse(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); } catch (IOException e) { String msg = "Error occurred while getting byte content of favicon"; log.error(msg, e); @@ -78,10 +80,10 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } @Override - public byte[] getWhiteLabelLogo() throws MetadataManagementException, NotFoundException { + public FileResponse getWhiteLabelLogo() throws MetadataManagementException, NotFoundException { try { WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(); - return getImageContent(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); + return getImageFileResponse(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); } catch (IOException e) { String msg = "Error occurred while getting byte content of logo"; log.error(msg, e); @@ -90,21 +92,36 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ } /** - * Useful to get white label image file byte content for provided {@link WhiteLabelImage.ImageName} + * Useful to get white label image file response for provided {@link WhiteLabelImage.ImageName} */ - private byte[] getImageContent(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws + private FileResponse getImageFileResponse(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws IOException, MetadataManagementException, NotFoundException { if (image.getImageLocationType() == WhiteLabelImage.ImageLocationType.URL) { - return getImageStreamFromUrl(image.getImageLocation()); + return getImageFileResponseFromUrl(image.getImageLocation()); } + return getImageFileResponseFromStorage(image, imageName); + } + + /** + * Useful to get white label image file response from provided image info + */ + private FileResponse getImageFileResponseFromStorage(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) + throws IOException, NotFoundException, MetadataManagementException { + FileResponse fileResponse = new FileResponse(); InputStream fileStream = WhiteLabelStorageUtil.getWhiteLabelImageStream(image, imageName); - return IOUtils.toByteArray(fileStream); + byte[] fileContent = IOUtils.toByteArray(fileStream); + String fileExtension = FileUtil.extractFileExtensionFromFilePath(image.getImageLocation()); + String mimeType = FileResponse.ImageExtension.mimeTypeOf(fileExtension); + fileResponse.setMimeType(mimeType); + fileResponse.setFileContent(fileContent); + return fileResponse; } /** - * Useful to get white label image file byte content from provided url + * Useful to get white label image file response from provided url */ - private byte[] getImageStreamFromUrl(String url) throws IOException, NotFoundException { + private FileResponse getImageFileResponseFromUrl(String url) throws IOException, NotFoundException { + FileResponse fileResponse = new FileResponse(); try(CloseableHttpClient client = HttpClients.createDefault()) { HttpGet imageGetRequest = new HttpGet(url); HttpResponse response = client.execute(imageGetRequest); @@ -114,7 +131,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ log.error(msg); throw new NotFoundException(msg); } - return IOUtils.toByteArray(imageStream); + byte[] fileContent = IOUtils.toByteArray(imageStream); + fileResponse.setFileContent(fileContent); + String mimeType = HttpUtil.getContentType(response); + fileResponse.setMimeType(mimeType); + return fileResponse; } } From b8a0ffe7c0aba814c976fdecaa5d38678885f8db Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 26 May 2022 04:16:57 +0530 Subject: [PATCH 08/15] Improve favicon/logo response content type handling --- .../carbon/device/mgt/common/FileResponse.java | 6 +++++- .../mgt/WhiteLabelManagementServiceImpl.java | 17 +---------------- .../mgt/util/WhiteLabelStorageUtil.java | 12 ++++++++++-- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java index d2b29e34b9..45ee74e020 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/FileResponse.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.common; public class FileResponse { + private static final String DEFAULT_MIME_TYPE = "application/octet-stream"; private byte[] fileContent; private String mimeType; @@ -53,10 +54,13 @@ public class FileResponse { GIF; public String mimeType() { - return "application/octet-stream"; + return DEFAULT_MIME_TYPE; } public static String mimeTypeOf(String extension) { + if (extension.isEmpty()) { + return DEFAULT_MIME_TYPE; + } ImageExtension imageExtension = ImageExtension.valueOf(extension.toUpperCase()); return imageExtension.mimeType(); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 6dfbda673b..73095e3690 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -99,22 +99,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ if (image.getImageLocationType() == WhiteLabelImage.ImageLocationType.URL) { return getImageFileResponseFromUrl(image.getImageLocation()); } - return getImageFileResponseFromStorage(image, imageName); - } - - /** - * Useful to get white label image file response from provided image info - */ - private FileResponse getImageFileResponseFromStorage(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) - throws IOException, NotFoundException, MetadataManagementException { - FileResponse fileResponse = new FileResponse(); - InputStream fileStream = WhiteLabelStorageUtil.getWhiteLabelImageStream(image, imageName); - byte[] fileContent = IOUtils.toByteArray(fileStream); - String fileExtension = FileUtil.extractFileExtensionFromFilePath(image.getImageLocation()); - String mimeType = FileResponse.ImageExtension.mimeTypeOf(fileExtension); - fileResponse.setMimeType(mimeType); - fileResponse.setFileContent(fileContent); - return fileResponse; + return WhiteLabelStorageUtil.getWhiteLabelImageStream(image, imageName); } /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index 26e2b23ce1..341e1130fe 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -17,10 +17,12 @@ package org.wso2.carbon.device.mgt.core.metadata.mgt.util; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Base64File; +import org.wso2.carbon.device.mgt.common.FileResponse; import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException; import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImage; @@ -126,8 +128,9 @@ public class WhiteLabelStorageUtil { * @param imageName (i.e: LOGO) * @return white label image input stream */ - public static InputStream getWhiteLabelImageStream(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) + public static FileResponse getWhiteLabelImageStream(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) throws MetadataManagementException, NotFoundException { + FileResponse fileResponse = new FileResponse(); String fullPathToFile = getPathToImage(image, imageName); try { InputStream imageStream = StorageManagementUtil.getInputStream(fullPathToFile); @@ -136,7 +139,12 @@ public class WhiteLabelStorageUtil { log.error(msg); throw new NotFoundException(msg); } - return imageStream; + byte[] fileContent = IOUtils.toByteArray(imageStream); + String fileExtension = FileUtil.extractFileExtensionFromFilePath(image.getImageLocation()); + String mimeType = FileResponse.ImageExtension.mimeTypeOf(fileExtension); + fileResponse.setMimeType(mimeType); + fileResponse.setFileContent(fileContent); + return fileResponse; } catch (IOException e) { String msg = "Error occurred when accessing the file in file path: " + fullPathToFile; log.error(msg, e); From 743a12083bb59586633951e52c6c4bcd4d36f1f3 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 7 Jun 2022 09:34:16 +0530 Subject: [PATCH 09/15] Refactor whitelabel update api method name to update from create --- .../carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java | 2 +- .../device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java index 68313eb878..5a7d715658 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/WhiteLabelService.java @@ -192,7 +192,7 @@ public interface WhiteLabelService { "\n Server error occurred while creating white label theme.", response = ErrorResponse.class) }) - Response createWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest); + Response updateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest); @GET @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java index 69cb3d9ea7..c61b9034cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/WhiteLabelServiceImpl.java @@ -88,7 +88,7 @@ public class WhiteLabelServiceImpl implements WhiteLabelService { @PUT @Override - public Response createWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { + public Response updateWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) { RequestValidationUtil.validateWhiteLabelTheme(whiteLabelThemeCreateRequest); try { WhiteLabelTheme createdWhiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().updateWhiteLabelTheme(whiteLabelThemeCreateRequest); From 7df4aff56932497b8221f56af8ced74f5030d92d Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Tue, 7 Jun 2022 13:32:42 +0530 Subject: [PATCH 10/15] Fix retrieving favicon as logo when retrieving existing images for rollback --- .../core/metadata/mgt/WhiteLabelManagementServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 73095e3690..5c5bf45b0b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -236,8 +236,8 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ if (theme.getFaviconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { existingFaviconImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); } - if (theme.getFaviconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { - existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); + if (theme.getLogoImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { + existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.LOGO); } storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getFavicon(), WhiteLabelImage.ImageName.FAVICON, tenantId); storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getLogo(), WhiteLabelImage.ImageName.LOGO, tenantId); From 78546125bc08ddbbca40a06a9daa2c88009320aa Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Wed, 8 Jun 2022 00:03:37 +0530 Subject: [PATCH 11/15] Add page title to whitelable --- .../service/impl/util/RequestValidationUtil.java | 7 +++++++ .../mgt/common/metadata/mgt/WhiteLabelTheme.java | 9 +++++++++ .../metadata/mgt/WhiteLabelThemeCreateRequest.java | 9 +++++++++ .../mgt/whitelabel/WhiteLabelConfiguration.java | 10 ++++++++++ .../mgt/WhiteLabelManagementServiceImpl.java | 13 +++++++++++++ .../src/main/resources/conf/cdm-config.xml | 1 + .../templates/repository/conf/cdm-config.xml.j2 | 1 + 7 files changed, 50 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 03c49ecb9d..d8c4efb7ac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -689,6 +689,13 @@ public class RequestValidationUtil { new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } + if (whiteLabelThemeCreateRequest.getPageTitle() == null) { + String msg = "Page title is required to whitelabel"; + log.error(msg); + throw new InputValidationException( + new ErrorResponse.ErrorResponseBuilder() + .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); + } try { validateWhiteLabelImage(whiteLabelThemeCreateRequest.getFavicon()); validateWhiteLabelImage(whiteLabelThemeCreateRequest.getLogo()); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java index 6eaa8b4d05..5b0dbfaca4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java @@ -22,6 +22,7 @@ public class WhiteLabelTheme { private WhiteLabelImage faviconImage; private WhiteLabelImage logoImage; private String footerText; + private String pageTitle; public String getFooterText() { return footerText; @@ -46,4 +47,12 @@ public class WhiteLabelTheme { public void setLogoImage(WhiteLabelImage logoImage) { this.logoImage = logoImage; } + + public String getPageTitle() { + return pageTitle; + } + + public void setPageTitle(String pageTitle) { + this.pageTitle = pageTitle; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java index 5e5e6f0d32..f1664371d9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java @@ -22,6 +22,7 @@ public class WhiteLabelThemeCreateRequest { private WhiteLabelImageRequestPayload favicon; private WhiteLabelImageRequestPayload logo; private String footerText; + private String pageTitle; public WhiteLabelImageRequestPayload getFavicon() { return favicon; @@ -46,4 +47,12 @@ public class WhiteLabelThemeCreateRequest { public void setFooterText(String footerText) { this.footerText = footerText; } + + public String getPageTitle() { + return pageTitle; + } + + public void setPageTitle(String pageTitle) { + this.pageTitle = pageTitle; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java index cac694eb2e..2424768a37 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "WhiteLabelConfiguration") public class WhiteLabelConfiguration { private String footerText; + private String pageTitle; private WhiteLabelImages whiteLabelImages; @XmlElement(name = "FooterText", required = true) @@ -43,4 +44,13 @@ public class WhiteLabelConfiguration { public void setWhiteLabelImages(WhiteLabelImages whiteLabelImages) { this.whiteLabelImages = whiteLabelImages; } + + @XmlElement(name = "PageTitle", required = true) + public String getPageTitle() { + return pageTitle; + } + + public void setPageTitle(String pageTitle) { + this.pageTitle = pageTitle; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 5c5bf45b0b..32008015f5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -165,15 +165,27 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ */ private WhiteLabelTheme getDefaultWhiteLabelTheme() { String footerText = getDefaultFooterText(); + String pageTitle = getDefaultPageTitle(); WhiteLabelImage favicon = constructDefaultFaviconImage(); WhiteLabelImage logo = constructDefaultLogoImage(); WhiteLabelTheme defaultTheme = new WhiteLabelTheme(); defaultTheme.setFooterText(footerText); + defaultTheme.setPageTitle(pageTitle); defaultTheme.setLogoImage(logo); defaultTheme.setFaviconImage(favicon); return defaultTheme; } + /** + * Get default whitelabel label page title from config + */ + private String getDefaultPageTitle() { + MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). + getDeviceManagementConfig().getMetaDataConfiguration(); + WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); + return whiteLabelConfiguration.getPageTitle(); + } + /** * Get default whitelabel label footer from config */ @@ -319,6 +331,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ whiteLabelTheme.setFaviconImage(faviconImage); whiteLabelTheme.setLogoImage(logoImage); whiteLabelTheme.setFooterText(whiteLabelThemeCreateRequest.getFooterText()); + whiteLabelTheme.setPageTitle(whiteLabelThemeCreateRequest.getPageTitle()); return whiteLabelTheme; } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index 2636456d80..f7e815596c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -187,6 +187,7 @@ IoT Server 5.0.0 | © 2022 , All Rights Reserved. + Entgra Endpoint Management repository/resources/whitelabel favicon.png diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 1370def31b..5190cf1c32 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -320,6 +320,7 @@ IoT Server 5.0.0 | © 2022 , All Rights Reserved. + Entgra Endpoint Management repository/resources/whitelabel favicon.png From eb061f94504eaaffaa1631680fd0430f6298e5e2 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Wed, 8 Jun 2022 13:40:33 +0530 Subject: [PATCH 12/15] Refator page tite to app title --- .../service/impl/util/RequestValidationUtil.java | 4 +--- .../mgt/common/metadata/mgt/WhiteLabelTheme.java | 10 +++++----- .../metadata/mgt/WhiteLabelThemeCreateRequest.java | 10 +++++----- .../mgt/whitelabel/WhiteLabelConfiguration.java | 12 ++++++------ .../mgt/WhiteLabelManagementServiceImpl.java | 11 +++++------ .../src/main/resources/conf/cdm-config.xml | 2 +- .../templates/repository/conf/cdm-config.xml.j2 | 2 +- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index d8c4efb7ac..bc41d45848 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl.util; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang3.EnumUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpStatus; @@ -35,7 +34,6 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; import org.wso2.carbon.device.mgt.common.exceptions.DeviceTypeNotFoundException; import org.wso2.carbon.device.mgt.common.metadata.mgt.Metadata; -import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImage; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayload; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.core.common.util.HttpUtil; @@ -689,7 +687,7 @@ public class RequestValidationUtil { new ErrorResponse.ErrorResponseBuilder() .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } - if (whiteLabelThemeCreateRequest.getPageTitle() == null) { + if (whiteLabelThemeCreateRequest.getAppTitle() == null) { String msg = "Page title is required to whitelabel"; log.error(msg); throw new InputValidationException( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java index 5b0dbfaca4..0b71979843 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelTheme.java @@ -22,7 +22,7 @@ public class WhiteLabelTheme { private WhiteLabelImage faviconImage; private WhiteLabelImage logoImage; private String footerText; - private String pageTitle; + private String appTitle; public String getFooterText() { return footerText; @@ -48,11 +48,11 @@ public class WhiteLabelTheme { this.logoImage = logoImage; } - public String getPageTitle() { - return pageTitle; + public String getAppTitle() { + return appTitle; } - public void setPageTitle(String pageTitle) { - this.pageTitle = pageTitle; + public void setAppTitle(String appTitle) { + this.appTitle = appTitle; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java index f1664371d9..4b720eeec4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/metadata/mgt/WhiteLabelThemeCreateRequest.java @@ -22,7 +22,7 @@ public class WhiteLabelThemeCreateRequest { private WhiteLabelImageRequestPayload favicon; private WhiteLabelImageRequestPayload logo; private String footerText; - private String pageTitle; + private String appTitle; public WhiteLabelImageRequestPayload getFavicon() { return favicon; @@ -48,11 +48,11 @@ public class WhiteLabelThemeCreateRequest { this.footerText = footerText; } - public String getPageTitle() { - return pageTitle; + public String getAppTitle() { + return appTitle; } - public void setPageTitle(String pageTitle) { - this.pageTitle = pageTitle; + public void setAppTitle(String appTitle) { + this.appTitle = appTitle; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java index 2424768a37..1fa808f5a7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/whitelabel/WhiteLabelConfiguration.java @@ -24,7 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "WhiteLabelConfiguration") public class WhiteLabelConfiguration { private String footerText; - private String pageTitle; + private String appTitle; private WhiteLabelImages whiteLabelImages; @XmlElement(name = "FooterText", required = true) @@ -45,12 +45,12 @@ public class WhiteLabelConfiguration { this.whiteLabelImages = whiteLabelImages; } - @XmlElement(name = "PageTitle", required = true) - public String getPageTitle() { - return pageTitle; + @XmlElement(name = "AppTitle", required = true) + public String getAppTitle() { + return appTitle; } - public void setPageTitle(String pageTitle) { - this.pageTitle = pageTitle; + public void setAppTitle(String appTitle) { + this.appTitle = appTitle; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 32008015f5..d816e63291 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -38,7 +38,6 @@ import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelImageRequestPayl import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelManagementService; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelTheme; import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest; -import org.wso2.carbon.device.mgt.core.common.util.FileUtil; import org.wso2.carbon.device.mgt.core.common.util.HttpUtil; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; @@ -165,12 +164,12 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ */ private WhiteLabelTheme getDefaultWhiteLabelTheme() { String footerText = getDefaultFooterText(); - String pageTitle = getDefaultPageTitle(); + String appTitle = getDefaultAppTitle(); WhiteLabelImage favicon = constructDefaultFaviconImage(); WhiteLabelImage logo = constructDefaultLogoImage(); WhiteLabelTheme defaultTheme = new WhiteLabelTheme(); defaultTheme.setFooterText(footerText); - defaultTheme.setPageTitle(pageTitle); + defaultTheme.setAppTitle(appTitle); defaultTheme.setLogoImage(logo); defaultTheme.setFaviconImage(favicon); return defaultTheme; @@ -179,11 +178,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ /** * Get default whitelabel label page title from config */ - private String getDefaultPageTitle() { + private String getDefaultAppTitle() { MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance(). getDeviceManagementConfig().getMetaDataConfiguration(); WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration(); - return whiteLabelConfiguration.getPageTitle(); + return whiteLabelConfiguration.getAppTitle(); } /** @@ -331,7 +330,7 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ whiteLabelTheme.setFaviconImage(faviconImage); whiteLabelTheme.setLogoImage(logoImage); whiteLabelTheme.setFooterText(whiteLabelThemeCreateRequest.getFooterText()); - whiteLabelTheme.setPageTitle(whiteLabelThemeCreateRequest.getPageTitle()); + whiteLabelTheme.setAppTitle(whiteLabelThemeCreateRequest.getAppTitle()); return whiteLabelTheme; } diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index f7e815596c..97d152235e 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -187,7 +187,7 @@ IoT Server 5.0.0 | © 2022 , All Rights Reserved. - Entgra Endpoint Management + Entgra repository/resources/whitelabel favicon.png diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index 5190cf1c32..c929882826 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -320,7 +320,7 @@ IoT Server 5.0.0 | © 2022 , All Rights Reserved. - Entgra Endpoint Management + Entgra repository/resources/whitelabel favicon.png From be15bf91858f00561fdf8c24178c5df50fec9608 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Wed, 8 Jun 2022 13:45:08 +0530 Subject: [PATCH 13/15] Fix log message --- .../mgt/jaxrs/service/impl/util/RequestValidationUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index bc41d45848..eaa8ba4f2b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -688,7 +688,7 @@ public class RequestValidationUtil { .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build()); } if (whiteLabelThemeCreateRequest.getAppTitle() == null) { - String msg = "Page title is required to whitelabel"; + String msg = "App title is required to whitelabel"; log.error(msg); throw new InputValidationException( new ErrorResponse.ErrorResponseBuilder() From c63168be62ac332e67864ea09ea535d26fc13c1c Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Thu, 9 Jun 2022 17:00:52 +0530 Subject: [PATCH 14/15] Fix passing favicon image bean when retrieving existing logo --- .../mgt/WhiteLabelManagementServiceImpl.java | 43 ++++++++++--------- .../mgt/util/WhiteLabelStorageUtil.java | 2 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index d816e63291..2af7aa361f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -248,37 +248,38 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ existingFaviconImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON); } if (theme.getLogoImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) { - existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.LOGO); + existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getLogoImage(), WhiteLabelImage.ImageName.LOGO); } storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getFavicon(), WhiteLabelImage.ImageName.FAVICON, tenantId); storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getLogo(), WhiteLabelImage.ImageName.LOGO, tenantId); WhiteLabelTheme whiteLabelTheme = constructWhiteLabelTheme(createWhiteLabelTheme); Metadata metadataWhiteLabelTheme = constructWhiteLabelThemeMetadata(whiteLabelTheme); - - MetadataManagementDAOFactory.beginTransaction(); - metadataDAO.updateMetadata(tenantId, metadataWhiteLabelTheme); - MetadataManagementDAOFactory.commitTransaction(); - if (log.isDebugEnabled()) { - log.debug("Metadata entry created successfully. " + createWhiteLabelTheme.toString()); + try { + MetadataManagementDAOFactory.beginTransaction(); + metadataDAO.updateMetadata(tenantId, metadataWhiteLabelTheme); + MetadataManagementDAOFactory.commitTransaction(); + if (log.isDebugEnabled()) { + log.debug("Metadata entry created successfully. " + createWhiteLabelTheme); + } + return whiteLabelTheme; + } catch (MetadataManagementDAOException e) { + MetadataManagementDAOFactory.rollbackTransaction(); + restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); + String msg = "Error occurred while creating the metadata entry. " + createWhiteLabelTheme; + log.error(msg, e); + throw new MetadataManagementException(msg, e); + } catch (TransactionManagementException e) { + restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); + String msg = "Error occurred while opening a connection to the data source"; + log.error(msg, e); + throw new MetadataManagementException("Error occurred while creating metadata record", e); + } finally { + MetadataManagementDAOFactory.closeConnection(); } - return whiteLabelTheme; - } catch (MetadataManagementDAOException e) { - MetadataManagementDAOFactory.rollbackTransaction(); - restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); - String msg = "Error occurred while creating the metadata entry. " + createWhiteLabelTheme.toString(); - log.error(msg, e); - throw new MetadataManagementException(msg, e); - } catch (TransactionManagementException e) { - restoreWhiteLabelImages(existingFaviconImage, existingLogoImage, tenantId); - String msg = "Error occurred while opening a connection to the data source"; - log.error(msg, e); - throw new MetadataManagementException("Error occurred while creating metadata record", e); } catch (NotFoundException e) { String msg = "Error occurred while retrieving existing white label theme"; log.error(msg, e); throw new MetadataManagementException(msg, e); - } finally { - MetadataManagementDAOFactory.closeConnection(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java index 341e1130fe..c426c86b69 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/util/WhiteLabelStorageUtil.java @@ -116,7 +116,7 @@ public class WhiteLabelStorageUtil { * @return white label image file {@link File} */ public static File getWhiteLabelImageFile(WhiteLabelImage image, WhiteLabelImage.ImageName imageName) - throws MetadataManagementException, NotFoundException { + throws MetadataManagementException { String fullPathToImage = getPathToImage(image, imageName); return new File(fullPathToImage); } From af25528a8bbd3b5434d8bdcca156be85b445e9b7 Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Fri, 10 Jun 2022 14:48:16 +0530 Subject: [PATCH 15/15] Delete custom whitelabel favicon and logo on whitelabel reset --- .../mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java index 2af7aa361f..cb46ec25d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/metadata/mgt/WhiteLabelManagementServiceImpl.java @@ -154,9 +154,11 @@ public class WhiteLabelManagementServiceImpl implements WhiteLabelManagementServ @Override public void resetToDefaultWhiteLabelTheme() throws MetadataManagementException { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); WhiteLabelTheme whiteLabelTheme = getDefaultWhiteLabelTheme(); Metadata metadata = constructWhiteLabelThemeMetadata(whiteLabelTheme); DeviceManagementDataHolder.getInstance().getMetadataManagementService().updateMetadata(metadata); + WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId); } /**