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 564673ef8b..5ddd2eacf8 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.20-SNAPSHOT
+ 5.0.22-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 1ba9a75dd3..b8f04c797d 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.20-SNAPSHOT
+ 5.0.22-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 56aacfa64d..020ebeec6b 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml
index e48aeca1f7..17251bd949 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml
index ded09a6876..9e3978e717 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml
new file mode 100644
index 0000000000..6f1da82ae9
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml
@@ -0,0 +1,119 @@
+
+
+
+
+ apimgt-extensions
+ org.wso2.carbon.devicemgt
+ 5.0.22-SNAPSHOT
+
+
+ 4.0.0
+ io.entgra.device.mgt.core.apimgt.analytics.extension
+ bundle
+ Entgra - API mgt analytics extension
+ http://wso2.org
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.core
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+
+
+ org.apache.velocity
+ velocity
+ 1.7
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/Abstract*
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${carbon.device.mgt.version}
+ API Management Application Bundle
+ org.wso2.carbon.apimgt.application.extension.internal
+
+ io.entgra.device.mgt.core.apimgt.analytics.extension.dto,
+ org.apache.velocity,
+ org.apache.velocity.app,
+ org.apache.velocity.context,
+ org.wso2.carbon.utils;version="[4.6,5)"
+
+
+ io.entgra.device.mgt.core.apimgt.analytics.extension.*
+
+
+ scribe;scope=compile|runtime;inline=false;
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+ ${basedir}/target/coverage-reports/jacoco-unit.exec
+
+
+
+ jacoco-initialize
+
+ prepare-agent
+
+
+
+ jacoco-site
+ test
+
+ report
+
+
+ ${basedir}/target/coverage-reports/jacoco-unit.exec
+ ${basedir}/target/coverage-reports/site
+
+
+
+
+
+
+
+
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java
new file mode 100644
index 0000000000..fcd197bb0e
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/AnalyticsArtifactsDeployer.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension;
+
+import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventPublisherData;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventReceiverData;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.EventStreamData;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.MetaData;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventPublisherDeployerException;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventReceiverDeployerException;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventStreamDeployerException;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+
+public class AnalyticsArtifactsDeployer {
+
+ public static final String TEMPLATE_LOCATION = "repository" + File.separator + "resources" + File.separator + "iot-analytics-templates";
+ public static final String EVENT_STREAM_LOCATION = "eventstreams";
+ public static final String EVENT_PUBLISHER_LOCATION = "eventpublishers";
+ public static final String EVENT_RECEIVER_LOCATION = "eventreceivers";
+ public static final String EVENT_STREAM_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_stream.json.template";
+ public static final String EVENT_PUBLISHER_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_publisher.xml.template";
+ public static final String EVENT_RECEIVER_TEMPLATE = TEMPLATE_LOCATION + File.separator + "event_receiver.xml.template";
+
+
+ public void deployEventStream(EventStreamData eventStreamData, int tenantId) throws EventStreamDeployerException {
+ try {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
+ ve.init();
+ Template template = ve.getTemplate(EVENT_STREAM_TEMPLATE);
+
+ VelocityContext context = populateContextForEventStreams(eventStreamData);
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+
+ String fileName = eventStreamData.getName() + "_" + eventStreamData.getVersion() + ".json";
+ String fileLocation = null;
+ if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
+ fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
+ + File.separator + "server" + File.separator + EVENT_STREAM_LOCATION + File.separator + fileName;
+ } else {
+ fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
+ + EVENT_STREAM_LOCATION + File.separator + fileName;
+ }
+
+ PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
+ printWriter.println(writer.toString());
+ printWriter.close();
+ } catch (FileNotFoundException | UnsupportedEncodingException e) {
+ throw new EventStreamDeployerException("Error while persisting event stream definition ", e);
+ }
+ }
+
+ public void deployEventPublisher(EventPublisherData eventPublisherData, int tenantId) throws EventPublisherDeployerException {
+ try {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
+ ve.init();
+ Template template = ve.getTemplate(EVENT_PUBLISHER_TEMPLATE);
+
+ VelocityContext context = populateContextForEventPublisher(eventPublisherData);
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+
+ String fileName = eventPublisherData.getName() + ".xml";
+ String fileLocation = null;
+ if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
+ fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
+ + File.separator + "server" + File.separator + EVENT_PUBLISHER_LOCATION + File.separator + fileName;
+ } else {
+ fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
+ + EVENT_PUBLISHER_LOCATION + File.separator + fileName;
+ }
+
+ PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
+ printWriter.println(writer.toString());
+ printWriter.close();
+ } catch (FileNotFoundException | UnsupportedEncodingException e) {
+ throw new EventPublisherDeployerException("Error while persisting rdbms event publisher ", e);
+ }
+ }
+
+ public void deployEventReceiver(EventReceiverData eventReceiverData, int tenantId) throws EventReceiverDeployerException {
+ try {
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, CarbonUtils.getCarbonHome());
+ ve.init();
+ Template template = ve.getTemplate(EVENT_RECEIVER_TEMPLATE);
+
+ VelocityContext context = populateContextForEventReceiver(eventReceiverData);
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+
+ String fileName = eventReceiverData.getName() + ".xml";
+ String fileLocation = null;
+ if (MultitenantConstants.SUPER_TENANT_ID == tenantId) {
+ fileLocation = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "deployment"
+ + File.separator + "server" + File.separator + EVENT_RECEIVER_LOCATION + File.separator + fileName;
+ } else {
+ fileLocation = CarbonUtils.getCarbonTenantsDirPath() + File.separator + tenantId + File.separator
+ + EVENT_RECEIVER_LOCATION + File.separator + fileName;
+ }
+
+ PrintWriter printWriter = new PrintWriter(fileLocation, "UTF-8");
+ printWriter.println(writer.toString());
+ printWriter.close();
+ } catch (FileNotFoundException | UnsupportedEncodingException e) {
+ throw new EventReceiverDeployerException("Error while persisting oauth mqtt event receiver ", e);
+ }
+ }
+
+ private VelocityContext populateContextForEventStreams(EventStreamData eventStreamData) {
+ VelocityContext context = new VelocityContext();
+ context.put("name", eventStreamData.getName());
+ context.put("version", eventStreamData.getVersion());
+ context.put("metaData",
+ eventStreamData.getMetaData() != null ? eventStreamData.getMetaData() : new MetaData("deviceId", "STRING"));
+ if (eventStreamData.getPayloadData() != null) {
+ context.put("properties", eventStreamData.getPayloadData());
+ }
+ return context;
+ }
+
+ private VelocityContext populateContextForEventPublisher(EventPublisherData eventPublisherData) {
+ VelocityContext context = new VelocityContext();
+
+ context.put("name", eventPublisherData.getName());
+ context.put("streamName", eventPublisherData.getStreamName());
+ context.put("streamVersion", eventPublisherData.getStreamVersion());
+ context.put("properties", eventPublisherData.getPropertyList());
+ context.put("eventAdapterType", eventPublisherData.getEventAdaptorType());
+ context.put("customMappingType", eventPublisherData.getCustomMappingType());
+
+ return context;
+ }
+
+ private VelocityContext populateContextForEventReceiver(EventReceiverData eventReceiverData) {
+ VelocityContext context = new VelocityContext();
+
+ context.put("name", eventReceiverData.getName());
+ context.put("streamName", eventReceiverData.getStreamName());
+ context.put("streamVersion", eventReceiverData.getStreamVersion());
+ context.put("properties", eventReceiverData.getPropertyList());
+ context.put("eventAdapterType", eventReceiverData.getEventAdapterType());
+ context.put("customMappingType", eventReceiverData.getCustomMappingType());
+
+ return context;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventPublisherData.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventPublisherData.java
new file mode 100644
index 0000000000..6d1620a5b9
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventPublisherData.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.dto;
+
+import java.util.List;
+
+public class EventPublisherData {
+ private String name;
+ private String streamVersion;
+ private String streamName;
+
+ private List propertyList;
+
+ private String eventAdaptorType;
+
+ private String customMappingType;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getStreamVersion() {
+ return streamVersion;
+ }
+
+ public void setStreamVersion(String streamVersion) {
+ this.streamVersion = streamVersion;
+ }
+
+ public String getStreamName() {
+ return streamName;
+ }
+
+ public void setStreamName(String streamName) {
+ this.streamName = streamName;
+ }
+
+ public List getPropertyList() {
+ return propertyList;
+ }
+
+ public void setPropertyList(List propertyList) {
+ this.propertyList = propertyList;
+ }
+
+ public String getEventAdaptorType() {
+ return eventAdaptorType;
+ }
+
+ public void setEventAdaptorType(String eventAdaptorType) {
+ this.eventAdaptorType = eventAdaptorType;
+ }
+
+ public String getCustomMappingType() {
+ return customMappingType;
+ }
+
+ public void setCustomMappingType(String customMappingType) {
+ this.customMappingType = customMappingType;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventReceiverData.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventReceiverData.java
new file mode 100644
index 0000000000..764229c55a
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventReceiverData.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.dto;
+
+import java.util.List;
+
+public class EventReceiverData {
+
+ private String name;
+ private String streamVersion;
+ private String streamName;
+
+ private String eventAdapterType;
+
+ List propertyList;
+
+ private String customMappingType;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getStreamVersion() {
+ return streamVersion;
+ }
+
+ public void setStreamVersion(String streamVersion) {
+ this.streamVersion = streamVersion;
+ }
+
+ public String getStreamName() {
+ return streamName;
+ }
+
+ public void setStreamName(String streamName) {
+ this.streamName = streamName;
+ }
+
+ public String getEventAdapterType() {
+ return eventAdapterType;
+ }
+
+ public void setEventAdapterType(String eventAdapterType) {
+ this.eventAdapterType = eventAdapterType;
+ }
+
+ public List getPropertyList() {
+ return propertyList;
+ }
+
+ public void setPropertyList(List propertyList) {
+ this.propertyList = propertyList;
+ }
+
+ public String getCustomMappingType() {
+ return customMappingType;
+ }
+
+ public void setCustomMappingType(String customMappingType) {
+ this.customMappingType = customMappingType;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventStreamData.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventStreamData.java
new file mode 100644
index 0000000000..a80520bef4
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/EventStreamData.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.dto;
+
+import java.util.List;
+
+public class EventStreamData {
+ private String name;
+ private String version;
+ private MetaData metaData;
+ private List payloadData;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public MetaData getMetaData() {
+ return metaData;
+ }
+
+ public void setMetaData(MetaData metaData) {
+ this.metaData = metaData;
+ }
+
+ public List getPayloadData() {
+ return payloadData;
+ }
+
+ public void setPayloadData(List payloadData) {
+ this.payloadData = payloadData;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/MetaData.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/MetaData.java
new file mode 100644
index 0000000000..ba77d04413
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/MetaData.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.dto;
+
+public class MetaData {
+ String name;
+ String type;
+
+ public MetaData(String name, String type){
+ this.setName(name);
+ this.setType(type);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/Property.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/Property.java
new file mode 100644
index 0000000000..995cf2c5a8
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/dto/Property.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.dto;
+
+public class Property {
+ String name;
+ String value;
+
+ public Property(String name, String value){
+ this.setName(name);
+ this.setValue(value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventPublisherDeployerException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventPublisherDeployerException.java
new file mode 100644
index 0000000000..2f924d0e7b
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventPublisherDeployerException.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.exception;
+
+public class EventPublisherDeployerException extends Exception {
+
+ private static final long serialVersionUID = -3151279311929070299L;
+
+ public EventPublisherDeployerException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ }
+
+ public EventPublisherDeployerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EventPublisherDeployerException(String msg) {
+ super(msg);
+ }
+
+ public EventPublisherDeployerException() {
+ super();
+ }
+
+ public EventPublisherDeployerException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventReceiverDeployerException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventReceiverDeployerException.java
new file mode 100644
index 0000000000..3e0d49e088
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventReceiverDeployerException.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.exception;
+
+public class EventReceiverDeployerException extends Exception {
+
+ private static final long serialVersionUID = -3151279311929070299L;
+
+ public EventReceiverDeployerException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ }
+
+ public EventReceiverDeployerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EventReceiverDeployerException(String msg) {
+ super(msg);
+ }
+
+ public EventReceiverDeployerException() {
+ super();
+ }
+
+ public EventReceiverDeployerException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventStreamDeployerException.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventStreamDeployerException.java
new file mode 100644
index 0000000000..1bba4c8cfe
--- /dev/null
+++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/src/main/java/io/entgra/device/mgt/core/apimgt/analytics/extension/exception/EventStreamDeployerException.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023, 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.apimgt.analytics.extension.exception;
+
+public class EventStreamDeployerException extends Exception {
+
+ private static final long serialVersionUID = -3151279311929070298L;
+
+ public EventStreamDeployerException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ }
+
+ public EventStreamDeployerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EventStreamDeployerException(String msg) {
+ super(msg);
+ }
+
+ public EventStreamDeployerException() {
+ super();
+ }
+
+ public EventStreamDeployerException(Throwable cause) {
+ super(cause);
+ }
+}
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 0918920bdc..dec91246ab 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.20-SNAPSHOT
+ 5.0.22-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 a064c551c1..e72bcc5d3b 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.20-SNAPSHOT
+ 5.0.22-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 9ebf10c38f..a7bcd9a3d0 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
index 4ef90936b2..41ee18da8a 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java
@@ -256,10 +256,14 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
keyManagerId = keyManagerConfigurationDTO.getUuid();
}
}
+ String applicationAccessTokenExpiryTime = "N/A";
+ if (!StringUtils.isEmpty(validityTime)) {
+ applicationAccessTokenExpiryTime = validityTime;
+ }
String jsonString = "{\"grant_types\":\"refresh_token,access_token," +
"urn:ietf:params:oauth:grant-type:saml2-bearer," +
"password,client_credentials,iwa:ntlm,urn:ietf:params:oauth:grant-type:jwt-bearer\"," +
- "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"N\\/A\\\"," +
+ "\"additionalProperties\":\"{\\\"application_access_token_expiry_time\\\":\\\"" + applicationAccessTokenExpiryTime + "\\\"," +
"\\\"user_access_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"refresh_token_expiry_time\\\":\\\"N\\/A\\\"," +
"\\\"id_token_expiry_time\\\":\\\"N\\/A\\\"}\"," +
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml
index 95be718e7a..6af6ec43bf 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/pom.xml
@@ -3,7 +3,7 @@
apimgt-extensions
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
4.0.0
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java
index 5054e2220d..7d45e71ef6 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/DCRRequest.java
@@ -40,6 +40,9 @@ public class DCRRequest {
@XmlElement
private boolean isSaasApp;
+ @XmlElement
+ private int validityPeriod;
+
public String getApplicationName() {
return applicationName;
}
@@ -87,4 +90,12 @@ public class DCRRequest {
public void setIsSaasApp(boolean saasApp) {
isSaasApp = saasApp;
}
+
+ public int getValidityPeriod() {
+ return validityPeriod;
+ }
+
+ public void setValidityPeriod(int validityPeriod) {
+ this.validityPeriod = validityPeriod;
+ }
}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java
index dfd6af295a..3775d6d9f1 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerService.java
@@ -46,5 +46,6 @@ public interface KeyManagerService {
@FormParam("assertion") String assertion,
@FormParam("admin_access_token") String admin_access_token,
@FormParam("username") String username,
- @FormParam("password") String password);
+ @FormParam("password") String password,
+ @FormParam("validityPeriod") int validityPeriod);
}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java
index 961951f865..59d93912b0 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension.api/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/api/KeyManagerServiceImpl.java
@@ -51,7 +51,7 @@ public class KeyManagerServiceImpl implements KeyManagerService {
try {
KeyMgtService keyMgtService = new KeyMgtServiceImpl();
DCRResponse resp = keyMgtService.dynamicClientRegistration(dcrRequest.getApplicationName(), dcrRequest.getUsername(),
- dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp());
+ dcrRequest.getGrantTypes(), dcrRequest.getCallBackUrl(), dcrRequest.getTags(), dcrRequest.getIsSaasApp(), dcrRequest.getValidityPeriod());
return Response.status(Response.Status.CREATED).entity(gson.toJson(resp)).build();
} catch (KeyMgtException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
@@ -69,7 +69,8 @@ public class KeyManagerServiceImpl implements KeyManagerService {
@FormParam("assertion") String assertion,
@FormParam("admin_access_token") String admin_access_token,
@FormParam("username") String username,
- @FormParam("password") String password) {
+ @FormParam("password") String password,
+ @FormParam("validityPeriod") int validityPeriod) {
try {
if (basicAuthHeader == null) {
String msg = "Invalid credentials. Make sure your API call is invoked with a Basic Authorization header.";
@@ -80,7 +81,7 @@ public class KeyManagerServiceImpl implements KeyManagerService {
TokenResponse resp = keyMgtService.generateAccessToken(
new TokenRequest(encodedClientCredentials.split(":")[0],
encodedClientCredentials.split(":")[1], refreshToken, scope,
- grantType, assertion, admin_access_token, username, password));
+ grantType, assertion, admin_access_token, username, password, validityPeriod));
return Response.status(Response.Status.OK).entity(gson.toJson(resp)).build();
} catch (KeyMgtException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
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 6c7db5b264..c122a2f802 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
@@ -3,7 +3,7 @@
apimgt-extensions
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/TokenRequest.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/TokenRequest.java
index 860b267161..6bddd30d0b 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/TokenRequest.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/TokenRequest.java
@@ -29,8 +29,10 @@ public class TokenRequest {
private String username;
private String password;
+ private int validityPeriod;
+
public TokenRequest(String clientId, String clientSecret, String refreshToken, String scope, String grantType,
- String assertion, String admin_access_token, String username, String password) {
+ String assertion, String admin_access_token, String username, String password, int validityPeriod) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.refreshToken = refreshToken;
@@ -40,6 +42,7 @@ public class TokenRequest {
this.admin_access_token = admin_access_token;
this.username = username;
this.password = password;
+ this.validityPeriod = validityPeriod;
}
public String getClientId() {
@@ -113,4 +116,12 @@ public class TokenRequest {
public void setPassword(String password) {
this.password = password;
}
+
+ public int getValidityPeriod() {
+ return validityPeriod;
+ }
+
+ public void setValidityPeriod(int validityPeriod) {
+ this.validityPeriod = validityPeriod;
+ }
}
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtService.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtService.java
index a9aa2d346a..4e185d2f4d 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtService.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtService.java
@@ -39,7 +39,7 @@ public interface KeyMgtService {
* @throws KeyMgtException if any error occurs during DCR process
*/
DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl,
- String[] tags, boolean isSaasApp) throws KeyMgtException;
+ String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException;
/***
* This method will handle the access token requests
diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java
index 4640fc9a57..1a564e1246 100644
--- a/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java
+++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.keymgt.extension/src/main/java/org/wso2/carbon/apimgt/keymgt/extension/service/KeyMgtServiceImpl.java
@@ -77,7 +77,7 @@ public class KeyMgtServiceImpl implements KeyMgtService {
String subTenantUserUsername, subTenantUserPassword, keyManagerName, msg = null;
public DCRResponse dynamicClientRegistration(String clientName, String owner, String grantTypes, String callBackUrl,
- String[] tags, boolean isSaasApp) throws KeyMgtException {
+ String[] tags, boolean isSaasApp, int validityPeriod) throws KeyMgtException {
if (owner == null) {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@@ -105,13 +105,13 @@ public class KeyMgtServiceImpl implements KeyMgtService {
kmConfig = getKeyManagerConfig();
if (KeyMgtConstants.SUPER_TENANT.equals(tenantDomain)) {
- OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags);
+ OAuthApplication dcrApplication = createOauthApplication(clientName, kmConfig.getAdminUsername(), tags, validityPeriod);
return new DCRResponse(dcrApplication.getClientId(), dcrApplication.getClientSecret());
} else {
// super-tenant admin dcr and token generation
OAuthApplication superTenantOauthApp = createOauthApplication(
KeyMgtConstants.RESERVED_OAUTH_APP_NAME_PREFIX + KeyMgtConstants.SUPER_TENANT,
- kmConfig.getAdminUsername(), null);
+ kmConfig.getAdminUsername(), null, validityPeriod);
String superAdminAccessToken = createAccessToken(superTenantOauthApp);
// create new key manager for the tenant, under super-tenant space
@@ -133,7 +133,7 @@ public class KeyMgtServiceImpl implements KeyMgtService {
createUserIfNotExists(subTenantUserUsername, subTenantUserPassword);
// DCR for the requesting user
- OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags);
+ OAuthApplication dcrApplication = createOauthApplication(clientName, owner, tags, validityPeriod);
String requestingUserAccessToken = createAccessToken(dcrApplication);
// get application id
@@ -167,7 +167,8 @@ public class KeyMgtServiceImpl implements KeyMgtService {
case "client_credentials":
appTokenPayload = new FormBody.Builder()
.add("grant_type", "client_credentials")
- .add("scope", tokenRequest.getScope()).build();
+ .add("scope", tokenRequest.getScope())
+ .add("validityPeriod", String.valueOf(tokenRequest.getValidityPeriod())).build();
break;
case "password":
appTokenPayload = new FormBody.Builder()
@@ -322,8 +323,8 @@ public class KeyMgtServiceImpl implements KeyMgtService {
* @return @{@link OAuthApplication} OAuth application object
* @throws KeyMgtException if any error occurs while creating response object
*/
- private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags) throws KeyMgtException {
- String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags);
+ private OAuthApplication createOauthApplication (String clientName, String owner, String[] tags, int validityPeriod) throws KeyMgtException {
+ String oauthAppCreationPayloadStr = createOauthAppCreationPayload(clientName, owner, tags, validityPeriod);
RequestBody oauthAppCreationPayload = RequestBody.Companion.create(oauthAppCreationPayloadStr, JSON);
kmConfig = getKeyManagerConfig();
String dcrEndpoint = kmConfig.getServerUrl() + KeyMgtConstants.DCR_ENDPOINT;
@@ -442,11 +443,12 @@ public class KeyMgtServiceImpl implements KeyMgtService {
}
}
- private String createOauthAppCreationPayload(String clientName, String owner, String[] tags) {
+ private String createOauthAppCreationPayload(String clientName, String owner, String[] tags, int validityPeriod) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("applicationName", clientName);
jsonObject.put("username", owner);
jsonObject.put("tags", tags);
+ jsonObject.put("validityPeriod", validityPeriod);
return jsonObject.toString();
}
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 81aea0503d..1db744409d 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml
index a2c8ece854..93638f60da 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
@@ -39,6 +39,7 @@
org.wso2.carbon.apimgt.annotations
org.wso2.carbon.apimgt.keymgt.extension
org.wso2.carbon.apimgt.keymgt.extension.api
+ io.entgra.device.mgt.core.apimgt.analytics.extension
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 a67eb8592f..5b018fa691 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.20-SNAPSHOT
+ 5.0.22-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 4f42850568..34e852922e 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.20-SNAPSHOT
+ 5.0.22-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 2e058b82dd..ec5c4ecbc8 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.20-SNAPSHOT
+ 5.0.22-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 e93b704269..79bfb74e1e 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.20-SNAPSHOT
+ 5.0.22-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 b570adff88..4ea91300ce 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,7 @@ 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.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@@ -600,16 +600,17 @@ 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);
+ log.error(msg, e);
throw new ApplicationManagementException(msg, e);
}
}
@@ -689,7 +690,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 +709,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, 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);
@@ -752,7 +758,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 +824,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, e);
+ throw new ApplicationStorageManagementException(msg, e);
} catch (IOException e) {
String msg = "Error occurred when getting byte array of binary file. Installer name: " + applicationArtifact
.getInstallerName();
@@ -2162,9 +2173,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())) {
@@ -2172,7 +2183,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg);
throw new BadRequestException(msg);
}
-
+
try{
if (lifecycleStateManager
.isValidStateChange(applicationReleaseDTO.getCurrentState(), lifecycleChanger.getAction(), userName,
@@ -3254,7 +3265,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();
@@ -3300,6 +3311,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, 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 91e3f4579b..09b7b20848 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
@@ -19,6 +19,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 +32,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 +114,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. UUID: "
+ + applicationReleaseDTO.getUuid();
+ log.error(msg, e);
+ throw new ResourceManagementException(msg, e);
}
}
@@ -159,6 +166,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. UUID: "
+ + applicationReleaseDTO.getUuid();
+ log.error(msg, e);
+ throw new ResourceManagementException(msg, e);
}
}
@@ -286,4 +298,15 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
throw new ApplicationStorageManagementException(msg);
}
}
+
+ @Override
+ public String getMD5(InputStream inputStream) throws StorageManagementException {
+ try {
+ return 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);
+ }
+ }
}
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 adddc4026a..b866b041e2 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.20-SNAPSHOT
+ 5.0.22-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 bfc2c7ed61..1580219385 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 21ad941f69..e8c0211166 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 ff4e816abc..dfbdceb72f 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml
index dfb1d48017..603debde5b 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.20-SNAPSHOT
+ 5.0.22-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 f70a1fa72c..401bf1e290 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.20-SNAPSHOT
+ 5.0.22-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 a5a16ab3c6..ca00607aa1 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.20-SNAPSHOT
+ 5.0.22-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 fdd5660b81..b78bc2a6dc 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/certificate-mgt/pom.xml b/components/certificate-mgt/pom.xml
index 99af2f9561..34f37128a7 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml
index e36b58f55e..8e56f845ac 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager/pom.xml
@@ -23,7 +23,7 @@
device-mgt-extensions
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml
index 475c8b4e6e..d71db17757 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/pom.xml
@@ -22,7 +22,7 @@
device-mgt-extensions
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/src/main/java/io/entgra/device/mgt/extensions/logger/spi/EntgraLogger.java b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/src/main/java/io/entgra/device/mgt/extensions/logger/spi/EntgraLogger.java
index c959eb4885..2ffa6ffa8d 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/src/main/java/io/entgra/device/mgt/extensions/logger/spi/EntgraLogger.java
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.logger/src/main/java/io/entgra/device/mgt/extensions/logger/spi/EntgraLogger.java
@@ -48,6 +48,22 @@ public interface EntgraLogger extends Log {
void warn(Object object, Throwable t, LogContext logContext);
+ void info(String message, LogContext logContext);
+
+ void debug(String message, LogContext logContext);
+
+ void error(String message, LogContext logContext);
+
+ void error(String message, Throwable t, LogContext logContext);
+
+ void warn(String message, LogContext logContext);
+
+ void warn(String message, Throwable t, LogContext logContext);
+
+ void trace(String message, LogContext logContext);
+
+ void fatal(String message, LogContext logContext);
+
void clearLogContext();
}
diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml
index 229e8d6e3e..ac423deb81 100644
--- a/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml
+++ b/components/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine/pom.xml
@@ -23,7 +23,7 @@
device-mgt-extensions
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-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 9a11f603e7..a16f0e46ca 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.20-SNAPSHOT
+ 5.0.22-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 7625a603b3..3d9e19dd8a 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.20-SNAPSHOT
+ 5.0.22-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 ec894c7900..658b51a8ce 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.20-SNAPSHOT
+ 5.0.22-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 2e107b2543..0d107ecda8 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.20-SNAPSHOT
+ 5.0.22-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 1cde061ac1..ba38443cd2 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.20-SNAPSHOT
+ 5.0.22-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 3fdd250307..7f4e6d7386 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt-extensions/pom.xml b/components/device-mgt-extensions/pom.xml
index d141f2ff6f..5b2bf7774f 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.20-SNAPSHOT
+ 5.0.22-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 2c0ea76ceb..7ffc616573 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.20-SNAPSHOT
+ 5.0.22-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 aca43d379e..fd55008151 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
@@ -425,5 +425,35 @@
io.entgra.application.mgt.core
provided
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.apimgt.keymgt.extension
+ provided
+
+
+ org.wso2.carbon.analytics-common
+ org.wso2.carbon.event.stream.core
+ provided
+
+
+ org.wso2.carbon.analytics-common
+ org.wso2.carbon.event.receiver.core
+ provided
+
+
+ org.wso2.carbon.analytics-common
+ org.wso2.carbon.event.publisher.core
+ provided
+
+
+ org.wso2.carbon.analytics-common
+ org.wso2.carbon.event.output.adapter.rdbms
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ io.entgra.device.mgt.core.apimgt.analytics.extension
+ provided
+
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceConfig.java
new file mode 100644
index 0000000000..158153fd91
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceConfig.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2023, 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.beans;
+
+import io.swagger.annotations.ApiModel;
+import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
+
+import java.util.List;
+
+@ApiModel(value = "DeviceConfig", description = "Device config")
+public class DeviceConfig {
+ private String clientId;
+ private String clientSecret;
+ private String deviceId;
+ private String type;
+ private String accessToken;
+ private String refreshToken;
+ private String mqttGateway;
+ private String httpsGateway;
+ private String httpGateway;
+ private PlatformConfiguration platformConfiguration;
+ public String getClientId() {
+ return clientId;
+ }
+
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ public String getClientSecret() {
+ return clientSecret;
+ }
+
+ public void setClientSecret(String clientSecret) {
+ this.clientSecret = clientSecret;
+ }
+
+ public String getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(String deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public String getRefreshToken() {
+ return refreshToken;
+ }
+
+ public void setRefreshToken(String refreshToken) {
+ this.refreshToken = refreshToken;
+ }
+
+ public String getMqttGateway() {
+ return mqttGateway;
+ }
+
+ public void setMqttGateway(String mqttGateway) {
+ this.mqttGateway = mqttGateway;
+ }
+
+ public String getHttpsGateway() {
+ return httpsGateway;
+ }
+
+ public void setHttpsGateway(String httpsGateway) {
+ this.httpsGateway = httpsGateway;
+ }
+
+ public String getHttpGateway() {
+ return httpGateway;
+ }
+
+ public void setHttpGateway(String httpGateway) {
+ this.httpGateway = httpGateway;
+ }
+
+ public PlatformConfiguration getPlatformConfiguration() {
+ return platformConfiguration;
+ }
+
+ public void setPlatformConfiguration(PlatformConfiguration platformConfiguration) {
+ this.platformConfiguration = platformConfiguration;
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/DeviceTypeEvent.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/DeviceTypeEvent.java
index b8e07df6d5..b5a715135e 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/DeviceTypeEvent.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/analytics/DeviceTypeEvent.java
@@ -20,14 +20,18 @@ package org.wso2.carbon.device.mgt.jaxrs.beans.analytics;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+
/**
* This hold stats data record
*/
public class DeviceTypeEvent {
+ private String eventName;
private EventAttributeList eventAttributes;
private TransportType transport;
+ private String eventTopicStructure;
@ApiModelProperty(value = "Attributes related to device type event")
@JsonProperty("eventAttributes")
public EventAttributeList getEventAttributeList() {
@@ -48,5 +52,25 @@ public class DeviceTypeEvent {
public void setTransportType(TransportType transport) {
this.transport = transport;
}
+
+ @ApiModelProperty(value = "event topic structure")
+ @JsonProperty("eventTopicStructure")
+ public String getEventTopicStructure() {
+ return eventTopicStructure;
+ }
+
+ public void setEventTopicStructure(String eventTopicStructure) {
+ this.eventTopicStructure = eventTopicStructure;
+ }
+
+ @ApiModelProperty(value = "event topic name")
+ @JsonProperty("eventName")
+ public String getEventName() {
+ return eventName;
+ }
+
+ public void setEventName(String eventName) {
+ this.eventName = eventName;
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java
index 82e0cdb897..83503248fc 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceEventManagementService.java
@@ -29,6 +29,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import java.util.List;
@SwaggerDefinition(
info = @Info(
@@ -69,64 +70,64 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON)
public interface DeviceEventManagementService {
-// @POST
-// @Path("/{type}")
-// @ApiOperation(
-// produces = MediaType.APPLICATION_JSON,
-// httpMethod = "POST",
-// value = "Adding the Event Type Definition",
-// notes = "Add the event definition for a device.",
-// tags = "Device Event Management",
-// extensions = {
-// @Extension(properties = {
-// @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
-// })
-// }
-// )
-// @ApiResponses(
-// value = {
-// @ApiResponse(
-// code = 200,
-// message = "OK. \n Successfully added the event defintion.",
-// 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 = 400,
-// message =
-// "Bad Request. \n"),
-// @ApiResponse(
-// code = 406,
-// message = "Not Acceptable.\n The requested media type is not supported"),
-// @ApiResponse(
-// code = 500,
-// message = "Internal Server Error. \n Server error occurred while fetching the " +
-// "list of supported device types.",
-// response = ErrorResponse.class)
-// }
-// )
-// Response deployDeviceTypeEventDefinition(
-// @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
-// @PathParam("type")String deviceType,
-// @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
-// @QueryParam("skipPersist") boolean skipPersist,
-// @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
-// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
-// @ApiParam(name = "deviceTypeEvent", value = "Add the data to complete the DeviceTypeEvent object.",
-// required = true)
-// @Valid DeviceTypeEvent deviceTypeEvent);
+ @POST
+ @Path("/{type}")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Adding the Event Type Definition",
+ notes = "Add the event definition for a device.",
+ tags = "Device Event Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully added the event defintion.",
+ 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 = 400,
+ message =
+ "Bad Request. \n"),
+ @ApiResponse(
+ code = 406,
+ message = "Not Acceptable.\n The requested media type is not supported"),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Server error occurred while fetching the " +
+ "list of supported device types.",
+ response = ErrorResponse.class)
+ }
+ )
+ Response deployDeviceTypeEventDefinition(
+ @ApiParam(name = "type", value = "The device type, such as android, ios, and windows.")
+ @PathParam("type")String deviceType,
+ @ApiParam(name = "skipPersist", value = "Is it required to persist the data or not")
+ @QueryParam("skipPersist") boolean skipPersist,
+ @ApiParam(name = "isSharedWithAllTenants", value = "Should artifacts be available to all tenants")
+ @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
+ @ApiParam(name = "deviceTypeEvents", value = "Add the data to complete the DeviceTypeEvent object.",
+ required = true)
+ @Valid List deviceTypeEvent);
@DELETE
@Path("/{type}")
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
index 3304be7c14..a080208de2 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java
@@ -188,6 +188,13 @@ import java.util.List;
roles = {"Internal/devicemgt-user"},
permissions = {"/device-mgt/devices/owning-device/add"}
),
+ @Scope(
+ name = "Viewing Enrollment Guide",
+ description = "Show enrollment guide to users",
+ key = "perm:devices:enrollment-guide:view",
+ roles = {"Internal/devicemgt-user"},
+ permissions = {"/device-mgt/devices/enrollment-guide/view"}
+ ),
}
)
@Path("/devices")
@@ -553,12 +560,12 @@ public interface DeviceManagementService {
required = false,
defaultValue = "0")
@QueryParam("offset") int offset,
- @ApiParam(
- name = "limit",
- value = "Provide how many device details you require from the starting pagination index/offset.",
- required = false,
- defaultValue = "100")
- @QueryParam("limit") int limit
+ @ApiParam(
+ name = "limit",
+ value = "Provide how many device details you require from the starting pagination index/offset.",
+ required = false,
+ defaultValue = "100")
+ @QueryParam("limit") int limit
);
@GET
@@ -802,6 +809,59 @@ public interface DeviceManagementService {
@QueryParam("requireDeviceInfo")
boolean requireDeviceInfo);
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ @Path("/enrollment/guide")
+ @ApiOperation(
+ consumes = MediaType.MULTIPART_FORM_DATA,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Sending Enrollment Mode chosen by customer",
+ notes = "Enrollment mode selected and path is sent as parameters",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:enrollment-guide:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully mailed the Enrollment Guide of customer.",
+ response = Device.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 = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while sending mail of the Enrollment Guide.",
+ response = ErrorResponse.class)
+ })
+ Response sendEnrollmentGuide(
+ @ApiParam(
+ name = "enrolmentGuide",
+ value = "The details of the enrolment path suggested.",
+ required = true)
+ String enrolmentGuide);
+
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("/type/any/list")
@@ -1059,6 +1119,82 @@ public interface DeviceManagementService {
@HeaderParam("If-Modified-Since")
String ifModifiedSince);
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{type}/{id}/config")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Getting the Configuration of a Device",
+ notes = "Get the configuration of a device by specifying the device type and device identifier.",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:details")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the configuration of the device.",
+ response = DeviceInfo.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 = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n Location data for the specified device was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
+ Response getDeviceConfiguration(
+ @ApiParam(
+ name = "type",
+ value = "The device type name, such as ios, android, windows, or fire-alarm.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "The device identifier of the device you want ot get details.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id,
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Checks if the requested variant was modified, since the specified date-time. \n" +
+ "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z. \n" +
+ "Example: Mon, 05 Jan 2014 15:10:00 +0200",
+ required = false)
+ @HeaderParam("If-Modified-Since")
+ String ifModifiedSince);
+
//device rename request would looks like follows
//POST devices/type/virtual_firealarm/id/us06ww93auzp/rename
@POST
@@ -1399,15 +1535,15 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "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.")}),
+ "Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 304,
message = "Not Modified. \n " +
- "Empty body because the client already has the latest version of the requested resource.\n"),
+ "Empty body because the client already has the latest version of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -1425,7 +1561,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while getting the device details.",
+ "Server error occurred while getting the device details.",
response = ErrorResponse.class)
})
Response queryDevicesByProperties(
@@ -1447,7 +1583,7 @@ public interface DeviceManagementService {
name = "device property map",
value = "properties by which devices need filtered",
required = true)
- PropertyMap map);
+ PropertyMap map);
@GET
@Produces(MediaType.APPLICATION_JSON)
@@ -1873,140 +2009,141 @@ public interface DeviceManagementService {
@Size(max = 45)
String id);
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/{type}/{id}/getstatushistory")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Get Device status history",
- notes = "Get a list of status history associated with the device type and id",
- tags = "Device Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
- })
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the status history of matching devices.",
- response = List.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 = 304,
- message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n A device with the specified device type and id was not found.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
- response = ErrorResponse.class)
- })
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{type}/{id}/status-history")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Get Device status history",
+ notes = "Get a list of status history associated with the device type and id",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the status history of matching devices.",
+ response = List.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 = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n A device with the specified device type and id was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
Response getDeviceStatusHistory(
- @ApiParam(
- name = "type",
- value = "The device type, such as ios, android, or windows.",
- required = true)
- @PathParam("type")
- @Size(max = 45)
- String type,
- @ApiParam(
- name = "id",
- value = "Device ID.",
- required = true)
- @PathParam("id")
- @Size(max = 45)
- String id);
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/{type}/{id}/getenrolmentstatushistory")
- @ApiOperation(
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "GET",
- value = "Get Device Current Enrolment status history",
- notes = "Get a list of status history associated with the device type and id for the current enrolment",
- tags = "Device Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
- })
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully fetched the status history of matching devices.",
- response = List.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 = 304,
- message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
- @ApiResponse(
- code = 400,
- message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 404,
- message = "Not Found. \n A device with the specified device type and id was not found.",
- response = ErrorResponse.class),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
- response = ErrorResponse.class)
- })
+ @ApiParam(
+ name = "type",
+ value = "The device type, such as ios, android, or windows.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "Device ID.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id);
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{type}/{id}/enrolment-status-history")
+ @ApiOperation(
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "Get Device Current Enrolment status history",
+ notes = "Get a list of status history associated with the device type and id for the current enrolment",
+ tags = "Device Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully fetched the status history of matching devices.",
+ response = List.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 = 304,
+ message = "Not Modified. Empty body because the client already has the latest version" +
+ " of the requested resource.\n"),
+ @ApiResponse(
+ code = 400,
+ message = "Bad Request. \n Invalid request or validation error.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 404,
+ message = "Not Found. \n A device with the specified device type and id was not found.",
+ response = ErrorResponse.class),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n " +
+ "Server error occurred while retrieving the device details.",
+ response = ErrorResponse.class)
+ })
Response getCurrentEnrolmentDeviceStatusHistory(
- @ApiParam(
- name = "type",
- value = "The device type, such as ios, android, or windows.",
- required = true)
- @PathParam("type")
- @Size(max = 45)
- String type,
- @ApiParam(
- name = "id",
- value = "Device ID.",
- required = true)
- @PathParam("id")
- @Size(max = 45)
- String id);
+ @ApiParam(
+ name = "type",
+ value = "The device type, such as ios, android, or windows.",
+ required = true)
+ @PathParam("type")
+ @Size(max = 45)
+ String type,
+ @ApiParam(
+ name = "id",
+ value = "Device ID.",
+ required = true)
+ @PathParam("id")
+ @Size(max = 45)
+ String id);
@PUT
@Produces(MediaType.APPLICATION_JSON)
@@ -2171,16 +2308,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "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."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
+ " of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2192,7 +2329,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
+ "Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response getDeviceCountByStatus(
@@ -2240,16 +2377,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "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."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest version" +
- " of the requested resource.\n"),
+ " of the requested resource.\n"),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2261,7 +2398,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving the device details.",
+ "Server error occurred while retrieving the device details.",
response = ErrorResponse.class)
})
Response getDeviceIdentifiersByStatus(
@@ -2310,16 +2447,16 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
- "Used by caches, or in conditional requests."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. Empty body because the client already has the latest " +
- "version of the requested resource."),
+ "version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
@@ -2331,7 +2468,7 @@ public interface DeviceManagementService {
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
- "Server error occurred while retrieving information requested device.",
+ "Server error occurred while retrieving information requested device.",
response = ErrorResponse.class)
})
Response bulkUpdateDeviceStatus(
@@ -2642,11 +2779,11 @@ public interface DeviceManagementService {
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
- "Used by caches, or in conditional requests."),
+ "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."),
+ "Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 500,
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..85be91bdd8
--- /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,324 @@
+/*
+ * Copyright (c) 2023, 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.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 io.swagger.annotations.ApiParam;
+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.util.Constants;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.PathParam;
+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("/{tenantDomain}/favicon")
+ @ApiOperation(
+ 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.",
+ 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( @ApiParam(
+ name = "tenantDomain",
+ value = "The tenant domain.",
+ required = true) @PathParam("tenantDomain") String tenantDomain);
+
+ @GET
+ @Path("/{tenantDomain}/logo")
+ @ApiOperation(
+ 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(
+ @ApiParam(
+ name = "tenantDomain",
+ value = "The tenant domain.",
+ required = true)
+ @PathParam("tenantDomain") String tenantDomain);
+
+ @GET
+ @Path("/{tenantDomain}/icon")
+ @ApiOperation(
+ httpMethod = HTTPConstants.HEADER_GET,
+ value = "Get whitelabel logo icon",
+ notes = "Get whitelabel logo icon 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 getWhiteLabelLogoIcon( @ApiParam(
+ name = "tenantDomain",
+ value = "The tenant domain.",
+ required = true) @PathParam("tenantDomain") String tenantDomain);
+
+ @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 updateWhiteLabelTheme(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/DeviceEventManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java
index 4cba178f12..23be4d88eb 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceEventManagementServiceImpl.java
@@ -1,11 +1,19 @@
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.AnalyticsArtifactsDeployer;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.dto.*;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventReceiverDeployerException;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventPublisherDeployerException;
+import io.entgra.device.mgt.core.apimgt.analytics.extension.exception.EventStreamDeployerException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Stub;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.databridge.commons.StreamDefinition;
+import org.wso2.carbon.databridge.commons.exception.MalformedStreamDefinitionException;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType;
@@ -15,26 +23,40 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.TransportType;
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceEventManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration;
+import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
+import org.wso2.carbon.event.publisher.core.EventPublisherService;
+import org.wso2.carbon.event.publisher.core.config.EventPublisherConfiguration;
+import org.wso2.carbon.event.publisher.core.config.mapping.JSONOutputMapping;
+import org.wso2.carbon.event.publisher.core.config.mapping.MapOutputMapping;
+import org.wso2.carbon.event.publisher.core.exception.EventPublisherConfigurationException;
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceCallbackHandler;
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub;
+import org.wso2.carbon.event.receiver.core.EventReceiverService;
+import org.wso2.carbon.event.receiver.core.config.EventReceiverConfiguration;
+import org.wso2.carbon.event.receiver.core.config.mapping.JSONInputMapping;
+import org.wso2.carbon.event.receiver.core.config.mapping.WSO2EventInputMapping;
+import org.wso2.carbon.event.receiver.core.exception.EventReceiverConfigurationException;
import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceCallbackHandler;
import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub;
import org.wso2.carbon.event.receiver.stub.types.BasicInputAdapterPropertyDto;
import org.wso2.carbon.event.receiver.stub.types.EventReceiverConfigurationDto;
+import org.wso2.carbon.event.stream.core.EventStreamService;
+import org.wso2.carbon.event.stream.core.exception.EventStreamConfigurationException;
import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub;
import org.wso2.carbon.event.stream.stub.types.EventStreamAttributeDto;
import org.wso2.carbon.event.stream.stub.types.EventStreamDefinitionDto;
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
import org.wso2.carbon.user.api.UserStoreException;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
+import javax.validation.Valid;
+import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import java.rmi.RemoteException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
@@ -173,65 +195,129 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
/**
* Deploy Event Stream, Receiver, Publisher and Store Configuration.
*/
-// @POST
-// @Path("/{type}")
-// @Override
-// public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
-// @QueryParam("skipPersist") boolean skipPersist,
-// @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
-// @Valid DeviceTypeEvent deviceTypeEvent) {
-// TransportType transportType = deviceTypeEvent.getTransportType();
-// EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
-// String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
-// try {
-// if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
-// deviceType == null || transportType == null ||
-// !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
-// String errorMessage = "Invalid Payload";
-// log.error(errorMessage);
-// return Response.status(Response.Status.BAD_REQUEST).build();
-// }
-// String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain);
-// String streamNameWithVersion = streamName + ":" + Constants.DEFAULT_STREAM_VERSION;
-// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
-// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
-// if (!skipPersist) {
-// publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
-// }
-// publishWebsocketPublisherDefinition(streamNameWithVersion, deviceType);
-// try {
-// PrivilegedCarbonContext.startTenantFlow();
-// PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
-// MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
-// if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
-// publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, deviceType, eventAttributes);
-// publishEventReceivers(streamNameWithVersion, transportType, tenantDomain, isSharedWithAllTenants, deviceType);
-// }
-// } finally {
-// PrivilegedCarbonContext.endTenantFlow();
-// }
-// return Response.ok().build();
-// } catch (AxisFault e) {
-// log.error("Failed to create event definitions for tenantDomain:" + tenantDomain, e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// } catch (RemoteException e) {
-// log.error("Failed to connect with the remote services:" + tenantDomain, e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// } catch (JWTClientException e) {
-// log.error("Failed to generate jwt token for tenantDomain:" + tenantDomain, e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// } catch (UserStoreException e) {
-// log.error("Failed to connect with the user store, tenantDomain: " + tenantDomain, e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// } catch (DeviceManagementException e) {
-// log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// } catch (EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException e) {
-// log.error("Failed to create event store for, tenantDomain: " + tenantDomain + " deviceType" + deviceType,
-// e);
-// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
-// }
-// }
+ @POST
+ @Path("/{type}")
+ @Override
+ public Response deployDeviceTypeEventDefinition(@PathParam("type") String deviceType,
+ @QueryParam("skipPersist") boolean skipPersist,
+ @QueryParam("isSharedWithAllTenants") boolean isSharedWithAllTenants,
+ @Valid List deviceTypeEvents) {
+
+
+ String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
+ try {
+ for (DeviceTypeEvent deviceTypeEvent : deviceTypeEvents) {
+ TransportType transportType = deviceTypeEvent.getTransportType();
+ EventAttributeList eventAttributes = deviceTypeEvent.getEventAttributeList();
+ String eventName = deviceTypeEvent.getEventName();
+
+
+ if (eventAttributes == null || eventAttributes.getList() == null || eventAttributes.getList().size() == 0 ||
+ deviceType == null || transportType == null ||
+ !DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(deviceType)) {
+ String errorMessage = "Invalid Payload";
+ log.error(errorMessage);
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+ // event stream
+ String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain, eventName);
+ AnalyticsArtifactsDeployer artifactsDeployer = new AnalyticsArtifactsDeployer();
+ List props = new ArrayList<>();
+ for (Attribute attribute : eventAttributes.getList()) {
+ props.add(new Property(attribute.getName(), attribute.getType().name()));
+ }
+ EventStreamData eventStreamData = new EventStreamData();
+ eventStreamData.setName(streamName);
+ eventStreamData.setVersion(Constants.DEFAULT_STREAM_VERSION);
+ eventStreamData.setMetaData(new MetaData(DEFAULT_DEVICE_ID_ATTRIBUTE, "STRING"));
+ eventStreamData.setPayloadData(props);
+ artifactsDeployer.deployEventStream(eventStreamData, tenantId);
+
+ // event receiver
+ String receiverName = getReceiverName(deviceType, tenantDomain, transportType, eventName);
+ EventReceiverData receiverData = new EventReceiverData();
+ receiverData.setName(receiverName);
+ receiverData.setStreamName(streamName);
+ receiverData.setStreamVersion(Constants.DEFAULT_STREAM_VERSION);
+ List propertyList = new ArrayList<>();
+ if (transportType == TransportType.MQTT) {
+ receiverData.setEventAdapterType(OAUTH_MQTT_ADAPTER_TYPE);
+ propertyList.add(new Property(MQTT_CONTENT_TRANSFORMER_TYPE, MQTT_CONTENT_TRANSFORMER));
+ propertyList.add(new Property(MQTT_CONTENT_VALIDATOR_TYPE, MQTT_CONTENT_VALIDATOR));
+ String topic;
+ if (!StringUtils.isEmpty(deviceTypeEvent.getEventTopicStructure())) {
+ if (isSharedWithAllTenants) {
+ topic = deviceTypeEvent.getEventTopicStructure().replace("${deviceId}", "+")
+ .replace("${deviceType}", deviceType)
+ .replace("${tenantDomain}", "+");
+ } else {
+ topic = deviceTypeEvent.getEventTopicStructure().replace("${deviceId}", "+")
+ .replace("${deviceType}", deviceType)
+ .replace("${tenantDomain}", tenantDomain);
+ }
+ } else {
+ if (isSharedWithAllTenants) {
+ topic = "+/" + deviceType + "/+/events";
+ } else {
+ topic = tenantDomain + "/" + deviceType + "/+/events";
+ }
+ }
+ propertyList.add(new Property("topic", topic));
+ receiverData.setCustomMappingType("json");
+
+ } else {
+ receiverData.setEventAdapterType(THRIFT_ADAPTER_TYPE);
+ propertyList.add(new Property("events.duplicated.in.cluster", "false"));
+ receiverData.setCustomMappingType("wso2event");
+ }
+ receiverData.setPropertyList(propertyList);
+ artifactsDeployer.deployEventReceiver(receiverData, tenantId);
+
+ if (!skipPersist) {
+ // rdbms event publisher
+ String rdbmsPublisherName = getPublisherName(deviceType, tenantDomain, eventName) + "_rdbms_publisher";
+
+ EventPublisherData eventPublisherData = new EventPublisherData();
+ eventPublisherData.setName(rdbmsPublisherName);
+ eventPublisherData.setStreamName(streamName);
+ eventPublisherData.setStreamVersion(Constants.DEFAULT_STREAM_VERSION);
+ eventPublisherData.setEventAdaptorType("rdbms");
+ eventPublisherData.setCustomMappingType("map");
+ List publisherProps = new ArrayList<>();
+ publisherProps.add(new Property("datasource.name", "EVENT_DB"));
+ publisherProps.add(new Property("table.name", "table_" + rdbmsPublisherName.replace(".", "")));
+ publisherProps.add(new Property("execution.mode", "insert"));
+ eventPublisherData.setPropertyList(publisherProps);
+ artifactsDeployer.deployEventPublisher(eventPublisherData, tenantId);
+ }
+
+ // web socket event publisher
+ String wsPublisherName = getPublisherName(deviceType, tenantDomain, eventName) + "_ws_publisher";
+ EventPublisherData wsEventPublisherData = new EventPublisherData();
+ wsEventPublisherData.setName(wsPublisherName);
+ wsEventPublisherData.setStreamName(streamName);
+ wsEventPublisherData.setStreamVersion(Constants.DEFAULT_STREAM_VERSION);
+ wsEventPublisherData.setEventAdaptorType("websocket-local");
+ wsEventPublisherData.setCustomMappingType("json");
+ artifactsDeployer.deployEventPublisher(wsEventPublisherData, tenantId);
+
+ }
+ return Response.ok().build();
+ } catch (DeviceManagementException e) {
+ log.error("Failed to access device management service, tenantDomain: " + tenantDomain, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ } catch (EventStreamDeployerException e) {
+ log.error("Failed while deploying event stream definition, tenantDomain: " + tenantDomain, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ } catch (EventPublisherDeployerException e) {
+ log.error("Failed while deploying event publisher, tenantDomain: " + tenantDomain, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ } catch (EventReceiverDeployerException e) {
+ log.error("Failed while deploying event receiver, tenantDomain: " + tenantDomain, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
+ }
+ }
/**
* Delete device type specific artifacts from DAS.
@@ -498,160 +584,174 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
// return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
// }
// }
-
-
- private void publishEventReceivers(String streamNameWithVersion, TransportType transportType
- , String requestedTenantDomain, boolean isSharedWithAllTenants, String deviceType)
- throws RemoteException, UserStoreException, JWTClientException {
- EventReceiverAdminServiceStub receiverAdminServiceStub = DeviceMgtAPIUtils.getEventReceiverAdminServiceStub();
+ private void publishEventReceivers(String streamName, String version, TransportType transportType
+ , String requestedTenantDomain, boolean isSharedWithAllTenants, String deviceType,
+ String eventTopicStructure, String receiverName) throws EventReceiverConfigurationException {
+ EventReceiverService eventReceiverService = DeviceMgtAPIUtils.getEventReceiverService();
try {
- TransportType transportTypeToBeRemoved = TransportType.HTTP;
- if (transportType == TransportType.HTTP) {
- transportTypeToBeRemoved = TransportType.MQTT;
- }
- String eventRecieverNameTobeRemoved = getReceiverName(deviceType, requestedTenantDomain, transportTypeToBeRemoved);
- EventReceiverConfigurationDto eventReceiverConfigurationDto = receiverAdminServiceStub
- .getActiveEventReceiverConfiguration(eventRecieverNameTobeRemoved);
- if (eventReceiverConfigurationDto != null) {
- EventReceiverAdminServiceCallbackHandler eventReceiverAdminServiceCallbackHandler =
- new EventReceiverAdminServiceCallbackHandler() {
- };
- receiverAdminServiceStub.startundeployActiveEventReceiverConfiguration(eventRecieverNameTobeRemoved
- , eventReceiverAdminServiceCallbackHandler);
+// TransportType transportTypeToBeRemoved = TransportType.HTTP;
+// if (transportType == TransportType.HTTP) {
+// transportTypeToBeRemoved = TransportType.MQTT;
+// }
+// String eventRecieverNameTobeRemoved = getReceiverName(deviceType, requestedTenantDomain, transportTypeToBeRemoved);
+ EventReceiverConfiguration eventReceiverConfiguration =
+ eventReceiverService.getActiveEventReceiverConfiguration(receiverName);
+ if (eventReceiverConfiguration != null) {
+ eventReceiverService.undeployActiveEventReceiverConfiguration(receiverName);
}
- String adapterType = OAUTH_MQTT_ADAPTER_TYPE;
- BasicInputAdapterPropertyDto basicInputAdapterPropertyDtos[];
+ InputEventAdapterConfiguration inputEventAdapterConfiguration = new InputEventAdapterConfiguration();
+ Map propertyMap = new HashMap<>();
if (transportType == TransportType.MQTT) {
- basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[3];
+ inputEventAdapterConfiguration.setType(OAUTH_MQTT_ADAPTER_TYPE);
String topic;
- if (isSharedWithAllTenants) {
- topic = "+/" + deviceType + "/+/events";
+ if (!StringUtils.isEmpty(eventTopicStructure)) {
+ if (isSharedWithAllTenants) {
+ topic = eventTopicStructure.replace("${deviceId}", "+")
+ .replace("${deviceType}", deviceType)
+ .replace("${tenantDomain}", "+");
+ } else {
+ topic = eventTopicStructure.replace("${deviceId}", "+")
+ .replace("${deviceType}", deviceType)
+ .replace("${tenantDomain}", requestedTenantDomain);
+ }
} else {
- topic = requestedTenantDomain + "/" + deviceType + "/+/events";
+ if (isSharedWithAllTenants) {
+ topic = "+/" + deviceType + "/+/events";
+ } else {
+ topic = requestedTenantDomain + "/" + deviceType + "/+/events";
+ }
}
- basicInputAdapterPropertyDtos[0] = getBasicInputAdapterPropertyDto("topic", topic);
- basicInputAdapterPropertyDtos[1] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_TRANSFORMER_TYPE
- , MQTT_CONTENT_TRANSFORMER);
- basicInputAdapterPropertyDtos[2] = getBasicInputAdapterPropertyDto(MQTT_CONTENT_VALIDATOR_TYPE
- , MQTT_CONTENT_VALIDATOR);
+ propertyMap.put("topic", topic);
+ propertyMap.put(MQTT_CONTENT_TRANSFORMER_TYPE, MQTT_CONTENT_TRANSFORMER);
+ propertyMap.put(MQTT_CONTENT_VALIDATOR_TYPE, MQTT_CONTENT_VALIDATOR);
} else {
- adapterType = THRIFT_ADAPTER_TYPE;
- basicInputAdapterPropertyDtos = new BasicInputAdapterPropertyDto[1];
- basicInputAdapterPropertyDtos[0] = getBasicInputAdapterPropertyDto("events.duplicated.in.cluster", "false");
+ inputEventAdapterConfiguration.setType(THRIFT_ADAPTER_TYPE);
+ propertyMap.put("events.duplicated.in.cluster", "false");
}
- String eventRecieverName = getReceiverName(deviceType, requestedTenantDomain, transportType);
- if (receiverAdminServiceStub.getActiveEventReceiverConfiguration(eventRecieverName) == null) {
+ inputEventAdapterConfiguration.setProperties(propertyMap);
+
+ if (eventReceiverService.getActiveEventReceiverConfiguration(receiverName) == null) {
+ EventReceiverConfiguration configuration = new EventReceiverConfiguration();
+ configuration.setEventReceiverName(receiverName);
+ configuration.setToStreamName(streamName);
+ configuration.setToStreamVersion(version);
+ configuration.setFromAdapterConfiguration(inputEventAdapterConfiguration);
if (transportType == TransportType.MQTT) {
- receiverAdminServiceStub.deployJsonEventReceiverConfiguration(eventRecieverName, streamNameWithVersion
- , adapterType, null, basicInputAdapterPropertyDtos, false);
+ JSONInputMapping jsonInputMapping = new JSONInputMapping();
+ jsonInputMapping.setCustomMappingEnabled(false);
+ configuration.setInputMapping(jsonInputMapping);
+ eventReceiverService.deployEventReceiverConfiguration(configuration);
} else {
- receiverAdminServiceStub.deployWso2EventReceiverConfiguration(eventRecieverName, streamNameWithVersion
- , adapterType, null, null, null, basicInputAdapterPropertyDtos, false, null);
+ WSO2EventInputMapping wso2EventInputMapping = new WSO2EventInputMapping();
+ wso2EventInputMapping.setCustomMappingEnabled(false);
+ configuration.setInputMapping(wso2EventInputMapping);
+ eventReceiverService.deployEventReceiverConfiguration(configuration);
}
}
- } finally {
- cleanup(receiverAdminServiceStub);
+ } catch (EventReceiverConfigurationException e) {
+ log.error("Error while publishing event receiver" , e);
+ throw new EventReceiverConfigurationException(e);
}
+
}
- private void publishStreamDefinitons(String streamName, String version, String deviceType
- , EventAttributeList eventAttributes)
- throws RemoteException, UserStoreException, JWTClientException {
- EventStreamAdminServiceStub eventStreamAdminServiceStub = DeviceMgtAPIUtils.getEventStreamAdminServiceStub();
+ private void publishStreamDefinitons(String streamName, String version, EventAttributeList eventAttributes)
+ throws MalformedStreamDefinitionException, EventStreamConfigurationException {
+ EventStreamService eventStreamService = DeviceMgtAPIUtils.getEventStreamService();
+
try {
- EventStreamDefinitionDto eventStreamDefinitionDto = new EventStreamDefinitionDto();
- eventStreamDefinitionDto.setName(streamName);
- eventStreamDefinitionDto.setVersion(version);
- EventStreamAttributeDto eventStreamAttributeDtos[] =
- new EventStreamAttributeDto[eventAttributes.getList().size()];
- EventStreamAttributeDto metaStreamAttributeDtos[] =
- new EventStreamAttributeDto[1];
- int i = 0;
+ StreamDefinition streamDefinition = new StreamDefinition(streamName, version);
+
+ List payloadDataAttributes = new ArrayList<>();
for (Attribute attribute : eventAttributes.getList()) {
- EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto();
- eventStreamAttributeDto.setAttributeName(attribute.getName());
- eventStreamAttributeDto.setAttributeType(attribute.getType().toString());
- eventStreamAttributeDtos[i] = eventStreamAttributeDto;
- i++;
+ payloadDataAttributes.add(new org.wso2.carbon.databridge.commons.Attribute(attribute.getName(),
+ org.wso2.carbon.databridge.commons.AttributeType.valueOf(attribute.getType().name())));
}
+ streamDefinition.setPayloadData(payloadDataAttributes);
+
+ List metaDataAttributes = new ArrayList<>();
+ metaDataAttributes.add(new org.wso2.carbon.databridge.commons.Attribute(DEFAULT_DEVICE_ID_ATTRIBUTE,
+ org.wso2.carbon.databridge.commons.AttributeType.STRING));
+ streamDefinition.setMetaData(metaDataAttributes);
- EventStreamAttributeDto eventStreamAttributeDto = new EventStreamAttributeDto();
- eventStreamAttributeDto.setAttributeName(DEFAULT_DEVICE_ID_ATTRIBUTE);
- eventStreamAttributeDto.setAttributeType(AttributeType.STRING.toString());
- metaStreamAttributeDtos[0] = eventStreamAttributeDto;
- eventStreamDefinitionDto.setPayloadData(eventStreamAttributeDtos);
- eventStreamDefinitionDto.setMetaData(metaStreamAttributeDtos);
- String streamId = streamName + ":" + version;
- if (eventStreamAdminServiceStub.getStreamDefinitionDto(streamId) != null) {
- eventStreamAdminServiceStub.editEventStreamDefinitionAsDto(eventStreamDefinitionDto, streamId);
+ if (eventStreamService.getStreamDefinition(streamDefinition.getStreamId()) != null) {
+ eventStreamService.removeEventStreamDefinition(streamName, version);
+ eventStreamService.addEventStreamDefinition(streamDefinition);
} else {
- eventStreamAdminServiceStub.addEventStreamDefinitionAsDto(eventStreamDefinitionDto);
+ eventStreamService.addEventStreamDefinition(streamDefinition);
}
- } finally {
- cleanup(eventStreamAdminServiceStub);
+
+ } catch (MalformedStreamDefinitionException e) {
+ log.error("Error while initializing stream definition " , e);
+ throw new MalformedStreamDefinitionException(e);
+ } catch (EventStreamConfigurationException e) {
+ log.error("Error while configuring stream definition " , e);
+ throw new EventStreamConfigurationException(e);
}
}
+ /*
-// private void publishEventStore(String streamName, String version, EventAttributeList eventAttributes)
-// throws RemoteException, UserStoreException, JWTClientException,
-// EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException {
-// EventStreamPersistenceAdminServiceStub eventStreamPersistenceAdminServiceStub =
-// DeviceMgtAPIUtils.getEventStreamPersistenceAdminServiceStub();
-// try {
-// AnalyticsTable analyticsTable = new AnalyticsTable();
-// analyticsTable.setRecordStoreName(DEFAULT_EVENT_STORE_NAME);
-// analyticsTable.setStreamVersion(version);
-// analyticsTable.setTableName(streamName);
-// analyticsTable.setMergeSchema(false);
-// analyticsTable.setPersist(true);
-// AnalyticsTableRecord analyticsTableRecords[] = new AnalyticsTableRecord[eventAttributes.getList().size() + 1];
-// int i = 0;
-// for (Attribute attribute : eventAttributes.getList()) {
-// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
-// analyticsTableRecord.setColumnName(attribute.getName());
-// analyticsTableRecord.setColumnType(attribute.getType().toString().toUpperCase());
-// analyticsTableRecord.setFacet(false);
-// analyticsTableRecord.setIndexed(false);
-// analyticsTableRecord.setPersist(true);
-// analyticsTableRecord.setPrimaryKey(false);
-// analyticsTableRecord.setScoreParam(false);
-// analyticsTableRecords[i] = analyticsTableRecord;
-// i++;
-// }
-// AnalyticsTableRecord analyticsTableRecord = new AnalyticsTableRecord();
-// analyticsTableRecord.setColumnName(DEFAULT_META_DEVICE_ID_ATTRIBUTE);
-// analyticsTableRecord.setColumnType(AttributeType.STRING.toString().toUpperCase());
-// analyticsTableRecord.setFacet(false);
-// analyticsTableRecord.setIndexed(true);
-// analyticsTableRecord.setPersist(true);
-// analyticsTableRecord.setPrimaryKey(false);
-// analyticsTableRecord.setScoreParam(false);
-// analyticsTableRecords[i] = analyticsTableRecord;
-// analyticsTable.setAnalyticsTableRecords(analyticsTableRecords);
-// eventStreamPersistenceAdminServiceStub.addAnalyticsTable(analyticsTable);
-// } finally {
-// cleanup(eventStreamPersistenceAdminServiceStub);
-// }
-// }
+ */
+
+ private void publishEventStore(String streamName, String version, String publisherName)
+ throws EventPublisherConfigurationException {
+
+ EventPublisherService eventPublisherService = DeviceMgtAPIUtils.getEventPublisherService();
- private void publishWebsocketPublisherDefinition(String streamNameWithVersion, String deviceType)
- throws RemoteException, UserStoreException, JWTClientException {
- EventPublisherAdminServiceStub eventPublisherAdminServiceStub = DeviceMgtAPIUtils
- .getEventPublisherAdminServiceStub();
try {
- String eventPublisherName = deviceType.trim().replace(" ", "_") + "_websocket_publisher";
- if (eventPublisherAdminServiceStub.getActiveEventPublisherConfiguration(eventPublisherName) == null) {
- eventPublisherAdminServiceStub.deployJsonEventPublisherConfiguration(eventPublisherName
- , streamNameWithVersion, DEFAULT_WEBSOCKET_PUBLISHER_ADAPTER_TYPE, null, null
- , null, false);
+ if (eventPublisherService.getActiveEventPublisherConfiguration(publisherName) == null) {
+ EventPublisherConfiguration configuration = new EventPublisherConfiguration();
+ configuration.setEventPublisherName(publisherName);
+ configuration.setFromStreamName(streamName);
+ configuration.setFromStreamVersion(version);
+ MapOutputMapping mapOutputMapping = new MapOutputMapping();
+ mapOutputMapping.setCustomMappingEnabled(false);
+ configuration.setOutputMapping(mapOutputMapping);
+ OutputEventAdapterConfiguration outputEventAdapterConfiguration = new OutputEventAdapterConfiguration();
+ outputEventAdapterConfiguration.setType("rdbms");
+ Map staticProperties = new HashMap<>();
+ staticProperties.put("datasource.name", "EVENT_DB");
+ staticProperties.put("execution.mode", "insert");
+ staticProperties.put("table.name", "table_" + publisherName.replace(".", ""));
+ outputEventAdapterConfiguration.setStaticProperties(staticProperties);
+ configuration.setProcessEnabled(true);
+ configuration.setToAdapterConfiguration(outputEventAdapterConfiguration);
+ eventPublisherService.deployEventPublisherConfiguration(configuration);
}
- } finally {
- cleanup(eventPublisherAdminServiceStub);
+
+ } catch (EventPublisherConfigurationException e) {
+ log.error("Error while publishing to rdbms store" , e);
+ throw new EventPublisherConfigurationException(e);
}
}
+ private void publishWebsocketPublisherDefinition(String streamName, String version, String publisherName)
+ throws EventPublisherConfigurationException {
+ EventPublisherService eventPublisherService = DeviceMgtAPIUtils.getEventPublisherService();
+
+ try {
+ if (eventPublisherService.getActiveEventPublisherConfiguration(publisherName) == null) {
+ EventPublisherConfiguration configuration = new EventPublisherConfiguration();
+ configuration.setEventPublisherName(publisherName);
+ configuration.setFromStreamName(streamName);
+ configuration.setFromStreamVersion(version);
+ JSONOutputMapping jsonOutputMapping = new JSONOutputMapping();
+ jsonOutputMapping.setCustomMappingEnabled(false);
+ configuration.setOutputMapping(jsonOutputMapping);
+ OutputEventAdapterConfiguration outputEventAdapterConfiguration = new OutputEventAdapterConfiguration();
+ outputEventAdapterConfiguration.setType("websocket-local");
+ configuration.setToAdapterConfiguration(outputEventAdapterConfiguration);
+ eventPublisherService.deployEventPublisherConfiguration(configuration);
+ }
+ } catch (EventPublisherConfigurationException e) {
+ log.error("Error while publishing to websocket-local" , e);
+ throw new EventPublisherConfigurationException(e);
+ }
+
+ }
+
private BasicInputAdapterPropertyDto getBasicInputAdapterPropertyDto(String key, String value) {
BasicInputAdapterPropertyDto basicInputAdapterPropertyDto = new BasicInputAdapterPropertyDto();
basicInputAdapterPropertyDto.setKey(key);
@@ -667,6 +767,13 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
return deviceType.replace(" ", "_").trim() + "-" + tenantDomain + "-" + transportType.toString() + "-receiver";
}
+ private String getReceiverName(String deviceType, String tenantDomain, TransportType transportType, String eventName) {
+ return eventName + "-" + getReceiverName(deviceType, tenantDomain, transportType);
+ }
+
+ private String getPublisherName(String tenantDomain, String deviceType, String eventName) {
+ return eventName + "_" + tenantDomain.replace(".", "_") + "_" + deviceType;
+ }
private void cleanup(Stub stub) {
if (stub != null) {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
index 3bcdeafbab..6d0696df84 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java
@@ -37,33 +37,26 @@
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import com.google.gson.Gson;
+import io.entgra.application.mgt.common.ApplicationInstallResponse;
+import io.entgra.application.mgt.common.SubscriptionType;
+import io.entgra.application.mgt.common.exception.SubscriptionManagementException;
import io.entgra.application.mgt.common.services.ApplicationManager;
+import io.entgra.application.mgt.common.services.SubscriptionManager;
+import io.entgra.application.mgt.core.util.HelperUtil;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.json.JSONException;
import org.json.JSONObject;
+import org.wso2.carbon.apimgt.keymgt.extension.DCRResponse;
+import org.wso2.carbon.apimgt.keymgt.extension.TokenRequest;
+import org.wso2.carbon.apimgt.keymgt.extension.TokenResponse;
+import org.wso2.carbon.apimgt.keymgt.extension.exception.KeyMgtException;
+import org.wso2.carbon.apimgt.keymgt.extension.service.KeyMgtService;
+import org.wso2.carbon.apimgt.keymgt.extension.service.KeyMgtServiceImpl;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
-import io.entgra.application.mgt.common.ApplicationInstallResponse;
-import io.entgra.application.mgt.common.SubscriptionType;
-import io.entgra.application.mgt.common.exception.SubscriptionManagementException;
-import io.entgra.application.mgt.common.services.SubscriptionManager;
-import io.entgra.application.mgt.core.util.HelperUtil;
-import org.wso2.carbon.device.mgt.common.DeviceFilters;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.OperationLogFilters;
-import org.wso2.carbon.device.mgt.common.MDMAppConstants;
-import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
-import org.wso2.carbon.device.mgt.common.Feature;
-import org.wso2.carbon.device.mgt.common.FeatureManager;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.PaginationRequest;
-import org.wso2.carbon.device.mgt.common.PaginationResult;
-import org.wso2.carbon.device.mgt.common.TrackerDeviceInfo;
-import org.wso2.carbon.device.mgt.common.TrackerPermissionInfo;
+import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
@@ -72,12 +65,8 @@ import org.wso2.carbon.device.mgt.common.device.details.DeviceData;
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper;
-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.exceptions.InvalidConfigurationException;
-import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.exceptions.BadRequestException;
-import org.wso2.carbon.device.mgt.common.exceptions.UnAuthorizedException;
+import org.wso2.carbon.device.mgt.common.exceptions.*;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
@@ -91,6 +80,8 @@ import org.wso2.carbon.device.mgt.common.search.PropertyMap;
import org.wso2.carbon.device.mgt.common.search.SearchContext;
import org.wso2.carbon.device.mgt.common.type.mgt.DeviceStatus;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService;
+import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
+import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
import org.wso2.carbon.device.mgt.core.dao.TrackerManagementDAOException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceDetailsMgtException;
import org.wso2.carbon.device.mgt.core.device.details.mgt.DeviceInformationManager;
@@ -103,19 +94,10 @@ import org.wso2.carbon.device.mgt.core.search.mgt.SearchMgtException;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.traccar.api.service.DeviceAPIClientService;
-import org.wso2.carbon.device.mgt.core.traccar.api.service.impl.DeviceAPIClientServiceImpl;
import org.wso2.carbon.device.mgt.core.traccar.common.TraccarHandlerConstants;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil;
-import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceList;
-import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
-import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceCompliance;
-import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationList;
-import org.wso2.carbon.device.mgt.jaxrs.beans.OperationStatusBean;
-import org.wso2.carbon.device.mgt.jaxrs.beans.ComplianceDeviceList;
-import org.wso2.carbon.device.mgt.jaxrs.beans.OperationRequest;
-import org.wso2.carbon.device.mgt.jaxrs.beans.OperationList;
-import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationUninstallation;
+import org.wso2.carbon.device.mgt.jaxrs.beans.*;
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceManagementService;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
@@ -128,29 +110,17 @@ import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerSer
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.validation.Valid;
-import javax.ws.rs.Consumes;
import javax.validation.constraints.Size;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.Response;
-import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.ArrayList;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
@@ -816,6 +786,32 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
return Response.status(Response.Status.OK).entity(device).build();
}
+ @POST
+ @Path("/enrollment/guide")
+ @Override
+ public Response sendEnrollmentGuide(String enrolmentGuide) {
+ if (log.isDebugEnabled()) {
+ log.debug("Sending enrollment invitation mail to existing user.");
+ }
+ DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
+ if (!config.getEnrollmentGuideConfiguration().isEnabled()) {
+ String msg = "Sending enrollment guide config is not enabled.";
+ log.error(msg);
+ return Response.status(Response.Status.FORBIDDEN).entity(msg).build();
+ }
+ DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
+ try {
+ dms.sendEnrolmentGuide(enrolmentGuide);
+ return Response.status(Response.Status.OK).entity("Invitation mails have been sent.").build();
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred sending mail to group in enrollment guide";
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ }
+
+
@POST
@Path("/type/any/list")
@Override
@@ -887,6 +883,107 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
}
return Response.status(Response.Status.OK).entity(deviceInfo).build();
+ }
+ @GET
+ @Path("/{type}/{id}/config")
+ @Override
+ public Response getDeviceConfiguration(
+ @PathParam("type") @Size(max = 45) String type,
+ @PathParam("id") @Size(max = 45) String id,
+ @HeaderParam("If-Modified-Since") String ifModifiedSince) {
+
+ DeviceConfig deviceConfig = new DeviceConfig();
+ deviceConfig.setDeviceId(id);
+ deviceConfig.setType(type);
+
+ // find token validity time
+ DeviceManagementProviderService deviceManagementProviderService =
+ DeviceMgtAPIUtils.getDeviceManagementService();
+ int validityTime = 3600;
+ // add scopes for event topics
+ List mqttEventTopicStructure = new ArrayList<>();
+ try {
+ DeviceType deviceType = deviceManagementProviderService.getDeviceType(type);
+ if (deviceType != null) {
+ if (deviceType.getDeviceTypeMetaDefinition().isLongLivedToken()) {
+ validityTime = Integer.MAX_VALUE;
+ }
+ mqttEventTopicStructure = deviceType.getDeviceTypeMetaDefinition().getMqttEventTopicStructures();
+ } else {
+ String msg = "Device not found, device id : " + id + ", device type : " + type;
+ log.error(msg);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while retrieving device, device id : " + id + ", device type : " + type;
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+
+ String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
+ String applicationName = type.replace(" ", "").replace("_", "")
+ + "_" + tenantDomain;
+
+ KeyMgtService keyMgtService = new KeyMgtServiceImpl();
+ try {
+ DCRResponse dcrResponse = keyMgtService.dynamicClientRegistration(applicationName, username,
+ "client_credentials", null, new String[] {"device_management"}, false, validityTime);
+ deviceConfig.setClientId(dcrResponse.getClientId());
+ deviceConfig.setClientSecret(dcrResponse.getClientSecret());
+
+ StringBuilder scopes = new StringBuilder("device_" + type.replace(" ", "")
+ .replace("_", "") + "_" + id);
+ for (String topic : mqttEventTopicStructure) {
+ if (topic.contains("${deviceId}")) {
+ topic = topic.replace("${deviceId}", id);
+ }
+ topic = topic.replace("/",":");
+// scopes.append(" perm:topic:sub:".concat(topic));
+ scopes.append(" perm:topic:pub:".concat(topic));
+ }
+
+ // add scopes for retrieve operation topic /tenantDomain/deviceType/deviceId/operation/#
+ scopes.append(" perm:topic:sub:" + tenantDomain + ":" + type + ":" + id + ":operation");
+
+ // add scopes for update operation /tenantDomain/deviceType/deviceId/update/operation
+ scopes.append(" perm:topic:pub:" + tenantDomain + ":" + type + ":" + id + ":update:operation");
+
+ TokenRequest tokenRequest = new TokenRequest(dcrResponse.getClientId(), dcrResponse.getClientSecret(),
+ null, scopes.toString(), "client_credentials", null,
+ null, null, null, validityTime);
+ TokenResponse tokenResponse = keyMgtService.generateAccessToken(tokenRequest);
+ deviceConfig.setAccessToken(tokenResponse.getAccessToken());
+ deviceConfig.setRefreshToken(tokenResponse.getRefreshToken());
+
+ try {
+ deviceConfig.setPlatformConfiguration(deviceManagementProviderService.getConfiguration(type));
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while reading platform configurations token, device id : " + id + ", device type : " + type;
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+
+ deviceConfig.setMqttGateway("tcp://" + System.getProperty("mqtt.broker.host") + ":" + System.getProperty("mqtt.broker.port"));
+ deviceConfig.setHttpGateway("http://" + System.getProperty("iot.gateway.host") + ":" + System.getProperty("iot.gateway.http.port"));
+ deviceConfig.setHttpsGateway("https://" + System.getProperty("iot.gateway.host") + ":" + System.getProperty("iot.gateway.https.port"));
+
+ } catch (KeyMgtException e) {
+ String msg = "Error occurred while creating oauth application, device id : " + id + ", device type : " + type;
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ } catch (org.wso2.carbon.apimgt.keymgt.extension.exception.BadRequestException e) {
+ String msg = "Error occurred while generating token, device id : " + id + ", device type : " + type;
+ log.error(msg, e);
+ return Response.serverError().entity(
+ new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
+ }
+ return Response.status(Response.Status.OK).entity(deviceConfig).build();
+
}
@GET
@@ -1262,7 +1359,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
* @return {@link Response} object
*/
@GET
- @Path("/{type}/{id}/getstatushistory")
+ @Path("/{type}/{id}/status-history")
public Response getDeviceStatusHistory(@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id) {
//TODO check authorization for this
@@ -1294,7 +1391,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
* @return {@link Response} object
*/
@GET
- @Path("/{type}/{id}/getenrolmentstatushistory")
+ @Path("/{type}/{id}/enrolment-status-history")
public Response getCurrentEnrolmentDeviceStatusHistory(@PathParam("type") @Size(max = 45) String type,
@PathParam("id") @Size(max = 45) String id) {
//TODO check authorization for this or current enrolment should be based on for the enrolment associated with the user
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..559ecc41ec 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,20 @@ 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-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..97621667dc
--- /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,175 @@
+/*
+ * Copyright (c) 2023, 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.context.PrivilegedCarbonContext;
+import org.wso2.carbon.device.mgt.common.FileResponse;
+import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
+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;
+import org.wso2.carbon.device.mgt.common.metadata.mgt.WhiteLabelThemeCreateRequest;
+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.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+/**
+ * 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("/{tenantDomain}/favicon")
+ public Response getWhiteLabelFavicon(@PathParam("tenantDomain") String tenantDomain) {
+ try {
+ FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelFavicon(tenantDomain);
+ return sendFileStream(fileResponse);
+ } catch (NotFoundException e) {
+ String msg = "Favicon white label image cannot be found in the system. Uploading the favicon white label image again might help solve the issue.";
+ log.error(msg, e);
+ return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
+ } catch (MetadataManagementException e) {
+ String msg = "Error occurred while getting favicon";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
+ @GET
+ @Override
+ @Path("/{tenantDomain}/logo")
+ public Response getWhiteLabelLogo(@PathParam("tenantDomain") String tenantDomain) {
+ try {
+ FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogo(tenantDomain);
+ return sendFileStream(fileResponse);
+ } catch (NotFoundException e) {
+ String msg = "Logo white label image cannot be found in the system. Uploading the logo white label image again might help solve the issue.";
+ log.error(msg, e);
+ return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
+ } catch (MetadataManagementException e) {
+ String msg = "Error occurred while getting logo";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
+ @GET
+ @Override
+ @Path("/{tenantDomain}/icon")
+ public Response getWhiteLabelLogoIcon(@PathParam("tenantDomain") String tenantDomain) {
+ try {
+ FileResponse fileResponse = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelLogoIcon(tenantDomain);
+ return sendFileStream(fileResponse);
+ } catch (NotFoundException e) {
+ String msg = "Icon white label image cannot be found in the system. Uploading the icon white label image again might help solve the issue.";
+ log.error(msg, e);
+ return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
+ } catch (MetadataManagementException e) {
+ String msg = "Error occurred while getting logo";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
+ }
+ }
+
+ @PUT
+ @Override
+ public Response updateWhiteLabelTheme(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 {
+ String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
+ WhiteLabelTheme whiteLabelTheme = DeviceMgtAPIUtils.getWhiteLabelManagementService().getWhiteLabelTheme(tenantDomain);
+ 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();
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while retrieving tenant details of whitelabel";
+ log.error(msg, e);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).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 file responses
+ */
+ private Response sendFileStream(FileResponse fileResponse) {
+ try (ByteArrayInputStream binaryDuplicate = new ByteArrayInputStream(fileResponse.getFileContent())) {
+ Response.ResponseBuilder response = Response
+ .ok(binaryDuplicate, fileResponse.getMimeType());
+ response.status(Response.Status.OK);
+ response.header("Content-Length", fileResponse.getFileContent().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 f9a27bee4c..564e16f8dd 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,13 @@
*/
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.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 +34,11 @@ 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.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;
@@ -670,6 +676,122 @@ public class RequestValidationUtil {
}
}
+ /**
+ * 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";
+ 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.getLogoIcon() == null) {
+ String msg = "Logo Icon 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());
+ }
+ if (whiteLabelThemeCreateRequest.getAppTitle() == null) {
+ String msg = "App 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());
+ validateWhiteLabelImage(whiteLabelThemeCreateRequest.getLogoIcon());
+ } catch (InputValidationException e) {
+ String msg = "Payload contains invalid base64 files";
+ log.error(msg, e);
+ 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, e);
+ throw new InputValidationException(
+ new ErrorResponse.ErrorResponseBuilder()
+ .setCode(HttpStatus.SC_BAD_REQUEST).setMessage(msg).build());
+ }
+ }
+ else 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, 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());
+ }
+ }
+
+ /**
+ * 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 92bc2790d4..37a08c7e00 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
@@ -50,15 +50,12 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
+import org.wso2.carbon.authenticator.stub.AuthenticationAdminStub;
import org.wso2.carbon.base.ServerConfiguration;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.util.Utils;
-import org.wso2.carbon.device.mgt.common.Device;
-import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
-import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
-import org.wso2.carbon.device.mgt.common.MonitoringOperation;
-import org.wso2.carbon.device.mgt.common.OperationMonitoringTaskConfig;
+import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
import org.wso2.carbon.device.mgt.common.configuration.mgt.ConfigurationEntry;
@@ -74,6 +71,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;
@@ -95,8 +93,11 @@ import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.EventAttributeList;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.RequestValidationUtil;
import org.wso2.carbon.event.processor.stub.EventProcessorAdminServiceStub;
+import org.wso2.carbon.event.publisher.core.EventPublisherService;
import org.wso2.carbon.event.publisher.stub.EventPublisherAdminServiceStub;
+import org.wso2.carbon.event.receiver.core.EventReceiverService;
import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceStub;
+import org.wso2.carbon.event.stream.core.EventStreamService;
import org.wso2.carbon.event.stream.stub.EventStreamAdminServiceStub;
import org.wso2.carbon.identity.claim.metadata.mgt.dto.ClaimPropertyDTO;
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
@@ -111,11 +112,7 @@ import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.user.api.AuthorizationManager;
-import org.wso2.carbon.user.api.RealmConfiguration;
-import org.wso2.carbon.user.api.UserRealm;
-import org.wso2.carbon.user.api.UserStoreException;
-import org.wso2.carbon.user.api.UserStoreManager;
+import org.wso2.carbon.user.api.*;
import org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager;
import org.wso2.carbon.user.core.service.RealmService;
import org.wso2.carbon.user.mgt.common.UIPermissionNode;
@@ -128,11 +125,7 @@ import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
+import java.security.*;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -172,8 +165,9 @@ public class DeviceMgtAPIUtils {
private static KeyStore trustStore;
private static char[] keyStorePassword;
-// private static IntegrationClientService integrationClientService;
+ // private static IntegrationClientService integrationClientService;
private static MetadataManagementService metadataManagementService;
+ private static WhiteLabelManagementService whiteLabelManagementService;
private static OTPManagementService otpManagementService;
private static volatile SubscriptionManager subscriptionManager;
@@ -511,6 +505,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("Whitelabel Management service not initialized.");
+ }
+ }
+ }
+ }
+ return whiteLabelManagementService;
+ }
+
/**
* Initializing and accessing method for MetadataManagementService.
*
@@ -581,6 +597,36 @@ public class DeviceMgtAPIUtils {
return geoService;
}
+ public static EventStreamService getEventStreamService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ EventStreamService
+ eventStreamService = (EventStreamService) ctx.getOSGiService(EventStreamService.class, null);
+ if (eventStreamService == null) {
+ throw new IllegalStateException("Event Stream Service has not been initialized.");
+ }
+ return eventStreamService;
+ }
+
+ public static EventReceiverService getEventReceiverService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ EventReceiverService
+ eventReceiverService = (EventReceiverService) ctx.getOSGiService(EventReceiverService.class, null);
+ if (eventReceiverService == null) {
+ throw new IllegalStateException("Event Receiver Service has not been initialized.");
+ }
+ return eventReceiverService;
+ }
+
+ public static EventPublisherService getEventPublisherService() {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ EventPublisherService
+ eventPublisherService = (EventPublisherService) ctx.getOSGiService(EventPublisherService.class, null);
+ if (eventPublisherService == null) {
+ throw new IllegalStateException("Event Receiver Service has not been initialized.");
+ }
+ return eventPublisherService;
+ }
+
public static AnalyticsDataAPI getAnalyticsDataAPI() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
AnalyticsDataAPI analyticsDataAPI =
@@ -642,10 +688,13 @@ public class DeviceMgtAPIUtils {
// return eventsPublisherService;
// }
+ public static String getStreamDefinition(String deviceType, String tenantDomain, String eventName) {
+ return getStreamDefinition(deviceType, tenantDomain) + "." + eventName;
+ }
+
public static String getStreamDefinition(String deviceType, String tenantDomain) {
return STREAM_DEFINITION_PREFIX + tenantDomain + "." + deviceType.replace(" ", ".");
}
-
public static EventStreamAdminServiceStub getEventStreamAdminServiceStub()
throws AxisFault, UserStoreException, JWTClientException {
EventStreamAdminServiceStub eventStreamAdminServiceStub = new EventStreamAdminServiceStub(
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..00c784efc5 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,7 +48,10 @@
nonSecuredEndPoints
- /api/device-mgt/v1.0/users/validate
+ /api/device-mgt/v1.0/users/validate,
+ /api/device-mgt/v1.0/whitelabel/.*/favicon,
+ /api/device-mgt/v1.0/whitelabel/.*/logo,
+ /api/device-mgt/v1.0/whitelabel/.*/icon,
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 1abb0dca0c..b769df0906 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.20-SNAPSHOT
+ 5.0.22-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 91%
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..93303f4493 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
@@ -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/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..e3e83cf3c2
--- /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,74 @@
+/*
+ * Copyright (c) 2023, 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 static final String DEFAULT_MIME_TYPE = "application/octet-stream";
+ 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 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();
+ }
+
+ @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/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..15986e31da
--- /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,34 @@
+/*
+ * Copyright (c) 2023, 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.exceptions;
+
+/**
+ * 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..501e35a074
--- /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,59 @@
+/*
+ * Copyright (c) 2023, 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;
+ private String logoIconPath;
+
+ public WhiteLabelArtifactPath() {
+
+ }
+
+ public WhiteLabelArtifactPath(String faviconPath, String logoPath, String logoIconPath) {
+ this.faviconPath = faviconPath;
+ this.logoPath = logoPath;
+ this.logoIconPath = logoIconPath;
+ }
+
+ 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;
+ }
+
+ public String getLogoIconPath() {
+ return logoIconPath;
+ }
+
+ public void setLogoIconPath(String logoIconPath) {
+ this.logoIconPath = logoIconPath;
+ }
+}
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..846aca5f76
--- /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,57 @@
+/*
+ * Copyright (c) 2023, 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 {
+ 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,
+ LOGO_ICON;
+
+ @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..0ccce87c93
--- /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,71 @@
+/*
+ * Copyright (c) 2023, 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;
+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..6ccf82eab4
--- /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,83 @@
+/*
+ * Copyright (c) 2023, 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.FileResponse;
+import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
+import org.wso2.carbon.device.mgt.common.exceptions.MetadataManagementException;
+import org.wso2.carbon.device.mgt.common.exceptions.NotFoundException;
+
+/**
+ * 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
+ */
+ FileResponse getWhiteLabelFavicon(String tenantDomain) throws
+ 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
+ */
+ FileResponse getWhiteLabelLogo(String tenantDomain) throws
+ MetadataManagementException, NotFoundException;
+
+ /**
+ * Use to get byte content of logo icon whitelabel image
+ * @return byte content of logo icon
+ * @throws MetadataManagementException if error occurred while retrieving logo icon
+ * @throws NotFoundException if logo icon is not found
+ */
+ FileResponse getWhiteLabelLogoIcon(String tenantDomain) throws
+ MetadataManagementException, NotFoundException;
+
+ /**
+ * 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(String tenantDomain) throws MetadataManagementException, NotFoundException, DeviceManagementException;
+}
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..2600eeef90
--- /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,67 @@
+/*
+ * Copyright (c) 2023, 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 WhiteLabelImage logoIconImage;
+ private String footerText;
+ private String appTitle;
+
+ 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;
+ }
+
+ public String getAppTitle() {
+ return appTitle;
+ }
+
+ public void setAppTitle(String appTitle) {
+ this.appTitle = appTitle;
+ }
+
+ public WhiteLabelImage getLogoIconImage() {
+ return logoIconImage;
+ }
+
+ public void setLogoIconImage(WhiteLabelImage logoIconImage) {
+ this.logoIconImage = logoIconImage;
+ }
+}
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..7939f3428a
--- /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,67 @@
+/*
+ * Copyright (c) 2023, 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 WhiteLabelImageRequestPayload logoIcon;
+ private String footerText;
+ private String appTitle;
+
+ 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;
+ }
+
+ public String getAppTitle() {
+ return appTitle;
+ }
+
+ public void setAppTitle(String appTitle) {
+ this.appTitle = appTitle;
+ }
+
+ public WhiteLabelImageRequestPayload getLogoIcon() {
+ return logoIcon;
+ }
+
+ public void setLogoIcon(WhiteLabelImageRequestPayload logoIcon) {
+ this.logoIcon = logoIcon;
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java
index dcc7ff47cd..835f450bb7 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/type/mgt/DeviceTypeMetaDefinition.java
@@ -5,6 +5,7 @@ import org.wso2.carbon.device.mgt.common.InitialOperationConfig;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
+import java.util.ArrayList;
import java.util.List;
public class DeviceTypeMetaDefinition {
@@ -19,6 +20,10 @@ public class DeviceTypeMetaDefinition {
private String description;
private boolean isSharedWithAllTenants;
+ private List mqttEventTopicStructures;
+
+ private boolean longLivedToken = false;
+
public String getDescription() {
return description;
}
@@ -83,4 +88,20 @@ public class DeviceTypeMetaDefinition {
public void setSharedWithAllTenants(boolean sharedWithAllTenants) {
isSharedWithAllTenants = sharedWithAllTenants;
}
+
+ public List getMqttEventTopicStructures() {
+ return mqttEventTopicStructures;
+ }
+
+ public void setMqttEventTopicStructures(List mqttEventTopicStructures) {
+ this.mqttEventTopicStructures = mqttEventTopicStructures;
+ }
+
+ public boolean isLongLivedToken() {
+ return longLivedToken;
+ }
+
+ public void setLongLivedToken(boolean longLivedToken) {
+ this.longLivedToken = longLivedToken;
+ }
}
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 a55ae5faff..07d7cdc4a7 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
@@ -113,7 +113,9 @@
org.wso2.carbon.event.processor.stub,
org.wso2.carbon.identity.jwt.client.extension.service,
org.apache.commons.codec.binary,
- io.entgra.server.bootup.heartbeat.beacon
+ io.entgra.server.bootup.heartbeat.beacon,
+ io.entgra.device.mgt.extensions.logger.*,
+ io.entgra.notification.logger.*
!org.wso2.carbon.device.mgt.core.internal,
@@ -352,6 +354,10 @@
org.wso2.carbon.devicemgt
io.entgra.task.mgt.common
+
+ org.wso2.carbon.devicemgt
+ io.entgra.notification.logger
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
index 9ba76f99fb..0d45a2efc1 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementConstants.java
@@ -136,6 +136,7 @@ public final class DeviceManagementConstants {
public static final String POLICY_VIOLATE_TEMPLATE = "policy-violating-notifier";
public static final String USER_WELCOME_TEMPLATE = "user-welcome";
public static final String DEFAULT_ENROLLMENT_TEMPLATE = "default-enrollment-invitation";
+ public static final String ENROLLMENT_GUIDE_TEMPLATE = "enrollment-guide";
}
public static final class OperationAttributes {
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..38985716de
--- /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) 2023, 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..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
@@ -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
@@ -75,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;
}
@@ -98,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/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 f2ad40abb7..891e286339 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,9 @@ import org.wso2.carbon.device.mgt.core.config.cache.BillingCacheConfiguration;
import org.wso2.carbon.device.mgt.core.config.cache.CertificateCacheConfiguration;
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.enrollment.guide.EnrollmentGuideConfiguration;
import org.wso2.carbon.device.mgt.core.config.operation.timeout.OperationTimeoutConfiguration;
+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;
@@ -70,6 +72,8 @@ public final class DeviceManagementConfig {
private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration;
private DefaultRoles defaultRoles;
private OperationTimeoutConfiguration operationTimeoutConfiguration;
+ private MetaDataConfiguration metaDataConfiguration;
+ private EnrollmentGuideConfiguration enrollmentGuideConfiguration;
@XmlElement(name = "ManagementRepository", required = true)
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
@@ -265,5 +269,23 @@ 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;
+ }
+
+ @XmlElement(name = "EnrollmentGuideConfiguration", required = true)
+ public EnrollmentGuideConfiguration getEnrollmentGuideConfiguration() {
+ return enrollmentGuideConfiguration;
+ }
+
+ public void setEnrollmentGuideConfiguration(EnrollmentGuideConfiguration enrollmentGuideConfiguration) {
+ this.enrollmentGuideConfiguration = enrollmentGuideConfiguration;
+ }
}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java
new file mode 100644
index 0000000000..5f54cf79d4
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/enrollment/guide/EnrollmentGuideConfiguration.java
@@ -0,0 +1,30 @@
+package org.wso2.carbon.device.mgt.core.config.enrollment.guide;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "EnrollmentGuideConfiguration")
+public class EnrollmentGuideConfiguration {
+
+ private boolean isEnabled;
+ private String mail;
+
+ @XmlElement(name = "Enable", required = true)
+ public boolean isEnabled() {
+ return isEnabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ isEnabled = enabled;
+ }
+
+ @XmlElement(name = "Mail", required = true)
+ public String getMail() {
+ return mail;
+ }
+
+ public void setMail(String mail) {
+ this.mail = mail;
+ }
+
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/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
new file mode 100644
index 0000000000..848f206441
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/metadata/mgt/MetaDataConfiguration.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2023, 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.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;
+
+@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/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
new file mode 100644
index 0000000000..436146f5b6
--- /dev/null
+++ 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
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2023, 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.metadata.mgt.whitelabel;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "WhiteLabelConfiguration")
+public class WhiteLabelConfiguration {
+ private String footerText;
+ private String appTitle;
+ 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;
+ }
+
+ @XmlElement(name = "AppTitle", required = true)
+ public String getAppTitle() {
+ return appTitle;
+ }
+
+ 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/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
new file mode 100644
index 0000000000..7a01bc2538
--- /dev/null
+++ 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
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2023, 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.metadata.mgt.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;
+ private String defaultLogoIconName;
+
+ @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;
+ }
+
+ @XmlElement(name = "DefaultLogoIconName", required = true)
+ public String getDefaultLogoIconName() {
+ return defaultLogoIconName;
+ }
+
+ public void setDefaultLogoIconName(String defaultLogoIconName) {
+ this.defaultLogoIconName = defaultLogoIconName;
+ }
+
+ 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/config/ui/HubspotChat.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/HubspotChat.java
new file mode 100644
index 0000000000..ec22d125a1
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/HubspotChat.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2023, 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.ui;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class HubspotChat {
+ private boolean isEnableHubspot;
+ private String trackingUrl;
+ private String accessToken;
+ private String senderActorId;
+
+ @XmlElement(name = "EnableHubspot")
+ public boolean isEnableHubspot() {
+ return isEnableHubspot;
+ }
+
+ public void setEnableHubspot(boolean enableHubspot) {
+ isEnableHubspot = enableHubspot;
+ }
+
+ @XmlElement(name = "TrackingUrl")
+ public String getTrackingUrl() {
+ return trackingUrl;
+ }
+
+ public void setTrackingUrl(String trackingUrl) {
+ this.trackingUrl = trackingUrl;
+ }
+
+ @XmlElement(name = "AccessToken")
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+ @XmlElement(name = "SenderActorId")
+ public String getSenderActorId() {
+ return senderActorId;
+ }
+
+ public void setSenderActorId(String senderActorId) {
+ this.senderActorId = senderActorId;
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java
index 551c1558ea..dca4a76a6b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/ui/UIConfiguration.java
@@ -34,6 +34,7 @@ public class UIConfiguration {
private int sessionTimeOut;
private int loginCacheCapacity;
private Billing billing;
+ private HubspotChat hubspotChat;
@XmlElement(name = "AppRegistration", required=true)
public AppRegistration getAppRegistration() {
@@ -63,6 +64,14 @@ public class UIConfiguration {
isSsoEnable = ssoEnable;
}
+ @XmlElement(name = "HubspotChat", required = true)
+ public HubspotChat getHubspotChat() {
+ return hubspotChat;
+ }
+
+ public void setHubspotChat(HubspotChat hubspotChat) {
+ this.hubspotChat = hubspotChat;
+ }
@XmlElement(name = "Billing", required=true)
public Billing getBilling() {
return billing;
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 6a69cb02ba..13999efbc7 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;
@@ -69,7 +72,7 @@ public class DeviceManagementDataHolder {
private AppManagementConfig appManagerConfig;
private OperationManager operationManager;
private ConfigurationContextService configurationContextService;
- private final HashMap requireDeviceAuthorization = new HashMap<>();
+ private final HashMap requireDeviceAuthorization = new HashMap<>();
private DeviceAccessAuthorizationService deviceAccessAuthorizationService;
private GroupManagementProviderService groupManagementProviderService;
private TaskService taskService;
@@ -85,17 +88,20 @@ public class DeviceManagementDataHolder {
private ExecutorService eventConfigExecutors;
private OperationTimeoutTaskManagerService operationTimeoutTaskManagerService;
private DeviceAPIClientService deviceAPIClientService;
+ private MetadataManagementService metadataManagementService;
+ private WhiteLabelManagementService whiteLabelManagementService;
private final Map deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<>());
private final Map map = new HashMap<>();
- public Map getMap(){
+ public Map getMap() {
return this.map;
}
- private DeviceManagementDataHolder() {}
+ private DeviceManagementDataHolder() {
+ }
public static DeviceManagementDataHolder getInstance() {
return thisInstance;
@@ -204,7 +210,7 @@ public class DeviceManagementDataHolder {
}
public void setRequireDeviceAuthorization(String pluginType, boolean requireAuthentication) {
- requireDeviceAuthorization.put(pluginType,requireAuthentication);
+ requireDeviceAuthorization.put(pluginType, requireAuthentication);
}
public boolean requireDeviceAuthorization(String pluginType) {
@@ -351,7 +357,7 @@ public class DeviceManagementDataHolder {
OperationTimeoutTaskManagerService operationTimeoutTaskManagerService) {
this.operationTimeoutTaskManagerService = operationTimeoutTaskManagerService;
}
-
+
public DeviceAPIClientService getDeviceAPIClientService() {
return deviceAPIClientService;
}
@@ -359,4 +365,20 @@ public class DeviceManagementDataHolder {
public void setDeviceAPIClientService(DeviceAPIClientService deviceAPIClientService) {
this.deviceAPIClientService = deviceAPIClientService;
}
+
+ 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 a266a40499..f36def494d 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;
@@ -31,6 +32,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;
@@ -59,6 +61,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;
@@ -293,6 +296,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,8 +363,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(tenantId);
+ } 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..5ba8888301 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
@@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.metadata.mgt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.base.MultitenantConstants;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
@@ -33,7 +34,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 +44,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();
@@ -91,8 +91,14 @@ public class MetadataManagementServiceImpl implements MetadataManagementService
}
try {
MetadataManagementDAOFactory.openConnection();
- return metadataDAO.getMetadata(
- PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true), metaKey);
+ int tenantId;
+ if (metaKey.equals("EVALUATE_TENANTS")){
+ // for getting evaluate tenant list to provide the live chat feature
+ tenantId = MultitenantConstants.SUPER_TENANT_ID;
+ } else {
+ tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
+ }
+ return metadataDAO.getMetadata(tenantId, metaKey);
} catch (MetadataManagementDAOException e) {
String msg = "Error occurred while retrieving the metadata entry for metaKey:" + metaKey;
log.error(msg, 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
new file mode 100644
index 0000000000..ec2bca767e
--- /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,458 @@
+/*
+ * Copyright (c) 2023, 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.CarbonContext;
+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.DeviceManagementException;
+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.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;
+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 org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
+
+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 FileResponse getWhiteLabelFavicon(String tenantDomain) throws MetadataManagementException, NotFoundException {
+ try {
+ WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(tenantDomain);
+ return getImageFileResponse(whiteLabelTheme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON, tenantDomain);
+ } catch (IOException e) {
+ String msg = "Error occurred while getting byte content of favicon";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while getting tenant details of favicon";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+
+ @Override
+ public FileResponse getWhiteLabelLogo(String tenantDomain) throws MetadataManagementException, NotFoundException {
+ try {
+ WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(tenantDomain);
+ return getImageFileResponse(whiteLabelTheme.getLogoImage(), WhiteLabelImage.ImageName.LOGO, tenantDomain);
+ } catch (IOException e) {
+ String msg = "Error occurred while getting byte content of logo";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while getting tenant details of logo";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+
+ @Override
+ public FileResponse getWhiteLabelLogoIcon(String tenantDomain) throws MetadataManagementException, NotFoundException {
+ try {
+ WhiteLabelTheme whiteLabelTheme = getWhiteLabelTheme(tenantDomain);
+ return getImageFileResponse(whiteLabelTheme.getLogoIconImage(), WhiteLabelImage.ImageName.LOGO_ICON, tenantDomain);
+ } catch (IOException e) {
+ String msg = "Error occurred while getting byte content of logo";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while getting tenant details of icon";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+
+ /**
+ * Useful to get white label image file response for provided {@link WhiteLabelImage.ImageName}
+ */
+ private FileResponse getImageFileResponse(WhiteLabelImage image, WhiteLabelImage.ImageName imageName, String tenantDomain) throws
+ IOException, MetadataManagementException, NotFoundException, DeviceManagementException {
+ if (image.getImageLocationType() == WhiteLabelImage.ImageLocationType.URL) {
+ return getImageFileResponseFromUrl(image.getImageLocation());
+ }
+ return WhiteLabelStorageUtil.getWhiteLabelImageStream(image, imageName, tenantDomain);
+ }
+
+ /**
+ * Useful to get white label image file response from provided url
+ */
+ 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);
+ 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);
+ }
+ byte[] fileContent = IOUtils.toByteArray(imageStream);
+ fileResponse.setFileContent(fileContent);
+ String mimeType = HttpUtil.getContentType(response);
+ fileResponse.setMimeType(mimeType);
+ return fileResponse;
+ }
+ }
+
+
+ @Override
+ public void addDefaultWhiteLabelThemeIfNotExist(int tenantId) throws MetadataManagementException {
+ 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 {
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
+ WhiteLabelTheme whiteLabelTheme = getDefaultWhiteLabelTheme();
+ Metadata metadata = constructWhiteLabelThemeMetadata(whiteLabelTheme);
+ DeviceManagementDataHolder.getInstance().getMetadataManagementService().updateMetadata(metadata);
+ WhiteLabelStorageUtil.deleteWhiteLabelImageForTenantIfExists(tenantId);
+ }
+
+ /**
+ * Construct and return default whitelabel detail bean {@link WhiteLabelImage}
+ */
+ private WhiteLabelTheme getDefaultWhiteLabelTheme() {
+ String footerText = getDefaultFooterText();
+ String appTitle = getDefaultAppTitle();
+ WhiteLabelImage favicon = constructDefaultFaviconImage();
+ WhiteLabelImage logo = constructDefaultLogoImage();
+ WhiteLabelImage logoIcon = constructDefaultLogoIconImage();
+ WhiteLabelTheme defaultTheme = new WhiteLabelTheme();
+ defaultTheme.setFooterText(footerText);
+ defaultTheme.setAppTitle(appTitle);
+ defaultTheme.setLogoImage(logo);
+ defaultTheme.setLogoIconImage(logoIcon);
+ defaultTheme.setFaviconImage(favicon);
+ return defaultTheme;
+ }
+
+ /**
+ * Get default whitelabel label page title from config
+ */
+ private String getDefaultAppTitle() {
+ MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance().
+ getDeviceManagementConfig().getMetaDataConfiguration();
+ WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration();
+ return whiteLabelConfiguration.getAppTitle();
+ }
+
+ /**
+ * Get default whitelabel label footer from config
+ */
+ private String getDefaultFooterText() {
+ MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance().
+ getDeviceManagementConfig().getMetaDataConfiguration();
+ WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration();
+ 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();
+ WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration();
+ WhiteLabelImage favicon = new WhiteLabelImage();
+ favicon.setImageLocation(whiteLabelConfiguration.getWhiteLabelImages().getDefaultFaviconName());
+ setDefaultWhiteLabelImageCommonProperties(favicon);
+ 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();
+ WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration();
+ WhiteLabelImage logo = new WhiteLabelImage();
+ logo.setImageLocation(whiteLabelConfiguration.getWhiteLabelImages().getDefaultLogoName());
+ setDefaultWhiteLabelImageCommonProperties(logo);
+ return logo;
+ }
+
+ /**
+ * This is useful to construct and get the default logo whitelabel image
+ *
+ * @return {@link WhiteLabelImage}
+ */
+ private WhiteLabelImage constructDefaultLogoIconImage() {
+ MetaDataConfiguration metaDataConfiguration = DeviceConfigurationManager.getInstance().
+ getDeviceManagementConfig().getMetaDataConfiguration();
+ WhiteLabelConfiguration whiteLabelConfiguration = metaDataConfiguration.getWhiteLabelConfiguration();
+ WhiteLabelImage logoIcon = new WhiteLabelImage();
+ logoIcon.setImageLocation(whiteLabelConfiguration.getWhiteLabelImages().getDefaultLogoIconName());
+ setDefaultWhiteLabelImageCommonProperties(logoIcon);
+ return logoIcon;
+ }
+
+ /**
+ * 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);
+ }
+
+ @Override
+ public WhiteLabelTheme updateWhiteLabelTheme(WhiteLabelThemeCreateRequest createWhiteLabelTheme)
+ throws MetadataManagementException {
+ if (log.isDebugEnabled()) {
+ log.debug("Creating Metadata : [" + createWhiteLabelTheme.toString() + "]");
+ }
+ int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
+ String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
+ File existingFaviconImage = null;
+ File existingLogoImage = null;
+ File existingLogoIconImage = null;
+ try {
+ WhiteLabelTheme theme = getWhiteLabelTheme(tenantDomain);
+ if (theme.getFaviconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) {
+ existingFaviconImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getFaviconImage(), WhiteLabelImage.ImageName.FAVICON, tenantDomain);
+ }
+ if (theme.getLogoImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) {
+ existingLogoImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getLogoImage(), WhiteLabelImage.ImageName.LOGO, tenantDomain);
+ }
+ if (theme.getLogoIconImage().getImageLocationType() == WhiteLabelImage.ImageLocationType.CUSTOM_FILE) {
+ existingLogoIconImage = WhiteLabelStorageUtil.getWhiteLabelImageFile(theme.getLogoIconImage(), WhiteLabelImage.ImageName.LOGO_ICON, tenantDomain);
+ }
+ storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getFavicon(), WhiteLabelImage.ImageName.FAVICON, tenantId);
+ storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getLogo(), WhiteLabelImage.ImageName.LOGO, tenantId);
+ storeWhiteLabelImageIfRequired(createWhiteLabelTheme.getLogoIcon(), WhiteLabelImage.ImageName.LOGO_ICON, tenantId);
+ WhiteLabelTheme whiteLabelTheme = constructWhiteLabelTheme(createWhiteLabelTheme);
+ Metadata metadataWhiteLabelTheme = constructWhiteLabelThemeMetadata(whiteLabelTheme);
+ 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, existingLogoIconImage, 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, existingLogoIconImage, 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();
+ }
+ } catch (NotFoundException e) {
+ String msg = "Error occurred while retrieving existing white label theme";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while getting tenant details of white label";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+
+ }
+ }
+
+ /**
+ * 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, File existingLogoIcon, 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);
+ }
+ if (existingLogoIcon != null) {
+ WhiteLabelStorageUtil.storeWhiteLabelImage(existingLogoIcon, WhiteLabelImage.ImageName.LOGO_ICON, tenantId);
+ }
+ }
+
+ /**
+ * 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 {
+ if (whiteLabelImage.getImageType() == WhiteLabelImageRequestPayload.ImageType.BASE64) {
+ Base64File imageBase64 = new Gson().fromJson(whiteLabelImage.getImage(), Base64File.class);
+ WhiteLabelStorageUtil.updateWhiteLabelImage(imageBase64, imageName, tenantId);
+ }
+ }
+
+ /**
+ * Generate {@link WhiteLabelTheme} from provided {@link WhiteLabelThemeCreateRequest}
+ */
+ private WhiteLabelTheme constructWhiteLabelTheme(WhiteLabelThemeCreateRequest whiteLabelThemeCreateRequest) {
+ WhiteLabelTheme whiteLabelTheme = new WhiteLabelTheme();
+ WhiteLabelImageRequestPayload faviconPayload = whiteLabelThemeCreateRequest.getFavicon();
+ WhiteLabelImageRequestPayload logoPayload = whiteLabelThemeCreateRequest.getLogo();
+ WhiteLabelImageRequestPayload logoIconPayload = whiteLabelThemeCreateRequest.getLogoIcon();
+ WhiteLabelImage faviconImage = constructWhiteLabelImageDTO(faviconPayload);
+ WhiteLabelImage logoImage = constructWhiteLabelImageDTO(logoPayload);
+ WhiteLabelImage logoIconImage = constructWhiteLabelImageDTO(logoIconPayload);
+ whiteLabelTheme.setFaviconImage(faviconImage);
+ whiteLabelTheme.setLogoImage(logoImage);
+ whiteLabelTheme.setLogoIconImage(logoIconImage);
+ whiteLabelTheme.setFooterText(whiteLabelThemeCreateRequest.getFooterText());
+ whiteLabelTheme.setAppTitle(whiteLabelThemeCreateRequest.getAppTitle());
+ return whiteLabelTheme;
+ }
+
+ /**
+ * Generate {@link WhiteLabelImage} from provided {@link WhiteLabelImageRequestPayload}
+ */
+ 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;
+ }
+
+ /**
+ * Generate {@link Metadata} from provided {@link WhiteLabelImage}
+ */
+ 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(String tenantDomain) throws MetadataManagementException, NotFoundException, DeviceManagementException {
+ int tenantId = DeviceManagerUtil.getTenantId(tenantDomain);
+ 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.error(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..e16f466c6e
--- /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) 2023, 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..fc71a89e5e
--- /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,222 @@
+/* Copyright (c) 2023, 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.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.DeviceManagementException;
+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.metadata.mgt.MetaDataConfiguration;
+import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
+
+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();
+ }
+
+ /**
+ * 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);
+ 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);
+ }
+ }
+
+ /**
+ * 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(image), imageName, tenantId);
+ } catch (IOException e) {
+ String msg = "Error occurred when converting provided File object to Base64File class";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+
+
+ /**
+ * 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, String tenantDomain)
+ throws MetadataManagementException, DeviceManagementException {
+ String fullPathToImage = getPathToImage(image, imageName, tenantDomain);
+ 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 FileResponse getWhiteLabelImageStream(WhiteLabelImage image, WhiteLabelImage.ImageName imageName, String tenantDomain)
+ throws MetadataManagementException, NotFoundException, DeviceManagementException {
+ FileResponse fileResponse = new FileResponse();
+ String fullPathToFile = getPathToImage(image, imageName, tenantDomain);
+ 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);
+ }
+ 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);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+
+ /**
+ * 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, String tenantDomain)
+ throws MetadataManagementException, DeviceManagementException {
+ 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 = 0;
+ try {
+ tenantId = DeviceManagerUtil.getTenantId(tenantDomain);
+ } catch (DeviceManagementException e) {
+ String msg = "Error occurred while getting tenant details of logo";
+ log.error(msg, e);
+ throw new DeviceManagementException(msg, e);
+ }
+ 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 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;
+ File artifact = new File(artifactPath);
+ if (artifact.exists()) {
+ try {
+ StorageManagementUtil.delete(artifact);
+ } catch (IOException e) {
+ String msg = "Error occurred while deleting whitelabel artifacts";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+ }
+
+ /***
+ * 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;
+ File artifact = new File(artifactPath);
+ if (artifact.exists()) {
+ try {
+ StorageManagementUtil.delete(artifact);
+ } catch (IOException e) {
+ String msg = "Error occurred while deleting whitelabel artifacts";
+ log.error(msg, e);
+ throw new MetadataManagementException(msg, e);
+ }
+ }
+ }
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java
index 3371f8d804..4770f9fee4 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java
@@ -18,8 +18,9 @@
package org.wso2.carbon.device.mgt.core.notification.mgt;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import io.entgra.device.mgt.extensions.logger.spi.EntgraLogger;
+import io.entgra.notification.logger.DeviceLogContext;
+import io.entgra.notification.logger.impl.EntgraDeviceLoggerImpl;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
@@ -45,8 +46,8 @@ import java.util.List;
*/
public class NotificationManagementServiceImpl implements NotificationManagementService {
- private static final Log log = LogFactory.getLog(NotificationManagementServiceImpl.class);
-
+ private static final EntgraLogger log = new EntgraDeviceLoggerImpl(NotificationManagementServiceImpl.class);
+ DeviceLogContext.Builder deviceLogContexBuilder = new DeviceLogContext.Builder();
private NotificationDAO notificationDAO;
public NotificationManagementServiceImpl() {
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
index 27882f4fbd..55e9279760 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java
@@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.operation.mgt;
+import com.google.gson.Gson;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -792,9 +793,7 @@ public class OperationManagerImpl implements OperationManager {
if (dtoOperation != null) {
long currentTime = Calendar.getInstance().getTime().getTime();
- log.info("Current timestamp:" + currentTime);
long updatedTime = Timestamp.valueOf(dtoOperation.getReceivedTimeStamp()).getTime();
- log.info("Updated timestamp: " + updatedTime);
// check if notnow frequency is met and set next pending operation if not, otherwise let notnow
// operation to proceed
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
index 4e12d2cf1a..3dedb8d551 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderService.java
@@ -645,6 +645,8 @@ public interface DeviceManagementProviderService {
void sendEnrolmentInvitation(String templateName, EmailMetaInfo metaInfo) throws DeviceManagementException,
ConfigurationManagementException;
+ void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException;
+
void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException, ConfigurationManagementException;
FeatureManager getFeatureManager(String deviceType) throws DeviceTypeNotFoundException;
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
index 9b28775687..6257e0b34d 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java
@@ -198,6 +198,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
private final ApplicationDAO applicationDAO;
private MetadataDAO metadataDAO;
private final DeviceStatusDAO deviceStatusDAO;
+ int count = 0;
public DeviceManagementProviderServiceImpl() {
this.pluginRepository = new DeviceManagementPluginRepository();
@@ -1555,6 +1556,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
}
+ @Override
+ public void sendEnrolmentGuide(String enrolmentGuide) throws DeviceManagementException {
+
+ DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
+ String recipientMail = config.getEnrollmentGuideConfiguration().getMail();
+ Properties props = new Properties();
+ props.setProperty("mail-subject", "[Enrollment Guide Triggered] (#" + ++count + ")");
+ props.setProperty("enrollment-guide", enrolmentGuide);
+
+ try {
+ EmailMetaInfo metaInfo = new EmailMetaInfo(recipientMail, props);
+ sendEnrolmentInvitation(DeviceManagementConstants.EmailAttributes.ENROLLMENT_GUIDE_TEMPLATE, metaInfo);
+ } catch (ConfigurationManagementException e) {
+ String msg = "Error occurred while sending the mail.";
+ log.error(msg, e);
+ throw new DeviceManagementException(msg, e);
+ }
+ }
+
@Override
public void sendRegistrationEmail(EmailMetaInfo metaInfo) throws DeviceManagementException,
ConfigurationManagementException {
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..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
@@ -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,12 @@ public class DeviceMgtTenantMgtListener implements TenantMgtListener {
PrivilegedCarbonContext.endTenantFlow();
}
}
+ try {
+ DeviceManagementDataHolder.getInstance().getWhiteLabelManagementService().
+ addDefaultWhiteLabelThemeIfNotExist(tenantInfoBean.getTenantId());
+ } 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 c359b575ef..a7be85cc99 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.20-SNAPSHOT
+ 5.0.22-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 ce0834d4a7..65d76a4ce8 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/device-mgt/pom.xml b/components/device-mgt/pom.xml
index d21057f7c5..33b9d79a2d 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.20-SNAPSHOT
+ 5.0.22-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 b77baba84f..675795d551 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/heartbeat-management/pom.xml b/components/heartbeat-management/pom.xml
index 8a34ff769a..0c11fed91d 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.20-SNAPSHOT
+ 5.0.22-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 15ce3a51ca..79bd49ff21 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.20-SNAPSHOT
+ 5.0.22-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 7c963d6254..58c581c51a 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/identity-extensions/pom.xml b/components/identity-extensions/pom.xml
index b1bdcdf8e3..f5f8d9e4f6 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/components/logger/io.entgra.notification.logger/pom.xml b/components/logger/io.entgra.notification.logger/pom.xml
new file mode 100644
index 0000000000..b0e30a6d4b
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/pom.xml
@@ -0,0 +1,86 @@
+
+
+
+
+ 4.0.0
+
+
+ org.wso2.carbon.devicemgt
+ logger
+ 5.0.22-SNAPSHOT
+
+
+ io.entgra.notification.logger
+ Entgra - Notification Logger
+ bundle
+ http://entgra.io
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+
+
+ org.testng
+ testng
+
+
+ org.wso2.carbon.devicemgt
+ io.entgra.device.mgt.extensions.logger
+
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+ ${carbon.device.mgt.version}
+ Device Notification Logger Bundle
+
+ io.entgra.device.mgt.extensions.logger.*,
+ org.apache.commons.logging;version="[1.2,2)",
+ org.apache.log4j;version="[1.2,2)",
+ org.wso2.carbon.context;version="[4.4,5)
+
+
+ io.entgra.notification.logger.*
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/DeviceLogContext.java b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/DeviceLogContext.java
new file mode 100644
index 0000000000..3becd28b9c
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/DeviceLogContext.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2023, 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 io.entgra.notification.logger;
+
+import io.entgra.device.mgt.extensions.logger.LogContext;
+
+public class DeviceLogContext extends LogContext {
+ private final String deviceName;
+ private final String operationCode;
+ private final String deviceType;
+ private final String tenantID;
+
+ private DeviceLogContext(Builder builder) {
+ this.operationCode = builder.operationCode;
+ this.deviceName = builder.deviceName;
+ this.deviceType = builder.deviceType;
+ this.tenantID = builder.tenantID;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public String getOperationCode() {
+ return operationCode;
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+
+ public static class Builder {
+ private String deviceName;
+ private String operationCode;
+ private String deviceType;
+ private String tenantID;
+
+ public Builder() {
+ }
+
+ public String getDeviceType() {
+ return deviceType;
+ }
+
+ public Builder setDeviceType(String deviceType) {
+ this.deviceType = deviceType;
+ return this;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public Builder setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ return this;
+ }
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public Builder setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ return this;
+ }
+
+ public String getOperationCode() {
+ return operationCode;
+ }
+
+ public Builder setOperationCode(String operationCode) {
+ this.operationCode = operationCode;
+ return this;
+ }
+
+ public DeviceLogContext build() {
+ return new DeviceLogContext(this);
+ }
+
+ }
+}
diff --git a/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/UserLogContext.java b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/UserLogContext.java
new file mode 100644
index 0000000000..13702d570b
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/UserLogContext.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2023, 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 io.entgra.notification.logger;
+
+import io.entgra.device.mgt.extensions.logger.LogContext;
+
+public class UserLogContext extends LogContext {
+ private final String userName;
+ private final String userEmail;
+ private final String metaInfo;
+ private final String tenantID;
+
+ private UserLogContext(Builder builder) {
+ this.userEmail = builder.userEmail;
+ this.userName = builder.userName;
+ this.metaInfo = builder.metaInfo;
+ this.tenantID = builder.tenantID;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getUserEmail() {
+ return userEmail;
+ }
+
+ public String getMetaInfo() {
+ return metaInfo;
+ }
+
+
+ public static class Builder {
+ private String userName;
+ private String userEmail;
+ private String metaInfo;
+ private String tenantID;
+
+ public Builder() {
+ }
+
+ public String getMetaInfo() {
+ return metaInfo;
+ }
+
+ public Builder setMetaInfo(String metaInfo) {
+ this.metaInfo = metaInfo;
+ return this;
+ }
+
+ public String getTenantID() {
+ return tenantID;
+ }
+
+ public Builder setTenantID(String tenantID) {
+ this.tenantID = tenantID;
+ return this;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public Builder setUserName(String userName) {
+ this.userName = userName;
+ return this;
+ }
+
+ public String getUserEmail() {
+ return userEmail;
+ }
+
+ public Builder setUserEmail(String userEmail) {
+ this.userEmail = userEmail;
+ return this;
+ }
+
+ public UserLogContext build() {
+ return new UserLogContext(this);
+ }
+
+ }
+}
diff --git a/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraDeviceLoggerImpl.java b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraDeviceLoggerImpl.java
new file mode 100644
index 0000000000..f1360ae6c3
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraDeviceLoggerImpl.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2023, 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 io.entgra.notification.logger.impl;
+
+
+import io.entgra.device.mgt.extensions.logger.LogContext;
+import io.entgra.device.mgt.extensions.logger.spi.EntgraLogger;
+import io.entgra.notification.logger.DeviceLogContext;
+import io.entgra.notification.logger.util.MDCContextUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
+
+
+public class EntgraDeviceLoggerImpl implements EntgraLogger {
+
+ private static Log log = null;
+
+ public EntgraDeviceLoggerImpl(Class> clazz) {
+ log = LogFactory.getLog(clazz);
+ }
+
+ @Override
+ public void info(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void info(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void debug(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void debug(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void error(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void error(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void fatal(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void fatal(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void trace(Object object, LogContext logContext) {
+
+ }
+
+ @Override
+ public void trace(Object object, Throwable t, LogContext logContext) {
+
+ }
+
+ @Override
+ public void warn(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void warn(Object object, Throwable t, LogContext logContext) {
+ }
+
+ public void info(String message) {
+ }
+
+ public void info(String message, Throwable t) {
+ log.info(message, t);
+ }
+
+ @Override
+ public void info(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.info(message);
+ }
+
+
+ public void debug(String message) {
+ log.debug(message);
+ }
+
+
+ public void debug(String message, Throwable t) {
+ log.debug(message, t);
+ }
+
+ @Override
+ public void debug(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.debug(message);
+ }
+
+ public void error(String message) {
+ log.error(message);
+ }
+
+
+ public void error(String message, Throwable t) {
+ log.error(message, t);
+ }
+
+ @Override
+ public void error(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.error(message);
+ }
+
+ @Override
+ public void error(String message, Throwable t, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.error(message, t);
+ }
+
+
+ public void warn(String message) {
+ log.warn(message);
+ }
+
+
+ public void warn(String message, Throwable t) {
+ log.warn(message, t);
+ }
+
+ @Override
+ public void warn(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.warn(message);
+ }
+
+ @Override
+ public void warn(String message, Throwable t, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.warn(message, t);
+ }
+
+
+ public void trace(String message) {
+ log.trace(message);
+ }
+
+
+ public void trace(String message, Throwable t) {
+ log.trace(message, t);
+ }
+
+ @Override
+ public void trace(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.trace(message);
+ }
+
+
+ public void fatal(String message) {
+ log.fatal(message);
+ }
+
+
+ public void fatal(String message, Throwable t) {
+ log.fatal(message, t);
+ }
+
+ @Override
+ public void fatal(String message, LogContext logContext) {
+ DeviceLogContext deviceLogContext = (DeviceLogContext) logContext;
+ MDCContextUtil.populateDeviceMDCContext(deviceLogContext);
+ log.fatal(message);
+ }
+
+ @Override
+ public void debug(Object o) {
+ log.debug(o);
+ }
+
+ @Override
+ public void debug(Object o, Throwable throwable) {
+ log.debug(o, throwable);
+ }
+
+ @Override
+ public void error(Object o) {
+ log.error(o);
+ }
+
+ @Override
+ public void error(Object o, Throwable throwable) {
+ log.error(o, throwable);
+ }
+
+ @Override
+ public void fatal(Object o) {
+ log.fatal(0);
+ }
+
+ @Override
+ public void fatal(Object o, Throwable throwable) {
+ log.fatal(0, throwable);
+ }
+
+ @Override
+ public void info(Object o) {
+ log.info(o);
+ }
+
+ @Override
+ public void info(Object o, Throwable throwable) {
+ log.info(o, throwable);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return log.isErrorEnabled();
+ }
+
+ @Override
+ public boolean isFatalEnabled() {
+ return log.isFatalEnabled();
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return log.isTraceEnabled();
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return log.isWarnEnabled();
+ }
+
+ @Override
+ public void trace(Object o) {
+ log.trace(o);
+ }
+
+ @Override
+ public void trace(Object o, Throwable throwable) {
+ log.trace(o, throwable);
+ }
+
+ @Override
+ public void warn(Object o) {
+ log.warn(o);
+ }
+
+ @Override
+ public void warn(Object o, Throwable throwable) {
+ log.warn(o, throwable);
+ }
+
+ @Override
+ public void clearLogContext() {
+ MDC.clear();
+ }
+}
diff --git a/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraUserLoggerImpl.java b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraUserLoggerImpl.java
new file mode 100644
index 0000000000..92beeabb2f
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/impl/EntgraUserLoggerImpl.java
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2023, 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 io.entgra.notification.logger.impl;
+
+
+import io.entgra.device.mgt.extensions.logger.LogContext;
+import io.entgra.device.mgt.extensions.logger.spi.EntgraLogger;
+import io.entgra.notification.logger.UserLogContext;
+import io.entgra.notification.logger.util.MDCContextUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.MDC;
+
+
+public class EntgraUserLoggerImpl implements EntgraLogger {
+
+ private static Log log = null;
+
+ public EntgraUserLoggerImpl(Class> clazz) {
+ log = LogFactory.getLog(clazz);
+ }
+
+ @Override
+ public void info(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void info(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void debug(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void debug(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void error(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void error(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void fatal(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void fatal(Object object, Throwable t, LogContext logContext) {
+ }
+
+ @Override
+ public void trace(Object object, LogContext logContext) {
+
+ }
+
+ @Override
+ public void trace(Object object, Throwable t, LogContext logContext) {
+
+ }
+
+ @Override
+ public void warn(Object object, LogContext logContext) {
+ }
+
+ @Override
+ public void warn(Object object, Throwable t, LogContext logContext) {
+ }
+
+ public void info(String message) {
+ }
+
+ public void info(String message, Throwable t) {
+ log.info(message, t);
+ }
+
+ @Override
+ public void info(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.info(message);
+ }
+
+
+ public void debug(String message) {
+ log.debug(message);
+ }
+
+
+ public void debug(String message, Throwable t) {
+ log.debug(message, t);
+ }
+
+ @Override
+ public void debug(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.debug(message);
+ }
+
+ public void error(String message) {
+ log.error(message);
+ }
+
+
+ public void error(String message, Throwable t) {
+ log.error(message, t);
+ }
+
+ @Override
+ public void error(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.error(message);
+ }
+
+ @Override
+ public void error(String message, Throwable t, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.error(message, t);
+ }
+
+
+ public void warn(String message) {
+ log.warn(message);
+ }
+
+
+ public void warn(String message, Throwable t) {
+ log.warn(message, t);
+ }
+
+ @Override
+ public void warn(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.warn(message);
+ }
+
+ @Override
+ public void warn(String message, Throwable t, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.warn(message, t);
+ }
+
+
+ public void trace(String message) {
+ log.trace(message);
+ }
+
+
+ public void trace(String message, Throwable t) {
+ log.trace(message, t);
+ }
+
+ @Override
+ public void trace(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.trace(message);
+ }
+
+
+ public void fatal(String message) {
+ log.fatal(message);
+ }
+
+
+ public void fatal(String message, Throwable t) {
+ log.fatal(message, t);
+ }
+
+ @Override
+ public void fatal(String message, LogContext logContext) {
+ UserLogContext userLogContext = (UserLogContext) logContext;
+ MDCContextUtil.populateUserMDCContext(userLogContext);
+ log.fatal(message);
+ }
+
+ @Override
+ public void debug(Object o) {
+ log.debug(o);
+ }
+
+ @Override
+ public void debug(Object o, Throwable throwable) {
+ log.debug(o, throwable);
+ }
+
+ @Override
+ public void error(Object o) {
+ log.error(o);
+ }
+
+ @Override
+ public void error(Object o, Throwable throwable) {
+ log.error(o, throwable);
+ }
+
+ @Override
+ public void fatal(Object o) {
+ log.fatal(0);
+ }
+
+ @Override
+ public void fatal(Object o, Throwable throwable) {
+ log.fatal(0, throwable);
+ }
+
+ @Override
+ public void info(Object o) {
+ log.info(o);
+ }
+
+ @Override
+ public void info(Object o, Throwable throwable) {
+ log.info(o, throwable);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return log.isErrorEnabled();
+ }
+
+ @Override
+ public boolean isFatalEnabled() {
+ return log.isFatalEnabled();
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return log.isTraceEnabled();
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return log.isWarnEnabled();
+ }
+
+ @Override
+ public void trace(Object o) {
+ log.trace(o);
+ }
+
+ @Override
+ public void trace(Object o, Throwable throwable) {
+ log.trace(o, throwable);
+ }
+
+ @Override
+ public void warn(Object o) {
+ log.warn(o);
+ }
+
+ @Override
+ public void warn(Object o, Throwable throwable) {
+ log.warn(o, throwable);
+ }
+
+ @Override
+ public void clearLogContext() {
+ MDC.clear();
+ }
+}
diff --git a/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/util/MDCContextUtil.java b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/util/MDCContextUtil.java
new file mode 100644
index 0000000000..fd78c26dba
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/main/java/io/entgra/notification/logger/util/MDCContextUtil.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2023, 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 io.entgra.notification.logger.util;
+
+import io.entgra.notification.logger.DeviceLogContext;
+import io.entgra.notification.logger.UserLogContext;
+import org.apache.log4j.MDC;
+
+public final class MDCContextUtil {
+
+ public static void populateDeviceMDCContext(final DeviceLogContext mdcContext) {
+ if (mdcContext.getDeviceName() != null) {
+ MDC.put("DeviceName", mdcContext.getDeviceName());
+ }
+ if (mdcContext.getDeviceType() != null) {
+ MDC.put("DeviceType", mdcContext.getDeviceType());
+ }
+ if (mdcContext.getOperationCode() != null) {
+ MDC.put("OperationCode", mdcContext.getOperationCode());
+ }
+ if (mdcContext.getTenantID() != null) {
+ MDC.put("TenantId", mdcContext.getTenantID());
+ }
+ }
+
+ public static void populateUserMDCContext(final UserLogContext mdcContext) {
+ if (mdcContext.getUserName() != null) {
+ MDC.put("UserName", mdcContext.getUserName());
+ }
+ if (mdcContext.getUserEmail() != null) {
+ MDC.put("UserEmail", mdcContext.getUserEmail());
+ }
+ if (mdcContext.getMetaInfo() != null) {
+ MDC.put("MetaInfo", mdcContext.getMetaInfo());
+ }
+ if (mdcContext.getTenantID() != null) {
+ MDC.put("TenantId", mdcContext.getTenantID());
+ }
+ }
+}
+
+
diff --git a/components/logger/io.entgra.notification.logger/src/test/resources/log4j.properties b/components/logger/io.entgra.notification.logger/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..b174b35e36
--- /dev/null
+++ b/components/logger/io.entgra.notification.logger/src/test/resources/log4j.properties
@@ -0,0 +1,32 @@
+#
+# Copyright 2023 Entgra Pvt. Ltd.. (http://entgra.io)
+#
+# Licensed 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 is the log4j configuration file used by Entgra Pvt. Ltd.
+#
+# IMPORTANT : Please do not remove or change the names of any
+# of the Appenders defined here. The layout pattern & log file
+# can be changed using the WSO2 Carbon Management Console, and those
+# settings will override the settings in this file.
+#
+
+log4j.rootLogger=DEBUG, STD_OUT
+
+# Redirect log messages to console
+log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender
+log4j.appender.STD_OUT.Target=System.out
+log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout
+log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
diff --git a/components/logger/pom.xml b/components/logger/pom.xml
new file mode 100644
index 0000000000..bc0f814449
--- /dev/null
+++ b/components/logger/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+ 4.0.0
+
+
+ carbon-devicemgt
+ org.wso2.carbon.devicemgt
+ 5.0.22-SNAPSHOT
+ ../../pom.xml
+
+
+ logger
+ pom
+ Entgra - Notification Logger Component
+ http://entgra.io
+
+
+ io.entgra.notification.logger
+
+
+
+ 8
+ 8
+ UTF-8
+
+
+
\ No newline at end of file
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 d8c8483db2..d35d3b5590 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.20-SNAPSHOT
+ 5.0.22-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 0dd2f16187..63bf49d90e 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.20-SNAPSHOT
+ 5.0.22-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 d13c9bb1ec..ad871a76f3 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.20-SNAPSHOT
+ 5.0.22-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 6991bb4e5f..00861dea8b 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
index 3667f258c6..74e5d8e7f1 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
@@ -44,6 +44,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept
import org.wso2.carbon.device.mgt.common.policy.mgt.Policy;
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
+import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
+import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint;
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException;
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
@@ -96,6 +98,7 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato
*/
if (devicePolicy == null || devicePolicy.getId() != policy.getId() || updatedPolicyIds.contains
(policy.getId())) {
+ this.markPreviousPolicyBundlesRepeated(device);
this.addPolicyRevokeOperation(deviceIdentifiers);
this.addPolicyOperation(deviceIdentifiers, policy);
}
@@ -202,4 +205,29 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato
throw new PolicyDelegationException(msg, e);
}
}
+
+ /**
+ * Update the previous pending policy operation's status as REPEATED
+ * @param device Device
+ * @throws PolicyDelegationException throws when getting pending operations
+ */
+ public void markPreviousPolicyBundlesRepeated(Device device) throws PolicyDelegationException {
+ DeviceManagementProviderService deviceManagerService = PolicyManagementDataHolder.getInstance().
+ getDeviceManagementService();
+ try {
+ List extends Operation> operations = deviceManagerService.getPendingOperations(device);
+ for(Operation operation : operations) {
+ String operationCode = operation.getCode();
+ if(PolicyOperation.POLICY_OPERATION_CODE.equals(operationCode) ||
+ OperationMgtConstants.OperationCodes.POLICY_REVOKE.equals(operationCode)) {
+ operation.setStatus(Operation.Status.REPEATED);
+ deviceManagerService.updateOperation(device, operation);
+ }
+ }
+ } catch (OperationManagementException e) {
+ String msg = "Error occurred while retrieving pending operations of device id "+device.getId();
+ log.error(msg, e);
+ throw new PolicyDelegationException(msg, e);
+ }
+ }
}
diff --git a/components/policy-mgt/pom.xml b/components/policy-mgt/pom.xml
index 2f0a6b7bf6..6709e90871 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/components/task-mgt/pom.xml b/components/task-mgt/pom.xml
index d9ab379c3b..3dd072c407 100755
--- a/components/task-mgt/pom.xml
+++ b/components/task-mgt/pom.xml
@@ -17,13 +17,11 @@
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
carbon-devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml
index ad7c991872..e58e7e4969 100755
--- a/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml
+++ b/components/task-mgt/task-manager/io.entgra.task.mgt.common/pom.xml
@@ -16,13 +16,11 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
task-manager
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml
index f0ffd6c1f5..d0621effa7 100755
--- a/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml
+++ b/components/task-mgt/task-manager/io.entgra.task.mgt.core/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
task-manager
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/service/TaskManagementServiceImpl.java b/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/service/TaskManagementServiceImpl.java
index c206d77dc3..fe3a7cb97e 100755
--- a/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/service/TaskManagementServiceImpl.java
+++ b/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/service/TaskManagementServiceImpl.java
@@ -62,8 +62,7 @@ public class TaskManagementServiceImpl implements TaskManagementService {
log.error(msg);
throw new TaskManagementException(msg);
}
- if (!nTaskService.getRegisteredTaskTypes().contains(
- TaskMgtConstants.Task.DYNAMIC_TASK_TYPE)) {
+ if (!nTaskService.getRegisteredTaskTypes().contains(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE)) {
try {
nTaskService.registerTaskType(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE);
this.taskManager = nTaskService.getTaskManager(TaskMgtConstants.Task.DYNAMIC_TASK_TYPE);
diff --git a/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/util/TaskManagementUtil.java b/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/util/TaskManagementUtil.java
index 747f7cfd32..5308fc29c9 100755
--- a/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/util/TaskManagementUtil.java
+++ b/components/task-mgt/task-manager/io.entgra.task.mgt.core/src/main/java/io/entgra/task/mgt/core/util/TaskManagementUtil.java
@@ -72,7 +72,7 @@ public class TaskManagementUtil {
+ TaskMgtConstants.Task.NAME_SEPARATOR + serverHashIdx;
}
- public static String generateTaskPropsMD5(Map taskProperties) throws TaskManagementException {
+ public static String generateTaskPropsMD5(Map taskProperties) {
taskProperties.remove(TaskMgtConstants.Task.TENANT_ID_PROP);
taskProperties.remove(TaskMgtConstants.Task.LOCAL_HASH_INDEX);
taskProperties.remove(TaskMgtConstants.Task.LOCAL_TASK_NAME);
diff --git a/components/task-mgt/task-manager/pom.xml b/components/task-mgt/task-manager/pom.xml
index a263d338e7..0b666e4a3e 100755
--- a/components/task-mgt/task-manager/pom.xml
+++ b/components/task-mgt/task-manager/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
task-mgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml
index d546c28698..26ee6b6e66 100755
--- a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml
+++ b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
task-watcher
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/src/main/java/io/entgra/task/mgt/watcher/IoTSStartupHandler.java b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/src/main/java/io/entgra/task/mgt/watcher/IoTSStartupHandler.java
index 8ae40d6a26..355fba3825 100755
--- a/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/src/main/java/io/entgra/task/mgt/watcher/IoTSStartupHandler.java
+++ b/components/task-mgt/task-watcher/io.entgra.task.mgt.watcher/src/main/java/io/entgra/task/mgt/watcher/IoTSStartupHandler.java
@@ -64,7 +64,7 @@ public class IoTSStartupHandler implements ServerStartupObserver {
log.error("Error occurred when comparing tasks.", e);
}
}
- }, 200000, 600000);
+ }, 200000, 300000);
}
private void compareTasks() {
@@ -127,29 +127,18 @@ public class IoTSStartupHandler implements ServerStartupObserver {
// add or update task into nTask core
for (DynamicTask dt : tenantedDynamicTasks.get(tenantId)) {
String generatedTaskId = TaskManagementUtil.generateTaskId(dt.getDynamicTaskId());
- Map taskProperties = dt.getProperties();
- try {
- int serverHashIdx = TaskWatcherDataHolder.getInstance().getHeartBeatService()
- .getServerCtxInfo().getLocalServerHashIdx();
- taskProperties.put(TaskMgtConstants.Task.LOCAL_HASH_INDEX, String.valueOf(serverHashIdx));
- taskProperties.put(TaskMgtConstants.Task.LOCAL_TASK_NAME, generatedTaskId);
- } catch (HeartBeatManagementException e) {
- String msg = "Unexpected exception when getting server hash index.";
- log.error(msg, e);
- throw new TaskManagementException(msg, e);
- }
boolean isExist = false;
for (TaskInfo taskInfo : tasks) {
if (taskInfo.getName().equals(generatedTaskId)) {
isExist = true;
TaskInfo.TriggerInfo triggerInfo = taskInfo.getTriggerInfo();
- String dynamicTaskPropMD5 = TaskManagementUtil.generateTaskPropsMD5(taskProperties);
+ String dynamicTaskPropMD5 = TaskManagementUtil.generateTaskPropsMD5(dt.getProperties());
String existingTaskPropMD5 = TaskManagementUtil.generateTaskPropsMD5(taskInfo.getProperties());
if (!triggerInfo.getCronExpression().equals(dt.getCronExpression())
|| !dynamicTaskPropMD5.equals(existingTaskPropMD5)) {
triggerInfo.setCronExpression(dt.getCronExpression());
taskInfo.setTriggerInfo(triggerInfo);
- taskInfo.setProperties(taskProperties);
+ taskInfo.setProperties(populateTaskProperties(tenantId, generatedTaskId, dt.getProperties()));
taskManager.registerTask(taskInfo);
taskManager.rescheduleTask(generatedTaskId);
if (log.isDebugEnabled()) {
@@ -176,7 +165,7 @@ public class IoTSStartupHandler implements ServerStartupObserver {
TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo();
triggerInfo.setCronExpression(dt.getCronExpression());
TaskInfo taskInfo = new TaskInfo(generatedTaskId, dt.getTaskClassName(),
- taskProperties, triggerInfo);
+ populateTaskProperties(tenantId, generatedTaskId, dt.getProperties()), triggerInfo);
taskManager.registerTask(taskInfo);
taskManager.scheduleTask(generatedTaskId);
if (log.isDebugEnabled()) {
@@ -188,6 +177,23 @@ public class IoTSStartupHandler implements ServerStartupObserver {
}
}
+ private static Map populateTaskProperties(int tenantId, String generatedTaskId,
+ Map taskProperties)
+ throws TaskManagementException {
+ try {
+ int serverHashIdx = TaskWatcherDataHolder.getInstance().getHeartBeatService()
+ .getServerCtxInfo().getLocalServerHashIdx();
+ taskProperties.put(TaskMgtConstants.Task.LOCAL_HASH_INDEX, String.valueOf(serverHashIdx));
+ taskProperties.put(TaskMgtConstants.Task.LOCAL_TASK_NAME, generatedTaskId);
+ taskProperties.put(TaskMgtConstants.Task.TENANT_ID_PROP, String.valueOf(tenantId));
+ return taskProperties;
+ } catch (HeartBeatManagementException e) {
+ String msg = "Unexpected exception when getting server hash index.";
+ log.error(msg, e);
+ throw new TaskManagementException(msg, e);
+ }
+ }
+
private static void deleteObsoleteTasks(TaskService nTaskService, List dynamicTasks)
throws TaskManagementException, TaskException {
diff --git a/components/task-mgt/task-watcher/pom.xml b/components/task-mgt/task-watcher/pom.xml
index a570d9f279..4e70adb636 100755
--- a/components/task-mgt/task-watcher/pom.xml
+++ b/components/task-mgt/task-watcher/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
task-mgt
- 5.0.20-SNAPSHOT
+ 5.0.22-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 a57921baf3..2b39b91979 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/email-sender/pom.xml b/components/transport-mgt/email-sender/pom.xml
index 8e4d752874..c4a5ab633e 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/pom.xml b/components/transport-mgt/pom.xml
index 9702d7f32c..7f600bc7b0 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.20-SNAPSHOT
+ 5.0.22-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 ae4b3ec78b..0685e39018 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.20-SNAPSHOT
+ 5.0.22-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 9f4858d961..95e6157997 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.20-SNAPSHOT
+ 5.0.22-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 b9dc37e51c..f97f7c1e01 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/transport-mgt/sms-handler/pom.xml b/components/transport-mgt/sms-handler/pom.xml
index 1124fd5609..170ea23fef 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.20-SNAPSHOT
+ 5.0.22-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 4f4a7e546d..811940eca0 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
4.0.0
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/HubspotHandler.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/HubspotHandler.java
new file mode 100644
index 0000000000..b649d341fe
--- /dev/null
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/HubspotHandler.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2023, 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.ui.request.interceptor;
+
+import com.google.gson.JsonObject;
+import io.entgra.ui.request.interceptor.beans.ProxyResponse;
+import io.entgra.ui.request.interceptor.util.HandlerConstants;
+import io.entgra.ui.request.interceptor.util.HandlerUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
+@MultipartConfig
+@WebServlet(
+ name = "HubspotRequestHandlerServlet",
+ description = "",
+ urlPatterns = {
+ "/hubspot/*"
+ }
+)
+public class HubspotHandler extends HttpServlet {
+
+ private static final Log log = LogFactory.getLog(HubspotHandler.class);
+ private HttpSession httpSession;
+ private static String hubspotEndpoint;
+ private static String chatConfig;
+ private JsonObject uiConfigJsonObject;
+ private static String gatewayUrl;
+ private static String iotsCoreUrl;
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ if (validateRequest(req, resp)) {
+ HttpPost postRequest = new HttpPost(HandlerUtil.generateBackendRequestURL(req, hubspotEndpoint));
+ HandlerUtil.generateChatRequestEntity(req, postRequest);
+ postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
+ postRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig);
+ ProxyResponse proxyResponse = HandlerUtil.execute(postRequest);
+ HandlerUtil.handleSuccess(resp, proxyResponse);
+ }
+ } catch (IOException e) {
+ log.error("Error occurred when processing POST request.", e);
+ }
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ if (validateRequest(req, resp)) {
+ HttpGet getRequest = new HttpGet(HandlerUtil.generateBackendRequestURL(req,hubspotEndpoint));
+ getRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
+ getRequest.setHeader(HttpHeaders.AUTHORIZATION, HandlerConstants.BEARER + chatConfig);
+ ProxyResponse proxyResponse = HandlerUtil.execute(getRequest);
+ HandlerUtil.handleSuccess(resp, proxyResponse);
+ }
+ } catch (IOException e) {
+ log.error("Error occurred when processing GET request.", e);
+ }
+ }
+
+ /***
+ * Validates the hubspot's incoming request.
+ *
+ * @param req {@link HttpServletRequest}
+ * @param resp {@link HttpServletResponse}
+ * @return If request is a valid one, returns TRUE, otherwise return FALSE
+ * @throws IOException If and error occurs while witting error response to client side
+ */
+ private boolean validateRequest(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+ httpSession = req.getSession(false);
+ if (httpSession == null) {
+ log.error("Unauthorized, You are not logged in. Please log in to the portal");
+ HandlerUtil.handleError(resp, HttpStatus.SC_UNAUTHORIZED);
+ return false;
+ }
+ if (req.getMethod() == null) {
+ log.error("Bad Request, Request method is empty");
+ HandlerUtil.handleError(resp, HttpStatus.SC_BAD_REQUEST);
+ return false;
+ }
+ gatewayUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_GW_HOST_ENV_VAR)
+ + HandlerConstants.COLON + HandlerUtil.getGatewayPort(req.getScheme());
+ iotsCoreUrl = req.getScheme() + HandlerConstants.SCHEME_SEPARATOR + System.getProperty(HandlerConstants.IOT_CORE_HOST_ENV_VAR)
+ + HandlerConstants.COLON + HandlerUtil.getCorePort(req.getScheme());
+ String uiConfigUrl = iotsCoreUrl + HandlerConstants.UI_CONFIG_ENDPOINT;
+ uiConfigJsonObject = HandlerUtil.getUIConfigAndPersistInSession(uiConfigUrl, gatewayUrl, httpSession, resp);
+ chatConfig = uiConfigJsonObject.get("hubspotChat").getAsJsonObject().get("accessToken").getAsString();
+ hubspotEndpoint = HandlerConstants.HTTPS_PROTOCOL + HandlerConstants.SCHEME_SEPARATOR + HandlerConstants.HUBSPOT_CHAT_URL;
+ return true;
+ }
+}
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
index bf9947a9af..27d6afaadc 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerConstants.java
@@ -105,4 +105,5 @@ public class HandlerConstants {
public static final String IOT_GW_HTTPS_PORT_ENV_VAR = "iot.gateway.https.port";
public static final String IOT_REPORTING_WEBAPP_HOST_ENV_VAR = "iot.reporting.webapp.host";
public static final String USER_SCOPES = "userScopes";
+ public static final String HUBSPOT_CHAT_URL = "api.hubapi.com";
}
diff --git a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
index fb565bf59b..b7376abddc 100644
--- a/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
+++ b/components/ui-request-interceptor/io.entgra.ui.request.interceptor/src/main/java/io/entgra/ui/request/interceptor/util/HandlerUtil.java
@@ -435,6 +435,23 @@ public class HandlerUtil {
}
}
+ /**
+ * Generate te request entity for POST requests from the hubspot's incoming request.
+ *
+ * @param req incoming {@link HttpServletRequest}.
+ * @param proxyRequest proxy request instance.
+ * @throws IOException If error occurred while generating the request body.
+ */
+ public static void generateChatRequestEntity(HttpServletRequest req, HttpEntityEnclosingRequestBase proxyRequest)
+ throws IOException {
+ if (StringUtils.isNotEmpty(req.getHeader(HttpHeaders.CONTENT_LENGTH)) ||
+ StringUtils.isNotEmpty(req.getHeader(HttpHeaders.TRANSFER_ENCODING))) {
+ InputStreamEntity entity = new InputStreamEntity(req.getInputStream(),
+ Long.parseLong(req.getHeader(HttpHeaders.CONTENT_LENGTH)));
+ proxyRequest.setEntity(new BufferedHttpEntity(entity));
+ }
+ }
+
/***
* Constructs the application registration payload for DCR.
*
diff --git a/components/ui-request-interceptor/pom.xml b/components/ui-request-interceptor/pom.xml
index e16c2d3f4b..0e28cc938a 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.20-SNAPSHOT
+ 5.0.22-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 fdfc56c1dd..cb4a230459 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/components/webapp-authenticator-framework/pom.xml b/components/webapp-authenticator-framework/pom.xml
index 6945454311..081ec8435d 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.20-SNAPSHOT
+ 5.0.22-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 e0ce823ef5..cf405ce872 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.20-SNAPSHOT
+ 5.0.22-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 6f52cf112c..6ca64815a7 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/analytics-mgt/grafana-mgt/pom.xml b/features/analytics-mgt/grafana-mgt/pom.xml
index f9c33243fd..95fad6f184 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/analytics-mgt/pom.xml b/features/analytics-mgt/pom.xml
index f6a2860e0b..cc859b27c8 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml
new file mode 100644
index 0000000000..bbe2d2226e
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/pom.xml
@@ -0,0 +1,99 @@
+
+
+
+
+ org.wso2.carbon.devicemgt
+ apimgt-extensions-feature
+ 5.0.22-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ io.entgra.device.mgt.core.apimgt.analytics.extension.feature
+ pom
+ Entgra - APIM Analytics Extension Feature
+ http://entgra.io
+
+
+
+ org.wso2.carbon.devicemgt
+ io.entgra.device.mgt.core.apimgt.analytics.extension
+
+
+
+
+
+
+ maven-resources-plugin
+ 2.6
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+ ${carbon.p2.plugin.version}
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ io.entgra.device.mgt.core.apimgt.analytics.extension
+ ../../../features/etc/feature.properties
+
+
+ org.wso2.carbon.p2.category.type:server
+ org.eclipse.equinox.p2.type.group:true
+
+
+
+
+ org.wso2.carbon.devicemgt:io.entgra.device.mgt.core.apimgt.analytics.extension:${carbon.device.mgt.version}
+
+
+
+
+
+
+
+
+
+
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/build.properties b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/build.properties
new file mode 100644
index 0000000000..93c4b10701
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/build.properties
@@ -0,0 +1 @@
+custom = true
\ No newline at end of file
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_publisher.xml.template b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_publisher.xml.template
new file mode 100644
index 0000000000..b103c8d1ac
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_publisher.xml.template
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ #foreach( $property in $properties )
+ ${property.value}
+ #end
+
+
\ No newline at end of file
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_receiver.xml.template b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_receiver.xml.template
new file mode 100644
index 0000000000..c9b90877f0
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_receiver.xml.template
@@ -0,0 +1,20 @@
+
+
+
+
+ #foreach( $property in $properties )
+ ${property.value}
+ #end
+
+
+
+
\ No newline at end of file
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_stream.json.template b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_stream.json.template
new file mode 100644
index 0000000000..5f0b85ad3b
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/iot-analytics-templates/event_stream.json.template
@@ -0,0 +1,26 @@
+{
+ "streamId": "$name:$version",
+ "name": "$name",
+ "version": "$version",
+ "nickName": "",
+ "description": "",
+ "metaData": [
+ {
+ "name": "${metaData.name}",
+ "type": "${metaData.type}"
+ }
+ ],
+ "correlationData": [],
+ "payloadData": [
+#foreach( $property in $properties )
+ {
+ "name": "${property.name}",
+ "type": "${property.value}"
+ },
+#end
+ {
+ "name": "ts",
+ "type": "LONG"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/p2.inf b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/p2.inf
new file mode 100644
index 0000000000..235bd0424c
--- /dev/null
+++ b/features/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension.feature/src/main/resources/p2.inf
@@ -0,0 +1,3 @@
+instructions.configure = \
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/iot-analytics-templates);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.apimgt.analytics.extension_${feature.version}/iot-analytics-templates/,target:${installFolder}/../../resources/iot-analytics-templates/,overwrite:true);\
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 5e789d64cb..a0f0b246eb 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.20-SNAPSHOT
+ 5.0.22-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 69c6b280e3..f202cbf25f 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
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt
apimgt-extensions-feature
- 5.0.20-SNAPSHOT
+ 5.0.22-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 c2ee07f0c9..bcfce9faed 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/apimgt-extensions/pom.xml b/features/apimgt-extensions/pom.xml
index c169946fd3..45123719f0 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
@@ -37,6 +37,7 @@
org.wso2.carbon.apimgt.webapp.publisher.feature
org.wso2.carbon.apimgt.application.extension.feature
org.wso2.carbon.apimgt.keymgt.extension.feature
+ io.entgra.device.mgt.core.apimgt.analytics.extension.feature
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 4c1f3edd29..40f8b41c8b 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.20-SNAPSHOT
+ 5.0.22-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 e46d58bb91..eb0727491a 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml
index 5e855e60c9..5148a57452 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.20-SNAPSHOT
+ 5.0.22-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 7a149fb63d..acfdb1ab6c 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.20-SNAPSHOT
+ 5.0.22-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 6829f4a0d6..5dc6185f23 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.20-SNAPSHOT
+ 5.0.22-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 27a40bd0a4..0c05cd78ff 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/certificate-mgt/pom.xml b/features/certificate-mgt/pom.xml
index f86d0bb8ef..f21dfc2695 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml
index 7d18bd12d5..fed8c0f25b 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.defaultrole.manager.feature/pom.xml
@@ -23,7 +23,7 @@
org.wso2.carbon.devicemgt
device-mgt-extensions-feature
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml
index 1dc330f67f..8f57e439c8 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.logger.feature/pom.xml
@@ -23,7 +23,7 @@
org.wso2.carbon.devicemgt
device-mgt-extensions-feature
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml
index f178b51f53..8dd649d652 100644
--- a/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml
+++ b/features/device-mgt-extensions/io.entgra.device.mgt.extensions.stateengine.feature/pom.xml
@@ -23,7 +23,7 @@
org.wso2.carbon.devicemgt
device-mgt-extensions-feature
- 5.0.20-SNAPSHOT
+ 5.0.22-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 b36bc24864..0016ab0066 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.20-SNAPSHOT
+ 5.0.22-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 822f213a82..2ef24d1914 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.20-SNAPSHOT
+ 5.0.22-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 e8121a2b25..46d7df4f25 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.20-SNAPSHOT
+ 5.0.22-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 469735e0c6..42442839de 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.20-SNAPSHOT
+ 5.0.22-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 91fddccc4e..b89b6ff19e 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt-extensions/pom.xml b/features/device-mgt-extensions/pom.xml
index 92cc4a384f..58eac7c911 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.20-SNAPSHOT
+ 5.0.22-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 0c2a6df02f..9a9b95bdf8 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.20-SNAPSHOT
+ 5.0.22-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 701de1d1b7..14457650ac 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
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 340b22802b..de35cf1ba8 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
@@ -183,9 +183,33 @@
+
+
+
+ <a href='https://entgra.io' target='_blank'>
+ Entgra
+ </a>
+ IoT Server 5.2.0 | © 2023
+ , All Rights Reserved.
+
+ Entgra
+
+ repository/resources/whitelabel
+ favicon.png
+ logo.png
+ icon.png
+ default
+
+
+
+
+
+ false
+ Replace with mail
+
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml
index 78db49688e..4494b4fcd6 100755
--- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf/datasources/cdm-datasources.xml
@@ -61,5 +61,25 @@
+
+ EVENT_DB
+ The datasource used for event storing
+
+ jdbc/EVENT_DB
+
+
+
+ jdbc:h2:./repository/database/EVENT_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000
+ wso2carbon
+ wso2carbon
+ org.h2.Driver
+ 50
+ 60000
+ true
+ SELECT 1
+ 30000
+
+
+
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 d36e26a3cc..9ffe2e072c 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
@@ -24,6 +24,14 @@
3600
10000
+
+
+ false
+ tracking_url
+
+ access_token
+ sender_actorId
+
false
true
@@ -100,6 +108,7 @@
perm:devices:details
perm:devices:update
perm:devices:view
+ perm:devices:enrollment-guide:view
perm:view-configuration
perm:manage-configuration
perm:policies:remove
@@ -196,6 +205,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
@@ -213,6 +224,8 @@
perm:admin:tenant:view
perm:admin:metadata:view
perm:admin:usage:view
+ perm:android:clear-applicatio
+ perm:android:suspend-package
perm:android:alternate-install
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 f567bb9dd2..264345c2e0 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
@@ -322,7 +322,26 @@
-
+
+
+
+ <a href='https://entgra.io' target='_blank'>
+ Entgra
+ </a>
+ IoT Server 5.2.0 | © 2023
+ , All Rights Reserved.
+
+ Entgra
+
+ repository/resources/whitelabel
+ favicon.png
+ logo.png
+ icon.png
+ default
+
+
+
+
@@ -350,6 +369,15 @@
{% endfor %}
{% endif%}
-
+
+
+ {% if device_mgt_conf.enrollment_guide_conf is defined %}
+ {{device_mgt_conf.enrollment_guide_conf.enable}}
+ {{device_mgt_conf.enrollment_guide_conf.mail}}
+ {% else %}
+ false
+ Replace with mail
+ {% endif %}
+
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2 b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2
index e9105a8d3e..81e6ed9714 100755
--- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/conf_templates/templates/repository/conf/datasources/cdm-datasources.xml.j2
@@ -83,5 +83,36 @@
+
+ EVENT_DB
+ The datasource used for event storing
+
+ jdbc/EVENT_DB
+
+
+
+ {% if database.device_mgt_event_db is defined %}
+ {{database.device_mgt_event_db.url}}
+ {{database.device_mgt_event_db.username}}
+ {{database.device_mgt_event_db.password}}
+ {{database.device_mgt_event_db.driver}}
+ {{database.device_mgt_event_db.validationQuery}}
+ {% for property_name,property_value in database.device_mgt_event_db.pool_options.items() %}
+ <{{property_name}}>{{property_value}}{{property_name}}>
+ {% endfor %}
+ {% else %}
+ jdbc:h2:./repository/database/EVENT_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000
+ wso2carbon
+ wso2carbon
+ org.h2.Driver
+ 50
+ 60000
+ true
+ SELECT 1
+ 30000
+ {% endif %}
+
+
+
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 7ae15434ee..0185636c8e 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.20-SNAPSHOT
+ 5.0.22-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 1f5a22014f..7f7ae96205 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.20-SNAPSHOT
+ 5.0.22-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 3d009aa9cb..baec385680 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/device-mgt/pom.xml b/features/device-mgt/pom.xml
index 43a0145b6e..62a22489dd 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.20-SNAPSHOT
+ 5.0.22-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 e5f9d4a316..0c4f1f09b6 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/heartbeat-management/pom.xml b/features/heartbeat-management/pom.xml
index 0616963355..9268f032b3 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.20-SNAPSHOT
+ 5.0.22-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 9d375e95c4..8fcbd20f07 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/jwt-client/pom.xml b/features/jwt-client/pom.xml
index 5eced82de5..70a1ee6741 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/features/logger/io.entgra.notification.logger.feature/pom.xml b/features/logger/io.entgra.notification.logger.feature/pom.xml
new file mode 100644
index 0000000000..c9630369bc
--- /dev/null
+++ b/features/logger/io.entgra.notification.logger.feature/pom.xml
@@ -0,0 +1,116 @@
+
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt
+ logger-feature
+ 5.0.22-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ io.entgra.notification.logger.feature
+ pom
+ Entgra - Notification logger
+ http://entgra.io
+
+ This feature bundles for the Entgra Notification logger
+
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+
+
+ org.testng
+ testng
+
+
+ org.wso2.carbon.devicemgt
+ io.entgra.device.mgt.extensions.logger
+
+
+ org.wso2.carbon.devicemgt
+ io.entgra.notification.logger
+
+
+
+
+
+
+ maven-resources-plugin
+ 2.6
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+ ${carbon.p2.plugin.version}
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ io.entgra.notification.logger
+ ../../../features/etc/feature.properties
+
+
+ org.wso2.carbon.p2.category.type:server
+ org.eclipse.equinox.p2.type.group:true
+
+
+
+
+ org.wso2.carbon.devicemgt:io.entgra.notification.logger:${carbon.device.mgt.version}
+
+
+
+
+
+
+
+
+
diff --git a/features/logger/io.entgra.notification.logger.feature/src/main/resources/build.properties b/features/logger/io.entgra.notification.logger.feature/src/main/resources/build.properties
new file mode 100644
index 0000000000..e98fb2729f
--- /dev/null
+++ b/features/logger/io.entgra.notification.logger.feature/src/main/resources/build.properties
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
+#
+# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
+#
+# Licensed under the Entgra Commercial License, Version 1.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://entgra.io/licenses/entgra-commercial/1.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.
+#
+
+custom = true
diff --git a/features/logger/io.entgra.notification.logger.feature/src/main/resources/p2.inf b/features/logger/io.entgra.notification.logger.feature/src/main/resources/p2.inf
new file mode 100644
index 0000000000..7ab37b9d7d
--- /dev/null
+++ b/features/logger/io.entgra.notification.logger.feature/src/main/resources/p2.inf
@@ -0,0 +1 @@
+instructions.configure = \
\ No newline at end of file
diff --git a/features/logger/pom.xml b/features/logger/pom.xml
new file mode 100644
index 0000000000..ab41d67cf8
--- /dev/null
+++ b/features/logger/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt
+ carbon-devicemgt
+ 5.0.22-SNAPSHOT
+ ../../pom.xml
+
+
+ 4.0.0
+ logger-feature
+ pom
+ Entgra - Logger Feature
+ http://entgra.io
+
+
+ io.entgra.notification.logger.feature
+
+
+
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 0a9bff010c..491b2810c6 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/policy-mgt/pom.xml b/features/policy-mgt/pom.xml
index 833e11aba4..97c4cc4e61 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../pom.xml
diff --git a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml
index c285c53040..ff0531217c 100755
--- a/features/task-mgt/io.entgra.task.mgt.feature/pom.xml
+++ b/features/task-mgt/io.entgra.task.mgt.feature/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
org.wso2.carbon.devicemgt
carbon-devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../../../pom.xml
diff --git a/features/task-mgt/pom.xml b/features/task-mgt/pom.xml
index 26638a6aa2..df640d0bec 100755
--- a/features/task-mgt/pom.xml
+++ b/features/task-mgt/pom.xml
@@ -16,14 +16,12 @@
~ specific language governing permissions and limitations
~ under the License.
-->
-
+
carbon-devicemgt
org.wso2.carbon.devicemgt
- 5.0.20-SNAPSHOT
+ 5.0.22-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 c86636d487..7e9f22200c 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.20-SNAPSHOT
+ 5.0.22-SNAPSHOT
../pom.xml
diff --git a/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm
new file mode 100644
index 0000000000..f4f16cc8d7
--- /dev/null
+++ b/features/transport-mgt/email-sender/org.wso2.carbon.email.sender.feature/src/main/resources/email/templates/enrollment-guide.vm
@@ -0,0 +1,34 @@
+#*
+ Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+
+ WSO2 Inc. 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.
+*#
+
+ $mail-subject
+
+
+
+ Enrollment Questions and Answers
+
+
+
+ $enrollment-guide
+
+
+
+ ]]>
+