From 5184d608055648738df30f10be0edfee82737394 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Thu, 11 Jan 2024 22:25:04 +0530 Subject: [PATCH 1/2] Add doc url template variable --- .../mgt/core/DeviceManagementConstants.java | 1 + .../metadata/mgt/MetaDataConfiguration.java | 11 +++++++++++ .../mgt/documentation/DocConfiguration.java | 18 ++++++++++++++++++ .../DeviceManagementProviderServiceImpl.java | 2 ++ .../mgt/core/util/DeviceManagerUtil.java | 12 ++++++++++++ .../carbon-home/repository/conf/cdm-config.xml | 5 +++++ .../src/main/resources/conf/cdm-config.xml | 3 +++ .../repository/conf/cdm-config.xml.j2 | 5 +++++ 8 files changed, 57 insertions(+) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java index 872b25205a..6fae7901d5 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementConstants.java @@ -124,6 +124,7 @@ public final class DeviceManagementConstants { public static final String DEVICE_ENROLLMENT_MAIL_KEY = "enrollment"; public static final String TEMPLATE_NAME_PART_JOINER = "-"; public static final String ENROLLMENT_TYPE_SPLITTER = "_"; + public static final String DOC_URL = "doc-url"; } public static final class OperationAttributes { diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java index 1812862dd5..52cf65dbf7 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt; +import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation.DocConfiguration; import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.whitelabel.WhiteLabelConfiguration; import javax.xml.bind.annotation.XmlElement; @@ -26,6 +27,7 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "MetaDataConfiguration") public class MetaDataConfiguration { private WhiteLabelConfiguration whiteLabelConfiguration; + private DocConfiguration docConfiguration; @XmlElement(name = "WhiteLabelConfiguration", required = true) public WhiteLabelConfiguration getWhiteLabelConfiguration() { @@ -35,4 +37,13 @@ public class MetaDataConfiguration { public void setWhiteLabelConfiguration(WhiteLabelConfiguration whiteLabelConfiguration) { this.whiteLabelConfiguration = whiteLabelConfiguration; } + + @XmlElement(name = "DocConfiguration", required = true) + public DocConfiguration getDocConfiguration() { + return docConfiguration; + } + + public void setDocConfiguration(DocConfiguration docConfiguration) { + this.docConfiguration = docConfiguration; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java new file mode 100644 index 0000000000..d0c42b6601 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java @@ -0,0 +1,18 @@ +package io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "DocConfiguration") +public class DocConfiguration { + private String docUrl; + + @XmlElement(name = "DocUrl", required = true) + public String getDocUrl() { + return docUrl; + } + + public void setDocUrl(String docUrl) { + this.docUrl = docUrl; + } +} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index bcd511123a..22c79aacc1 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -1564,6 +1564,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv new TypedValue<>(String.class, DeviceManagerUtil.getServerBaseHttpsUrl())); params.put(io.entgra.device.mgt.core.device.mgt.core.DeviceManagementConstants.EmailAttributes.SERVER_BASE_URL_HTTP, new TypedValue<>(String.class, DeviceManagerUtil.getServerBaseHttpUrl())); + params.put(DeviceManagementConstants.EmailAttributes.DOC_URL, + new TypedValue<>(String.class, DeviceManagerUtil.getDocUrl())); try { EmailContext ctx = new EmailContext.EmailContextBuilder(new ContentProviderInfo(templateName, params), diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java index b5b0dd11f9..3e04ada25f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/util/DeviceManagerUtil.java @@ -19,6 +19,8 @@ package io.entgra.device.mgt.core.device.mgt.core.util; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.MetaDataConfiguration; +import io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation.DocConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -1276,4 +1278,14 @@ public final class DeviceManagerUtil { + deviceGroup.getGroupId(); } } + + /** + * Retrieve the documentation url + * @return documentation url + */ + public static String getDocUrl() { + DeviceManagementConfig deviceManagementConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(); + DocConfiguration docConfiguration = deviceManagementConfig.getMetaDataConfiguration().getDocConfiguration(); + return docConfiguration.getDocUrl(); + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml index 0cf4f89617..d12d30b401 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/carbon-home/repository/conf/cdm-config.xml @@ -159,5 +159,10 @@ 640 BYOD,COPE + + + https://docs.entgra.io/uem/6.0.0 + + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml index e2646e6070..a9214f24a8 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/cdm-config.xml @@ -201,6 +201,9 @@ default + + https://docs.entgra.io/uem/6.0.0 + diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 index bd6961e7d8..259a12301a 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/cdm-config.xml.j2 @@ -344,6 +344,11 @@ default + + {% if product_conf is defined %} + https://docs.entgra.io/uem/{{product_conf.server_version}} + {% endif %} + -- 2.36.3 From bdfb21800cf55836bffb1ab2b6c55bbaf1c009d6 Mon Sep 17 00:00:00 2001 From: Rajitha Kumara Date: Fri, 12 Jan 2024 06:08:55 +0530 Subject: [PATCH 2/2] Add license --- .../mgt/documentation/DocConfiguration.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java index d0c42b6601..63a6981146 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/config/metadata/mgt/documentation/DocConfiguration.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation; import javax.xml.bind.annotation.XmlElement; -- 2.36.3