forked from community/device-mgt-core
commit
9b9defed19
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ApiModel(value = "DeviceConfig", description = "Device config")
|
||||||
|
public class DeviceConfig {
|
||||||
|
private String clientId;
|
||||||
|
private String clientSecret;
|
||||||
|
private String deviceId;
|
||||||
|
private String type;
|
||||||
|
private String accessToken;
|
||||||
|
private String refreshToken;
|
||||||
|
private String mqttGateway;
|
||||||
|
private String httpsGateway;
|
||||||
|
private String httpGateway;
|
||||||
|
private PlatformConfiguration platformConfiguration;
|
||||||
|
public String getClientId() {
|
||||||
|
return clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientId(String clientId) {
|
||||||
|
this.clientId = clientId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClientSecret() {
|
||||||
|
return clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClientSecret(String clientSecret) {
|
||||||
|
this.clientSecret = clientSecret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceId(String deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRefreshToken() {
|
||||||
|
return refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRefreshToken(String refreshToken) {
|
||||||
|
this.refreshToken = refreshToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMqttGateway() {
|
||||||
|
return mqttGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMqttGateway(String mqttGateway) {
|
||||||
|
this.mqttGateway = mqttGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHttpsGateway() {
|
||||||
|
return httpsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHttpsGateway(String httpsGateway) {
|
||||||
|
this.httpsGateway = httpsGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHttpGateway() {
|
||||||
|
return httpGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHttpGateway(String httpGateway) {
|
||||||
|
this.httpGateway = httpGateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformConfiguration getPlatformConfiguration() {
|
||||||
|
return platformConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlatformConfiguration(PlatformConfiguration platformConfiguration) {
|
||||||
|
this.platformConfiguration = platformConfiguration;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Entgra (pvt) Ltd. (https://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class holds required parameters for a querying a sort by column in pagination.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SortColumn {
|
||||||
|
String name;
|
||||||
|
SortColumn.types type;
|
||||||
|
|
||||||
|
public enum types {
|
||||||
|
ASC, DESC
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ColumnName setter method
|
||||||
|
* @param name of the column
|
||||||
|
*/
|
||||||
|
public void setName(String name) { this.name = name; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the name of the column
|
||||||
|
* @return name
|
||||||
|
*/
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Column sort type
|
||||||
|
* @param type of sort as ASC or DESC
|
||||||
|
*/
|
||||||
|
public void setType(SortColumn.types type) { this.type = type; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get column sort type
|
||||||
|
* @return type of sort
|
||||||
|
*/
|
||||||
|
public SortColumn.types getType() { return type; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Column Name - " + this.name + ", Type - " + this.type ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Entgra (pvt) Ltd. (https://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.common.group.mgt;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@ApiModel(value = "DeviceTypesOfGroups", description = "This class carries whether the groups has device type or not.")
|
||||||
|
public class DeviceTypesOfGroups implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 5562356373277828099L;
|
||||||
|
@ApiModelProperty(name = "hasAndroid", value = "groups has Android devices.")
|
||||||
|
private boolean hasAndroid;
|
||||||
|
@ApiModelProperty(name = "id", value = "groups has iOS devices.")
|
||||||
|
private boolean hasIos;
|
||||||
|
@ApiModelProperty(name = "hasAndroid", value = "groups has Windows devices.")
|
||||||
|
private boolean hasWindows;
|
||||||
|
|
||||||
|
public boolean isHasAndroid() {
|
||||||
|
return hasAndroid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasAndroid(boolean hasAndroid) {
|
||||||
|
this.hasAndroid = hasAndroid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasIos() {
|
||||||
|
return hasIos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasIos(boolean hasIos) {
|
||||||
|
this.hasIos = hasIos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHasWindows() {
|
||||||
|
return hasWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasWindows(boolean hasWindows) {
|
||||||
|
this.hasWindows = hasWindows;
|
||||||
|
}
|
||||||
|
}
|
@ -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,72 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
private long channelAccountId;
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
@XmlElement(name = "ChannelAccountId")
|
||||||
|
public long getChannelAccountId() {
|
||||||
|
return channelAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelAccountId(long channelAccountId) {
|
||||||
|
this.channelAccountId = channelAccountId;
|
||||||
|
}
|
||||||
|
}
|
@ -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
|
@ -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>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue