[jbpm-commits] JBoss JBPM SVN: r5082 - in jbpm4/trunk: modules/test-db/src/test/java/org/jbpm/test/identity and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jun 22 13:03:37 EDT 2009
Author: jeff.yuchang
Date: 2009-06-22 13:03:36 -0400 (Mon, 22 Jun 2009)
New Revision: 5082
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
jbpm4/trunk/qa/build.xml
Log:
JBPM-2172
* Finish the jbpmGroupId <-> idmGroupId as a current solution, will switch to other if we've reached another solution.
* Update the qa build script to get the idm component correctly.
* Will release the idm beta1 tomorrow, and then update the version into beta1. Then this jira issue should be resolved.
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-06-22 15:18:50 UTC (rev 5081)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-06-22 17:03:36 UTC (rev 5082)
@@ -24,15 +24,18 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.StringTokenizer;
import org.jboss.identity.idm.api.Attribute;
import org.jboss.identity.idm.api.AttributesManager;
import org.jboss.identity.idm.api.IdentitySearchCriteria;
import org.jboss.identity.idm.api.IdentitySession;
import org.jboss.identity.idm.api.RoleType;
+import org.jboss.identity.idm.common.exception.FeatureNotSupportedException;
import org.jboss.identity.idm.common.exception.IdentityException;
import org.jboss.identity.idm.common.p3p.P3PConstants;
import org.jboss.identity.idm.impl.api.SimpleAttribute;
+import org.jboss.identity.idm.impl.api.model.GroupId;
import org.jbpm.api.JbpmException;
import org.jbpm.api.identity.Group;
import org.jbpm.api.identity.User;
@@ -45,8 +48,10 @@
protected IdentitySession identitySession;
- protected String MEMBER_ROLE = "jbpm_member_role";
+ public String DEFAULT_JBPM_MEMBER_ROLE = "default_jBPM_member_role";
+ public String DEFAUL_JBPM_GROUP_TYPE = "default_jBPM_Group_Type";
+
public JBossIdmIdentitySessionImpl(IdentitySession identitySession) {
this.identitySession = identitySession;
}
@@ -132,12 +137,12 @@
public List<User> findUsersByGroup(String groupId) {
try {
List<User> users = new ArrayList<User>();
- org.jboss.identity.idm.api.Group idGroup = findIdmGroupById(groupId);
+ org.jboss.identity.idm.api.Group idGroup = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(groupId));
if (idGroup == null){
return users;
}
Collection<org.jboss.identity.idm.api.User> idusers =
- identitySession.getRelationshipManager().findAssociatedUsers(idGroup, false);
+ identitySession.getRoleManager().findUsersWithRelatedRole(idGroup, null);
for (org.jboss.identity.idm.api.User iduser : idusers) {
users.add(findUserById(iduser.getId()));
}
@@ -145,6 +150,8 @@
return users;
} catch (IdentityException e) {
throw new JbpmException("couldn't find users by groupid: " + groupId, e);
+ } catch (FeatureNotSupportedException e) {
+ throw new JbpmException("couldn't find users by groupid: " + groupId, e);
}
}
@@ -162,19 +169,19 @@
try {
String gtype = groupType;
if (gtype == null) {
- gtype = Group.TYPE_UNIT;
+ gtype = DEFAUL_JBPM_GROUP_TYPE;
}
org.jboss.identity.idm.api.Group group = identitySession.getPersistenceManager().createGroup(groupName, gtype);
String groupId = group.getId();
if (parentGroupId!=null) {
- org.jboss.identity.idm.api.Group parentGroup = findIdmGroupById(parentGroupId);
+ org.jboss.identity.idm.api.Group parentGroup = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(parentGroupId));
if (parentGroup==null) {
throw new JbpmException("parent group "+parentGroupId+" doesn't exist");
}
identitySession.getRelationshipManager().associateGroups(parentGroup, group);
}
- return groupId;
+ return convertIdmGroupId2jbpmGroupId(groupId);
} catch (IdentityException e) {
throw new JbpmException("couldn't create group "+groupName, e);
@@ -184,12 +191,12 @@
public Group findGroupById(String groupId) {
try {
- org.jboss.identity.idm.api.Group idGroup = findIdmGroupById(groupId);
+ org.jboss.identity.idm.api.Group idGroup = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(groupId));
if (idGroup == null) {
return null;
}
GroupImpl group = new GroupImpl();
- group.setId(idGroup.getId());
+ group.setId(convertIdmGroupId2jbpmGroupId(idGroup.getId()));
group.setType(idGroup.getGroupType());
group.setName(idGroup.getName());
@@ -199,7 +206,7 @@
if (idParentGroups.size() > 0) {
org.jboss.identity.idm.api.Group idParent = idParentGroups.iterator().next();
GroupImpl parentGroup = new GroupImpl();
- parentGroup.setId(idParent.getId());
+ parentGroup.setId(convertIdmGroupId2jbpmGroupId(idParent.getId()));
parentGroup.setType(idParent.getGroupType());
parentGroup.setName(idParent.getName());
@@ -220,7 +227,7 @@
List<Group> groups = new ArrayList<Group>();
for (org.jboss.identity.idm.api.Group idGroup: idGroups) {
- groups.add(findGroupById(idGroup.getId()));
+ groups.add(findGroupById(convertIdmGroupId2jbpmGroupId(idGroup.getId())));
}
return groups;
@@ -238,7 +245,7 @@
List<Group> groups = new ArrayList<Group>();
for (org.jboss.identity.idm.api.Group idGroup : idGroups) {
- groups.add(findGroupById(idGroup.getId()));
+ groups.add(findGroupById(convertIdmGroupId2jbpmGroupId(idGroup.getId())));
}
return groups;
} catch (Exception e) {
@@ -256,7 +263,7 @@
List<Group> groups = new ArrayList<Group>();
for (org.jboss.identity.idm.api.Group idGroup : idGroups) {
- groups.add(findGroupById(idGroup.getId()));
+ groups.add(findGroupById(convertIdmGroupId2jbpmGroupId(idGroup.getId())));
}
return groups;
} catch (Exception e) {
@@ -266,7 +273,7 @@
public void deleteGroup(String groupId) {
try {
- org.jboss.identity.idm.api.Group group = findIdmGroupById(groupId);
+ org.jboss.identity.idm.api.Group group = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(groupId));
if (group==null) {
return;
@@ -281,7 +288,7 @@
public void createMembership(String userId, String groupId, String role) {
try {
- org.jboss.identity.idm.api.Group group = findIdmGroupById(groupId);
+ org.jboss.identity.idm.api.Group group = findIdmGroupByIdmGroupId(convertjbpmGroupId2IdmGroupId(groupId));
if (group==null) {
throw new JbpmException("group "+groupId+" doesn't exist");
}
@@ -292,10 +299,11 @@
}
if (role == null) {
- role = MEMBER_ROLE;
+ role = DEFAULT_JBPM_MEMBER_ROLE;
}
RoleType roleType = identitySession.getRoleManager().getRoleType(role);
- if (roleType==null) {
+ System.out.println("The Role Type is: " + roleType);
+ if (roleType == null) {
roleType = identitySession.getRoleManager().createRoleType(role);
}
identitySession.getRoleManager().createRole(roleType, idUser, group);
@@ -308,22 +316,16 @@
public void deleteMembership(String userId, String groupId, String role) {
try {
RoleType rtype = identitySession.getRoleManager().getRoleType(role);
- identitySession.getRoleManager().removeRole(rtype.getName(), userId, groupId);
+ identitySession.getRoleManager().removeRole(rtype.getName(), userId, convertjbpmGroupId2IdmGroupId(groupId));
} catch (Exception e) {
throw new JbpmException("couldn't delete the membership [" + userId + "," + groupId + "," + role + "]", e);
}
}
- protected org.jboss.identity.idm.api.Group findIdmGroupById(String groupId) {
+ protected org.jboss.identity.idm.api.Group findIdmGroupByIdmGroupId(String groupId) {
try {
- Collection<org.jboss.identity.idm.api.Group> groups = identitySession.getPersistenceManager().findGroup(Group.TYPE_UNIT);
- for (org.jboss.identity.idm.api.Group group : groups) {
- if (groupId.equals(group.getId())) {
- return group;
- }
- }
- return null;
+ return identitySession.getPersistenceManager().findGroupById(groupId);
} catch (IdentityException e) {
throw new JbpmException("couldn't find the group by groupId: " + groupId, e);
}
@@ -350,8 +352,39 @@
}
return null;
}
-
-
+
+
+ /**
+ * Return jBPM groupId, which is: GroupType.GroupName, from IDM GroupId
+ *
+ * @param groupId
+ * @return
+ */
+ private String convertIdmGroupId2jbpmGroupId(String groupId) {
+ GroupId theGroupId = new GroupId(groupId);
+ if (this.DEFAUL_JBPM_GROUP_TYPE.equals(theGroupId.getType()) || theGroupId.getType() == null) {
+ return theGroupId.getName();
+ }
+ return theGroupId.getType() + "." + theGroupId.getName();
+ }
+
+ /**
+ * Convert the jBPM GroupId to IDM GroupId.
+ *
+ * @param jbpmGroupId
+ * @return
+ */
+ private String convertjbpmGroupId2IdmGroupId(String jbpmGroupId) {
+ StringTokenizer st = new StringTokenizer(jbpmGroupId, ".");
+ String type = DEFAUL_JBPM_GROUP_TYPE;
+ if (st.countTokens() > 1) {
+ type = st.nextToken();
+ }
+ String name = st.nextToken();
+
+ return new GroupId(name, type).getId();
+ }
+
public IdentitySession getIdentitySession() {
return identitySession;
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java 2009-06-22 15:18:50 UTC (rev 5081)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/identity/IdentityTest.java 2009-06-22 17:03:36 UTC (rev 5082)
@@ -83,7 +83,7 @@
identityService.createUser("johndoe", "John", "Doe");
String redhatGroupId = identityService.createGroup("redhat", Group.TYPE_UNIT, null);
- identityService.createMembership("johndoe", redhatGroupId, "Developer");
+ identityService.createMembership("johndoe", redhatGroupId, "developer");
List<Group> groups = identityService.findGroupsByUserAndGroupType("johndoe", Group.TYPE_UNIT);
assertTrue(groups.size() > 0);
@@ -111,7 +111,7 @@
String jbossId = identityService.createGroup("jboss", Group.TYPE_UNIT, redhatGroupId);
String jbpmId = identityService.createGroup("jbpm", Group.TYPE_UNIT, jbossId);
- identityService.createMembership("johndoe", redhatGroupId, "Developer");
+ identityService.createMembership("johndoe", redhatGroupId, "developer");
identityService.createMembership("joesmoe", jbpmId, "leader");
identityService.createMembership("jackblack", jbossId, "manager");
Modified: jbpm4/trunk/qa/build.xml
===================================================================
--- jbpm4/trunk/qa/build.xml 2009-06-22 15:18:50 UTC (rev 5081)
+++ jbpm4/trunk/qa/build.xml 2009-06-22 17:03:36 UTC (rev 5082)
@@ -8,7 +8,8 @@
<fail message="property jbpm.parent.dir must be specified" unless="jbpm.parent.dir" />
<!-- CONFIGURABLE PROPERTIES -->
- <property name="database" value="hsqldb" />
+ <property name="database" value="hsqldb" />
+ <property name="identity.component" value="jbpm-built-in" />
<property name="jbpm.version" value="4.0-SNAPSHOT" />
<property name="jbpm.home" value="${jbpm.parent.dir}/jbpm-${jbpm.version}" /> <!-- jbpm.home should not be configured. change jbpm.parent.dir instead -->
<property name="jboss.version" value="5.0.0.GA" />
@@ -35,7 +36,11 @@
<echo message="jbpm.distro.path.. ${jbpm.distro.path}" />
<echo message="jbossidm.home .... ${jbossidm.home}" />
</target>
-
+
+ <condition property="jbpm.identity.idm">
+ <equals arg1="${identity.component}" arg2="jboss.idm"/>
+ </condition>
+
<!-- TARGETS -->
<target name="delete.jbpm.installation"
description="deletes ${jbpm.home}">
@@ -122,7 +127,7 @@
</condition>
<target name="copy.jbossidm.jdbc.configuration" if="identity.component.idm">
- <copy file="../modules/distro/target/oracle/ojdbc14.jar"
+ <copy file="../modules/distro/target/libs/ojdbc14.jar"
todir="${jbossidm.home}/lib" />
<!--copy file="jdbc/${database}.properties"
todir="${jbossidm.home}/db/jdbc"
More information about the jbpm-commits
mailing list