Author: thomas.heute(a)jboss.com
Date: 2010-11-26 05:18:30 -0500 (Fri, 26 Nov 2010)
New Revision: 5289
Added:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
Log:
JBEPP-681: Improve logging in PicketLink IDM integration layer
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -22,6 +22,9 @@
import org.exoplatform.services.organization.Group;
import org.exoplatform.services.organization.GroupEventListener;
import org.exoplatform.services.organization.GroupHandler;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.Attribute;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.impl.api.SimpleAttribute;
@@ -35,10 +38,10 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
+
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
@@ -73,16 +76,50 @@
final public Group createGroupInstance()
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createGroupInstance",
+ null
+ );
+ }
return new ExtGroup();
}
public void createGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createGroup",
+ new Object[]{
+ "broadcast", broadcast
+ }
+ );
+ }
addChild(null, group, broadcast);
}
public void addChild(Group parent, Group child, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "addChild",
+ new Object[]{
+ "parent", parent,
+ "child", child,
+ "broadcast", broadcast
+ }
+ );
+ }
+
org.picketlink.idm.api.Group parentGroup = null;
String childPLGroupName = getPLIDMGroupName(child.getGroupName());
@@ -148,6 +185,19 @@
public void saveGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveGroup",
+ new Object[]{
+ "group", group,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (broadcast)
{
preSave(group, false);
@@ -161,6 +211,19 @@
public Group removeGroup(Group group, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeGroup",
+ new Object[]{
+ "group", group,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (broadcast)
{
preDelete(group);
@@ -228,6 +291,19 @@
public Collection findGroupByMembership(String userName, String membershipType) throws
Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupsByMembership",
+ new Object[]{
+ "userName", membershipType
+ }
+ );
+ }
+
+
Collection<org.picketlink.idm.api.Role> allRoles = new HashSet();
try
@@ -272,25 +348,84 @@
}
// UI has hardcoded casts to List
- return new LinkedList<Group>(exoGroups);
+ Collection result = new LinkedList<Group>(exoGroups);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupByMembership",
+ result
+ );
+ }
+
+ return result;
}
//
public Group findGroupById(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
org.picketlink.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
if (jbidGroup == null)
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ null
+ );
+ }
+
return null;
}
- return convertGroup(jbidGroup);
+ Group result = convertGroup(jbidGroup);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupById",
+ result
+ );
+ }
+
+ return result;
+
}
public Collection findGroups(Group parent) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroups",
+ new Object[]{
+ "parent", parent
+ }
+ );
+ }
+
org.picketlink.idm.api.Group jbidGroup = null;
if (parent == null)
@@ -396,6 +531,16 @@
Collections.sort(results);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroups",
+ results
+ );
+ }
+
return results;
}
@@ -403,6 +548,19 @@
public Collection findGroupsOfUser(String user) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ new Object[]{
+ "user", user
+ }
+ );
+ }
+
+
if (user == null)
{
// julien : integration bug
@@ -415,6 +573,17 @@
// at
org.exoplatform.organization.webui.component.GroupManagement.isMemberOfGroup(GroupManagement.java:72)
// at
org.exoplatform.organization.webui.component.GroupManagement.isAdministrator(GroupManagement.java:125)
// at
org.exoplatform.organization.webui.component.UIGroupExplorer.<init>(UIGroupExplorer.java:57)
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ Collections.emptyList()
+ );
+ }
+
return Collections.emptyList();
}
@@ -439,12 +608,32 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findGroupsOfUser",
+ exoGroups
+ );
+ }
+
return exoGroups;
}
public Collection getAllGroups() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getAllGroups",
+ null
+ );
+ }
+
Set<org.picketlink.idm.api.Group> plGroups = new
HashSet<org.picketlink.idm.api.Group>();
try
@@ -490,7 +679,19 @@
}
// UI has hardcoded casts to List
- return new LinkedList<Group>(exoGroups);
+ Collection result = new LinkedList<Group>(exoGroups);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getAllGroups",
+ result
+ );
+ }
+
+ return result;
}
@@ -529,6 +730,18 @@
protected Group convertGroup(org.picketlink.idm.api.Group jbidGroup) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "convertGroup",
+ new Object[]{
+ "jbidGroup", jbidGroup
+ }
+ );
+ }
+
Map<String, Attribute> attrs = new HashMap();
try
@@ -562,6 +775,16 @@
// Resolve full ID
String id = getGroupId(jbidGroup, null);
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getGroupId",
+ id
+ );
+ }
+
exoGroup.setId(id);
// child of root
@@ -575,6 +798,16 @@
exoGroup.setParentId(id.substring(0, id.lastIndexOf("/")));
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "convertGroup",
+ exoGroup
+ );
+ }
+
return exoGroup;
}
@@ -589,6 +822,20 @@
private String getGroupId(org.picketlink.idm.api.Group jbidGroup,
List<org.picketlink.idm.api.Group> processed) throws
Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getGroupId",
+ new Object[]{
+ "jbidGroup", jbidGroup,
+ "processed", processed
+ }
+ );
+ }
+
+
// Check in cache
if (getIntegrationCache() != null)
{
@@ -633,6 +880,10 @@
// Check if there is cross reference so we ended in a loop and break the process.
if (parents.size() > 0 &&
processed.contains(parents.iterator().next()))
{
+ if (log.isTraceEnabled())
+ {
+ log.trace("Detected looped relationship between groups!!!");
+ }
processed.remove(processed.size() - 1);
return CYCLIC_ID;
}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IDMUserListAccess.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -21,10 +21,14 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.services.organization.User;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.SortOrder;
import org.picketlink.idm.api.query.UserQuery;
import org.picketlink.idm.api.query.UserQueryBuilder;
+
import java.util.List;
/*
@@ -32,6 +36,8 @@
*/
public class IDMUserListAccess implements ListAccess<User>
{
+ private static Logger log = LoggerFactory.getLogger(IDMUserListAccess.class);
+
private final UserDAOImpl userDAO;
private final PicketLinkIDMService idmService;
@@ -54,6 +60,19 @@
public User[] load(int index, int length) throws Exception, IllegalArgumentException
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "load",
+ new Object[]{
+ "index", index,
+ "length", length
+ }
+ );
+ }
+
userQueryBuilder.page(index, length);
UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
List<org.picketlink.idm.api.User> users =
idmService.getIdentitySession().list(query);
@@ -67,21 +86,55 @@
exoUsers[i] = UserDAOImpl.getPopulatedUser(user.getId(),
idmService.getIdentitySession());
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "load",
+ exoUsers
+ );
+ }
+
return exoUsers;
}
public int getSize() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getSize",
+ null
+ );
+ }
+
+ int result;
+
if (countAll)
{
- return idmService.getIdentitySession().getPersistenceManager().getUserCount();
+ result =
idmService.getIdentitySession().getPersistenceManager().getUserCount();
}
else
{
userQueryBuilder.page(0, 0);
UserQuery query = userQueryBuilder.sort(SortOrder.ASCENDING).createQuery();
- return idmService.getIdentitySession().execute(query).size();
+ result = idmService.getIdentitySession().execute(query).size();
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "getSize",
+ result
+ );
+ }
+
+ return result;
+
}
}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/IntegrationCache.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -149,15 +149,17 @@
Node ioNode = getCache().getRoot().addChild(nodeFqn);
- ioNode.put(NODE_OBJECT_KEY, id);
-
- if (log.isLoggable(Level.FINER))
+ if (ioNode != null)
{
+ ioNode.put(NODE_OBJECT_KEY, id);
- log.finer(this.toString() + "GateIn group id cached. PLIDM group id: "
+ pLIDMId +
- "GateIn group id: " + id + ";namespace=" + ns);
+ if (log.isLoggable(Level.FINER))
+ {
+
+ log.finer(this.toString() + "GateIn group id cached. PLIDM group id:
" + pLIDMId +
+ "GateIn group id: " + id + ";namespace=" + ns);
+ }
}
-
}
/**
@@ -201,14 +203,16 @@
Node ioNode = getCache().getRoot().addChild(nodeFqn);
- ioNode.put(NODE_OBJECT_KEY, rootGroup);
-
- if (log.isLoggable(Level.FINER))
+ if (ioNode != null)
{
+ ioNode.put(NODE_OBJECT_KEY, rootGroup);
- log.finer(this.toString() + "GateIn root group stored in cache" +
";namespace=" + ns);
+ if (log.isLoggable(Level.FINER))
+ {
+
+ log.finer(this.toString() + "GateIn root group stored in cache" +
";namespace=" + ns);
+ }
}
-
}
/**
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -26,12 +26,14 @@
import org.exoplatform.services.organization.MembershipHandler;
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.User;
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.Role;
import org.picketlink.idm.api.RoleType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -74,6 +76,19 @@
public void createMembership(Membership m, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createMembership",
+ new Object[]{
+ "membership", m,
+ "broadcast", broadcast,
+ }
+ );
+ }
+
if (broadcast)
{
preSave(m, true);
@@ -90,6 +105,21 @@
public void linkMembership(User user, Group g, MembershipType mt, boolean broadcast)
throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "linkMembership",
+ new Object[]{
+ "user", user,
+ "group", g,
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
+
if (g == null)
{
throw new InvalidNameException("Can not create membership record for "
+ user.getUserName()
@@ -154,7 +184,20 @@
public void saveMembership(Membership m, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveMembership",
+ new Object[]{
+ "membership", m,
+ "broadcast", broadcast
+ }
+ );
+ }
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
String groupId =
@@ -222,7 +265,20 @@
public Membership removeMembership(String id, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembership",
+ new Object[]{
+ "id", id,
+ "broadcast", broadcast
+ }
+ );
+ }
+
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
@@ -308,6 +364,20 @@
public Collection removeMembershipByUser(String userName, boolean broadcast) throws
Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembershipByUser",
+ new Object[]{
+ "userName", userName,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
Collection<Role> roles = new HashSet();
try
@@ -388,6 +458,22 @@
public Membership findMembershipByUserGroupAndType(String userName, String groupId,
String type) throws Exception
{
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndType",
+ new Object[]{
+ "userName", userName,
+ "groupId", groupId,
+ "type", type,
+ }
+ );
+ }
+
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
String gid =
@@ -437,6 +523,8 @@
hasMembership = true;
}
+ Membership result = null;
+
if (hasMembership)
{
@@ -446,16 +534,51 @@
m.setUserName(userName);
m.setMembershipType(type);
- return m;
+ result = m;
}
- return null;
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserGroupAndType",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByUserAndGroup(String userName, String groupId)
throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ new Object[]{
+ "userName", userName,
+ "groupId", groupId,
+ }
+ );
+ }
+
if (userName == null)
{
// julien fix : if user name is null, need to check if we do need to return a
special group
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ Collections.emptyList()
+ );
+ }
+
return Collections.emptyList();
}
@@ -515,11 +638,36 @@
}
//TODO: Exo UI has hardcoded casts to List
- return new LinkedList(memberships);
+ Collection result = new LinkedList(memberships);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipByUserAndGroup",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByUser(String userName) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByUser",
+ new Object[]{
+ "userName", userName
+ }
+ );
+ }
+
+
Collection<Role> roles = new HashSet();
try
@@ -577,7 +725,19 @@
}
- return new LinkedList(memberships);
+ Collection result = new LinkedList(memberships);
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByUser",
+ result
+ );
+ }
+
+ return result;
}
public Collection findMembershipsByGroup(Group group) throws Exception
@@ -587,6 +747,18 @@
public Collection findMembershipsByGroupId(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByGroup",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
String gid =
@@ -656,11 +828,34 @@
Collections.sort(results);
}
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipsByGroupId",
+ results
+ );
+ }
+
return results;
}
public Membership findMembership(String id) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ new Object[]{
+ "id", id
+ }
+ );
+ }
+
Membership m = new MembershipImpl(id);
String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
@@ -675,6 +870,15 @@
if (isCreateMembership(m.getMembershipType()) &&
getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId,
m.getMembershipType()))
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ m
+ );
+ }
return m;
}
}
@@ -690,6 +894,16 @@
if (isAssociationMapped() &&
getAssociationMapping().equals(m.getMembershipType()) &&
getIdentitySession().getRelationshipManager().isAssociatedByKeys(groupId,
m.getUserName()))
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ m
+ );
+ }
+
return m;
}
}
@@ -700,6 +914,15 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembership",
+ null
+ );
+ }
return null;
}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -157,4 +157,14 @@
return userName.compareTo(m.getUserName());
}
+
+ @Override
+ public String toString()
+ {
+ return "MembershipImpl{" +
+ "membershipType='" + membershipType + '\'' +
+ ", userName='" + userName + '\'' +
+ ", groupId='" + groupId + '\'' +
+ '}';
+ }
}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipTypeDAOImpl.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -22,6 +22,7 @@
import org.exoplatform.services.organization.MembershipType;
import org.exoplatform.services.organization.MembershipTypeHandler;
import org.exoplatform.services.organization.impl.MembershipTypeImpl;
+import org.gatein.common.logging.LogLevel;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.IdentitySession;
@@ -71,6 +72,20 @@
public MembershipType createMembershipType(MembershipType mt, boolean broadcast)
throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createMembershipType",
+ new Object[]{
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
Date now = new Date();
mt.setCreatedDate(now);
mt.setModifiedDate(now);
@@ -83,6 +98,18 @@
public MembershipType saveMembershipType(MembershipType mt, boolean broadcast) throws
Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveMembershipType",
+ new Object[]{
+ "membershipType", mt,
+ "broadcast", broadcast
+ }
+ );
+ }
Date now = new Date();
mt.setModifiedDate(now);
updateMembershipType(mt);
@@ -91,6 +118,18 @@
public MembershipType findMembershipType(String name) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipType",
+ new Object[]{
+ "name", name
+ }
+ );
+ }
+
RoleType rt = getIdentitySession().getRoleManager().getRoleType(name);
MembershipType mt = null;
@@ -101,11 +140,35 @@
populateMembershipType(mt);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipType",
+ mt
+ );
+ }
+
return mt;
}
public MembershipType removeMembershipType(String name, boolean broadcast) throws
Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeMembershipType",
+ new Object[]{
+ "name", name,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
MembershipType mt = findMembershipType(name);
if (mt != null)
@@ -119,6 +182,15 @@
public Collection findMembershipTypes() throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findMembershipTypes",
+ null
+ );
+ }
Collection<RoleType> rts =
getIdentitySession().getRoleManager().findRoleTypes();
@@ -131,6 +203,16 @@
mts.add(mt);
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findMembershipTypes",
+ mts
+ );
+ }
+
return mts;
}
Copied:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java
(from rev 5282,
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java)
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java
(rev 0)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/Tools.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -0,0 +1,106 @@
+package org.exoplatform.services.organization.idm;
+
+import org.gatein.common.logging.LogLevel;
+import org.gatein.common.logging.Logger;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+/*
+* JBoss, a division of Red Hat
+* Copyright 2010, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+/**
+ * Some helper methods
+ */
+public class Tools
+{
+ public static void logMethodIn(Logger log, LogLevel level, String methodName, Object[]
args)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Method '")
+ .append(methodName)
+ .append("' called with arguments: ");
+
+ if (args != null)
+ {
+ for (Object arg : args)
+ {
+ if (arg != null && arg instanceof Object[])
+ {
+ sb.append(Arrays.toString((Object[])arg))
+ .append("; ");
+ }
+ else
+ {
+ sb.append(arg)
+ .append("; ");
+ }
+ }
+ }
+ else
+ {
+ sb.append(args);
+ }
+
+ log.log(level, sb.toString());
+ }
+ catch (Throwable t)
+ {
+ log.log(level, "Error in logging code block (not related to application
code): ", t);
+ }
+
+ }
+
+ public static void logMethodOut(Logger log, LogLevel level, String methodName, Object
result)
+ {
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Method '")
+ .append(methodName)
+ .append("' returning object: ");
+
+ if (result != null && result instanceof Collection)
+ {
+ sb.append("Collection of size:
").append(((Collection)result).size());
+ }
+ else
+ {
+ if (result != null)
+ {
+
sb.append("[").append(result.getClass().getCanonicalName()).append("]");
+ }
+ sb.append(result);
+ }
+
+ log.log(level, sb.toString());
+
+ }
+ catch (Throwable t)
+ {
+ log.log(level, "Error in logging code block (not related to application
code): ", t);
+ }
+ }
+
+}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-11-26
10:13:55 UTC (rev 5288)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/UserDAOImpl.java 2010-11-26
10:18:30 UTC (rev 5289)
@@ -28,6 +28,7 @@
import org.exoplatform.services.organization.UserEventListener;
import org.exoplatform.services.organization.UserHandler;
import org.exoplatform.services.organization.impl.UserImpl;
+import org.gatein.common.logging.LogLevel;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;
import org.picketlink.idm.api.Attribute;
@@ -122,6 +123,20 @@
public void createUser(User user, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "createUser",
+ new Object[]{
+ "user", user,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
IdentitySession session = service_.getIdentitySession();
if (broadcast)
{
@@ -149,6 +164,20 @@
public void saveUser(User user, boolean broadcast) throws Exception
{
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "saveUser",
+ new Object[]{
+ "user", user,
+ "broadcast", broadcast
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
if (broadcast)
{
@@ -165,6 +194,20 @@
public User removeUser(String userName, boolean broadcast) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "removeUser",
+ new Object[]{
+ "userName", userName,
+ "broadcast", broadcast
+ }
+ );
+ }
+
+
IdentitySession session = service_.getIdentitySession();
org.picketlink.idm.api.User foundUser = null;
@@ -223,15 +266,49 @@
//
public User findUserByName(String userName) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUserByName",
+ new Object[]{
+ "userName", userName,
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
User user = getPopulatedUser(userName, session);
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findUserByName",
+ user
+ );
+ }
+
return user;
}
public LazyPageList getUserPageList(int pageSize) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "getUserPagetList",
+ new Object[]{
+ "pageSize", pageSize
+ }
+ );
+ }
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
return new LazyPageList(new IDMUserListAccess(this, service_, qb, pageSize, true),
pageSize);
@@ -245,9 +322,32 @@
//
public boolean authenticate(String username, String password) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ new Object[]{
+ "userName", username,
+ "password", "****"
+ }
+ );
+ }
+
User user = findUserByName(username);
if (user == null)
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ false
+ );
+ }
+
return false;
}
@@ -279,12 +379,35 @@
userImpl.setLastLoginTime(Calendar.getInstance().getTime());
saveUser(userImpl, false);
}
+
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "authenticate",
+ authenticated
+ );
+ }
+
return authenticated;
}
public LazyPageList findUsers(Query q) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUsers",
+ new Object[]{
+ "q", q
+ }
+ );
+ }
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
if (q.getUserName() != null)
@@ -319,6 +442,19 @@
public LazyPageList findUsersByGroup(String groupId) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUsersByGroup",
+ new Object[]{
+ "groupId", groupId
+ }
+ );
+ }
+
+
UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
org.picketlink.idm.api.Group jbidGroup = null;
@@ -339,6 +475,18 @@
public User findUserByEmail(String email) throws Exception
{
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodIn(
+ log,
+ LogLevel.TRACE,
+ "findUserByEmail",
+ new Object[]{
+ "findUserByEmail", email
+ }
+ );
+ }
+
IdentitySession session = service_.getIdentitySession();
@@ -363,6 +511,16 @@
}
+ if (log.isTraceEnabled())
+ {
+ Tools.logMethodOut(
+ log,
+ LogLevel.TRACE,
+ "findUserByEmail",
+ user
+ );
+ }
+
return user;
}