diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/ContextLoader.java b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/ContextLoader.java index af6cd5b1c4..24dbf211b9 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/ContextLoader.java +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/ContextLoader.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.expired.password.identification.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.identity.core.util.IdentityCoreConstants; import org.wso2.carbon.identity.core.util.IdentityUtil; @@ -27,6 +29,8 @@ */ public class ContextLoader { + private static final Log log = LogFactory.getLog(ContextLoader.class); + /** * Retrieves loaded tenant domain from carbon context. * @@ -34,10 +38,21 @@ public class ContextLoader { */ public static String getTenantDomainFromContext() { + if (log.isDebugEnabled()) { + log.debug("Retrieving tenant domain from carbon context."); + } String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; - if (IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT) != null) { + if (IdentityUtil.threadLocalProperties.get() != null && + IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT) != null) { tenantDomain = (String) IdentityUtil.threadLocalProperties.get() .get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT); + if (log.isDebugEnabled()) { + log.debug("Retrieved tenant domain from context: " + tenantDomain); + } + } else { + if (log.isDebugEnabled()) { + log.debug("Using default super tenant domain: " + tenantDomain); + } } return tenantDomain; } diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/PasswordExpiryServiceHolder.java b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/PasswordExpiryServiceHolder.java index c38570889b..cfcda57eb5 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/PasswordExpiryServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.common/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/common/PasswordExpiryServiceHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.expired.password.identification.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.password.expiry.services.ExpiredPasswordIdentificationService; @@ -26,6 +28,8 @@ */ public class PasswordExpiryServiceHolder { + private static final Log log = LogFactory.getLog(PasswordExpiryServiceHolder.class); + private PasswordExpiryServiceHolder() {} private static class ExpiredPasswordIdentificationServiceHolder { @@ -40,6 +44,14 @@ private static class ExpiredPasswordIdentificationServiceHolder { * @return ExpiredPassword identification Service. */ public static ExpiredPasswordIdentificationService getExpiredPasswordIdentificationService() { - return ExpiredPasswordIdentificationServiceHolder.SERVICE; + + if (log.isDebugEnabled()) { + log.debug("Retrieving ExpiredPasswordIdentificationService from OSGi context."); + } + ExpiredPasswordIdentificationService service = ExpiredPasswordIdentificationServiceHolder.SERVICE; + if (service == null) { + log.warn("ExpiredPasswordIdentificationService is not available in the OSGi context."); + } + return service; } } diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/core/PasswordExpiredUsersManagementApiService.java b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/core/PasswordExpiredUsersManagementApiService.java index a4aac5262a..7483c073c9 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/core/PasswordExpiredUsersManagementApiService.java +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/core/PasswordExpiredUsersManagementApiService.java @@ -71,6 +71,10 @@ public PasswordExpiredUsersManagementApiService( public List getPasswordExpiredUsers( String expiredAfter, String excludeAfter, String tenantDomain) { + if (LOG.isDebugEnabled()) { + LOG.debug("Processing password expired users request for tenant: " + tenantDomain + + ", expiredAfter: " + expiredAfter + ", excludeAfter: " + excludeAfter); + } List passwordExpiredUsers = null; try { validateDates(expiredAfter, excludeAfter); @@ -78,13 +82,22 @@ public List getPasswordExpiredUsers( LocalDateTime expiredAfterDate = convertToDateObject(expiredAfter, DATE_EXPIRED_AFTER); LocalDateTime excludeAfterDate = convertToDateObject(excludeAfter, DATE_EXCLUDE_AFTER); if (excludeAfterDate == null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving password expired users from specific date for tenant: " + tenantDomain); + } passwordExpiredUsers = expiredPasswordIdentificationService .getPasswordExpiredUsersFromSpecificDate(expiredAfterDate, tenantDomain); } else { + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving password expired users between specific dates for tenant: " + tenantDomain); + } passwordExpiredUsers = expiredPasswordIdentificationService .getPasswordExpiredUsersBetweenSpecificDates(expiredAfterDate, excludeAfterDate, tenantDomain); } - return buildResponse(passwordExpiredUsers); + List result = buildResponse(passwordExpiredUsers); + LOG.info("Successfully retrieved " + result.size() + + " password expired users for tenant: " + tenantDomain); + return result; } catch (ExpiredPasswordIdentificationException e) { throw handleExpiredPasswordIdentificationException(e, ErrorMessage.ERROR_RETRIEVING_PASSWORD_EXPIRED_USERS, tenantDomain); @@ -251,13 +264,21 @@ private String includeData(ErrorMessage error, String data) { private void validatePasswordExpiryFeatureEnabled (String tenantDomain) throws ExpiredPasswordIdentificationException { + if (LOG.isDebugEnabled()) { + LOG.debug("Validating password expiry feature for tenant: " + tenantDomain); + } try { if (!PasswordPolicyUtils.isPasswordExpiryEnabled(tenantDomain)) { + LOG.warn("Password expiry feature is not enabled for tenant: " + tenantDomain); ErrorMessage error = ErrorMessage.PASSWORD_EXPIRY_FEATURE_NOT_ENABLED; throw new ExpiredPasswordIdentificationClientException(error.getCode(), error.getMessage(), error.getDescription()); } + if (LOG.isDebugEnabled()) { + LOG.debug("Password expiry feature validation successful for tenant: " + tenantDomain); + } } catch (PostAuthenticationFailedException e) { + LOG.error("Error occurred while validating password expiry feature for tenant: " + tenantDomain, e); throw new ExpiredPasswordIdentificationServerException(e); } } diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/factories/PasswordExpiredUsersManagementApiServiceFactory.java b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/factories/PasswordExpiredUsersManagementApiServiceFactory.java index e3c5df9500..de442dae0b 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/factories/PasswordExpiredUsersManagementApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/factories/PasswordExpiredUsersManagementApiServiceFactory.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.expired.password.identification.v1.factories; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.expired.password.identification.common.PasswordExpiryServiceHolder; import org.wso2.carbon.identity.api.expired.password.identification.v1.core.PasswordExpiredUsersManagementApiService; import org.wso2.carbon.identity.password.expiry.services.ExpiredPasswordIdentificationService; @@ -27,17 +29,23 @@ */ public class PasswordExpiredUsersManagementApiServiceFactory { + private static final Log LOG = LogFactory.getLog(PasswordExpiredUsersManagementApiServiceFactory.class); private static final PasswordExpiredUsersManagementApiService SERVICE; static { + if (LOG.isDebugEnabled()) { + LOG.debug("Initializing PasswordExpiredUsersManagementApiServiceFactory."); + } ExpiredPasswordIdentificationService expiredPasswordIdentificationService = PasswordExpiryServiceHolder.getExpiredPasswordIdentificationService(); if (expiredPasswordIdentificationService == null) { - throw new IllegalStateException("RolePermissionManagementService is not available from OSGi context."); + LOG.error("ExpiredPasswordIdentificationService is not available from OSGi context."); + throw new IllegalStateException("ExpiredPasswordIdentificationService is not available from OSGi context."); } SERVICE = new PasswordExpiredUsersManagementApiService(expiredPasswordIdentificationService); + LOG.info("PasswordExpiredUsersManagementApiService initialized successfully."); } /** diff --git a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/impl/PasswordExpiredUsersApiServiceImpl.java b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/impl/PasswordExpiredUsersApiServiceImpl.java index 0bcddade50..faec4b1a24 100644 --- a/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/impl/PasswordExpiredUsersApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.expired.password.identification/org.wso2.carbon.identity.api.expired.password.identification.v1/src/main/java/org/wso2/carbon/identity/api/expired/password/identification/v1/impl/PasswordExpiredUsersApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.expired.password.identification.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.expired.password.identification.common.ContextLoader; import org.wso2.carbon.identity.api.expired.password.identification.v1.PasswordExpiredUsersApiService; import org.wso2.carbon.identity.api.expired.password.identification.v1.core.PasswordExpiredUsersManagementApiService; @@ -30,6 +32,7 @@ */ public class PasswordExpiredUsersApiServiceImpl implements PasswordExpiredUsersApiService { + private static final Log LOG = LogFactory.getLog(PasswordExpiredUsersApiServiceImpl.class); private final PasswordExpiredUsersManagementApiService passwordExpiredUsersManagementApiService; public PasswordExpiredUsersApiServiceImpl() { @@ -37,7 +40,11 @@ public PasswordExpiredUsersApiServiceImpl() { try { this.passwordExpiredUsersManagementApiService = PasswordExpiredUsersManagementApiServiceFactory .getExpiredPasswordIdentificationService(); + if (LOG.isDebugEnabled()) { + LOG.debug("PasswordExpiredUsersApiServiceImpl initialized successfully."); + } } catch (IllegalStateException e) { + LOG.error("Error occurred while initiating password expired users management service.", e); throw new RuntimeException("Error occurred while initiating password expired users management service.", e); } } @@ -46,6 +53,10 @@ public PasswordExpiredUsersApiServiceImpl() { public Response getPasswordExpiredUsers(String expiredAfter, String excludeAfter) { String tenantDomain = ContextLoader.getTenantDomainFromContext(); + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving password expired users for tenant: " + tenantDomain + + ", expiredAfter: " + expiredAfter + ", excludeAfter: " + excludeAfter); + } return Response.ok().entity(passwordExpiredUsersManagementApiService.getPasswordExpiredUsers( expiredAfter, excludeAfter, tenantDomain)).build(); } diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/ContextLoader.java b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/ContextLoader.java index cee43a7c86..7f4713fd6b 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/ContextLoader.java +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/ContextLoader.java @@ -39,9 +39,21 @@ public class ContextLoader { public static String getTenantDomainFromContext() { String tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; - if (IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT) != null) { + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving tenant domain from carbon context. Default tenant domain: " + tenantDomain); + } + + if (IdentityUtil.threadLocalProperties.get() != null && + IdentityUtil.threadLocalProperties.get().get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT) != null) { tenantDomain = (String) IdentityUtil.threadLocalProperties.get() .get(IdentityCoreConstants.TENANT_NAME_FROM_CONTEXT); + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieved tenant domain from context: " + tenantDomain); + } + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("No tenant domain found in context. Using default tenant domain: " + tenantDomain); + } } return tenantDomain; } diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/IdleAccountIdentificationServiceHolder.java b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/IdleAccountIdentificationServiceHolder.java index 2b7faf2931..7b49de1d15 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/IdleAccountIdentificationServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.common/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/common/IdleAccountIdentificationServiceHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.idle.account.identification.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService; @@ -26,6 +28,8 @@ */ public class IdleAccountIdentificationServiceHolder { + private static final Log LOG = LogFactory.getLog(IdleAccountIdentificationServiceHolder.class); + private IdleAccountIdentificationServiceHolder() {} private static class IdleAccountServiceHolder { @@ -42,6 +46,13 @@ private static class IdleAccountServiceHolder { */ public static IdleAccountIdentificationService getIdleAccountIdentificationService() { - return IdleAccountServiceHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving IdleAccountIdentificationService from OSGi service registry."); + } + IdleAccountIdentificationService service = IdleAccountServiceHolder.SERVICE; + if (service == null) { + LOG.warn("IdleAccountIdentificationService is not available in the OSGi service registry."); + } + return service; } } diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/core/InactiveUsersManagementApiService.java b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/core/InactiveUsersManagementApiService.java index 78e52e9ed4..d6d6f2e5c5 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/core/InactiveUsersManagementApiService.java +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/core/InactiveUsersManagementApiService.java @@ -96,6 +96,10 @@ public List getInactiveUsers(String inactiveAfter, String excludeB public List getInactiveUsers(String inactiveAfter, String excludeBefore, String tenantDomain, String filter) throws IdleAccountIdentificationClientException { + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Getting inactive users for tenant: %s with parameters - inactiveAfter: %s, " + + "excludeBefore: %s, filter: %s", tenantDomain, inactiveAfter, excludeBefore, filter)); + } List inactiveUsers = null; try { validateDates(inactiveAfter, excludeBefore); @@ -113,18 +117,30 @@ public List getInactiveUsers(String inactiveAfter, String excludeB idleAccountIdentificationService.getLimitedInactiveUsersFromSpecificDate(inactiveAfterDate, excludeBeforeDate, tenantDomain); } - return buildResponse(inactiveUsers); + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Retrieved %d inactive users for tenant: %s", + inactiveUsers != null ? inactiveUsers.size() : 0, tenantDomain)); + } + return buildResponse(inactiveUsers != null ? inactiveUsers : new ArrayList<>()); } List expressionNodes = getExpressionNodes(filter); if (validateExpressionNodes(expressionNodes)) { boolean isDisabled = Boolean.parseBoolean(expressionNodes.get(0).getValue()); + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Filtering inactive users by disabled status: %s for tenant: %s", + isDisabled, tenantDomain)); + } inactiveUsers = IdleAccountIdentificationServiceHolder.getIdleAccountIdentificationService() .filterInactiveUsersIfDisabled(inactiveAfterDate, excludeBeforeDate, tenantDomain, isDisabled); - return buildResponse(inactiveUsers); + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Retrieved %d filtered inactive users for tenant: %s", + inactiveUsers != null ? inactiveUsers.size() : 0, tenantDomain)); + } + return buildResponse(inactiveUsers != null ? inactiveUsers : new ArrayList<>()); } return getInactiveUsers(inactiveAfter, excludeBefore, tenantDomain); @@ -143,8 +159,14 @@ public List getInactiveUsers(String inactiveAfter, String excludeB private void validateDates(String inactiveAfter, String excludeBefore) throws IdleAccountIdentificationClientException { + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Validating dates - inactiveAfter: %s, excludeBefore: %s", + inactiveAfter, excludeBefore)); + } + // Check if the required parameter 'inactiveAfter' is present. if (StringUtils.isEmpty(inactiveAfter)) { + LOG.warn("Required parameter 'inactiveAfter' is missing."); ErrorMessage error = ErrorMessage.ERROR_REQUIRED_PARAMETER_MISSING; throw new IdleAccountIdentificationClientException(error.getCode(), error.getMessage(), String.format(error.getDescription(), DATE_INACTIVE_AFTER)); @@ -168,8 +190,12 @@ private void validateDateFormat(String dateString, String dateType) throws IdleAccountIdentificationClientException { if (Pattern.matches(DATE_FORMAT_REGEX, dateString)) { + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Date format validation successful for %s: %s", dateType, dateString)); + } return; } + LOG.warn(String.format("Invalid date format for %s: %s", dateType, dateString)); ErrorMessage error = ErrorMessage.ERROR_DATE_REGEX_MISMATCH; throw new IdleAccountIdentificationClientException(error.getCode(), error.getMessage(), String.format(error.getDescription(), dateType)); @@ -302,6 +328,8 @@ private void validateDatesCombination(LocalDateTime inactiveAfterDate, LocalDate if (inactiveAfterDate != null && excludeBeforeDate != null && inactiveAfterDate.isBefore(excludeBeforeDate)) { + LOG.warn(String.format("Invalid date combination: inactiveAfter (%s) is before excludeBefore (%s)", + inactiveAfterDate, excludeBeforeDate)); ErrorMessage error = ErrorMessage.ERROR_INVALID_DATE_COMBINATION; throw new IdleAccountIdentificationClientException(error.getCode(), error.getMessage(), String.format(error.getDescription())); @@ -318,6 +346,9 @@ private void validateDatesCombination(LocalDateTime inactiveAfterDate, LocalDate private List getExpressionNodes(String filter) throws IdleAccountIdentificationClientException { // Filter example : isDisabled eq true. + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Processing filter expression: %s", filter)); + } List expressionNodes = new ArrayList<>(); FilterTreeBuilder filterTreeBuilder; if (StringUtils.isNotBlank(filter)) { @@ -326,6 +357,7 @@ private List getExpressionNodes(String filter) throws IdleAccoun Node rootNode = filterTreeBuilder.buildTree(); setExpressionNodeList(rootNode, expressionNodes); } catch (IOException | IdentityException e) { + LOG.warn(String.format("Invalid filter expression: %s", filter), e); ErrorMessage error = ErrorMessage.ERROR_INVALID_FILTER; throw new IdleAccountIdentificationClientException(error.getCode(), error.getMessage(), String.format(error.getDescription())); diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/factories/InactiveUsersManagementApiServiceFactory.java b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/factories/InactiveUsersManagementApiServiceFactory.java index 757d317120..2a6cdc7a75 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/factories/InactiveUsersManagementApiServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/factories/InactiveUsersManagementApiServiceFactory.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.idle.account.identification.v1.factories; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.idle.account.identification.common.IdleAccountIdentificationServiceHolder; import org.wso2.carbon.identity.api.idle.account.identification.v1.core.InactiveUsersManagementApiService; import org.wso2.carbon.identity.idle.account.identification.services.IdleAccountIdentificationService; @@ -27,15 +29,21 @@ */ public class InactiveUsersManagementApiServiceFactory { + private static final Log LOG = LogFactory.getLog(InactiveUsersManagementApiServiceFactory.class); private static final InactiveUsersManagementApiService SERVICE; static { + if (LOG.isDebugEnabled()) { + LOG.debug("Initializing InactiveUsersManagementApiServiceFactory."); + } IdleAccountIdentificationService idleAccountIdentificationService = IdleAccountIdentificationServiceHolder .getIdleAccountIdentificationService(); if (idleAccountIdentificationService == null) { + LOG.error("IdleAccountIdentificationService is not available from OSGi context."); throw new IllegalStateException("IdleAccountIdentificationService is not available from OSGi context."); } SERVICE = new InactiveUsersManagementApiService(idleAccountIdentificationService); + LOG.info("InactiveUsersManagementApiService initialized successfully."); } /** diff --git a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/impl/InactiveUsersApiServiceImpl.java b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/impl/InactiveUsersApiServiceImpl.java index c8d8d4210d..12e982d166 100644 --- a/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/impl/InactiveUsersApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.idle.account.identification/org.wso2.carbon.identity.api.idle.account.identification.v1/src/main/java/org/wso2/carbon/identity/api/idle/account/identification/v1/impl/InactiveUsersApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.idle.account.identification.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.idle.account.identification.common.ContextLoader; import org.wso2.carbon.identity.api.idle.account.identification.v1.InactiveUsersApiService; import org.wso2.carbon.identity.api.idle.account.identification.v1.core.InactiveUsersManagementApiService; @@ -31,13 +33,19 @@ */ public class InactiveUsersApiServiceImpl implements InactiveUsersApiService { + private static final Log LOG = LogFactory.getLog(InactiveUsersApiServiceImpl.class); private final InactiveUsersManagementApiService inactiveUsersManagementApiService; public InactiveUsersApiServiceImpl() { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Initializing InactiveUsersApiServiceImpl."); + } this.inactiveUsersManagementApiService = InactiveUsersManagementApiServiceFactory .getInactiveUsersManagementApiService(); + LOG.info("InactiveUsersApiServiceImpl initialized successfully."); } catch (IllegalStateException e) { + LOG.error("Error occurred while initiating inactive users management service.", e); throw new RuntimeException("Error occurred while initiating inactive users management service.", e); } } @@ -46,6 +54,10 @@ public InactiveUsersApiServiceImpl() { public Response getInactiveUsers(String inactiveAfter, String excludeBefore) { String tenantDomain = ContextLoader.getTenantDomainFromContext(); + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Retrieving inactive users for tenant: %s, inactiveAfter: %s, excludeBefore: %s", + tenantDomain, inactiveAfter, excludeBefore)); + } return Response.ok().entity(inactiveUsersManagementApiService .getInactiveUsers(inactiveAfter, excludeBefore, tenantDomain)).build(); } @@ -55,6 +67,10 @@ public Response getInactiveUsers(String inactiveAfter, String excludeBefore, Str throws IdleAccountIdentificationClientException { String tenantDomain = ContextLoader.getTenantDomainFromContext(); + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Retrieving inactive users with filter for tenant: %s, inactiveAfter: %s, " + + "excludeBefore: %s, filter: %s", tenantDomain, inactiveAfter, excludeBefore, filter)); + } if (filter != null) { return Response.ok().entity( diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java index f176aeeee1..72744b9587 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.common/src/main/java/org/wso2/carbon/identity/api/server/action/management/common/ActionManagementServiceHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.action.management.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.action.management.api.service.ActionManagementService; @@ -26,6 +28,8 @@ */ public class ActionManagementServiceHolder { + private static final Log log = LogFactory.getLog(ActionManagementServiceHolder.class); + private ActionManagementServiceHolder() {} private static class ServiceHolder { @@ -41,6 +45,15 @@ private static class ServiceHolder { */ public static ActionManagementService getActionManagementService() { - return ServiceHolder.SERVICE; + if (log.isDebugEnabled()) { + log.debug("Retrieving ActionManagementService from OSGi service registry."); + } + ActionManagementService service = ServiceHolder.SERVICE; + if (service == null) { + log.warn("ActionManagementService is not available from OSGi service registry."); + } else if (log.isDebugEnabled()) { + log.debug("ActionManagementService retrieved successfully from OSGi service registry."); + } + return service; } } diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java index afea047dd6..d33e07ff48 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/core/ServerActionManagementService.java @@ -77,10 +77,19 @@ public ServerActionManagementService(ActionManagementService actionManagementSer public ActionResponse createAction(String actionType, String jsonBody) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Creating action of type: " + actionType); + } Action.ActionTypes validatedActionType = validateActionType(actionType); Action action = buildAction(validatedActionType, jsonBody); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - return buildActionResponse(actionManagementService.addAction(actionType, action, tenantDomain)); + ActionResponse response = buildActionResponse(actionManagementService.addAction(actionType, action, + tenantDomain)); + if (LOG.isDebugEnabled()) { + LOG.debug("Successfully created action with id: " + (response != null ? response.getId() : "null") + + " for tenant: " + tenantDomain); + } + return response; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -89,14 +98,21 @@ public ActionResponse createAction(String actionType, String jsonBody) { public List getActionsByActionType(String actionType) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving actions by action type: " + actionType); + } validateActionType(actionType); - List actions = actionManagementService.getActionsByActionType(actionType, - CarbonContext.getThreadLocalCarbonContext().getTenantDomain()); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + List actions = actionManagementService.getActionsByActionType(actionType, tenantDomain); List actionBasicResponses = new ArrayList<>(); for (Action action : actions) { actionBasicResponses.add(buildActionBasicResponse(action)); } + if (LOG.isDebugEnabled()) { + LOG.debug("Successfully retrieved " + actionBasicResponses.size() + " actions for type: " + + actionType + " and tenant: " + tenantDomain); + } return actionBasicResponses; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); @@ -122,11 +138,18 @@ public ActionResponse getActionByActionId(String actionType, String actionId) { public ActionResponse updateAction(String actionType, String actionId, String jsonBody) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Updating action with type: " + actionType + " and id: " + actionId); + } Action.ActionTypes validatedActionType = validateActionType(actionType); Action updatingAction = buildUpdatingAction(validatedActionType, jsonBody); String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - return buildActionResponse(actionManagementService.updateAction(actionType, actionId, updatingAction, - tenantDomain)); + ActionResponse response = buildActionResponse(actionManagementService.updateAction(actionType, + actionId, updatingAction, tenantDomain)); + if (LOG.isDebugEnabled()) { + LOG.debug("Successfully updated action with id: " + actionId + " for tenant: " + tenantDomain); + } + return response; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -135,9 +158,15 @@ public ActionResponse updateAction(String actionType, String actionId, String js public void deleteAction(String actionType, String actionId) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Deleting action with type: " + actionType + " and id: " + actionId); + } validateActionType(actionType); - actionManagementService.deleteAction(actionType, actionId, CarbonContext.getThreadLocalCarbonContext() - .getTenantDomain()); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + actionManagementService.deleteAction(actionType, actionId, tenantDomain); + if (LOG.isDebugEnabled()) { + LOG.debug("Successfully deleted action with id: " + actionId + " for tenant: " + tenantDomain); + } } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -146,9 +175,15 @@ public void deleteAction(String actionType, String actionId) { public ActionBasicResponse activateAction(String actionType, String actionId) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Activating action with type: " + actionType + " and id: " + actionId); + } validateActionType(actionType); - return buildActionBasicResponse(actionManagementService.activateAction(actionType, actionId, - CarbonContext.getThreadLocalCarbonContext().getTenantDomain())); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + ActionBasicResponse response = buildActionBasicResponse(actionManagementService + .activateAction(actionType, actionId, tenantDomain)); + LOG.info("Action activated successfully with id: " + actionId); + return response; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -157,9 +192,15 @@ public ActionBasicResponse activateAction(String actionType, String actionId) { public ActionBasicResponse deactivateAction(String actionType, String actionId) { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Deactivating action with type: " + actionType + " and id: " + actionId); + } validateActionType(actionType); - return buildActionBasicResponse(actionManagementService.deactivateAction(actionType, actionId, - CarbonContext.getThreadLocalCarbonContext().getTenantDomain())); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + ActionBasicResponse response = buildActionBasicResponse(actionManagementService + .deactivateAction(actionType, actionId, tenantDomain)); + LOG.info("Action deactivated successfully with id: " + actionId); + return response; } catch (ActionMgtException e) { throw ActionMgtEndpointUtil.handleActionMgtException(e); } @@ -171,8 +212,8 @@ public List getActionTypes() { LOG.debug("Retrieving Action Types."); } try { - Map actionsCountPerType = actionManagementService.getActionsCountPerType(CarbonContext - .getThreadLocalCarbonContext().getTenantDomain()); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + Map actionsCountPerType = actionManagementService.getActionsCountPerType(tenantDomain); List actionTypesResponseItems = new ArrayList<>(); for (Action.ActionTypes actionType : Action.ActionTypes.filterByCategory( @@ -256,15 +297,20 @@ private Action buildUpdatingAction(Action.ActionTypes actionType, String jsonBod private Action.ActionTypes validateActionType(String actionType) throws ActionMgtException { + if (LOG.isDebugEnabled()) { + LOG.debug("Validating action type: " + actionType); + } Action.ActionTypes actionTypeEnum = getActionTypeFromPath(actionType); if (NOT_IMPLEMENTED_ACTION_TYPES.contains(actionTypeEnum.getPathParam())) { + LOG.warn("Action type not implemented: " + actionType); throw ActionMgtEndpointUtil.handleException(Response.Status.NOT_IMPLEMENTED, ERROR_NOT_IMPLEMENTED_ACTION_TYPE); } if (isOrganization() && NOT_ALLOWED_ACTION_TYPES_IN_ORG_LEVEL.contains(actionTypeEnum.getPathParam())) { - throw ActionMgtEndpointUtil.handleException(Response.Status.FORBIDDEN, - ERROR_NOT_ALLOWED_ACTION_TYPE_IN_ORG_LEVEL, actionTypeEnum.getActionType()); + LOG.warn("Action type not allowed in organization level: " + actionType); + throw ActionMgtEndpointUtil.handleException(Response.Status.FORBIDDEN, + ERROR_NOT_ALLOWED_ACTION_TYPE_IN_ORG_LEVEL, actionTypeEnum.getActionType()); } return actionTypeEnum; @@ -282,7 +328,8 @@ private Action.ActionTypes getActionTypeFromPath(String actionType) { private boolean isOrganization() throws ActionMgtException { try { - return OrganizationManagementUtil.isOrganization(CarbonContext.getThreadLocalCarbonContext().getTenantId()); + return OrganizationManagementUtil.isOrganization(CarbonContext.getThreadLocalCarbonContext() + .getTenantId()); } catch (OrganizationManagementException e) { throw new ActionMgtServerException("Error while checking if the tenant is an organization.", e); } diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/factories/ActionManagementServiceFactory.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/factories/ActionManagementServiceFactory.java index 5ef4a18802..b605cfbd18 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/factories/ActionManagementServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/factories/ActionManagementServiceFactory.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.action.management.v1.factories; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.action.management.api.service.ActionManagementService; import org.wso2.carbon.identity.api.server.action.management.common.ActionManagementServiceHolder; import org.wso2.carbon.identity.api.server.action.management.v1.core.ServerActionManagementService; @@ -27,15 +29,20 @@ */ public class ActionManagementServiceFactory { + private static final Log LOG = LogFactory.getLog(ActionManagementServiceFactory.class); private static final ServerActionManagementService SERVICE; static { ActionManagementService actionManagementService = ActionManagementServiceHolder.getActionManagementService(); if (actionManagementService == null) { + LOG.error("ActionManagementService is not available from OSGi context."); throw new IllegalStateException("ActionManagementService is not available from OSGi context."); } + if (LOG.isDebugEnabled()) { + LOG.debug("Initializing ServerActionManagementService with ActionManagementService."); + } SERVICE = new ServerActionManagementService(actionManagementService); } diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/impl/ActionsApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/impl/ActionsApiServiceImpl.java index c297424128..58cdb131c9 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/impl/ActionsApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/impl/ActionsApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.action.management.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.action.management.v1.ActionResponse; import org.wso2.carbon.identity.api.server.action.management.v1.ActionsApiService; import org.wso2.carbon.identity.api.server.action.management.v1.constants.ActionMgtEndpointConstants; @@ -36,13 +38,18 @@ */ public class ActionsApiServiceImpl implements ActionsApiService { + private static final Log LOG = LogFactory.getLog(ActionsApiServiceImpl.class); private final ServerActionManagementService serverActionManagementService; public ActionsApiServiceImpl() { try { + if (LOG.isDebugEnabled()) { + LOG.debug("Initializing Actions API service implementation."); + } this.serverActionManagementService = ActionManagementServiceFactory.getActionManagementService(); } catch (IllegalStateException e) { + LOG.error("Error occurred while initiating server action management service.", e); throw new RuntimeException("Error occurred while initiating server action management service.", e); } } @@ -50,35 +57,50 @@ public ActionsApiServiceImpl() { @Override public Response activateAction(String actionType, String actionId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Activating action with type: " + actionType + " and id: " + actionId); + } return Response.ok().entity(serverActionManagementService.activateAction(actionType, actionId)).build(); } @Override public Response createAction(String actionType, String body) { + if (LOG.isDebugEnabled()) { + LOG.debug("Creating action with type: " + actionType); + } ActionResponse actionResponse = serverActionManagementService.createAction(actionType, body); URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + ActionMgtEndpointConstants.ACTION_PATH_COMPONENT + "/" + actionResponse.getId()); + LOG.info("Action created successfully with id: " + actionResponse.getId()); return Response.created(location).entity(actionResponse).build(); } @Override public Response deactivateAction(String actionType, String actionId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Deactivating action with type: " + actionType + " and id: " + actionId); + } return Response.ok().entity(serverActionManagementService.deactivateAction(actionType, actionId)).build(); } @Override public Response deleteAction(String actionType, String actionId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Deleting action with type: " + actionType + " and id: " + actionId); + } serverActionManagementService.deleteAction(actionType, actionId); + LOG.info("Action deleted successfully with id: " + actionId); return Response.noContent().build(); } @Override public Response getActionByActionId(String actionType, String actionId) { - return Response.ok().entity(serverActionManagementService.getActionByActionId(actionType, actionId)).build(); + return Response.ok().entity(serverActionManagementService.getActionByActionId(actionType, + actionId)).build(); } @Override @@ -96,6 +118,11 @@ public Response getActionsByActionType(String actionType) { @Override public Response updateAction(String actionType, String actionId, String body) { - return Response.ok().entity(serverActionManagementService.updateAction(actionType, actionId, body)).build(); + if (LOG.isDebugEnabled()) { + LOG.debug("Updating action with type: " + actionType + " and id: " + actionId); + } + ActionResponse response = serverActionManagementService.updateAction(actionType, actionId, body); + LOG.info("Action updated successfully with id: " + actionId); + return Response.ok().entity(response).build(); } } diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/mapper/ActionMapperFactory.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/mapper/ActionMapperFactory.java index c20f9b46cc..82ee8cbfa7 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/mapper/ActionMapperFactory.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/mapper/ActionMapperFactory.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.action.management.v1.mapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.action.management.api.exception.ActionMgtServerException; import org.wso2.carbon.identity.action.management.api.model.Action; @@ -26,6 +28,8 @@ */ public class ActionMapperFactory { + private static final Log LOG = LogFactory.getLog(ActionMapperFactory.class); + /** * Get ActionMapper object based on the action type. * @@ -50,8 +54,9 @@ public static ActionMapper getActionMapper(Action.ActionTypes actionType) throws } if (actionMapper == null) { - throw new ActionMgtServerException("No Action Mapper found for the given action type: " + - actionType.getDisplayName()); + String errorMessage = "No Action Mapper found for the given action type: " + actionType.getDisplayName(); + LOG.error(errorMessage); + throw new ActionMgtServerException(errorMessage); } return actionMapper; diff --git a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionDeserializer.java b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionDeserializer.java index a8eed1b9c1..2b62f07f20 100644 --- a/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionDeserializer.java +++ b/components/org.wso2.carbon.identity.api.server.action.management/org.wso2.carbon.identity.api.server.action.management.v1/src/main/java/org/wso2/carbon/identity/api/server/action/management/v1/util/ActionDeserializer.java @@ -20,6 +20,8 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.action.management.api.model.Action; import org.wso2.carbon.identity.api.server.action.management.v1.ActionModel; import org.wso2.carbon.identity.api.server.action.management.v1.ActionUpdateModel; @@ -43,6 +45,8 @@ */ public class ActionDeserializer { + private static final Log LOG = LogFactory.getLog(ActionDeserializer.class); + /** * Deserialize the action model. * @@ -52,6 +56,9 @@ public class ActionDeserializer { */ public static ActionModel deserializeActionModel(Action.ActionTypes actionType, String jsonBody) { + if (LOG.isDebugEnabled()) { + LOG.debug("Deserializing action model for action type: " + actionType); + } ActionModel actionModel = null; try { ObjectMapper objectMapper = new ObjectMapper(); @@ -78,6 +85,7 @@ public static ActionModel deserializeActionModel(Action.ActionTypes actionType, break; } } catch (JsonProcessingException e) { + LOG.debug("Error occurred while deserializing action model JSON payload: " + e.getMessage(), e); throw ActionMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, ActionMgtEndpointConstants.ErrorMessage.ERROR_INVALID_PAYLOAD); } @@ -94,6 +102,9 @@ public static ActionModel deserializeActionModel(Action.ActionTypes actionType, */ public static ActionUpdateModel deserializeActionUpdateModel(Action.ActionTypes actionType, String jsonBody) { + if (LOG.isDebugEnabled()) { + LOG.debug("Deserializing action update model for action type: " + actionType); + } ActionUpdateModel actionUpdateModel = null; try { ObjectMapper objectMapper = new ObjectMapper(); @@ -120,6 +131,7 @@ public static ActionUpdateModel deserializeActionUpdateModel(Action.ActionTypes break; } } catch (JsonProcessingException e) { + LOG.debug("Error occurred while deserializing action update model JSON payload: " + e.getMessage(), e); throw ActionMgtEndpointUtil.handleException(Response.Status.BAD_REQUEST, ActionMgtEndpointConstants.ErrorMessage.ERROR_INVALID_PAYLOAD); } diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java index b80e14fa1a..f463181c7a 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.common/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/common/AdminAdvisoryManagementServiceHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.admin.advisory.management.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -26,6 +28,8 @@ */ public class AdminAdvisoryManagementServiceHolder { + private static final Log LOG = LogFactory.getLog(AdminAdvisoryManagementServiceHolder.class); + public AdminAdvisoryManagementServiceHolder() {} private static class AdminAdvisoryServiceHolder { @@ -39,6 +43,13 @@ private static class AdminAdvisoryServiceHolder { */ public static AdminAdvisoryManagementService getAdminAdvisoryManagementService() { - return AdminAdvisoryServiceHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving AdminAdvisoryManagementService from OSGi service registry."); + } + AdminAdvisoryManagementService service = AdminAdvisoryServiceHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("AdminAdvisoryManagementService is not available."); + } + return service; } } diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java index 8c50d54db7..2e7d4bc753 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/core/ServerAdminAdvisoryManagementService.java @@ -42,7 +42,9 @@ public class ServerAdminAdvisoryManagementService { public ServerAdminAdvisoryManagementService(AdminAdvisoryManagementService adminAdvisoryManagementService) { + LOG.debug("Initializing ServerAdminAdvisoryManagementService."); this.adminAdvisoryManagementService = adminAdvisoryManagementService; + LOG.debug("ServerAdminAdvisoryManagementService initialized successfully."); } /** @@ -53,11 +55,14 @@ public ServerAdminAdvisoryManagementService(AdminAdvisoryManagementService admin public AdminAdvisoryConfig getAdminAdvisoryConfig() { try { + LOG.debug("Retrieving admin advisory banner configuration from core service."); AdminAdvisoryBannerDTO adminAdvisoryBannerDTO = adminAdvisoryManagementService.getAdminAdvisoryConfig(); + LOG.debug("Admin advisory banner configuration retrieved successfully from core service."); return buildAdminAdvisoryConfigResponse(adminAdvisoryBannerDTO); } catch (AdminAdvisoryMgtException e) { + LOG.error("Error occurred while retrieving admin advisory banner configuration.", e); AdminAdvisoryConstants.ErrorMessage errorEnum = AdminAdvisoryConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_BANNER_CONFIG; Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; @@ -73,12 +78,15 @@ public AdminAdvisoryConfig getAdminAdvisoryConfig() { public void saveAdminAdvisoryConfig(AdminAdvisoryConfig adminAdvisoryConfig) { try { + LOG.debug("Saving admin advisory banner configuration to core service."); AdminAdvisoryBannerDTO modifiedAdminAdvisoryBannerDTO = createModifiedAdminAdvisoryBannerDTO( adminAdvisoryManagementService.getAdminAdvisoryConfig(), adminAdvisoryConfig); adminAdvisoryManagementService.saveAdminAdvisoryConfig(modifiedAdminAdvisoryBannerDTO); + LOG.debug("Admin advisory banner configuration saved successfully to core service."); } catch (AdminAdvisoryMgtException e) { + LOG.error("Error occurred while saving admin advisory banner configuration.", e); AdminAdvisoryConstants.ErrorMessage errorEnum = AdminAdvisoryConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_BANNER_CONFIG; Response.Status status = Response.Status.INTERNAL_SERVER_ERROR; @@ -125,20 +133,25 @@ private String buildErrorDescription(AdminAdvisoryConstants.ErrorMessage errorEn private AdminAdvisoryBannerDTO createModifiedAdminAdvisoryBannerDTO(AdminAdvisoryBannerDTO currentAdminAdvisoryBannerDTO, AdminAdvisoryConfig adminAdvisoryConfig) throws AdminAdvisoryMgtException { + LOG.debug("Creating modified admin advisory banner DTO from configuration update."); AdminAdvisoryBannerDTO modifiedAdminAdvisoryBannerDTO = new AdminAdvisoryBannerDTO(); boolean isEnableBanner; String bannerContent; if (adminAdvisoryConfig.getEnableBanner() == null) { isEnableBanner = currentAdminAdvisoryBannerDTO.getEnableBanner(); + LOG.debug("EnableBanner field not provided in update, retaining current value: " + isEnableBanner); } else { isEnableBanner = adminAdvisoryConfig.getEnableBanner(); + LOG.debug("EnableBanner field updated to: " + isEnableBanner); } if (StringUtils.isBlank(adminAdvisoryConfig.getBannerContent())) { bannerContent = currentAdminAdvisoryBannerDTO.getBannerContent(); + LOG.debug("BannerContent not provided in update, retaining current value."); } else { bannerContent = adminAdvisoryConfig.getBannerContent(); + LOG.debug("BannerContent field updated."); } modifiedAdminAdvisoryBannerDTO.setEnableBanner(isEnableBanner); diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java index ee8aeb4ad7..feac99ca6e 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/factories/ServerAdminAdvisoryManagementServiceFactory.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.admin.advisory.management.v1.factories; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.admin.advisory.mgt.service.AdminAdvisoryManagementService; import org.wso2.carbon.identity.api.server.admin.advisory.management.common.AdminAdvisoryManagementServiceHolder; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.core.ServerAdminAdvisoryManagementService; @@ -27,17 +29,21 @@ */ public class ServerAdminAdvisoryManagementServiceFactory { + private static final Log LOG = LogFactory.getLog(ServerAdminAdvisoryManagementServiceFactory.class); private static final ServerAdminAdvisoryManagementService SERVICE; static { + LOG.debug("Initializing ServerAdminAdvisoryManagementServiceFactory."); AdminAdvisoryManagementService adminAdvisoryManagementService = AdminAdvisoryManagementServiceHolder .getAdminAdvisoryManagementService(); if (adminAdvisoryManagementService == null) { + LOG.error("AdminAdvisoryManagementService is not available from OSGi context."); throw new IllegalStateException("AdminAdvisoryManagementService is not available from OSGi context."); } SERVICE = new ServerAdminAdvisoryManagementService(adminAdvisoryManagementService); + LOG.debug("ServerAdminAdvisoryManagementServiceFactory initialized successfully."); } /** @@ -47,6 +53,7 @@ public class ServerAdminAdvisoryManagementServiceFactory { */ public static ServerAdminAdvisoryManagementService getServerAdminAdvisoryManagementService() { + LOG.debug("Returning ServerAdminAdvisoryManagementService instance."); return SERVICE; } } diff --git a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java index e79784edd3..1ae27cb604 100644 --- a/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.admin.advisory.management/org.wso2.carbon.identity.api.server.admin.advisory.management.v1/src/main/java/org/wso2/carbon/identity/api/server/admin/advisory/management/v1/impl/AdminAdvisoryManagementApiServiceImpl.java @@ -18,9 +18,12 @@ package org.wso2.carbon.identity.api.server.admin.advisory.management.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.AdminAdvisoryManagementApiService; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.core.ServerAdminAdvisoryManagementService; -import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.factories.ServerAdminAdvisoryManagementServiceFactory; +import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.factories + .ServerAdminAdvisoryManagementServiceFactory; import org.wso2.carbon.identity.api.server.admin.advisory.management.v1.model.AdminAdvisoryConfig; import javax.ws.rs.core.Response; @@ -30,14 +33,18 @@ **/ public class AdminAdvisoryManagementApiServiceImpl implements AdminAdvisoryManagementApiService { + private static final Log LOG = LogFactory.getLog(AdminAdvisoryManagementApiServiceImpl.class); private final ServerAdminAdvisoryManagementService adminAdvisoryManagementService; public AdminAdvisoryManagementApiServiceImpl() { try { + LOG.debug("Initializing AdminAdvisoryManagementApiServiceImpl."); this.adminAdvisoryManagementService = ServerAdminAdvisoryManagementServiceFactory .getServerAdminAdvisoryManagementService(); + LOG.debug("AdminAdvisoryManagementApiServiceImpl initialized successfully."); } catch (Exception e) { + LOG.error("Error occurred while initiating admin advisory management service.", e); throw new RuntimeException("Error occurred while initiating admin advisory management service.", e); } } @@ -50,6 +57,7 @@ public AdminAdvisoryManagementApiServiceImpl() { @Override public Response getAdminAdvisoryConfig() { + LOG.debug("Retrieving admin advisory banner configuration."); return Response.ok().entity(adminAdvisoryManagementService.getAdminAdvisoryConfig()).build(); } @@ -63,7 +71,9 @@ public Response getAdminAdvisoryConfig() { @Override public Response updateAdminAdvisoryConfig(AdminAdvisoryConfig adminAdvisoryConfig) { + LOG.debug("Updating admin advisory banner configuration."); adminAdvisoryManagementService.saveAdminAdvisoryConfig(adminAdvisoryConfig); + LOG.debug("Admin advisory banner configuration updated successfully."); return Response.ok().build(); } } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java index 24bb33ffe5..fcd7a78ca5 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.common/src/main/java/org/wso2/carbon/identity/api/server/api/resource/common/APIResourceManagementServiceHolder.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.api.resource.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager; import org.wso2.carbon.identity.api.resource.mgt.APIResourceManager; @@ -30,6 +32,8 @@ */ public class APIResourceManagementServiceHolder { + private static final Log LOG = LogFactory.getLog(APIResourceManagementServiceHolder.class); + private APIResourceManagementServiceHolder() {} private static class APIResourceManagerHolder { @@ -70,7 +74,14 @@ private static class AuthorizationDetailsSchemaValidatorHolder { */ public static APIResourceManager getApiResourceManager() { - return APIResourceManagerHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving APIResourceManager from OSGi service registry."); + } + APIResourceManager service = APIResourceManagerHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("APIResourceManager service is not available."); + } + return service; } /** @@ -80,7 +91,14 @@ public static APIResourceManager getApiResourceManager() { */ public static APIResourceCollectionManager getApiResourceCollectionManager() { - return APIResourceCollectionManagerHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving APIResourceCollectionManager from OSGi service registry."); + } + APIResourceCollectionManager service = APIResourceCollectionManagerHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("APIResourceCollectionManager service is not available."); + } + return service; } /** @@ -90,7 +108,14 @@ public static APIResourceCollectionManager getApiResourceCollectionManager() { */ public static OAuthAdminServiceImpl getOAuthAdminServiceImpl() { - return OAuthAdminServiceImplHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving OAuthAdminServiceImpl from OSGi service registry."); + } + OAuthAdminServiceImpl service = OAuthAdminServiceImplHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("OAuthAdminServiceImpl service is not available."); + } + return service; } /** @@ -100,7 +125,14 @@ public static OAuthAdminServiceImpl getOAuthAdminServiceImpl() { */ public static AuthorizationDetailsTypeManager getAuthorizationDetailsTypeManager() { - return AuthorizationDetailsTypeManagerHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving AuthorizationDetailsTypeManager from OSGi service registry."); + } + AuthorizationDetailsTypeManager service = AuthorizationDetailsTypeManagerHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("AuthorizationDetailsTypeManager service is not available."); + } + return service; } /** @@ -110,6 +142,13 @@ public static AuthorizationDetailsTypeManager getAuthorizationDetailsTypeManager */ public static AuthorizationDetailsSchemaValidator getAuthorizationDetailsSchemaValidator() { - return AuthorizationDetailsSchemaValidatorHolder.SERVICE; + if (LOG.isDebugEnabled()) { + LOG.debug("Retrieving AuthorizationDetailsSchemaValidator from OSGi service registry."); + } + AuthorizationDetailsSchemaValidator service = AuthorizationDetailsSchemaValidatorHolder.SERVICE; + if (service == null && LOG.isWarnEnabled()) { + LOG.warn("AuthorizationDetailsSchemaValidator service is not available."); + } + return service; } } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/AuthorizationDetailsTypeManagementService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/AuthorizationDetailsTypeManagementService.java index cf57ed97ce..8a118f99ab 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/AuthorizationDetailsTypeManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/AuthorizationDetailsTypeManagementService.java @@ -53,6 +53,7 @@ public AuthorizationDetailsTypeManagementService(APIResourceManager apiResourceM this.apiResourceManager = apiResourceManager; this.authorizationDetailsTypeManager = authorizationDetailsTypeManager; + LOG.info("Authorization details type management service initialized successfully."); } /** @@ -72,11 +73,14 @@ public List addAuthorizationDetailsTypes( try { this.assertApiResourceIdExistence(apiResourceId); - return this.authorizationDetailsTypeManager.addAuthorizationDetailsTypes( + List result = this.authorizationDetailsTypeManager.addAuthorizationDetailsTypes( apiResourceId, AuthorizationDetailsTypeMgtUtil.toAuthorizationDetailsTypes(creationModels), getThreadLocalCarbonContext().getTenantDomain() ); + LOG.info("Successfully added " + (result != null ? result.size() : 0) + + " authorization details types for API resource ID: " + apiResourceId); + return result; } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); } @@ -100,6 +104,8 @@ public void deleteAuthorizationDetailsTypeById(String apiResourceId, String auth authorizationDetailsTypeId, getThreadLocalCarbonContext().getTenantDomain() ); + LOG.info("Successfully deleted authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); } @@ -195,6 +201,8 @@ public void updateAuthorizationDetailsTypes(String apiResourceId, String authori toAuthorizationDetailsType(authorizationDetailsTypeId, creationModel), getThreadLocalCarbonContext().getTenantDomain() ); + LOG.info("Successfully updated authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceCollectionManagementService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceCollectionManagementService.java index f1358c7145..d113c6ee0f 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceCollectionManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceCollectionManagementService.java @@ -20,6 +20,8 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.identity.api.resource.collection.mgt.APIResourceCollectionManager; import org.wso2.carbon.identity.api.resource.collection.mgt.constant.APIResourceCollectionManagementConstants; @@ -55,11 +57,13 @@ */ public class ServerAPIResourceCollectionManagementService { + private static final Log LOG = LogFactory.getLog(ServerAPIResourceCollectionManagementService.class); private final APIResourceCollectionManager apiResourceCollectionManager; public ServerAPIResourceCollectionManagementService(APIResourceCollectionManager apiResourceCollectionManager) { this.apiResourceCollectionManager = apiResourceCollectionManager; + LOG.info("Server API resource collection management service initialized successfully."); } /** @@ -71,6 +75,9 @@ public ServerAPIResourceCollectionManagementService(APIResourceCollectionManager */ public APIResourceCollectionListResponse getAPIResourceCollections(String filter, String requiredAttributes) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resource collections with filter: " + filter); + } APIResourceCollectionListResponse apiResourceCollectionListResponse = new APIResourceCollectionListResponse(); try { List requestedAttributeList = StringUtils.isNotEmpty(requiredAttributes) ? @@ -110,6 +117,9 @@ public APIResourceCollectionListResponse getAPIResourceCollections(String filter */ public APIResourceCollectionResponse getAPIResourceCollectionByCollectionId(String collectionId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resource collection by ID: " + collectionId); + } APIResourceCollectionResponse apiResourceCollectionResponse = new APIResourceCollectionResponse(); try { diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java index 58707d2d0e..8401565b10 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/core/ServerAPIResourceManagementService.java @@ -80,6 +80,7 @@ public class ServerAPIResourceManagementService { public ServerAPIResourceManagementService(APIResourceManager apiResourceManager) { this.apiResourceManager = apiResourceManager; + LOG.info("Server API resource management service initialized successfully."); } /** @@ -102,6 +103,8 @@ public APIResourceResponse addAPIResourceWithResourceId(APIResourceCreationModel throw APIResourceMgtEndpointUtil.handleException(Response.Status.INTERNAL_SERVER_ERROR, ErrorMessage.ERROR_CODE_ADD_API_RESOURCE); } + LOG.info("Successfully added API resource with ID: " + createdAPIResource.getId() + + " and identifier: " + createdAPIResource.getIdentifier()); return buildAPIResourceResponse(createdAPIResource); } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); @@ -119,6 +122,9 @@ public APIResourceResponse addAPIResourceWithResourceId(APIResourceCreationModel public APIResourceListResponse getAPIResources(String before, String after, String filter, Integer limit, String requiredAttributes) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resources with filter: " + filter + ", limit: " + limit); + } APIResourceListResponse apiResourceListResponse = new APIResourceListResponse(); try { @@ -291,6 +297,7 @@ public void deleteAPIResource(String apiResourceID) { } handleSystemAPI(apiResource); apiResourceManager.deleteAPIResourceById(apiResourceID, tenantDomain); + LOG.info("Successfully deleted API resource with ID: " + apiResourceID); } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); } @@ -361,6 +368,7 @@ public void deleteScopeByScopeName(String apiResourceId, String scopeName) { handleSystemAPI(apiResource); apiResourceManager.deleteAPIScopeByScopeName(apiResourceId, scopeName, tenantDomain); + LOG.info("Successfully deleted scope '" + scopeName + "' for API resource ID: " + apiResourceId); } catch (APIResourceMgtException e) { throw APIResourceMgtEndpointUtil.handleAPIResourceMgtException(e); } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java index 9b6b58d013..f0adda52a2 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ApiResourcesApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.api.resource.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceCreationModel; import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourcePatchModel; import org.wso2.carbon.identity.api.server.api.resource.v1.APIResourceResponse; @@ -45,6 +47,7 @@ */ public class ApiResourcesApiServiceImpl implements ApiResourcesApiService { + private static final Log LOG = LogFactory.getLog(ApiResourcesApiServiceImpl.class); private final ServerAPIResourceManagementService serverAPIResourceManagementService; private final AuthorizationDetailsTypeManagementService typeMgtService; @@ -55,7 +58,9 @@ public ApiResourcesApiServiceImpl() { .getServerAPIResourceManagementService(); this.typeMgtService = AuthorizationDetailsTypeManagementServiceFactory .getAuthorizationDetailsTypeManagementService(); + LOG.info("API resource service implementation initialized successfully."); } catch (IllegalStateException e) { + LOG.error("Failed to initialize API resource management service.", e); throw new RuntimeException("Error occurred while initiating API resource management service.", e); } } @@ -63,10 +68,19 @@ public ApiResourcesApiServiceImpl() { @Override public Response addAPIResource(APIResourceCreationModel apIResourceCreationModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to add new API resource with identifier: " + + (apIResourceCreationModel != null ? apIResourceCreationModel.getIdentifier() : "null")); + } + if (apIResourceCreationModel == null) { + LOG.error("API resource creation model cannot be null"); + return Response.status(Response.Status.BAD_REQUEST).build(); + } APIResourceResponse apiResourceResponse = serverAPIResourceManagementService.addAPIResourceWithResourceId(apIResourceCreationModel); URI location = ContextLoader.buildURIForHeader(V1_API_PATH_COMPONENT + APIResourceMgtEndpointConstants.API_RESOURCE_PATH_COMPONENT + "/" + apiResourceResponse.getId()); + LOG.info("Successfully created API resource with ID: " + apiResourceResponse.getId()); return Response.created(location).entity(apiResourceResponse).build(); } @@ -74,21 +88,32 @@ public Response addAPIResource(APIResourceCreationModel apIResourceCreationModel public Response addAuthorizationDetailsTypes( String apiResourceId, List authorizationDetailsTypesCreationModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to add authorization details types for API resource ID: " + apiResourceId); + } List authorizationDetailsTypes = typeMgtService.addAuthorizationDetailsTypes(apiResourceId, authorizationDetailsTypesCreationModel); + LOG.info("Successfully added authorization details types for API resource ID: " + apiResourceId); return Response.ok().entity(authorizationDetailsTypes).build(); } @Override public Response apiResourcesApiResourceIdDelete(String apiResourceId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to delete API resource with ID: " + apiResourceId); + } serverAPIResourceManagementService.deleteAPIResource(apiResourceId); + LOG.info("Successfully deleted API resource with ID: " + apiResourceId); return Response.noContent().build(); } @Override public Response apiResourcesApiResourceIdGet(String apiResourceId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resource with ID: " + apiResourceId); + } return Response.ok().entity( serverAPIResourceManagementService.getAPIResourceResponseById(apiResourceId)).build(); } @@ -96,13 +121,20 @@ public Response apiResourcesApiResourceIdGet(String apiResourceId) { @Override public Response apiResourcesApiResourceIdPatch(String apiResourceId, APIResourcePatchModel apIResourcePatchModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to patch API resource with ID: " + apiResourceId); + } serverAPIResourceManagementService.patchAPIResourceById(apiResourceId, apIResourcePatchModel); + LOG.info("Successfully patched API resource with ID: " + apiResourceId); return Response.noContent().build(); } @Override public Response apiResourcesApiResourceIdScopesGet(String apiResourceId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get scopes for API resource with ID: " + apiResourceId); + } return Response.ok().entity(serverAPIResourceManagementService.getScopesByAPIId(apiResourceId)).build(); } @@ -110,14 +142,22 @@ public Response apiResourcesApiResourceIdScopesGet(String apiResourceId) { public Response apiResourcesApiResourceIdScopesPut(String apiResourceId, List scopeCreationModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to update scopes for API resource with ID: " + apiResourceId); + } serverAPIResourceManagementService.putScopesByAPIId(apiResourceId, scopeCreationModel); + LOG.info("Successfully updated scopes for API resource with ID: " + apiResourceId); return Response.noContent().build(); } @Override public Response apiResourcesApiResourceIdScopesScopeNameDelete(String apiResourceId, String scopeName) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to delete scope '" + scopeName + "' for API resource ID: " + apiResourceId); + } serverAPIResourceManagementService.deleteScopeByScopeName(apiResourceId, scopeName); + LOG.info("Successfully deleted scope '" + scopeName + "' for API resource ID: " + apiResourceId); return Response.noContent().build(); } @@ -125,20 +165,33 @@ public Response apiResourcesApiResourceIdScopesScopeNameDelete(String apiResourc public Response apiResourcesApiResourceIdScopesScopeNamePatch(String apiResourceId, String scopeName, ScopePatchModel scopePatchModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to patch scope '" + scopeName + "' for API resource ID: " + apiResourceId); + } serverAPIResourceManagementService.patchScopeMetadataByScopeName(apiResourceId, scopeName, scopePatchModel); + LOG.info("Successfully patched scope '" + scopeName + "' for API resource ID: " + apiResourceId); return Response.noContent().build(); } @Override public Response deleteAuthorizationDetailsType(String apiResourceId, String authorizationDetailsTypeId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to delete authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); + } typeMgtService.deleteAuthorizationDetailsTypeById(apiResourceId, authorizationDetailsTypeId); + LOG.info("Successfully deleted authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); return Response.noContent().build(); } @Override public Response getAPIResources(String before, String after, String filter, Integer limit, String attributes) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resources with filter: " + filter + ", limit: " + limit); + } return Response.ok().entity(serverAPIResourceManagementService.getAPIResources(before, after, filter, limit, attributes)).build(); } @@ -146,6 +199,10 @@ public Response getAPIResources(String before, String after, String filter, Inte @Override public Response getAuthorizationDetailsType(String apiResourceId, String authorizationDetailsTypeId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); + } return Response.ok().entity(typeMgtService .getAuthorizationDetailsTypeById(apiResourceId, authorizationDetailsTypeId)).build(); } @@ -153,6 +210,9 @@ public Response getAuthorizationDetailsType(String apiResourceId, String authori @Override public Response getAuthorizationDetailsTypes(String apiResourceId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get authorization details types for API resource ID: " + apiResourceId); + } return Response.ok().entity(typeMgtService.getAuthorizationDetailsTypes(apiResourceId)).build(); } @@ -160,7 +220,13 @@ public Response getAuthorizationDetailsTypes(String apiResourceId) { public Response updateAuthorizationDetailsType(String apiResourceId, String authorizationDetailsTypeId, AuthorizationDetailsTypesCreationModel creationModel) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to update authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); + } typeMgtService.updateAuthorizationDetailsTypes(apiResourceId, authorizationDetailsTypeId, creationModel); + LOG.info("Successfully updated authorization details type with ID: " + authorizationDetailsTypeId + + " for API resource ID: " + apiResourceId); return Response.noContent().build(); } } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/AuthorizationDetailsTypesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/AuthorizationDetailsTypesApiServiceImpl.java index ff30b2e6b3..fd6489d3a6 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/AuthorizationDetailsTypesApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/AuthorizationDetailsTypesApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.api.resource.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.api.resource.v1.AuthorizationDetailsTypesApiService; import org.wso2.carbon.identity.api.server.api.resource.v1.core.AuthorizationDetailsTypeManagementService; import org.wso2.carbon.identity.api.server.api.resource.v1.factories.AuthorizationDetailsTypeManagementServiceFactory; @@ -31,6 +33,7 @@ */ public class AuthorizationDetailsTypesApiServiceImpl implements AuthorizationDetailsTypesApiService { + private static final Log LOG = LogFactory.getLog(AuthorizationDetailsTypesApiServiceImpl.class); private final AuthorizationDetailsTypeManagementService typeMgtService; public AuthorizationDetailsTypesApiServiceImpl() { @@ -38,7 +41,9 @@ public AuthorizationDetailsTypesApiServiceImpl() { try { this.typeMgtService = AuthorizationDetailsTypeManagementServiceFactory .getAuthorizationDetailsTypeManagementService(); + LOG.info("Authorization details types API service implementation initialized successfully."); } catch (IllegalStateException e) { + LOG.error("Failed to initialize authorization details types API service.", e); throw new RuntimeException("Error occurred while initiating AuthorizationDetailsTypeManagementService.", e); } } @@ -46,12 +51,18 @@ public AuthorizationDetailsTypesApiServiceImpl() { @Override public Response authorizationDetailsTypesGet(String filter) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get authorization details types with filter: " + filter); + } return Response.ok().entity(typeMgtService.getAllAuthorizationDetailsTypes(filter)).build(); } @Override public Response isAuthorizationDetailsTypeExists(final String filter) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to check authorization details type existence with filter: " + filter); + } return typeMgtService.isAuthorizationDetailsTypeExists(filter) ? Response.ok().build() : Response.status(NOT_FOUND).build(); diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/MetaApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/MetaApiServiceImpl.java index 52e0a3bc11..3bae53bdb6 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/MetaApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/MetaApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.api.resource.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.api.resource.v1.MetaApiService; import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerAPIResourceCollectionManagementService; import org.wso2.carbon.identity.api.server.api.resource.v1.factories.ServerAPIResourceCollectionManagementServiceFactory; @@ -29,6 +31,7 @@ */ public class MetaApiServiceImpl implements MetaApiService { + private static final Log LOG = LogFactory.getLog(MetaApiServiceImpl.class); private final ServerAPIResourceCollectionManagementService serverAPIResourceManagementService; public MetaApiServiceImpl() { @@ -36,7 +39,9 @@ public MetaApiServiceImpl() { try { this.serverAPIResourceManagementService = ServerAPIResourceCollectionManagementServiceFactory .getServerAPIResourceCollectionManagementService(); + LOG.info("Meta API service implementation initialized successfully."); } catch (IllegalStateException e) { + LOG.error("Failed to initialize meta API service.", e); throw new RuntimeException("Error occurred while initiating API resource collection management service.", e); } @@ -45,6 +50,9 @@ public MetaApiServiceImpl() { @Override public Response getAPIResourceCollectionByCollectionId(String collectionId) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resource collection by ID: " + collectionId); + } return Response.ok().entity( serverAPIResourceManagementService.getAPIResourceCollectionByCollectionId(collectionId)).build(); } @@ -52,6 +60,9 @@ public Response getAPIResourceCollectionByCollectionId(String collectionId) { @Override public Response getAPIResourceCollections(String filter, String attributes) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get API resource collections with filter: " + filter); + } return Response.ok().entity(serverAPIResourceManagementService.getAPIResourceCollections(filter, attributes)) .build(); } diff --git a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java index 642a94d924..0c5fa8b5e2 100644 --- a/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java +++ b/components/org.wso2.carbon.identity.api.server.api.resource/org.wso2.carbon.identity.api.server.api.resource.v1/src/main/java/org/wso2/carbon/identity/api/server/api/resource/v1/impl/ScopesApiServiceImpl.java @@ -18,6 +18,8 @@ package org.wso2.carbon.identity.api.server.api.resource.v1.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.identity.api.server.api.resource.v1.ScopesApiService; import org.wso2.carbon.identity.api.server.api.resource.v1.core.ServerAPIResourceManagementService; import org.wso2.carbon.identity.api.server.api.resource.v1.factories.ServerAPIResourceManagementServiceFactory; @@ -29,6 +31,7 @@ */ public class ScopesApiServiceImpl implements ScopesApiService { + private static final Log LOG = LogFactory.getLog(ScopesApiServiceImpl.class); private final ServerAPIResourceManagementService serverAPIResourceManagementService; public ScopesApiServiceImpl() { @@ -36,7 +39,9 @@ public ScopesApiServiceImpl() { try { this.serverAPIResourceManagementService = ServerAPIResourceManagementServiceFactory .getServerAPIResourceManagementService(); + LOG.info("Scopes API service implementation initialized successfully."); } catch (IllegalStateException e) { + LOG.error("Failed to initialize scopes API service.", e); throw new RuntimeException("Error occurred while initiating API resource management service.", e); } } @@ -44,6 +49,9 @@ public ScopesApiServiceImpl() { @Override public Response scopesGet(String filter) { + if (LOG.isDebugEnabled()) { + LOG.debug("Request received to get scopes by tenant with filter: " + filter); + } return Response.ok().entity(serverAPIResourceManagementService.getScopesByTenant(filter)).build(); } }