From 78546125bc08ddbbca40a06a9daa2c88009320aa Mon Sep 17 00:00:00 2001 From: Mohamed Rashd Date: Wed, 8 Jun 2022 00:03:37 +0530 Subject: [PATCH] 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