mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://repository.entgra.net/community/device-mgt-core into try_it
This commit is contained in:
commit
a9a7a03ebd
@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>apimgt-extensions</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>Entgra - API mgt analytics extension</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>API Management Application Bundle</Bundle-Description>
|
||||
<Private-Package>org.wso2.carbon.apimgt.application.extension.internal</Private-Package>
|
||||
<Import-Packages>
|
||||
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)"
|
||||
</Import-Packages>
|
||||
<Export-Package>
|
||||
io.entgra.device.mgt.core.apimgt.analytics.extension.*
|
||||
</Export-Package>
|
||||
<Embed-Dependency>
|
||||
scribe;scope=compile|runtime;inline=false;
|
||||
</Embed-Dependency>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-site</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
|
||||
<outputDirectory>${basedir}/target/coverage-reports/site</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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<Property> 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<Property> getPropertyList() {
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
public void setPropertyList(List<Property> 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;
|
||||
}
|
||||
}
|
||||
@ -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<Property> 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<Property> getPropertyList() {
|
||||
return propertyList;
|
||||
}
|
||||
|
||||
public void setPropertyList(List<Property> propertyList) {
|
||||
this.propertyList = propertyList;
|
||||
}
|
||||
|
||||
public String getCustomMappingType() {
|
||||
return customMappingType;
|
||||
}
|
||||
|
||||
public void setCustomMappingType(String customMappingType) {
|
||||
this.customMappingType = customMappingType;
|
||||
}
|
||||
}
|
||||
@ -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<Property> 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<Property> getPayloadData() {
|
||||
return payloadData;
|
||||
}
|
||||
|
||||
public void setPayloadData(List<Property> payloadData) {
|
||||
this.payloadData = payloadData;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -39,6 +39,7 @@
|
||||
<module>org.wso2.carbon.apimgt.annotations</module>
|
||||
<module>org.wso2.carbon.apimgt.keymgt.extension</module>
|
||||
<module>org.wso2.carbon.apimgt.keymgt.extension.api</module>
|
||||
<module>io.entgra.device.mgt.core.apimgt.analytics.extension</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
||||
@ -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();
|
||||
|
||||
}
|
||||
|
||||
@ -450,5 +450,10 @@
|
||||
<artifactId>org.wso2.carbon.event.output.adapter.rdbms</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -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")
|
||||
@ -1475,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.",
|
||||
@ -1501,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(
|
||||
@ -1523,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)
|
||||
@ -1949,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)
|
||||
@ -2247,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.",
|
||||
@ -2268,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(
|
||||
@ -2316,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.",
|
||||
@ -2337,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(
|
||||
@ -2386,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.",
|
||||
@ -2407,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(
|
||||
@ -2718,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,
|
||||
|
||||
@ -1,30 +1,20 @@
|
||||
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Arrays;
|
||||
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.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.velocity.util.ArrayListWrapper;
|
||||
import org.json.JSONObject;
|
||||
import org.opensaml.xml.signature.J;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminService;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceEventStreamPersistenceAdminServiceExceptionException;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.EventStreamPersistenceAdminServiceStub;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTable;
|
||||
import org.wso2.carbon.analytics.stream.persistence.stub.dto.AnalyticsTableRecord;
|
||||
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.core.dto.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.Attribute;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.AttributeType;
|
||||
import org.wso2.carbon.device.mgt.jaxrs.beans.analytics.DeviceTypeEvent;
|
||||
@ -34,24 +24,16 @@ 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.input.adapter.core.MessageType;
|
||||
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
|
||||
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
|
||||
import org.wso2.carbon.event.output.adapter.rdbms.RDBMSEventAdapter;
|
||||
import org.wso2.carbon.event.output.adapter.rdbms.internal.ds.RDBMSEventAdapterServiceDS;
|
||||
import org.wso2.carbon.event.processor.manager.core.EventProcessorManagementService;
|
||||
import org.wso2.carbon.event.processor.manager.core.EventPublisherManagementService;
|
||||
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.core.internal.ds.EventPublisherServiceDS;
|
||||
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.InputMapping;
|
||||
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;
|
||||
@ -59,7 +41,6 @@ import org.wso2.carbon.event.receiver.stub.EventReceiverAdminServiceCallbackHand
|
||||
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.receiver.stub.types.InputAdapterConfigurationDto;
|
||||
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;
|
||||
@ -71,7 +52,6 @@ import org.wso2.carbon.user.api.UserStoreException;
|
||||
import javax.validation.Valid;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -225,6 +205,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
|
||||
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
try {
|
||||
for (DeviceTypeEvent deviceTypeEvent : deviceTypeEvents) {
|
||||
TransportType transportType = deviceTypeEvent.getTransportType();
|
||||
@ -239,46 +220,101 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
||||
log.error(errorMessage);
|
||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
||||
}
|
||||
// event stream
|
||||
String streamName = DeviceMgtAPIUtils.getStreamDefinition(deviceType, tenantDomain, eventName);
|
||||
publishStreamDefinitons(streamName, Constants.DEFAULT_STREAM_VERSION, eventAttributes);
|
||||
AnalyticsArtifactsDeployer artifactsDeployer = new AnalyticsArtifactsDeployer();
|
||||
List<Property> 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);
|
||||
publishEventReceivers(streamName, Constants.DEFAULT_STREAM_VERSION, transportType, tenantDomain,
|
||||
isSharedWithAllTenants, deviceType, deviceTypeEvent.getEventTopicStructure(), receiverName);
|
||||
if (!skipPersist) {
|
||||
String rdbmsPublisherName = getPublisherName(deviceType, tenantDomain, eventName) + "_rdbms_publisher";
|
||||
publishEventStore(streamName, Constants.DEFAULT_STREAM_VERSION, rdbmsPublisherName);
|
||||
}
|
||||
String wsPublisherName = getPublisherName(deviceType, tenantDomain, eventName) + "_ws_publisher";
|
||||
publishWebsocketPublisherDefinition(streamName, Constants.DEFAULT_STREAM_VERSION, wsPublisherName);
|
||||
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, eventAttributes);
|
||||
publishEventReceivers(streamName, Constants.DEFAULT_STREAM_VERSION, transportType, tenantDomain,
|
||||
isSharedWithAllTenants, deviceType, deviceTypeEvent.getEventTopicStructure(), receiverName);
|
||||
EventReceiverData receiverData = new EventReceiverData();
|
||||
receiverData.setName(receiverName);
|
||||
receiverData.setStreamName(streamName);
|
||||
receiverData.setStreamVersion(Constants.DEFAULT_STREAM_VERSION);
|
||||
List<Property> 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";
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
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<Property> 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 (MalformedStreamDefinitionException e) {
|
||||
log.error("Failed while creating stream definition, tenantDomain: " + tenantDomain, e);
|
||||
} catch (EventStreamDeployerException e) {
|
||||
log.error("Failed while deploying event stream definition, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (EventStreamConfigurationException e) {
|
||||
log.error("Failed while configuring stream definition, tenantDomain: " + tenantDomain, e);
|
||||
} catch (EventPublisherDeployerException e) {
|
||||
log.error("Failed while deploying event publisher, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (EventPublisherConfigurationException e) {
|
||||
log.error("Failed while configuring event publisher, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
} catch (EventReceiverConfigurationException e) {
|
||||
log.error("Failed while configuring event receiver, tenantDomain: " + tenantDomain, e);
|
||||
} catch (EventReceiverDeployerException e) {
|
||||
log.error("Failed while deploying event receiver, tenantDomain: " + tenantDomain, e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,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;
|
||||
@ -784,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
|
||||
@ -872,6 +900,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
DeviceMgtAPIUtils.getDeviceManagementService();
|
||||
int validityTime = 3600;
|
||||
// add scopes for event topics
|
||||
List<String> mqttEventTopicStructure = new ArrayList<>();
|
||||
try {
|
||||
DeviceType deviceType = deviceManagementProviderService.getDeviceType(type);
|
||||
@ -912,10 +941,16 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
||||
topic = topic.replace("${deviceId}", id);
|
||||
}
|
||||
topic = topic.replace("/",":");
|
||||
scopes.append(" perm:topic:sub:".concat(topic));
|
||||
// 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);
|
||||
@ -1324,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
|
||||
@ -1356,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
|
||||
|
||||
@ -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.*
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!org.wso2.carbon.device.mgt.core.internal,
|
||||
@ -352,6 +354,10 @@
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.task.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.notification.logger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -25,6 +25,7 @@ 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.event.config.EventOperationTaskConfiguration;
|
||||
import org.wso2.carbon.device.mgt.core.config.geo.location.GeoLocationConfiguration;
|
||||
@ -70,6 +71,7 @@ public final class DeviceManagementConfig {
|
||||
private EnrollmentNotificationConfiguration enrollmentNotificationConfiguration;
|
||||
private DefaultRoles defaultRoles;
|
||||
private OperationTimeoutConfiguration operationTimeoutConfiguration;
|
||||
private EnrollmentGuideConfiguration enrollmentGuideConfiguration;
|
||||
|
||||
@XmlElement(name = "ManagementRepository", required = true)
|
||||
public DeviceManagementConfigRepository getDeviceManagementConfigRepository() {
|
||||
@ -265,5 +267,14 @@ public final class DeviceManagementConfig {
|
||||
public void setOperationTimeoutConfiguration(OperationTimeoutConfiguration operationTimeoutConfiguration) {
|
||||
this.operationTimeoutConfiguration = operationTimeoutConfiguration;
|
||||
}
|
||||
|
||||
@XmlElement(name = "EnrollmentGuideConfiguration", required = true)
|
||||
public EnrollmentGuideConfiguration getEnrollmentGuideConfiguration() {
|
||||
return enrollmentGuideConfiguration;
|
||||
}
|
||||
|
||||
public void setEnrollmentGuideConfiguration(EnrollmentGuideConfiguration enrollmentGuideConfiguration) {
|
||||
this.enrollmentGuideConfiguration = enrollmentGuideConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
@ -91,8 +92,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);
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
88
components/logger/io.entgra.notification.logger/pom.xml
Normal file
88
components/logger/io.entgra.notification.logger/pom.xml
Normal file
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>logger</artifactId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>io.entgra.notification.logger</artifactId>
|
||||
<name>Entgra - Notification Logger</name>
|
||||
<packaging>bundle</packaging>
|
||||
<url>http://entgra.io</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.extensions.logger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||
<Bundle-Description>Device Notification Logger Bundle</Bundle-Description>
|
||||
<Import-Package>
|
||||
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)
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
io.entgra.notification.logger.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
46
components/logger/pom.xml
Normal file
46
components/logger/pom.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>logger</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra - Notification Logger Component</name>
|
||||
<url>http://entgra.io</url>
|
||||
|
||||
<modules>
|
||||
<module>io.entgra.notification.logger</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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";
|
||||
}
|
||||
|
||||
@ -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.
|
||||
*
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>apimgt-extensions-feature</artifactId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra - APIM Analytics Extension Feature</name>
|
||||
<url>http://entgra.io</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<version>${carbon.p2.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>io.entgra.device.mgt.core.apimgt.analytics.extension</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt:io.entgra.device.mgt.core.apimgt.analytics.extension:${carbon.device.mgt.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1 @@
|
||||
custom = true
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (pvt) Ltd. (http://entgra.io)
|
||||
~
|
||||
~ All Rights Reserved.
|
||||
~
|
||||
~ Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
~ Proprietary and confidential.
|
||||
-->
|
||||
<eventPublisher name="${name}" processing="enable"
|
||||
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
||||
<from streamName="${streamName}" version="${streamVersion}"/>
|
||||
<mapping customMapping="disable" type="${customMappingType}"/>
|
||||
<to eventAdapterType="${eventAdapterType}">
|
||||
#foreach( $property in $properties )
|
||||
<property name="${property.name}">${property.value}</property>
|
||||
#end
|
||||
</to>
|
||||
</eventPublisher>
|
||||
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2023, Entgra (pvt) Ltd. (http://entgra.io)
|
||||
~
|
||||
~ All Rights Reserved.
|
||||
~
|
||||
~ Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
~ Proprietary and confidential.
|
||||
-->
|
||||
<eventReceiver name="${name}"
|
||||
statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
|
||||
<from eventAdapterType="${eventAdapterType}">
|
||||
#foreach( $property in $properties )
|
||||
<property name="${property.name}">${property.value}</property>
|
||||
#end
|
||||
</from>
|
||||
<mapping customMapping="disable" type="${customMappingType}"/>
|
||||
<to
|
||||
streamName="${streamName}" version="${streamVersion}"/>
|
||||
</eventReceiver>
|
||||
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -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);\
|
||||
@ -37,6 +37,7 @@
|
||||
<module>org.wso2.carbon.apimgt.webapp.publisher.feature</module>
|
||||
<module>org.wso2.carbon.apimgt.application.extension.feature</module>
|
||||
<module>org.wso2.carbon.apimgt.keymgt.extension.feature</module>
|
||||
<module>io.entgra.device.mgt.core.apimgt.analytics.extension.feature</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
@ -187,5 +187,9 @@
|
||||
<OperationTimeouts>
|
||||
</OperationTimeouts>
|
||||
</OperationTimeoutConfigurations>
|
||||
<EnrollmentGuideConfiguration>
|
||||
<Enable>false</Enable>
|
||||
<Mail>Replace with mail</Mail>
|
||||
</EnrollmentGuideConfiguration>
|
||||
</DeviceMgtConfiguration>
|
||||
|
||||
|
||||
@ -24,6 +24,14 @@
|
||||
<SessionTimeOut>3600</SessionTimeOut>
|
||||
<!-- maximum number of login cache entries -->
|
||||
<LoginCacheCapacity>10000</LoginCacheCapacity>
|
||||
<!-- hubspot account info for live chat -->
|
||||
<HubspotChat>
|
||||
<EnableHubspot>false</EnableHubspot>
|
||||
<TrackingUrl>tracking_url</TrackingUrl>
|
||||
<!-- access token - whenever the access token will be rotated, needs to be changed this with the new token -->
|
||||
<AccessToken>access_token</AccessToken>
|
||||
<SenderActorId>sender_actorId</SenderActorId>
|
||||
</HubspotChat>
|
||||
<Billing>
|
||||
<HideBillGenerationInSuperTenant>false</HideBillGenerationInSuperTenant>
|
||||
<HideBillGenerationInSubTenant>true</HideBillGenerationInSubTenant>
|
||||
@ -100,6 +108,7 @@
|
||||
<Scope>perm:devices:details</Scope>
|
||||
<Scope>perm:devices:update</Scope>
|
||||
<Scope>perm:devices:view</Scope>
|
||||
<Scope>perm:devices:enrollment-guide:view</Scope>
|
||||
<Scope>perm:view-configuration</Scope>
|
||||
<Scope>perm:manage-configuration</Scope>
|
||||
<Scope>perm:policies:remove</Scope>
|
||||
|
||||
@ -322,7 +322,7 @@
|
||||
</Role>
|
||||
</Roles>
|
||||
</DefaultRoles>
|
||||
<OperationTimeoutConfigurations>
|
||||
<OperationTimeoutConfigurations>
|
||||
<OperationTimeouts>
|
||||
<!--<OperationTimeout>-->
|
||||
<!--<DeviceTypes>-->
|
||||
@ -350,6 +350,15 @@
|
||||
{% endfor %}
|
||||
{% endif%}
|
||||
</OperationTimeouts>
|
||||
</OperationTimeoutConfigurations>
|
||||
</OperationTimeoutConfigurations>
|
||||
<EnrollmentGuideConfiguration>
|
||||
{% if device_mgt_conf.enrollment_guide_conf is defined %}
|
||||
<Enable>{{device_mgt_conf.enrollment_guide_conf.enable}}</Enable>
|
||||
<Mail>{{device_mgt_conf.enrollment_guide_conf.mail}}</Mail>
|
||||
{% else %}
|
||||
<Enable>false</Enable>
|
||||
<Mail>Replace with mail</Mail>
|
||||
{% endif %}
|
||||
</EnrollmentGuideConfiguration>
|
||||
</DeviceMgtConfiguration>
|
||||
|
||||
|
||||
116
features/logger/io.entgra.notification.logger.feature/pom.xml
Normal file
116
features/logger/io.entgra.notification.logger.feature/pom.xml
Normal file
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>logger-feature</artifactId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>io.entgra.notification.logger.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra - Notification logger</name>
|
||||
<url>http://entgra.io</url>
|
||||
<description>
|
||||
This feature bundles for the Entgra Notification logger
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.extensions.logger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.notification.logger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<version>${carbon.p2.plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>io.entgra.notification.logger</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt:io.entgra.notification.logger:${carbon.device.mgt.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@ -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
|
||||
@ -0,0 +1 @@
|
||||
instructions.configure = \
|
||||
40
features/logger/pom.xml
Normal file
40
features/logger/pom.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>carbon-devicemgt</artifactId>
|
||||
<version>5.0.21-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>logger-feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Entgra - Logger Feature</name>
|
||||
<url>http://entgra.io</url>
|
||||
|
||||
<modules>
|
||||
<module>io.entgra.notification.logger.feature</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
@ -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.
|
||||
*#
|
||||
<EmailConfig>
|
||||
<Subject>$mail-subject</Subject>
|
||||
<Body>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>Enrollment Questions and Answers</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
$enrollment-guide
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</Body>
|
||||
</EmailConfig>
|
||||
12
pom.xml
12
pom.xml
@ -46,6 +46,7 @@
|
||||
<module>components/transport-mgt</module>
|
||||
<module>components/analytics-mgt</module>
|
||||
<module>components/webapp-authenticator-framework</module>
|
||||
<module>components/logger</module>
|
||||
<module>components/task-mgt</module>
|
||||
<module>features/device-mgt</module>
|
||||
<module>features/apimgt-extensions</module>
|
||||
@ -59,6 +60,7 @@
|
||||
<module>features/transport-mgt</module>
|
||||
<module>features/analytics-mgt</module>
|
||||
<module>features/webapp-authenticator-framework</module>
|
||||
<module>features/logger</module>
|
||||
<module>features/task-mgt</module>
|
||||
|
||||
</modules>
|
||||
@ -282,6 +284,11 @@
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.device.mgt.core.apimgt.analytics.extension</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
|
||||
@ -356,6 +363,11 @@
|
||||
<artifactId>org.wso2.carbon.apimgt.keymgt.extension</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>io.entgra.notification.logger</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
</dependency>
|
||||
<!-- Device Management dependencies -->
|
||||
|
||||
<!-- Task Management dependencies -->
|
||||
|
||||
Loading…
Reference in New Issue
Block a user