forked from community/device-mgt-core
commit
6a12911487
18
components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java → components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/APIManagerServiceComponent.java
18
components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIServiceComponent.java → components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/APIManagerServiceComponent.java
49
components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java → components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/APIManagerServiceDataHolder.java
49
components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/PublisherRESTAPIDataHolder.java → components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/src/main/java/io/entgra/device/mgt/core/apimgt/extension/rest/api/internal/APIManagerServiceDataHolder.java
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.apimgt.extension.rest.api.util;
|
||||
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.constants.Constants;
|
||||
import io.entgra.device.mgt.core.apimgt.extension.rest.api.exceptions.APIServicesException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
import org.wso2.carbon.user.api.UserStoreManager;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||
|
||||
/**
|
||||
* This class contains utility methods needed for API publishing
|
||||
*/
|
||||
public class APIPublisherUtils {
|
||||
private static final Log log = LogFactory.getLog(APIPublisherUtils.class);
|
||||
|
||||
/**
|
||||
* This method will create the temporary user created to publish scopes to the sub tenant space.
|
||||
* @param tenantDomain sub tenant domain from which the user will be created
|
||||
* @throws APIServicesException if the user was unable to be created
|
||||
*/
|
||||
public static void createScopePublishUserIfNotExists(String tenantDomain) throws APIServicesException {
|
||||
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
try {
|
||||
UserStoreManager userStoreManager =
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getUserStoreManager();
|
||||
if (!userStoreManager.isExistingUser(MultitenantUtils.getTenantAwareUsername(Constants.SCOPE_PUBLISH_RESERVED_USER_NAME))) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Creating scope publish user '" + Constants.SCOPE_PUBLISH_RESERVED_USER_NAME + "' in '" +
|
||||
tenantDomain + "' tenant domain.");
|
||||
}
|
||||
String[] roles = {Constants.ADMIN_ROLE_KEY};
|
||||
userStoreManager.addUser(
|
||||
MultitenantUtils.getTenantAwareUsername(Constants.SCOPE_PUBLISH_RESERVED_USER_NAME),
|
||||
Constants.SCOPE_PUBLISH_RESERVED_USER_PASSWORD,
|
||||
roles,
|
||||
null,
|
||||
""
|
||||
);
|
||||
}
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while creating scope publishing user in tenant: '" + tenantDomain + "'.";
|
||||
log.error(msg);
|
||||
throw new APIServicesException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will delete the temporary user created to publish scopes to the sub tenant space.
|
||||
* @param tenantDomain sub tenant domain from which the scope publish user will be removed from
|
||||
*/
|
||||
public static void removeScopePublishUserIfExists(String tenantDomain) {
|
||||
if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
|
||||
try {
|
||||
UserStoreManager userStoreManager =
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getUserStoreManager();
|
||||
if (userStoreManager.isExistingUser(MultitenantUtils.getTenantAwareUsername(Constants.SCOPE_PUBLISH_RESERVED_USER_NAME))) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Deleting scope publish user '" + Constants.SCOPE_PUBLISH_RESERVED_USER_NAME + "' from '" +
|
||||
tenantDomain + "' tenant domain.");
|
||||
}
|
||||
userStoreManager.deleteUser(MultitenantUtils.getTenantAwareUsername(Constants.SCOPE_PUBLISH_RESERVED_USER_NAME));
|
||||
}
|
||||
} catch(UserStoreException e){
|
||||
String msg = "Error occurred while deleting scope publishing user from tenant: '" + tenantDomain + "'.";
|
||||
log.error(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||
*
|
||||
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.entgra.device.mgt.core.device.mgt.core.config.metadata.mgt.documentation;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "DocConfiguration")
|
||||
public class DocConfiguration {
|
||||
private String docUrl;
|
||||
|
||||
@XmlElement(name = "DocUrl", required = true)
|
||||
public String getDocUrl() {
|
||||
return docUrl;
|
||||
}
|
||||
|
||||
public void setDocUrl(String docUrl) {
|
||||
this.docUrl = docUrl;
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
|
||||
public class GroupMgtLogContext extends LogContext {
|
||||
private final String groupId;
|
||||
private final String name;
|
||||
private final String owner;
|
||||
private final String actionTag;
|
||||
private final String deviceCount;
|
||||
private final String devices;
|
||||
private final String userName;
|
||||
private final String tenantID;
|
||||
private final String tenantDomain;
|
||||
|
||||
private GroupMgtLogContext(Builder builder) {
|
||||
this.groupId = builder.groupId;
|
||||
this.name = builder.name;
|
||||
this.owner = builder.owner;
|
||||
this.actionTag = builder.actionTag;
|
||||
this.deviceCount = builder.deviceCount;
|
||||
this.devices = builder.devices;
|
||||
this.userName = builder.userName;
|
||||
this.tenantID = builder.tenantID;
|
||||
this.tenantDomain = builder.tenantDomain;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public String getDeviceCount() {
|
||||
return deviceCount;
|
||||
}
|
||||
|
||||
public String getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String groupId;
|
||||
private String name;
|
||||
private String owner;
|
||||
private String actionTag;
|
||||
private String deviceCount;
|
||||
private String devices;
|
||||
private String userName;
|
||||
private String tenantID;
|
||||
private String tenantDomain;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public Builder setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Builder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Builder setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public Builder setActionTag(String actionTag) {
|
||||
this.actionTag = actionTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDeviceCount() {
|
||||
return deviceCount;
|
||||
}
|
||||
|
||||
public Builder setDeviceCount(String deviceCount) {
|
||||
this.deviceCount = deviceCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public Builder setDevices(String devices) {
|
||||
this.devices = devices;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public Builder setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public Builder setTenantID(String tenantID) {
|
||||
this.tenantID = tenantID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public Builder setTenantDomain(String tenantDomain) {
|
||||
this.tenantDomain = tenantDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GroupMgtLogContext build() {
|
||||
return new GroupMgtLogContext(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
|
||||
public class RoleMgtLogContext extends LogContext {
|
||||
private final String userStoreDomain;
|
||||
private final String roleName;
|
||||
private final String users;
|
||||
private final String actionTag;
|
||||
private final String userName;
|
||||
private final String tenantID;
|
||||
private final String tenantDomain;
|
||||
|
||||
private RoleMgtLogContext(Builder builder) {
|
||||
this.userStoreDomain = builder.userStoreDomain;
|
||||
this.roleName = builder.roleName;
|
||||
this.users = builder.users;
|
||||
this.actionTag = builder.actionTag;
|
||||
this.userName = builder.userName;
|
||||
this.tenantID = builder.tenantID;
|
||||
this.tenantDomain = builder.tenantDomain;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public String getUserStoreDomain() {
|
||||
return userStoreDomain;
|
||||
}
|
||||
|
||||
public String getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String userStoreDomain;
|
||||
private String roleName;
|
||||
private String users;
|
||||
private String actionTag;
|
||||
private String userName;
|
||||
private String tenantID;
|
||||
private String tenantDomain;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
public String getUserStoreDomain() {
|
||||
return userStoreDomain;
|
||||
}
|
||||
|
||||
public Builder setUserStoreDomain(String userStoreDomain) {
|
||||
this.userStoreDomain = userStoreDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public Builder setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public Builder setUsers(String users) {
|
||||
this.users = users;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public Builder setActionTag(String actionTag) {
|
||||
this.actionTag = actionTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public Builder setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public Builder setTenantID(String tenantID) {
|
||||
this.tenantID = tenantID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public Builder setTenantDomain(String tenantDomain) {
|
||||
this.tenantDomain = tenantDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RoleMgtLogContext build() {
|
||||
return new RoleMgtLogContext(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
|
||||
public class UserMgtLogContext extends LogContext {
|
||||
private final String userStoreDomain;
|
||||
private final String firstName;
|
||||
private final String lastName;
|
||||
private final String email;
|
||||
private final String userRoles;
|
||||
private final String actionTag;
|
||||
private final String userName;
|
||||
private final String tenantID;
|
||||
private final String tenantDomain;
|
||||
|
||||
private UserMgtLogContext(Builder builder) {
|
||||
this.userStoreDomain = builder.userStoreDomain;
|
||||
this.firstName = builder.firstName;
|
||||
this.lastName = builder.lastName;
|
||||
this.email = builder.email;
|
||||
this.userRoles = builder.userRoles;
|
||||
this.actionTag = builder.actionTag;
|
||||
this.userName = builder.userName;
|
||||
this.tenantID = builder.tenantID;
|
||||
this.tenantDomain = builder.tenantDomain;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public String getUserStoreDomain() {
|
||||
return userStoreDomain;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getUserRoles() {
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String userStoreDomain;
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private String email;
|
||||
private String userRoles;
|
||||
private String actionTag;
|
||||
private String userName;
|
||||
private String tenantID;
|
||||
private String tenantDomain;
|
||||
|
||||
public Builder() {
|
||||
}
|
||||
|
||||
public String getUserStoreDomain() {
|
||||
return userStoreDomain;
|
||||
}
|
||||
|
||||
public Builder setUserStoreDomain(String userStoreDomain) {
|
||||
this.userStoreDomain = userStoreDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public Builder setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public Builder setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Builder setEmail(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserRoles() {
|
||||
return userRoles;
|
||||
}
|
||||
|
||||
public Builder setUserRoles(String userRoles) {
|
||||
this.userRoles = userRoles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getActionTag() {
|
||||
return actionTag;
|
||||
}
|
||||
|
||||
public Builder setActionTag(String actionTag) {
|
||||
this.actionTag = actionTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public Builder setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantID() {
|
||||
return tenantID;
|
||||
}
|
||||
|
||||
public Builder setTenantID(String tenantID) {
|
||||
this.tenantID = tenantID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTenantDomain() {
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public Builder setTenantDomain(String tenantDomain) {
|
||||
this.tenantDomain = tenantDomain;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserMgtLogContext build() {
|
||||
return new UserMgtLogContext(this);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||
import io.entgra.device.mgt.core.notification.logger.GroupMgtLogContext;
|
||||
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
public class EntgraGroupMgtLoggerImpl implements EntgraLogger {
|
||||
|
||||
private static Log log = null;
|
||||
|
||||
public EntgraGroupMgtLoggerImpl(Class<?> clazz) {
|
||||
log = LogFactory.getLog(clazz);
|
||||
}
|
||||
|
||||
public void info(String message) {
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
public void info(String message, Throwable t) {
|
||||
log.info(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o) {
|
||||
log.info(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o, Throwable throwable) {
|
||||
log.info(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.info(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.info(object, t);
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
public void debug(String message, Throwable t) {
|
||||
log.debug(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o) {
|
||||
log.debug(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o, Throwable throwable) {
|
||||
log.debug(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.debug(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.debug(object, t);
|
||||
}
|
||||
|
||||
public void error(String message) {
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
public void error(String message, Throwable t) {
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o) {
|
||||
log.error(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o, Throwable throwable) {
|
||||
log.error(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.error(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.error(object, t);
|
||||
}
|
||||
|
||||
public void warn(String message) {
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
public void warn(String message, Throwable t) {
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o) {
|
||||
log.warn(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o, Throwable throwable) {
|
||||
log.warn(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.warn(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.warn(object, t);
|
||||
}
|
||||
|
||||
public void trace(String message) {
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
public void trace(String message, Throwable t) {
|
||||
log.trace(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o) {
|
||||
log.trace(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o, Throwable throwable) {
|
||||
log.trace(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.trace(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.trace(object, t);
|
||||
}
|
||||
|
||||
public void fatal(String message) {
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
public void fatal(String message, Throwable t) {
|
||||
log.fatal(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o) {
|
||||
log.fatal(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o, Throwable throwable) {
|
||||
log.fatal(0, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.fatal(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||
GroupMgtLogContext groupMgtLogContext = (GroupMgtLogContext) logContext;
|
||||
MDCContextUtil.populateGroupMgtMDCContext(groupMgtLogContext);
|
||||
log.fatal(object, t);
|
||||
}
|
||||
|
||||
@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 clearLogContext() {
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
91
components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java → components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java
91
components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraUserLoggerImpl.java → components/logger/io.entgra.device.mgt.core.notification.logger/src/main/java/io/entgra/device/mgt/core/notification/logger/impl/EntgraRoleMgtLoggerImpl.java
@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||
import io.entgra.device.mgt.core.notification.logger.UserLoginLogContext;
|
||||
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
public class EntgraUserLoginLoggerImpl implements EntgraLogger {
|
||||
|
||||
private static Log log = null;
|
||||
|
||||
public EntgraUserLoginLoggerImpl(Class<?> clazz) {
|
||||
log = LogFactory.getLog(clazz);
|
||||
}
|
||||
|
||||
public void info(String message) {
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
public void info(String message, Throwable t) {
|
||||
log.info(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o) {
|
||||
log.info(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o, Throwable throwable) {
|
||||
log.info(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.info(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.info(object, t);
|
||||
}
|
||||
|
||||
|
||||
public void debug(String message) {
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
public void debug(String message, Throwable t) {
|
||||
log.debug(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o) {
|
||||
log.debug(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o, Throwable throwable) {
|
||||
log.debug(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.debug(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.debug(object, t);
|
||||
}
|
||||
|
||||
|
||||
public void error(String message) {
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
public void error(String message, Throwable t) {
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o) {
|
||||
log.error(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o, Throwable throwable) {
|
||||
log.error(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.error(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.error(object, t);
|
||||
}
|
||||
|
||||
|
||||
public void warn(String message) {
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
public void warn(String message, Throwable t) {
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o) {
|
||||
log.warn(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o, Throwable throwable) {
|
||||
log.warn(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.warn(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.warn(object, t);
|
||||
}
|
||||
|
||||
public void trace(String message) {
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
public void trace(String message, Throwable t) {
|
||||
log.trace(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o) {
|
||||
log.trace(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o, Throwable throwable) {
|
||||
log.trace(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.trace(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.trace(object, t);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void fatal(String message) {
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
public void fatal(String message, Throwable t) {
|
||||
log.fatal(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o) {
|
||||
log.fatal(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o, Throwable throwable) {
|
||||
log.fatal(0, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.fatal(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||
UserLoginLogContext userLoginLogContext = (UserLoginLogContext) logContext;
|
||||
MDCContextUtil.populateUserMDCContext(userLoginLogContext);
|
||||
log.fatal(object, t);
|
||||
}
|
||||
|
||||
@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 clearLogContext() {
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 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.notification.logger.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.LogContext;
|
||||
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
|
||||
import io.entgra.device.mgt.core.notification.logger.UserMgtLogContext;
|
||||
import io.entgra.device.mgt.core.notification.logger.util.MDCContextUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
public class EntgraUserMgtLoggerImpl implements EntgraLogger {
|
||||
|
||||
private static Log log = null;
|
||||
|
||||
public EntgraUserMgtLoggerImpl(Class<?> clazz) {
|
||||
log = LogFactory.getLog(clazz);
|
||||
}
|
||||
|
||||
public void info(String message) {
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
public void info(String message, Throwable t) {
|
||||
log.info(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o) {
|
||||
log.info(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object o, Throwable throwable) {
|
||||
log.info(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.info(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.info(object, t);
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
public void debug(String message, Throwable t) {
|
||||
log.debug(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o) {
|
||||
log.debug(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object o, Throwable throwable) {
|
||||
log.debug(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.debug(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.debug(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.debug(object, t);
|
||||
}
|
||||
|
||||
public void error(String message) {
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
public void error(String message, Throwable t) {
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o) {
|
||||
log.error(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object o, Throwable throwable) {
|
||||
log.error(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.error(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.error(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.error(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.error(object, t);
|
||||
}
|
||||
|
||||
public void warn(String message) {
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
public void warn(String message, Throwable t) {
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o) {
|
||||
log.warn(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object o, Throwable throwable) {
|
||||
log.warn(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.warn(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.warn(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.warn(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.warn(object, t);
|
||||
}
|
||||
|
||||
public void trace(String message) {
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
public void trace(String message, Throwable t) {
|
||||
log.trace(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o) {
|
||||
log.trace(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object o, Throwable throwable) {
|
||||
log.trace(o, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.trace(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.trace(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.trace(object, t);
|
||||
}
|
||||
|
||||
public void fatal(String message) {
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
public void fatal(String message, Throwable t) {
|
||||
log.fatal(message, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o) {
|
||||
log.fatal(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object o, Throwable throwable) {
|
||||
log.fatal(0, throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(String message, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.fatal(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.fatal(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatal(Object object, Throwable t, LogContext logContext) {
|
||||
UserMgtLogContext userMgtLogContext = (UserMgtLogContext) logContext;
|
||||
MDCContextUtil.populateUserMgtMDCContext(userMgtLogContext);
|
||||
log.fatal(object, t);
|
||||
}
|
||||
|
||||
@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 clearLogContext() {
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue