Author: thomas.heute(a)jboss.com
Date: 2010-10-27 06:24:33 -0400 (Wed, 27 Oct 2010)
New Revision: 4854
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/test/java/org/exoplatform/services/organization/TestOrganizationService.java
Log:
JBEPP-582: A MembershipType is automatically created if missing while making a membership
link
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-10-27
09:59:57 UTC (rev 4853)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/main/java/org/exoplatform/services/organization/idm/MembershipDAOImpl.java 2010-10-27
10:24:33 UTC (rev 4854)
@@ -102,6 +102,11 @@
+ " because membership type is null");
}
+ if (orgService.getMembershipTypeHandler().findMembershipType(mt.getName()) ==
null)
+ {
+ throw new InvalidNameException("MembershipType doesn't exist: " +
mt.getName());
+ }
+
String plGroupName = getPLIDMGroupName(g.getGroupName());
String groupId =
Modified:
epp/portal/branches/EPP_5_1_Branch/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java 2010-10-27
09:59:57 UTC (rev 4853)
+++
epp/portal/branches/EPP_5_1_Branch/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java 2010-10-27
10:24:33 UTC (rev 4854)
@@ -340,6 +340,7 @@
mt = mtHandler_.createMembershipTypeInstance();
mt.setName("membershipType3");
+ mtHandler_.createMembershipType(mt, true);
membershipHandler_.linkMembership(userBenj, group2, mt, true);
/*
@@ -491,6 +492,37 @@
// userHandler_.removeUser(user.getUserName(), false);
// }
+ public void testLinkMembership() throws Exception {
+ String g1 = "grp1";
+ String usr1 = "usr1";
+ String mstype1 = "mstype1";
+
+ Group group1 = groupHandler_.createGroupInstance();
+ group1.setGroupName(g1);
+ groupHandler_.addChild(null, group1, true);
+
+ User user = createUser(usr1);
+
+ MembershipType mt = mtHandler_.createMembershipTypeInstance();
+ mt.setName(mstype1);
+
+ try {
+
+ membershipHandler_.linkMembership(user, group1, mt, true);
+ fail();
+ }
+ catch (Exception e)
+ {
+ //expected as membership type was not created first
+ }
+
+ assertNull(mtHandler_.findMembershipType(mstype1));
+
+ userHandler_.removeUser(usr1, true);
+ groupHandler_.removeGroup(group1, true);
+ }
+
+
public void testFindUsersByGroupId() throws Exception
{
PageList users = userHandler_.findUsersByGroup("/users");
Show replies by date