Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.wso2.carbon.identity.api.server.claim.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.claim.metadata.mgt.ClaimMetadataManagementService;
import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
Expand All @@ -25,6 +27,8 @@
*/
public class ClaimManagementDataHolder {

private static final Log log = LogFactory.getLog(ClaimManagementDataHolder.class);

private static class OrganizationManagerHolder {

static final OrganizationManager SERVICE = (OrganizationManager) PrivilegedCarbonContext
Expand All @@ -44,7 +48,14 @@ private static class ClaimMetadataManagementServiceHolder {
*/
public static ClaimMetadataManagementService getClaimMetadataManagementService() {

return ClaimMetadataManagementServiceHolder.SERVICE;
if (log.isDebugEnabled()) {
log.debug("Retrieving ClaimMetadataManagementService from OSGi context.");
}
ClaimMetadataManagementService service = ClaimMetadataManagementServiceHolder.SERVICE;
if (service == null && log.isDebugEnabled()) {
log.debug("ClaimMetadataManagementService is not available in the OSGi context.");
}
return service;
}

/**
Expand All @@ -54,6 +65,13 @@ public static ClaimMetadataManagementService getClaimMetadataManagementService()
*/
public static OrganizationManager getOrganizationManager() {

return OrganizationManagerHolder.SERVICE;
if (log.isDebugEnabled()) {
log.debug("Retrieving OrganizationManager from OSGi context.");
}
OrganizationManager service = OrganizationManagerHolder.SERVICE;
if (service == null && log.isDebugEnabled()) {
log.debug("OrganizationManager is not available in the OSGi context.");
}
return service;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package org.wso2.carbon.identity.api.server.claim.management.common;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -247,6 +250,7 @@ public enum ErrorMessage {
"The attribute: %s is not a string data type and canonical values are only supported for " +
"string data type.");

private static final Log log = LogFactory.getLog(ErrorMessage.class);
private final String code;
private final String message;
private final String description;
Expand Down Expand Up @@ -296,9 +300,14 @@ public static ErrorMessage getMappedErrorMessage(String serverCode) {

try {
String errorCode = resourceBundle.getString(serverCode);
if (log.isDebugEnabled()) {
log.debug("Successfully mapped server error code: " + serverCode + " to error code: " + errorCode);
}
return messageIndex.get(errorCode);
} catch (Throwable e) {
// Ignore if error mapping has invalid input.
if (log.isDebugEnabled()) {
log.debug("Failed to map server error code: " + serverCode + ". Using default error code.", e);
}
}
return ErrorMessage.ERROR_CODE_INVALID_INPUT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.wso2.carbon.identity.api.server.claim.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.claim.metadata.mgt.ClaimMetadataManagementService;
import org.wso2.carbon.user.core.service.RealmService;
Expand All @@ -25,15 +27,24 @@
*/
public class Util {

private static final Log log = LogFactory.getLog(Util.class);

/**
* Get ClaimMetadataManagementService osgi service.
*
* @return ClaimMetadataManagementService
*/
@Deprecated
public static ClaimMetadataManagementService getClaimMetadataManagementService() {
return (ClaimMetadataManagementService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(ClaimMetadataManagementService.class, null);
if (log.isDebugEnabled()) {
log.debug("Retrieving deprecated ClaimMetadataManagementService from OSGi context.");
}
ClaimMetadataManagementService service = (ClaimMetadataManagementService) PrivilegedCarbonContext
.getThreadLocalCarbonContext().getOSGiService(ClaimMetadataManagementService.class, null);
if (service == null && log.isDebugEnabled()) {
log.debug("ClaimMetadataManagementService is not available in the OSGi context.");
}
return service;
}

/**
Expand All @@ -43,7 +54,14 @@ public static ClaimMetadataManagementService getClaimMetadataManagementService()
*/
@Deprecated
public static RealmService getRealmService() {
return (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
if (log.isDebugEnabled()) {
log.debug("Retrieving deprecated RealmService from OSGi context.");
}
RealmService service = (RealmService) PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getOSGiService(RealmService.class, null);
if (service == null && log.isDebugEnabled()) {
log.debug("RealmService is not available in the OSGi context.");
}
return service;
}
}
Loading