[Ils-source] r1336 - in branches/1.6: . webapp/api/group/put webapp/api/user/put
scribe at crosswire.org
scribe at crosswire.org
Thu Jun 25 16:49:08 MST 2015
Author: scribe
Date: 2015-06-25 16:49:07 -0700 (Thu, 25 Jun 2015)
New Revision: 1336
Modified:
branches/1.6/
branches/1.6/webapp/api/group/put/index.jsp
branches/1.6/webapp/api/user/put/index.jsp
Log:
merged in fixed to logic to determine action if not specified
merged in group UserData concept in user/put
Property changes on: branches/1.6
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:796-1303,1306-1307,1309-1311,1319-1320,1322-1323,1325,1328-1330,1332
+ /trunk:796-1303,1306-1307,1309-1311,1319-1320,1322-1323,1325,1328-1330,1332,1334-1335
Modified: branches/1.6/webapp/api/group/put/index.jsp
===================================================================
--- branches/1.6/webapp/api/group/put/index.jsp 2015-06-25 23:44:30 UTC (rev 1335)
+++ branches/1.6/webapp/api/group/put/index.jsp 2015-06-25 23:49:07 UTC (rev 1336)
@@ -52,30 +52,36 @@
++errCode;
if ((adminUser.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_ADD_USER)) || (adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_MODIFY_USER))) {
- if (!createMode) {
- if (groupID != -1) {
- current = Group.getGroup(ilsSession, groupID);
+ Group lookup = null;
+ if (groupID != -1) {
+ lookup = Group.getGroup(ilsSession, groupID);
+ if (lookup == null) {
+ out.print("<error code=\""+errCode+"\" message=\"Group not found.\"/>");
+ return;
}
- else if (userData != null) {
- current = Group.getGroupByUserData(ilsSession, groupTypeID, userData);
+ }
+ else if (userData != null) {
+ lookup = Group.getGroupByUserData(ilsSession, groupTypeID, userData);
+ }
+ if (createMode) {
+ if (lookup != null) {
+ ++errCode;
+ out.print("<error code=\""+errCode+"\" message=\"Group exists.\"/>");
+ return;
}
}
+ else {
+ createMode = lookup == null;
+ }
+ if (lookup != null) current = lookup;
}
else {
+ errCode += 2;
out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
return;
}
- ++errCode;
- if (current == null) {
- out.print("<error code=\""+errCode+"\" message=\"Group not found.\"/>");
- return;
- }
- ++errCode;
- if (createMode && current.getGroupID() > 0) {
- out.print("<error code=\""+errCode+"\" message=\"Group exists.\"/>");
- return;
- }
+ errCode += 3;
if (current.getGroupID() > 0 && adminUser.getUserProfileAccessLevel() <= UserProfile.ACCESS_MANAGER && !adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_MODIFY_USER)) {
out.print("<error code=\""+errCode+"\" message=\"Permission denied to edit group.\"/>");
return;
Modified: branches/1.6/webapp/api/user/put/index.jsp
===================================================================
--- branches/1.6/webapp/api/user/put/index.jsp 2015-06-25 23:44:30 UTC (rev 1335)
+++ branches/1.6/webapp/api/user/put/index.jsp 2015-06-25 23:49:07 UTC (rev 1336)
@@ -58,29 +58,43 @@
int currentRoleID = -1;
int currentLocationID = -1;
String roleName = null;
+ String roleUserData = null;
String workgroupName = null;
+ String workgroupUserData = null;
boolean createMode = "create".equals(request.getParameter("action"));
++errCode;
if ((adminUser.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
if (!createMode) {
+ UserProfile lookup = null;
if (userProfileID != -1) {
- current = UserProfile.getUserProfile(ilsSession, userProfileID);
+ lookup = UserProfile.getUserProfile(ilsSession, userProfileID);
+ if (lookup == null) {
+ out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
+ return;
+ }
}
- else if (loginID != null) {
- current = UserProfile.getUserProfile(ilsSession, loginID);
+ if (lookup == null && loginID != null) {
+ lookup = UserProfile.getUserProfile(ilsSession, loginID);
}
- else if (userData != null) {
- current = UserProfile.getUserProfileByUserData(ilsSession, userData);
+ if (lookup == null && userData != null) {
+ lookup = UserProfile.getUserProfileByUserData(ilsSession, userData);
}
+ if (lookup != null) {
+ current = lookup;
+ }
+ else {
+ createMode = true;
+ }
}
}
else {
+ ++errCode;
out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
return;
}
- ++errCode;
+ errCode += 2;
if (current == null) {
out.print("<error code=\""+errCode+"\" message=\"User Profile not found.\"/>");
return;
@@ -97,12 +111,13 @@
boolean createGroupOnDemand = false; try { createGroupOnDemand = "true".equals(request.getParameter("createGroupOnDemand")); } catch (Exception e) {}
String val = request.getParameter("roleName");
+ String val2 = request.getParameter("roleUserData");
int requestedRole = -1;
++errCode;
- if (val != null && val.trim().length() > 0) {
+ if ((val != null && val.trim().length() > 0) || (val2 != null && val2.trim().length() > 0)) {
for (int i = 0; i < 2; ++i) {
- Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_ROLE, val);
+ Group g = (val2 != null) ? Group.getGroupByUserData(ilsSession, Group.GROUPTYPE_ROLE, val2) : Group.getGroupByName(ilsSession, Group.GROUPTYPE_ROLE, val);
if (g != null) {
requestedRole = g.getGroupID();
roleName = g.getGroupName();
@@ -110,16 +125,17 @@
}
else {
if (i < 1 && createGroupOnDemand) {
- Group grp = new Group();
- grp.defaultAll();
- grp.setGroupTypeID(Group.GROUPTYPE_ROLE);
- grp.setGroupName(val);
- roleName = val;
- grp.setGroupDesc(val);
- grp.saveNew(ilsSession);
+ Group grp = new Group();
+ grp.defaultAll();
+ grp.setGroupTypeID(Group.GROUPTYPE_ROLE);
+ grp.setGroupName(val != null ? val : val2);
+ roleName = grp.getGroupName();
+ grp.setGroupDesc(roleName);
+ if (val2 != null) grp.setValue("USERDATA", val2);
+ grp.saveNew(ilsSession);
}
else {
- out.print("<error code=\""+errCode+"\" message=\"roleName was submitted but was not found in the database. roleName must be the name of a valid Role or createGroupOnDemand must be passed as true.\"/>");
+ out.print("<error code=\""+errCode+"\" message=\"" + ((val2 != null) ? "roleUserData" : "roleName") + " was submitted but was not found in the database. You must specify an existing Role or createGroupOnDemand must be passed as true.\"/>");
return;
}
}
@@ -128,10 +144,11 @@
++errCode;
val = request.getParameter("locationName");
+ val2 = request.getParameter("locationUserData");
int requestedLocation = -1;
- if (val != null && val.trim().length() > 0) {
+ if ((val != null && val.trim().length() > 0) || (val2 != null && val2.trim().length() > 0)) {
for (int i = 0; i < 2; ++i) {
- Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, val);
+ Group g = (val2 != null) ? Group.getGroupByUserData(ilsSession, Group.GROUPTYPE_LOCATION, val2) : Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, val);
if (g != null) {
requestedLocation = g.getGroupID();
workgroupName = g.getGroupName();
@@ -139,16 +156,17 @@
}
else {
if (i < 1 && createGroupOnDemand) {
- Group grp = new Group();
- grp.defaultAll();
- grp.setGroupTypeID(Group.GROUPTYPE_LOCATION);
- grp.setGroupName(val);
- workgroupName = val;
- grp.setGroupDesc(val);
- grp.saveNew(ilsSession);
+ Group grp = new Group();
+ grp.defaultAll();
+ grp.setGroupTypeID(Group.GROUPTYPE_LOCATION);
+ grp.setGroupName(val != null ? val : val2);
+ workgroupName = grp.getGroupName();
+ grp.setGroupDesc(workgroupName);
+ if (val2 != null) grp.setValue("USERDATA", val2);
+ grp.saveNew(ilsSession);
}
else {
- out.print("<error code=\""+errCode+"\" message=\"locationName was submitted but was not found in the database. locationName must be the name of a valid Location or createGroupOnDemand must be passed as true.\"/>");
+ out.print("<error code=\""+errCode+"\" message=\""+((val2 != null) ? "locationUserData" : "locationName") + " was submitted but was not found in the database. You must specify an existing Location or createGroupOnDemand must be passed as true.\"/>");
return;
}
}
@@ -344,8 +362,10 @@
<tr><th>accessLevel</th><td>User Access Level</td></tr>
<tr><th>accessMode</th><td>User Access Mode</td></tr>
<tr><th>roleName</th><td>Assign this user only to this group type 1 {ROLE}. Any other group type 1's are unassigned.</td></tr>
+<tr><th>roleUserData</th><td>Assign this user only to this group type 1 {ROLE}. Any other group type 1's are unassigned.</td></tr>
<tr><th>locationName</th><td>Assign this user only to this group type 2 {WORKGROUP}. Any other group type 2's are unassigned.</td></tr>
-<tr><th>createGroupOnDemand</th><td>If locationName or roleName is supplied but the group does not exist, this will cause the group to be created.</td></tr>
+<tr><th>locationUserData</th><td>Assign this user only to this group type 2 {WORKGROUP}. Any other group type 2's are unassigned.</td></tr>
+<tr><th>createGroupOnDemand</th><td>If location[UserData|Name] or role[UserData|Name] is supplied but the group does not exist, this will cause the group to be created. If group is created and both *Name and *UserData are supplied, both will be saved for the new group.</td></tr>
<tr><th>ILSUSER</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
<tr><th>ILSPASSWD</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
</tbody>
More information about the Ils-source
mailing list