Author: bdaw
Date: 2010-05-20 18:03:47 -0400 (Thu, 20 May 2010)
New Revision: 3161
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
portal/trunk/pom.xml
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
Log:
- GTNPORTAL-1231 - Problem when LDAP group name contains slash
- GTNPORTAL-1232 - Groups and user memberships are displayed unordered
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/Config.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -44,6 +44,8 @@
private String pathSeparator = ".";
+ private String slashReplacement = "@_@_@";
+
private boolean forceMembershipOfMappedTypes = false;
private String associationMembershipType;
@@ -52,7 +54,10 @@
private boolean useJTA = false;
+ private boolean sortGroups = true;
+ private boolean sortMemberships = true;
+
public Config()
{
}
@@ -154,6 +159,16 @@
return null;
}
+ public String getPLIDMGroupName(String gtnGroupName)
+ {
+ return gtnGroupName.replaceAll(getSlashReplacement(), "/");
+ }
+
+ public String getGtnGroupName(String plidmGroupName)
+ {
+ return plidmGroupName.replaceAll("/", getSlashReplacement());
+ }
+
Set<String> getTypes(String id)
{
HashSet<String> types = new HashSet<String>();
@@ -283,4 +298,34 @@
{
this.useJTA = useJTA;
}
+
+ public String getSlashReplacement()
+ {
+ return slashReplacement;
+ }
+
+ public void setSlashReplacement(String slashReplacement)
+ {
+ this.slashReplacement = slashReplacement;
+ }
+
+ public boolean isSortGroups()
+ {
+ return sortGroups;
+ }
+
+ public void setSortGroups(boolean sortGroups)
+ {
+ this.sortGroups = sortGroups;
+ }
+
+ public boolean isSortMemberships()
+ {
+ return sortMemberships;
+ }
+
+ public void setSortMemberships(boolean sortMemberships)
+ {
+ this.sortMemberships = sortMemberships;
+ }
}
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/ExtGroup.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -29,7 +29,7 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class ExtGroup implements Group, Serializable
+public class ExtGroup implements Group, Serializable, Comparable
{
private String id;
@@ -155,4 +155,17 @@
result = 31 * result + (desc != null ? desc.hashCode() : 0);
return result;
}
+
+ public int compareTo(Object o)
+ {
+ if (!(o instanceof Group))
+ {
+ return 0;
+ }
+
+ Group group = (Group)o;
+
+ return groupName.compareTo(group.getGroupName());
+
+ }
}
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/GroupDAOImpl.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -83,17 +83,21 @@
{
org.picketlink.idm.api.Group parentGroup = null;
+ String childPLGroupName = getPLIDMGroupName(child.getGroupName());
+
if (parent != null)
{
+
+ String parentPLGroupName = getPLIDMGroupName(parent.getGroupName());
try
{
parentGroup =
getIdentitySession().getPersistenceManager().
- findGroup(parent.getGroupName(),
orgService.getConfiguration().getGroupType(parent.getParentId()));
+ findGroup(parentPLGroupName,
orgService.getConfiguration().getGroupType(parent.getParentId()));
}
catch (Exception e)
{
- log.info("Cannot obtain group: " + parent.getGroupName(), e);
+ log.info("Cannot obtain group: " + parentPLGroupName, e);
}
@@ -162,15 +166,17 @@
org.picketlink.idm.api.Group jbidGroup = null;
+ String plGroupName = getPLIDMGroupName(group.getGroupName());
+
try
{
jbidGroup =
getIdentitySession().getPersistenceManager().
- findGroup(group.getGroupName(),
orgService.getConfiguration().getGroupType(group.getParentId()));
+ findGroup(plGroupName,
orgService.getConfiguration().getGroupType(group.getParentId()));
}
catch (Exception e)
{
- log.info("Cannot obtain group: " + group.getGroupName() + ";
", e);
+ log.info("Cannot obtain group: " + plGroupName + "; ", e);
}
if (jbidGroup == null)
@@ -198,7 +204,7 @@
}
catch (Exception e)
{
- log.info("Cannot clear group relationships: " + group.getGroupName() +
"; ", e);
+ log.info("Cannot clear group relationships: " + plGroupName + ";
", e);
}
try
@@ -207,7 +213,7 @@
}
catch (Exception e)
{
- log.info("Cannot remove group: " + group.getGroupName() + ";
", e);
+ log.info("Cannot remove group: " + plGroupName + "; ", e);
}
if (broadcast)
@@ -292,9 +298,11 @@
{
try
{
+ String plGroupName = getPLIDMGroupName(parent.getGroupName());
+
jbidGroup =
getIdentitySession().getPersistenceManager().
- findGroup(parent.getGroupName(),
orgService.getConfiguration().getGroupType(parent.getParentId()));
+ findGroup(plGroupName,
orgService.getConfiguration().getGroupType(parent.getParentId()));
}
catch (Exception e)
{
@@ -377,8 +385,15 @@
// UI has hardcoded casts to List
- return new LinkedList<Group>(exoGroups);
+ List results = new LinkedList<Group>(exoGroups);
+ if (orgService.getConfiguration().isSortGroups())
+ {
+ Collections.sort(results);
+ }
+
+ return results;
+
}
public Collection findGroupsOfUser(String user) throws Exception
@@ -522,8 +537,10 @@
log.info("Identity operation error: ", e);
}
- ExtGroup exoGroup = new ExtGroup(jbidGroup.getName());
+ String gtnGroupName = getGtnGroupName(jbidGroup.getName());
+ ExtGroup exoGroup = new ExtGroup(gtnGroupName);
+
if (attrs.containsKey(GROUP_DESCRIPTION) &&
attrs.get(GROUP_DESCRIPTION).getValue() != null)
{
exoGroup.setDescription(attrs.get(GROUP_DESCRIPTION).getValue().toString());
@@ -535,7 +552,7 @@
// UI requires that group has label
else
{
- exoGroup.setLabel(exoGroup.getGroupName());
+ exoGroup.setLabel(gtnGroupName);
}
// Resolve full ID
@@ -544,7 +561,7 @@
exoGroup.setId(id);
// child of root
- if (id.length() == jbidGroup.getName().length() + 1)
+ if (id.length() == gtnGroupName.length() + 1)
{
exoGroup.setParentId(null);
}
@@ -566,6 +583,8 @@
Collection<org.picketlink.idm.api.Group> parents = new HashSet();
+ String gtnGroupName = getGtnGroupName(jbidGroup.getName());
+
try
{
parents =
getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, null, false,
false);
@@ -589,6 +608,8 @@
String id =
orgService.getConfiguration().getParentId(jbidGroup.getGroupType());
+
+
if (id != null &&
orgService.getConfiguration().isForceMembershipOfMappedTypes())
{
if (id.endsWith("/*"))
@@ -596,12 +617,12 @@
id = id.substring(0, id.length() - 2);
}
- return id + "/" + jbidGroup.getName();
+ return id + "/" + gtnGroupName;
}
// All groups not connected to the root should be just below the root
- return "/" + jbidGroup.getName();
+ return "/" + gtnGroupName;
//TODO: make it configurable
// throw new IllegalStateException("Group present that is not connected to
the root: " + jbidGroup.getName());
@@ -610,7 +631,7 @@
String parentGroupId =
getGroupId(((org.picketlink.idm.api.Group)parents.iterator().next()));
- return parentGroupId + "/" + jbidGroup.getName();
+ return parentGroupId + "/" + gtnGroupName;
}
@@ -619,10 +640,12 @@
org.picketlink.idm.api.Group jbidGroup = null;
+ String plGroupName = getPLIDMGroupName(exoGroup.getGroupName());
+
try
{
jbidGroup = getIdentitySession().getPersistenceManager().
- findGroup(exoGroup.getGroupName(),
orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ findGroup(plGroupName,
orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
}
catch (Exception e)
{
@@ -636,7 +659,7 @@
{
jbidGroup =
getIdentitySession().getPersistenceManager().
- createGroup(exoGroup.getGroupName(),
orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
+ createGroup(plGroupName,
orgService.getConfiguration().getGroupType(exoGroup.getParentId()));
}
catch (Exception e)
{
@@ -719,5 +742,16 @@
return rootGroup;
}
+ public String getPLIDMGroupName(String gtnGroupName)
+ {
+ return orgService.getConfiguration().getPLIDMGroupName(gtnGroupName);
+ }
+ public String getGtnGroupName(String plidmGroupName)
+ {
+ return orgService.getConfiguration().getGtnGroupName(plidmGroupName);
+ }
+
+
+
}
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -102,9 +102,11 @@
+ " because membership type is null");
}
+ String plGroupName = getPLIDMGroupName(g.getGroupName());
+
String groupId =
getIdentitySession().getPersistenceManager().
- createGroupKey(g.getGroupName(),
orgService.getConfiguration().getGroupType(g.getParentId()));
+ createGroupKey(plGroupName,
orgService.getConfiguration().getGroupType(g.getParentId()));
if (isCreateMembership(mt.getName()))
@@ -147,9 +149,12 @@
public void saveMembership(Membership m, boolean broadcast) throws Exception
{
+
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
+
String groupId =
getIdentitySession().getPersistenceManager().
- createGroupKey(getGroupNameFromId(m.getGroupId()),
getGroupTypeFromId(m.getGroupId()));
+ createGroupKey(plGroupName, getGroupTypeFromId(m.getGroupId()));
boolean hasRole = false;
@@ -215,9 +220,11 @@
Membership m = new MembershipImpl(id);
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
+
String groupId =
getIdentitySession().getPersistenceManager().
- createGroupKey(getGroupNameFromId(m.getGroupId()),
getGroupTypeFromId(m.getGroupId()));
+ createGroupKey(plGroupName, getGroupTypeFromId(m.getGroupId()));
boolean hasRole = false;
@@ -376,9 +383,11 @@
public Membership findMembershipByUserGroupAndType(String userName, String groupId,
String type) throws Exception
{
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
+
String gid =
getIdentitySession().getPersistenceManager().
- createGroupKey(getGroupNameFromId(groupId), getGroupTypeFromId(groupId));
+ createGroupKey(plGroupName, getGroupTypeFromId(groupId));
boolean hasMembership = false;
@@ -445,9 +454,11 @@
return Collections.emptyList();
}
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
+
String gid =
getIdentitySession().getPersistenceManager().
- createGroupKey(getGroupNameFromId(groupId), getGroupTypeFromId(groupId));
+ createGroupKey(plGroupName, getGroupTypeFromId(groupId));
Collection<RoleType> roleTypes = new HashSet();
@@ -571,8 +582,10 @@
public Collection findMembershipsByGroupId(String groupId) throws Exception
{
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(groupId));
+
String gid =
-
getIdentitySession().getPersistenceManager().createGroupKey(getGroupNameFromId(groupId),
+ getIdentitySession().getPersistenceManager().createGroupKey(plGroupName,
getGroupTypeFromId(groupId));
Collection<Role> roles = new HashSet();
@@ -631,16 +644,24 @@
}
//TODO: Exo UI has harcoded casts to List
- return new LinkedList(memberships);
+ List<MembershipImpl> results = new
LinkedList<MembershipImpl>(memberships);
+ if (orgService.getConfiguration().isSortMemberships())
+ {
+ Collections.sort(results);
+ }
+
+ return results;
}
public Membership findMembership(String id) throws Exception
{
Membership m = new MembershipImpl(id);
+ String plGroupName = getPLIDMGroupName(getGroupNameFromId(m.getGroupId()));
+
String groupId =
-
getIdentitySession().getPersistenceManager().createGroupKey(getGroupNameFromId(m.getGroupId()),
+ getIdentitySession().getPersistenceManager().createGroupKey(plGroupName,
getGroupTypeFromId(m.getGroupId()));
@@ -765,4 +786,14 @@
}
return true;
}
+
+ public String getPLIDMGroupName(String gtnGroupName)
+ {
+ return orgService.getConfiguration().getPLIDMGroupName(gtnGroupName);
+ }
+
+ public String getGtnGroupName(String plidmGroupName)
+ {
+ return orgService.getConfiguration().getGtnGroupName(plidmGroupName);
+ }
}
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipImpl.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -24,7 +24,7 @@
/*
* @author <a href="mailto:boleslaw.dawidowicz at redhat.com">Boleslaw
Dawidowicz</a>
*/
-public class MembershipImpl implements Membership
+public class MembershipImpl implements Membership, Comparable
{
private String membershipType = "member";
@@ -145,4 +145,16 @@
result = 31 * result + (groupId != null ? groupId.hashCode() : 0);
return result;
}
+
+ public int compareTo(Object o)
+ {
+ if (!(o instanceof Membership) || userName == null)
+ {
+ return 0;
+ }
+
+ Membership m = (Membership)o;
+
+ return userName.compareTo(m.getUserName());
+ }
}
Modified:
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java
===================================================================
---
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/PicketLinkIDMOrganizationServiceImpl.java 2010-05-20
22:03:47 UTC (rev 3161)
@@ -85,8 +85,11 @@
{
parentId = groupId.substring(0, groupId.lastIndexOf("/"));
}
+
+ String plGroupName = configuration.getPLIDMGroupName(name);
+
return idmService_.getIdentitySession().getPersistenceManager().
- findGroup(name, getConfiguration().getGroupType(parentId));
+ findGroup(plGroupName, getConfiguration().getGroupType(parentId));
}
@Override
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-05-20 16:04:25 UTC (rev 3160)
+++ portal/trunk/pom.xml 2010-05-20 22:03:47 UTC (rev 3161)
@@ -47,7 +47,7 @@
<org.gatein.common.version>2.0.2-GA</org.gatein.common.version>
<org.gatein.wci.version>2.0.1-GA</org.gatein.wci.version>
<org.gatein.pc.version>2.1.1-GA</org.gatein.pc.version>
- <org.picketlink.idm>1.1.4.GA</org.picketlink.idm>
+ <org.picketlink.idm>1.1.5.CR01</org.picketlink.idm>
<org.gatein.wsrp.version>1.1.1-GA</org.gatein.wsrp.version>
<org.gatein.mop.version>1.0.2-GA</org.gatein.mop.version>
<org.slf4j.version>1.5.6</org.slf4j.version>
Modified:
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
===================================================================
---
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2010-05-20
16:04:25 UTC (rev 3160)
+++
portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml 2010-05-20
22:03:47 UTC (rev 3161)
@@ -210,6 +210,22 @@
<field name="useJTA">
<boolean>false</boolean>
</field>
+
+ <!-- If PLIDM group will have name containing slash "/" char than
it will be replace with following string.
+ Slashes are used in group paths and if present in names may cause
unpredictable behaviour -->
+ <field name="slashReplacement">
+ <string>@_@_@</string>
+ </field>
+
+ <!-- If groups should be displayed in a sorted order in the management
UI-->
+ <field name="sortGroups">
+ <boolean>true</boolean>
+ </field>
+
+ <!-- If memberships should be displayed in a sorted order in the management
UI-->
+ <field name="sortMemberships">
+ <boolean>true</boolean>
+ </field>
</object>
</object-param>
</init-params>