[Ils-source] r1324 - in branches/1.6: . src/com/resolutions/ils src/com/resolutions/ils/data webapp/WEB-INF/lib webapp/api/group webapp/api/group/get webapp/api/group/put webapp/api/user/edit webapp/api/user/get webapp/api/user/put

scribe at crosswire.org scribe at crosswire.org
Sun Jun 7 20:53:59 MST 2015


Author: scribe
Date: 2015-06-07 20:53:59 -0700 (Sun, 07 Jun 2015)
New Revision: 1324

Added:
   branches/1.6/webapp/api/group/put/
   branches/1.6/webapp/api/group/put/index.jsp
Removed:
   branches/1.6/webapp/api/group/put/index.jsp
Modified:
   branches/1.6/
   branches/1.6/src/com/resolutions/ils/Utils.java
   branches/1.6/src/com/resolutions/ils/data/Group.java
   branches/1.6/src/com/resolutions/ils/data/UserProfile.java
   branches/1.6/webapp/WEB-INF/lib/ils.jar
   branches/1.6/webapp/api/group/get/index.jsp
   branches/1.6/webapp/api/user/edit/index.jsp
   branches/1.6/webapp/api/user/get/index.jsp
   branches/1.6/webapp/api/user/put/index.jsp
Log:
merged in new API rework and special group batch magic for Markel 



Property changes on: branches/1.6
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:796-1303,1306-1307,1309-1311,1319-1320
   + /trunk:796-1303,1306-1307,1309-1311,1319-1320,1322-1323

Modified: branches/1.6/src/com/resolutions/ils/Utils.java
===================================================================
--- branches/1.6/src/com/resolutions/ils/Utils.java	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/src/com/resolutions/ils/Utils.java	2015-06-08 03:53:59 UTC (rev 1324)
@@ -17,10 +17,12 @@
 import javax.mail.internet.MimeMessage;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSession;
-
+import javax.servlet.http.HttpServletRequest;
 import org.apache.log4j.Logger;
 
+import com.resolutions.ils.data.Company;
 
+
 public class Utils {
 	
 	static Logger logger = Logger.getLogger(Utils.class);
@@ -97,6 +99,19 @@
         return null;
     }
 
+	public static Company getCompany(HttpServletRequest request) {
+		String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
+		HttpSession session = request.getSession();
+		String co = Utils.getCompanyFromConfig(session, requestURL);
+		if (co == null) co = Utils.getSysConfig(session).getProperty("Company", null);
+		if (co == null) co = request.getParameter("co");
+		if (co != null) session.setAttribute("co", co);
+		co = (String) session.getAttribute("co");
+		Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
+
+		return company;
+	}
+
     public static String getVersionString() {
     	String version = "";
     	try {

Modified: branches/1.6/src/com/resolutions/ils/data/Group.java
===================================================================
--- branches/1.6/src/com/resolutions/ils/data/Group.java	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/src/com/resolutions/ils/data/Group.java	2015-06-08 03:53:59 UTC (rev 1324)
@@ -19,6 +19,7 @@
     static String LOOKUPCOURSEGROUPS = "SELECT * FROM ILSGROUP T1, COURSEGROUP T2 WHERE T1.ILSGROUPID=T2.ILSGROUPID AND T2.COURSID={COURSID} AND T1.COMPANYID={COMPANYID} AND T2.COMPANYID={COMPANYID}";
     static String LOOKUP = "SELECT * FROM ILSGROUP WHERE ILSGROUPID={ILSGROUPID} AND COMPANYID={COMPANYID}";
     static String LOOKUPBYNAME = "SELECT * FROM ILSGROUP WHERE GROUPTYPEID={GROUPTYPEID} AND GROUPNAME={GROUPNAME} AND COMPANYID={COMPANYID}";
+    static String LOOKUPBYUSERDATA = "SELECT * FROM ILSGROUP WHERE ILSGROUP.USERDATA={USERDATA} AND COMPANYID={COMPANYID}";
 	static String DELETE[] = {
 		"DELETE FROM ILSGROUP WHERE ILSGROUPID={ILSGROUPID} AND COMPANYID={COMPANYID}",
 		"DELETE FROM USERGROUP WHERE ILSGROUPID={ILSGROUPID} AND COMPANYID={COMPANYID}",
@@ -67,6 +68,18 @@
         return (rows.size() > 0) ? (Group) rows.get(0) : null;
     }
 
+	static public Group getGroupByUserData(ILSSession session, String userData) {
+		return getGroupByUserData(session, -1, userData);
+	}
+	static public Group getGroupByUserData(ILSSession session, int groupTypeID, String userData) {
+		Group query = new Group();
+		query.setGroupTypeID(groupTypeID);
+		query.setValue("USERDATA", userData);
+		query.setCompanyID(session.getCompanyID());
+		Vector rows = query.getDataSet(LOOKUPBYUSERDATA + (groupTypeID > -1 ? " AND GROUPTYPEID={GROUPTYPEID} " : ""));
+		return (rows.size() > 0) ? (Group) rows.get(0) : null;
+	}
+
     public Vector getGroupUsers() {
         UserProfile query = new UserProfile();
         query.setValue("COMPANYID", getCompanyID());
@@ -175,14 +188,23 @@
     public Group() {
     }
 
-    public String getGroupDesc() {
-        return getStringValue("GROUPDESC");
-    }
 
-    public void setGroupDesc(String val) {
-        setValue("GROUPDESC", val);
-    }
+	@Deprecated
+	public String getGroupDesc() {
+		return getGroupDescription();
+	}
+	public String getGroupDescription() {
+		return getStringValue("GROUPDESC");
+	}
 
+	@Deprecated
+	public void setGroupDesc(String val) {
+		setGroupDescription(val);
+	}
+	public void setGroupDescription(String val) {
+		setValue("GROUPDESC", val);
+	}
+
     public int getGroupTypeID() {
         return getIntValue("GROUPTYPEID");
     }
@@ -221,16 +243,34 @@
         setGroupDesc("");
         setGroupTypeID(1);
     }
-	public String toFormattedXML() {
+	public String toXML() {
+		return toXML(DETAIL_COMPLETE);
+	}
+	public String toXML(int detail) {
 		
 		StringBuffer xml = new StringBuffer();
-		xml.append("<Group");
-		xml.append(" id=\""+ getGroupID()+"\"");
-		xml.append(" typeID=\""+ getGroupTypeID()+"\"");
-		xml.append(">\n");
-		xml.append(" <GroupName>"+HTTPUtils.canonize(getGroupName())+"</GroupName>\n");
-		xml.append(" <GroupDescription>"+HTTPUtils.canonize(getGroupDesc())+"</GroupDescription>\n");
-		xml.append("</Group>\n");
+		xml.append("<group");
+		xml.append(" groupID=\""+ getGroupID()+"\"");
+		xml.append(" groupTypeID=\""+ getGroupTypeID()+"\"");
+		xml.append(" groupName=\""+HTTPUtils.canonize(getGroupName())+"\"");
+		xml.append(" userData=\""+getStringValue("USERDATA")+"\"");
+		if (detail == DETAIL_HEADERONLY) {
+			xml.append("/>");
+		}
+		else {
+			xml.append(">\n");
+			xml.append(" <groupDescription>"+HTTPUtils.canonize(getGroupDescription())+"</groupDescription>\n");
+			if (detail == DETAIL_EXTRA) {
+				Vector<Object> users = getGroupUsers();
+				xml.append("<userProfiles count=\""+users.size()+"\">");
+				for (Object o2 : users) {
+					UserProfile u = (UserProfile)o2;
+					xml.append(u.toXML(DETAIL_HEADERONLY));
+				}
+				xml.append("</userProfiles>");
+			}
+			xml.append("</group>\n");
+		}
 
 		return xml.toString();
 	}

Modified: branches/1.6/src/com/resolutions/ils/data/UserProfile.java
===================================================================
--- branches/1.6/src/com/resolutions/ils/data/UserProfile.java	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/src/com/resolutions/ils/data/UserProfile.java	2015-06-08 03:53:59 UTC (rev 1324)
@@ -20,6 +20,7 @@
 import org.apache.log4j.Logger;
 import org.crosswire.data.DataObject;
 import org.crosswire.utils.SMTPMail;
+import org.crosswire.utils.HTTPUtils;
 
 import com.resolutions.ils.ILSSession;
 import com.resolutions.ils.Utils;
@@ -72,6 +73,7 @@
     };
 
 	static String COUNTWOULDBEDELETES = "SELECT COUNT(*) WOULDBE FROM ("+SELECTOLDIDS+") TMPTABLE";
+	static String LOOKUPUSERGROUPS = "SELECT * FROM ILSGROUP T1, USERGROUP T2 WHERE T1.ILSGROUPID=T2.ILSGROUPID AND T2.USERPRID={USERPRID} AND T1.COMPANYID={COMPANYID} AND T2.COMPANYID={COMPANYID}";
 
 
     private boolean isRoleLoaded              = false;
@@ -256,6 +258,16 @@
         return (rows.size() > 0) ? rows.get(0) : null;
     }
 
+    static public UserProfile getUserProfileByUserData(ILSSession session,
+                                             String userData) {
+        UserProfile retVal = new UserProfile();
+        String sql = LOOKUP + " AND USERPROFILE.USERDATA={USERDATA}";
+        retVal.setValue("USERDATA", userData);
+        retVal.setCompanyID(session.getCompanyID());
+        Vector<UserProfile> rows = retVal.getDataSet(sql);
+        return (rows.size() > 0) ? rows.get(0) : null;
+    }
+
     
 /*
     static String USERCOURSESUMMARY=
@@ -758,6 +770,18 @@
 		return upLocation;
 	}
 
+	public Vector getUserGroups() {
+		return getUserGroups(-1);
+	}
+	public Vector<Group> getUserGroups(int groupTypeID) {
+		Group query = new Group();
+		query.setIntValue("COMPANYID", getCompanyID());
+		query.setGroupTypeID(groupTypeID);
+		query.setValue("USERPRID", getUserProfileID());
+		
+		return (Vector<Group>)query.getDataSet(LOOKUPUSERGROUPS+(groupTypeID != -1 ? "GROUPTYPEID={GROUPTYPEID}" : ""));
+	}
+
     public int getCoursesOpen(ILSSession ilsSession) {
         if (!isCourseSummaryDataLoaded) loadCourseSummaryData(ilsSession);
         return getIntValue("COURSESOPEN");
@@ -864,5 +888,52 @@
         Utils.closeMailConnection();
         return results.size();
     }
+
+	public String toXML() {
+		return toXML(DETAIL_COMPLETE);
+	}
+
+	public String toXML(int detail) {
+		StringBuffer xml = new StringBuffer();
+		xml.append("<userProfile userProfileID=\""+getUserProfileID()+"\"");
+		xml.append(" loginID=\""+getUserProfileNum()+"\"");
+		xml.append(" statusID=\""+getUserProfileStatusID()+"\"");
+		xml.append(" userData=\""+getStringValue("USERDATA")+"\"");
+		if (detail == DETAIL_HEADERONLY) {
+			xml.append("/>");
+		}
+		else {
+			xml.append(">");
+
+			xml.append("<firstName>").append(HTTPUtils.canonize(getUserProfileFirstName())).append("</firstName>");
+			xml.append("<middleName>").append(HTTPUtils.canonize(getUserProfileMiddleName())).append("</middleName>");
+			xml.append("<lastName>").append(HTTPUtils.canonize(getUserProfileLastName())).append("</lastName>");
+			xml.append("<employeeTitle>").append(getUserProfileEmployeeTitleID()).append("</employeeTitle>");
+			xml.append("<addr1>").append(HTTPUtils.canonize(getUserProfileAddr1())).append("</addr1>");
+			xml.append("<addr2>").append(HTTPUtils.canonize(getUserProfileAddr2())).append("</addr2>");
+			xml.append("<city>").append(HTTPUtils.canonize(getUserProfileCity())).append("</city>");
+			xml.append("<state>").append(HTTPUtils.canonize(getUserProfileState())).append("</state>");
+			xml.append("<zip>").append(HTTPUtils.canonize(getUserProfileZip())).append("</zip>");
+			xml.append("<country>").append(HTTPUtils.canonize(getUserProfileCountry())).append("</country>");
+			xml.append("<email>").append(HTTPUtils.canonize(getUserProfileEMail())).append("</email>");
+			xml.append("<phone>").append(HTTPUtils.canonize(getUserProfilePhone())).append("</phone>");
+			xml.append("<hireDate>").append(HTTPUtils.canonize(getUserProfileHireDate() != null ? getUserProfileHireDate().toString() : "")).append("</hireDate>");
+			xml.append("<termDate>").append(HTTPUtils.canonize(getUserProfileTermDate() != null ? getUserProfileTermDate().toString() : "")).append("</termDate>");
+			xml.append("<access level=\""+getUserProfileAccessLevel()+"\" mode=\""+getUserProfileAccessMode()+"\"/>");
+
+
+			if (detail == DETAIL_EXTRA) {
+				Vector<Group> groups = getUserGroups();
+				xml.append("<groups count=\""+groups.size()+"\">");
+				for (Group g : groups) {
+					xml.append(g.toXML(DETAIL_HEADERONLY));
+				}
+				xml.append("</groups>");
+			}
+
+			xml.append("</userProfile>");
+		}
+		return xml.toString();
+	}
     
 }

Modified: branches/1.6/webapp/WEB-INF/lib/ils.jar
===================================================================
(Binary files differ)

Modified: branches/1.6/webapp/api/group/get/index.jsp
===================================================================
--- branches/1.6/webapp/api/group/get/index.jsp	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/webapp/api/group/get/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -3,109 +3,88 @@
     contentType="text/html;charset=utf-8"
 %>
 <%@ page trimDirectiveWhitespaces="true" %>
-<%@ page import="org.crosswire.utils.HTTPUtils" %>
-<%@ page import="org.crosswire.xml.XMLBlock" %>
 <%@ page import="com.resolutions.ils.Utils" %>
 <%@ page import="com.resolutions.ils.ILSSession" %>
-<%@ page import="com.resolutions.ils.data.UserProfile" %>
 <%@ page import="com.resolutions.ils.data.Company" %>
 <%@ page import="com.resolutions.ils.data.Group" %>
 <%@ page import="java.util.Vector" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.util.TimeZone" %>
-<%@ page import="java.io.File" %>
-<%@ page import="java.net.URL" %>
-<%@ page import="java.util.Properties" %>
-<%@ page import="java.text.SimpleDateFormat" %>
 <%@ page import="org.apache.log4j.Logger" %>
 
 <%
-
+	// standard service header ---------------------------------------
 	response.setContentType("text/xml");
-	String errorMsg = "";
-	//-- Company logic from login.jsp -------
-	// TODO: consolidate this somewhere
-	String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
-	String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
-	if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
-	if (co == null) co = request.getParameter("co");
-	if (co != null) session.setAttribute("co", co);
-	co = (String) session.getAttribute("co");
-	Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
-
+	int errCode = 0;
+	Company company = Company.getCompany(request);
+    
 	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
+	++errCode;
 	if (!apiEnabled) {
-		out.print("<error message=\"API not enabled in system management settings.\" />");
-	return;
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
+		return;
 	}
-	//-----------------------
-	ILSSession ilsSession = null;
+
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
-	ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
 	if (ilsSession == null) {
-		out.print("<error message=\"Your iLS sign in information is not valid. Please try again.\" />");
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
+	// end standard service header -----------------------------------
+
+
+	String errorMsg = "";
     
 	int groupID = -2; try { groupID = Integer.parseInt(request.getParameter("groupID")); } catch (Exception e) {}
 	if (groupID == -2) if ("ALL".equals(request.getParameter("groupID"))) groupID = -1;
 	int groupTypeID = -1; try { groupTypeID = Integer.parseInt(request.getParameter("groupTypeID")); } catch (Exception e) {}
 	String groupName = request.getParameter("groupName");
+	String userData = request.getParameter("userData");
+
 	String detail = request.getParameter("detail");
 
 	Logger logger = Logger.getLogger(this.getClass());
 	Logger eventsLogger = Logger.getLogger("EVENTS");
 	String statusMsg = "";
-	SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmm");
-	df.setTimeZone(TimeZone.getTimeZone("GMT"));
-	SimpleDateFormat df_out = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
-	df_out.setTimeZone(TimeZone.getTimeZone("GMT"));
 
-	if (groupTypeID > -1 &&(groupID > -2 || groupName != null)) {
+	if (groupTypeID > -1 && (groupID > -2 || groupName != null || userData != null)) {
 		Vector<Group> groups = null;
 		if (groupID == -1) groups = Group.getAllGroups(ilsSession, groupTypeID);
 		else {
 			groups = new Vector<Group>();
-			if (groupID > -1) try { groups.add((Group)Group.getGroup(ilsSession, groupID)); } catch (Exception e) {}
-			else if (groupName != null) try { groups.add((Group)Group.getGroupByName(ilsSession, groupTypeID, groupName)); } catch (Exception e) {}
+			if (groupID > -1) try { Group g = Group.getGroup(ilsSession, groupID); if (g != null) groups.add(g); } catch (Exception e) {}
+			else if (groupName != null) try { Group g = Group.getGroupByName(ilsSession, groupTypeID, groupName); if (g != null) groups.add(g); } catch (Exception e) {}
+			else if (userData != null) try { Group g = Group.getGroupByUserData(ilsSession, groupTypeID, userData); if (g != null) groups.add(g); } catch (Exception e) {}
 		}
-		out.print("<Groups count=\""+groups.size()+"\">\n");
-		for (Object o : groups) {
-			Group g = (Group)o;
-			XMLBlock x = new XMLBlock(g.toFormattedXML());
-			if ("user".equals(detail)) {
-				XMLBlock users = x.createBlock("Users");
-				int count = 0;
-				for (Object o2 : g.getGroupUsers()) {
-					UserProfile u = (UserProfile)o2;
-					XMLBlock ux = users.createBlock("User");
-					ux.setAttribute("userID", Integer.toString(u.getUserProfileID()));
-					ux.setAttribute("statusID", Integer.toString(u.getUserProfileStatusID()));
-					++count;
-				}
-				users.setAttribute("count", Integer.toString(count));
-			}
-			out.print(x.toString());
+		out.print("<groups count=\""+groups.size()+"\">\n");
+		for (Group g : groups) {
+			out.print(g.toXML(("extra".equals(detail))?g.DETAIL_EXTRA:g.DETAIL_COMPLETE));
 		}
-		out.print("</Groups>\n");
+		out.print("</groups>\n");
 		return;
 	}
 
 	response.setContentType("text/html");
 %>
 <html>
+<style>th { text-align:left; }</style>
 <body>
 <h1>group/get</h1>
 <p>Retrieve Groups</p>
 <h3>Parameters</h3>
 <table border="1">
-<tr><td><b>groupTypeID</b></td><td>GroupTypeID to retrieve; required. default groups {1 - ROLE; 2 - WORKGROUP}</td></tr>
-<tr><td><b>groupID</b></td><td>GroupID to retrieve; ALL, for all groups</td></tr>
-<tr><td><b>groupName</b></td><td>Group Name to retrieve</td></tr>
-<tr><td><b>detail</b></td><td>{user - include user info}</td></tr>
-<tr><td><b>ILSUSER</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
-<tr><td><b>ILSPASSWD</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+<tbody>
+<tr><th>groupTypeID</th><td>GroupTypeID to retrieve; required. default groups {1 - ROLE; 2 - WORKGROUP}</td></tr>
+<tr><th>groupID</th><td>GroupID to retrieve; ALL, for all groups</td></tr>
+<tr><th>groupName</th><td>Group Name to retrieve</td></tr>
+<tr><th>userData</th><td>Group to retrieve by 3rd party user data</td></tr>
+<tr><th>detail</th><td>{extra - include userProfile info}</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>
 <table>
 </body>
 </html>

Deleted: branches/1.6/webapp/api/group/put/index.jsp
===================================================================
--- trunk/webapp/api/group/put/index.jsp	2015-06-08 03:24:58 UTC (rev 1322)
+++ branches/1.6/webapp/api/group/put/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -1,155 +0,0 @@
-<%@ page language="java" contentType="text/xml;charset=utf-8" %>
-<%@ page trimDirectiveWhitespaces="true" %>
-<%@ page import="com.resolutions.ils.Utils" %>
-<%@ page import="com.resolutions.ils.ILSSession" %>
-<%@ page import="com.resolutions.ils.data.Company" %>
-<%@ page import="com.resolutions.ils.data.Group" %>
-<%@ page import="com.resolutions.ils.data.UserProfile" %>
-<%@ page import="org.apache.log4j.Logger" %>
-
-<%
-	// standard service header ---------------------------------------
-	response.setContentType("text/xml");
-	int errCode = 0;
-	Company company = Company.getCompany(request);
-    
-	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
-	++errCode;
-	if (!apiEnabled) {
-		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
-		return;
-	}
-
-	String userID = request.getParameter("ILSUSER");
-	String userPw = request.getParameter("ILSPASSWD");
-	ILSSession ilsSession = (userID != null && userPw != null)
-			? ILSSession.login(company.getCompanyName(), userID, userPw)
-			: (ILSSession)session.getAttribute("ilsSession");
-	++errCode;
-	if (ilsSession == null) {
-		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
-		return;
-	}
-	// end standard service header -----------------------------------
-
-
-	int groupID  = -1; try { groupID = Integer.parseInt(request.getParameter("groupID")); } catch(Exception e) {}
-	int groupTypeID  = -1; try { groupTypeID = Integer.parseInt(request.getParameter("groupTypeID")); } catch(Exception e) {}
-	String userData   = request.getParameter("userData");
-	String groupName  = request.getParameter("groupName");
-
-// one of these must be supplied; otherwise, show usage info
-if (groupID != -1 || groupName != null || userData != null) {
-	String errMsg = "";
-
-	UserProfile adminUser = ilsSession.getCurrentUserProfile();
-
-	Logger logger         = Logger.getLogger(this.getClass());
-	Logger eventsLogger   = Logger.getLogger("EVENTS");
-	Group current   = new Group();
-	current.defaultAll();
-	boolean createMode    = "create".equals(request.getParameter("action"));
-
-	++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);
-			}
-			else if (userData != null) {
-				current = Group.getGroupByUserData(ilsSession, groupTypeID, userData);
-			}
-		}
-	}
-	else {
-		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;
-	}
-	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;
-	}
-
-	Group orig = (Group)current.clone();
-
-	// set associated external data, typically used for API client to map this user back to their system
-	if (userData != null && userData.length() > 0) current.setValue("USERDATA", userData);
-
-	if (groupName != null && groupName.trim().length() > 0) current.setGroupName(groupName);
-	String val = request.getParameter("groupDescription");
-	if (val != null && val.trim().length() > 0) current.setGroupDescription(val);
-	if (groupTypeID > -1) current.setGroupTypeID(groupTypeID);
-
-	++errCode;
-	if ((current.getGroupName() == null) || (current.getGroupName().length() < 1)) {
-		errMsg = "You must supply a Group Name (groupName)";
-		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
-		return;
-	}
-	++errCode;
-	if ((current.getGroupTypeID() < 1)) {
-		errMsg = "You must supply a Group Type ID (groupTypeID)";
-		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
-		return;
-	}
-
-	if (orig.getGroupID() > 0) {
-		current.save(orig);
-	}
-	else {
-		current = current.saveNew(ilsSession);
-	}
-%>
-<success groupID="<%=current.getGroupID()%>"/>
-<%
-	return;
-
-}
-response.setContentType("text/html");
-%>
-<html>
-<style>th { text-align:left; }</style>
-<body>
-<h1>group/put</h1>
-<p>Create or modify a group record</p>
-<h3>Parameters</h3>
-<table border="1">
-<tbody>
-<tr><th>groupID</th><td>The record to modify.  Either this parameter, or userData can be supplied to update an existing record. This order of precedence is used. If more than one of these is supplied, the subsequent parameter is used as an update field for the record.</td></tr>
-<tr><th>action</th><td>(optional) [update|create] If not supplied, action is determined by: <ul><li>if groupID is supplied, action is update.</li><li>if a record is found by using userData, action is update.</li><li>otherwise, action is create.</li></ul></td></tr>
-<tr><th>userData</th><td>3rd-party supplied record identifier</td></tr>
-<tr><th>groupTypeID</th><td>Group Type ID. default groups {1 - ROLE; 2 - WORKGROUP}</td></tr>
-<tr><th>groupName</th><td>Group Name</td></tr>
-<tr><th>groupDescription</th><td>Group Description</td></tr>
-<tr><th>lastName</th><td>Last Name</td></tr>
-<tr><th>employeeTitle</th><td>Employee Title ID {unfinished, will lookup by title string in the future}</td></tr>
-<tr><th>addr1</th><td>Address, Line 1</td></tr>
-<tr><th>addr2</th><td>Address, Line 2</td></tr>
-<tr><th>city</th><td>City</td></tr>
-<tr><th>state</th><td>State</td></tr>
-<tr><th>zip</th><td>Postal Code</td></tr>
-<tr><th>country</th><td>Country</td></tr>
-<tr><th>email</th><td>EMail Address</td></tr>
-<tr><th>phone</th><td>Phone Number</td></tr>
-<tr><th>hireDate</th><td>Date Hired</td></tr>
-<tr><th>termDate</th><td>Date Terminated</td></tr>
-<tr><th>accessLevel</th><td>User Access Level</td></tr>
-<tr><th>accessMode</th><td>User Access Mode</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>
-</table>
-</body>
-</html>
-

Copied: branches/1.6/webapp/api/group/put/index.jsp (from rev 1322, trunk/webapp/api/group/put/index.jsp)
===================================================================
--- branches/1.6/webapp/api/group/put/index.jsp	                        (rev 0)
+++ branches/1.6/webapp/api/group/put/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -0,0 +1,169 @@
+<%@ page language="java" contentType="text/xml;charset=utf-8" %>
+<%@ page trimDirectiveWhitespaces="true" %>
+<%@ page import="com.resolutions.ils.Utils" %>
+<%@ page import="com.resolutions.ils.ILSSession" %>
+<%@ page import="com.resolutions.ils.data.Company" %>
+<%@ page import="com.resolutions.ils.data.Group" %>
+<%@ page import="com.resolutions.ils.data.UserProfile" %>
+<%@ page import="org.apache.log4j.Logger" %>
+
+<%
+	// standard service header ---------------------------------------
+	response.setContentType("text/xml");
+	int errCode = 0;
+	Company company = Company.getCompany(request);
+    
+	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
+	++errCode;
+	if (!apiEnabled) {
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
+		return;
+	}
+
+	String userID = request.getParameter("ILSUSER");
+	String userPw = request.getParameter("ILSPASSWD");
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
+	if (ilsSession == null) {
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
+		return;
+	}
+	// end standard service header -----------------------------------
+
+
+	int groupID  = -1; try { groupID = Integer.parseInt(request.getParameter("groupID")); } catch(Exception e) {}
+	int groupTypeID  = -1; try { groupTypeID = Integer.parseInt(request.getParameter("groupTypeID")); } catch(Exception e) {}
+	String userData   = request.getParameter("userData");
+	String groupName  = request.getParameter("groupName");
+
+// one of these must be supplied; otherwise, show usage info
+if (groupID != -1 || groupName != null || userData != null) {
+	String errMsg = "";
+
+	UserProfile adminUser = ilsSession.getCurrentUserProfile();
+
+	Logger logger         = Logger.getLogger(this.getClass());
+	Logger eventsLogger   = Logger.getLogger("EVENTS");
+	Group current   = new Group();
+	current.defaultAll();
+	boolean createMode    = "create".equals(request.getParameter("action"));
+
+	++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);
+			}
+			else if (userData != null) {
+				current = Group.getGroupByUserData(ilsSession, groupTypeID, userData);
+			}
+		}
+	}
+	else {
+		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;
+	}
+	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;
+	}
+
+	Group orig = (Group)current.clone();
+
+	// set associated external data, typically used for API client to map this user back to their system
+	if (userData != null && userData.length() > 0) current.setValue("USERDATA", userData);
+
+	if (groupName != null && groupName.trim().length() > 0) current.setGroupName(groupName);
+	String val = request.getParameter("groupDescription");
+	if (val != null && val.trim().length() > 0) current.setGroupDescription(val);
+	if (groupTypeID > -1) current.setGroupTypeID(groupTypeID);
+
+	++errCode;
+	if ((current.getGroupName() == null) || (current.getGroupName().length() < 1)) {
+		errMsg = "You must supply a Group Name (groupName)";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
+	}
+	++errCode;
+	if ((current.getGroupTypeID() < 1)) {
+		errMsg = "You must supply a Group Type ID (groupTypeID)";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
+	}
+
+	int updateCount = -1;
+	if (orig.getGroupID() > 0) {
+		current.save(orig);
+		int statusID = -1; try { statusID = Integer.parseInt(request.getParameter("allMembersSetStatusID")); } catch (Exception e) {}
+		if (statusID != -1) {
+			updateCount = 0;
+			for (UserProfile u : current.getGroupUsers()) {
+				UserProfile uorig = (UserProfile)u.clone();
+				if (u.getUserProfileStatusID() != statusID) {
+					u.setUserProfileStatusID(statusID);
+					u.save(ilsSession, uorig);
+					++updateCount;
+				}
+			}
+		}
+	}
+	else {
+		current = current.saveNew(ilsSession);
+	}
+%>
+<success groupID="<%=current.getGroupID()%>"<%= updateCount > -1 ? (" membersUpdated=\""+updateCount+"\"") : ""%>/>
+<%
+	return;
+
+}
+response.setContentType("text/html");
+%>
+<html>
+<style>th { text-align:left; }</style>
+<body>
+<h1>group/put</h1>
+<p>Create or modify a group record</p>
+<h3>Parameters</h3>
+<table border="1">
+<tbody>
+<tr><th>groupID</th><td>The record to modify.  Either this parameter, or userData can be supplied to update an existing record. This order of precedence is used. If more than one of these is supplied, the subsequent parameter is used as an update field for the record.</td></tr>
+<tr><th>action</th><td>(optional) [update|create] If not supplied, action is determined by: <ul><li>if groupID is supplied, action is update.</li><li>if a record is found by using userData, action is update.</li><li>otherwise, action is create.</li></ul></td></tr>
+<tr><th>userData</th><td>3rd-party supplied record identifier</td></tr>
+<tr><th>groupTypeID</th><td>Group Type ID. default groups {1 - ROLE; 2 - WORKGROUP}</td></tr>
+<tr><th>groupName</th><td>Group Name</td></tr>
+<tr><th>groupDescription</th><td>Group Description</td></tr>
+<tr><th>lastName</th><td>Last Name</td></tr>
+<tr><th>employeeTitle</th><td>Employee Title ID {unfinished, will lookup by title string in the future}</td></tr>
+<tr><th>addr1</th><td>Address, Line 1</td></tr>
+<tr><th>addr2</th><td>Address, Line 2</td></tr>
+<tr><th>city</th><td>City</td></tr>
+<tr><th>state</th><td>State</td></tr>
+<tr><th>zip</th><td>Postal Code</td></tr>
+<tr><th>country</th><td>Country</td></tr>
+<tr><th>email</th><td>EMail Address</td></tr>
+<tr><th>phone</th><td>Phone Number</td></tr>
+<tr><th>hireDate</th><td>Date Hired</td></tr>
+<tr><th>termDate</th><td>Date Terminated</td></tr>
+<tr><th>accessLevel</th><td>User Access Level</td></tr>
+<tr><th>accessMode</th><td>User Access Mode</td></tr>
+<tr><th>allMembersSetStatusID</th><td>Sets the statusID for all User Profiles in this 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>
+</table>
+</body>
+</html>
+

Modified: branches/1.6/webapp/api/user/edit/index.jsp
===================================================================
--- branches/1.6/webapp/api/user/edit/index.jsp	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/webapp/api/user/edit/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -17,199 +17,228 @@
 <%@ page import="org.apache.log4j.Logger" %>
 
 <%
-    boolean apiEnabled = "on".equals(Utils.getSysConfig(session).getProperty("APIEnable", "off"));
+	int errCode = 0;
+	response.setContentType("text/xml");
+	boolean apiEnabled = "on".equals(Utils.getSysConfig(session).getProperty("APIEnable", "off"));
+	++errCode;
 	if (!apiEnabled) {
-		out.print("API not enabled in system management settings.");
+%>
+		<error code="<%=errCode%>" message="API not enabled in system management settings."/>
+<%
 		return;
 	}
 	String errorMsg = "";
-	//-- Company logic from login.jsp -------
-	// TODO: consolidate this somewhere
-    String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
-    String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
-    if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
-    if (co == null) co = request.getParameter("co");
-    if (co != null) session.setAttribute("co", co);
-    co = (String) session.getAttribute("co");
-    Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
-    //-----------------------
-    ILSSession ilsSession = null;
-    String userID = request.getParameter("ILSUSER");
-    String userPw = request.getParameter("ILSPASSWD");
-    ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
-    if (ilsSession == null) {
-    	out.print("Your iLS sign in information is not valid. Please try again.");
-        return;
-    }
-    UserProfile user = ilsSession.getCurrentUserProfile();
+
+	Company company = Utils.getCompany(request);
+
+	ILSSession ilsSession = null;
+	String userID = request.getParameter("ILSUSER");
+	String userPw = request.getParameter("ILSPASSWD");
+	ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
+	++errCode;
+	if (ilsSession == null) {
+%>
+		<error code="<%=errCode%>" message="Your iLS sign in information is not valid. Please try again."/>
+<%
+		return;
+	}
+
+	UserProfile user = ilsSession.getCurrentUserProfile();
     
 	Logger logger = Logger.getLogger(this.getClass());
 	Logger eventsLogger = Logger.getLogger("EVENTS");
-    String statusMsg = "";
-    SimpleDateFormat df  = new SimpleDateFormat("MM/dd/yyyy");
+	SimpleDateFormat df  = new SimpleDateFormat("MM/dd/yyyy");
 
-    String tmpBuf = request.getParameter("USERPRNUM");
-    if (tmpBuf == null) {
-		out.print("Must specify a USERPRNUM to edit.");
-		return;
-    }
-    
-    int profileID = -1;
-    UserProfile current = null;
-    try {
-	    if ((user.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (user.hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
-			current = UserProfile.getUserProfile(ilsSession, tmpBuf);
-	    }
-    }
-    catch (Exception e) { logger.error(e, e); }
-    
-    if (current == null) {
-		out.print("USERPRNUM supplied does not exist in iLS.");
-		return;
-    }
-    
-    UserProfile orig = (UserProfile)current.clone();
-    int currentRoleID = -1;
-    int currentLocationID = -1;
+	String userPrID = request.getParameter("USERPRID");
+	String userPrNum = request.getParameter("USERPRNUM");
+	String userData = request.getParameter("USERDATA");
 
-	String val = request.getParameter("ILSGROUPROLE");
-	int requestedRole = -1;
-	if (val != null && val.trim().length() > 0) {
-		Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_ROLE, val);
-		if (g != null) {
-			requestedRole = g.getGroupID();
+	if (userPrID != null || userPrNum != null || userData != null) {
+
+		int profileID = -1;
+		UserProfile current = null;
+		try {
+			if ((user.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (user.hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
+				if (userPrID != null) {
+			
+					current = UserProfile.getUserProfile(ilsSession, userPrID);
+				} else if (userPrNum != null) {
+					current = UserProfile.getUserProfile(ilsSession, userPrNum);
+				} else if (userData != null) {
+				}
+			}
 		}
-		else {
-	    	out.print("ILSGROUPROLE was submitted but was not found in the database. ILSGROUPROLE must be the name of a valid Role or CREATEGROUPONDEMAND must be passed as 'true'.");
-	        return;
+		catch (Exception e) { logger.error(e, e); }
+
+		++errCode;
+		if (current == null) {
+%>
+			<error code="<%=errCode%>" message="Could not find specified user using USERPRID|USERPRNUM|USERDATA."/>
+<%
+			return;
 		}
-	}
-	val = request.getParameter("ILSGROUPLOCATION");
-	int requestedLocation = -1;
-	if (val != null && val.trim().length() > 0) {
-		Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, val);
-		if (g != null) {
-			requestedLocation = g.getGroupID();
+
+		UserProfile orig = (UserProfile)current.clone();
+		int currentRoleID = -1;
+		int currentLocationID = -1;
+
+		String val = request.getParameter("ILSGROUPROLE");
+		int requestedRole = -1;
+		if (val != null && val.trim().length() > 0) {
+			Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_ROLE, val);
+			if (g != null) {
+				requestedRole = g.getGroupID();
+			}
+			else {
+			out.print("ILSGROUPROLE was submitted but was not found in the database. ILSGROUPROLE must be the name of a valid Role or CREATEGROUPONDEMAND must be passed as 'true'.");
+			return;
+			}
 		}
-		else {
-	    	out.print("ILSGROUPLOCATION was submitted but was not found in the database. ILSGROUPLOCATION must be the name of a valid Location or CREATEGROUPONDEMAND must be passed as 'true'.");
-	        return;
+		val = request.getParameter("ILSGROUPLOCATION");
+		int requestedLocation = -1;
+		if (val != null && val.trim().length() > 0) {
+			Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, val);
+			if (g != null) {
+				requestedLocation = g.getGroupID();
+			}
+			else {
+			out.print("ILSGROUPLOCATION was submitted but was not found in the database. ILSGROUPLOCATION must be the name of a valid Location or CREATEGROUPONDEMAND must be passed as 'true'.");
+			return;
+			}
 		}
-	}
 
 
-        // set associated external data, typically used for API client to map this user back to their system
-        val = request.getParameter("USERDATA");
-        if (val != null && val.trim().length() > 0) current.setValue("USERDATA", val);
-        
-        val = request.getParameter("USERPRPASSWD");
-        if (val != null && val.trim().length() > 0) current.setUserProfilePasswd(val);
-        val = request.getParameter("USERPRSTATUSID");
-        try { if (val != null && val.trim().length() > 0) current.setUserProfileStatusID(Integer.parseInt(val)); } catch (Exception e) {}
-        val = request.getParameter("USERPRACCESSLEVEL");
-        try { if (val != null && val.trim().length() > 0) current.setUserProfileAccessLevel(Integer.parseInt(val)); } catch (Exception e) {}
-        val = request.getParameter("USERPRFNAME");
-        if (val != null && val.trim().length() > 0) current.setUserProfileFirstName(val);
-        val = request.getParameter("USERPRLNAME");
-        if (val != null && val.trim().length() > 0) current.setUserProfileLastName(val);
-        val = request.getParameter("empTitle");
-        if (val != null && val.trim().length() > 0) current.setUserProfileEmployeeTitleID(Integer.parseInt(val));
-        val = request.getParameter("addr1");
-        if (val != null && val.trim().length() > 0) current.setUserProfileAddr1(val);
-        val = request.getParameter("addr2");
-        if (val != null && val.trim().length() > 0) current.setUserProfileAddr2(val);
-        val = request.getParameter("city");
-        if (val != null && val.trim().length() > 0) current.setUserProfileCity(val);
-        val = request.getParameter("state");
-        if (val != null && val.trim().length() > 0) current.setUserProfileState(val);
-        val = request.getParameter("zip");
-        if (val != null && val.trim().length() > 0) current.setUserProfileZip(val);
-        val = request.getParameter("country");
-        if (val != null && val.trim().length() > 0) current.setUserProfileCountry(val);
-        val = request.getParameter("USERPREMAIL");
-        if (val != null && val.trim().length() > 0) current.setUserProfileEMail(val);
-        val = request.getParameter("phone");
-        if (val != null && val.trim().length() > 0) current.setUserProfilePhone(val);
-        val = request.getParameter("USERPRHIREDATE");
-        current.setUserProfileHireDate(new Date());
-        if ((val != null && val.trim().length() > 0) && (!val.startsWith("m"))) {
-            Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
-            if (v != null) {
-                current.setUserProfileHireDate(v);
-            }
-            else {
-                errorMsg = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
-            }
-        }
-        val = request.getParameter("USERPRTERMDATE");
-        if ((val != null) && (!val.startsWith("m"))) {
-            Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
-            if (v != null) {
-                current.setUserProfileTermDate(v);
-            }
-            else {
-                errorMsg = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
-            }
-        }
-        if ((current.getUserProfilePasswd() == null) || (current.getUserProfilePasswd().trim().length() < 1)) {
-            current.setUserProfilePasswd("changeme");
-        }
+		// set associated external data, typically used for API client to map this user back to their system
+		val = request.getParameter("USERDATA");
+		if (val != null && val.trim().length() > 0) current.setValue("USERDATA", val);
 
-        if (errorMsg.length() > 0) {
-            // we already have an error
-        }
-        else if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
-          errorMsg = "You must supply a First Name (USERPRFNAME)";
-        }
-        else if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
-          errorMsg = "You must supply a Last Name (USERPRLNAME)";
-        }
-        else if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
-            errorMsg = "You must supply an Employee ID (USERPRNUM)";
-        }
-        /*
-        else if (currentRoleID < 0 && requestedRole < 0) {
-            errorMsg = "You must choose a Role for this employee";
-        }
-        else if (currentLocationID < 0 && requestedLocation < 0) {
-            errorMsg = "You must choose a Workgroup for this employee";
-        }
-        */
-//        else if (current.getUserProfileEmployeeTitleID() < 1) {
-//            errorMsg = "You must supply an Employee Title";
-//        }
-        if (errorMsg.length() < 1) {
-            if (orig.getUserProfileID() > 0) {
-			    boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
-		   		HttpSession sendEmail = (emailNotice) ? session : null;
-	            current.save(ilsSession, orig, sendEmail);
-            }
-            else {
-                current = current.saveNew(ilsSession);
-                profileID = current.getUserProfileID();
-            }
-            if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
-                Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
-                Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
-                // modifying an existing user
-                if (orig.getUserProfileID() > 0) {
-                	eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
-                }
-            }
-            if ((requestedLocation != currentLocationID) && (requestedLocation > -1)) {
-                Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
-                Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
-                if (orig.getUserProfileID() > 0) {
-                	eventsLogger.info("User " + current.getUserProfileNum() + " WORKGROUP changed from " + currentLocationID + " to " + requestedLocation + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
-                }
-            }
-            current = ilsSession.getCurrentUserProfile();
-            if (profileID != current.getUserProfileID()) {
-                current = UserProfile.getUserProfile(ilsSession, profileID);
-            }
-            %>OK<%
-        }
-        else {
-        	%><%= errorMsg %><%
-        }
+		val = request.getParameter("USERPRPASSWD");
+		if (val != null && val.trim().length() > 0) current.setUserProfilePasswd(val);
+		val = request.getParameter("USERPRSTATUSID");
+		try { if (val != null && val.trim().length() > 0) current.setUserProfileStatusID(Integer.parseInt(val)); } catch (Exception e) {}
+		val = request.getParameter("USERPRACCESSLEVEL");
+		try { if (val != null && val.trim().length() > 0) current.setUserProfileAccessLevel(Integer.parseInt(val)); } catch (Exception e) {}
+		val = request.getParameter("USERPRFNAME");
+		if (val != null && val.trim().length() > 0) current.setUserProfileFirstName(val);
+		val = request.getParameter("USERPRLNAME");
+		if (val != null && val.trim().length() > 0) current.setUserProfileLastName(val);
+		val = request.getParameter("empTitle");
+		if (val != null && val.trim().length() > 0) current.setUserProfileEmployeeTitleID(Integer.parseInt(val));
+		val = request.getParameter("addr1");
+		if (val != null && val.trim().length() > 0) current.setUserProfileAddr1(val);
+		val = request.getParameter("addr2");
+		if (val != null && val.trim().length() > 0) current.setUserProfileAddr2(val);
+		val = request.getParameter("city");
+		if (val != null && val.trim().length() > 0) current.setUserProfileCity(val);
+		val = request.getParameter("state");
+		if (val != null && val.trim().length() > 0) current.setUserProfileState(val);
+		val = request.getParameter("zip");
+		if (val != null && val.trim().length() > 0) current.setUserProfileZip(val);
+		val = request.getParameter("country");
+		if (val != null && val.trim().length() > 0) current.setUserProfileCountry(val);
+		val = request.getParameter("USERPREMAIL");
+		if (val != null && val.trim().length() > 0) current.setUserProfileEMail(val);
+		val = request.getParameter("phone");
+		if (val != null && val.trim().length() > 0) current.setUserProfilePhone(val);
+		val = request.getParameter("USERPRHIREDATE");
+		current.setUserProfileHireDate(new Date());
+		if ((val != null && val.trim().length() > 0) && (!val.startsWith("m"))) {
+		    Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
+		    if (v != null) {
+			current.setUserProfileHireDate(v);
+		    }
+		    else {
+			errorMsg = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
+		    }
+		}
+		val = request.getParameter("USERPRTERMDATE");
+		if ((val != null) && (!val.startsWith("m"))) {
+		    Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
+		    if (v != null) {
+			current.setUserProfileTermDate(v);
+		    }
+		    else {
+			errorMsg = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
+		    }
+		}
+		if ((current.getUserProfilePasswd() == null) || (current.getUserProfilePasswd().trim().length() < 1)) {
+		    current.setUserProfilePasswd("changeme");
+		}
+
+		if (errorMsg.length() > 0) {
+		    // we already have an error
+		}
+		else if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
+		  errorMsg = "You must supply a First Name (USERPRFNAME)";
+		}
+		else if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
+		  errorMsg = "You must supply a Last Name (USERPRLNAME)";
+		}
+		else if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
+		    errorMsg = "You must supply an Employee ID (USERPRNUM)";
+		}
+		/*
+		else if (currentRoleID < 0 && requestedRole < 0) {
+		    errorMsg = "You must choose a Role for this employee";
+		}
+		else if (currentLocationID < 0 && requestedLocation < 0) {
+		    errorMsg = "You must choose a Workgroup for this employee";
+		}
+		*/
+		//        else if (current.getUserProfileEmployeeTitleID() < 1) {
+		//            errorMsg = "You must supply an Employee Title";
+		//        }
+		if (errorMsg.length() < 1) {
+		    if (orig.getUserProfileID() > 0) {
+				    boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
+					HttpSession sendEmail = (emailNotice) ? session : null;
+			    current.save(ilsSession, orig, sendEmail);
+		    }
+		    else {
+			current = current.saveNew(ilsSession);
+			profileID = current.getUserProfileID();
+		    }
+		    if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
+			Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
+			Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
+			// modifying an existing user
+			if (orig.getUserProfileID() > 0) {
+				eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
+			}
+		    }
+		    if ((requestedLocation != currentLocationID) && (requestedLocation > -1)) {
+			Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
+			Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
+			if (orig.getUserProfileID() > 0) {
+				eventsLogger.info("User " + current.getUserProfileNum() + " WORKGROUP changed from " + currentLocationID + " to " + requestedLocation + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
+			}
+		    }
+		    current = ilsSession.getCurrentUserProfile();
+		    if (profileID != current.getUserProfileID()) {
+			current = UserProfile.getUserProfile(ilsSession, profileID);
+		    }
+		    %>OK<%
+		}
+		else {
+			%><%= errorMsg %><%
+		}
+		return;
+	}
+	response.setContentType("text/html");
 %>
+<html>
+<style>th { text-align:left; }</style>
+<body>
+<h1>user/edit</h1>
+<p>Change one or more fields of an existing user profile record</p>
+<h3>Parameters</h3>
+<table border="1">
+<tr><th>USERPRID</th><td>The record to modify.  Either this parameter, USERPRNUM, or USERDATA must be supplied. This order of precedence is used. If more than one is supplied, the subsequent parameters are used to edit the record.</td></tr>
+<tr><th>USERPRNUM</th><td>User login name</td></tr>
+<tr><th>USERDATA</th><td>3rd-party supplied record identifier</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>
+<table>
+</body>
+</html>
+

Modified: branches/1.6/webapp/api/user/get/index.jsp
===================================================================
--- branches/1.6/webapp/api/user/get/index.jsp	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/webapp/api/user/get/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -1,86 +1,98 @@
 <%@ page language="java" contentType="text/xml;charset=utf-8" %>
 <%@ page trimDirectiveWhitespaces="true" %>
-<%@ page import="org.crosswire.utils.HTTPUtils" %>
 <%@ page import="com.resolutions.ils.Utils" %>
 <%@ page import="com.resolutions.ils.ILSSession" %>
 <%@ page import="com.resolutions.ils.data.UserProfile" %>
 <%@ page import="com.resolutions.ils.data.Company" %>
-<%@ page import="com.resolutions.ils.data.CourseAttempt" %>
-<%@ page import="java.util.Vector" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.util.TimeZone" %>
-<%@ page import="java.io.File" %>
-<%@ page import="java.net.URL" %>
-<%@ page import="java.util.Properties" %>
-<%@ page import="java.text.SimpleDateFormat" %>
 <%@ page import="org.apache.log4j.Logger" %>
 
 <%
-
+	// standard service header ---------------------------------------
+	response.setContentType("text/xml");
+	int errCode = 0;
 	Company company = Company.getCompany(request);
-	response.setContentType("text/xml");
-	String errorMsg = "";
-
+    
 	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
+	++errCode;
 	if (!apiEnabled) {
-		out.print("<error message=\"API not enabled in system management settings.\" />");
-	return;
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
+		return;
 	}
-	//-----------------------
-	ILSSession ilsSession = null;
+
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
-	ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
 	if (ilsSession == null) {
-		out.print("<error message=\"Your iLS sign in information is not valid. Please try again.\" />");
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
-    
+	// end standard service header -----------------------------------
+
+
+	int userProfileID  = -1; try { userProfileID = Integer.parseInt(request.getParameter("userProfileID")); } catch(Exception e) {}
+	String loginID     = request.getParameter("loginID");
+	String userData    = request.getParameter("userData");
+
+
+// one of these must be supplied; otherwise, show usage info
+if (userProfileID != -1 || loginID != null || userData != null) {
+
 	Logger logger = Logger.getLogger(this.getClass());
 	Logger eventsLogger = Logger.getLogger("EVENTS");
-	String statusMsg = "";
-	SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmm");
-	df.setTimeZone(TimeZone.getTimeZone("GMT"));
-	SimpleDateFormat df_out = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
-	df_out.setTimeZone(TimeZone.getTimeZone("GMT"));
 
-	UserProfile current = new UserProfile();
-	current.defaultAll();
-	int currentRoleID = -1;
-	int currentLocationID = -1;
-	int profileID = -1;
+	UserProfile current = null;
 
-	String val = request.getParameter("startDateTime");
-	Date startDateTime = null;
-	try { startDateTime = df.parse(val); } catch (Exception e) {}
-	if (startDateTime != null) {
-		val = request.getParameter("endDateTime");
-		Date endDateTime = null;
-		try { if (val != null) endDateTime = df.parse(val); } catch (Exception e) {
-			out.print("<error message=\"startDateTime must be passed and formatted as yyyyMMddhhmm\"/>");
-			return;
+	++errCode;
+	if ((ilsSession.getCurrentUserProfile().getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (ilsSession.getCurrentUserProfile().hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
+		if (userProfileID != -1) {
+			current = UserProfile.getUserProfile(ilsSession, userProfileID);
 		}
-
-		Vector cas = CourseAttempt.getCourseAttempts(ilsSession, startDateTime, endDateTime);
-		out.print("<CourseAttempts count=\""+cas.size()+"\" startDateTime=\""+df_out.format(startDateTime)+"\">\n");
-		for (Object o : cas) {
-			out.print(((CourseAttempt)o).toFormattedXML());
+		else if (loginID != null) {
+			current = UserProfile.getUserProfile(ilsSession, loginID);
 		}
-		out.print("</CourseAttempts>\n");
+		else if (userData != null) {
+			current = UserProfile.getUserProfileByUserData(ilsSession, userData);
+		}
+	}
+	else {
+		out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
 		return;
 	}
-	response.setContentType("text/html");
+
+	++errCode;
+	if (current == null) {
+		out.print("<error code=\""+errCode+"\" message=\"User Profile not found.\"/>");
+		return;
+	}
+
+	String detail = request.getParameter("detail");
 %>
+<userProfiles count="1">
+<%= current.toXML(("extra".equals(detail))?current.DETAIL_EXTRA:current.DETAIL_COMPLETE)%>
+</userProfiles>
+<%
+	return;
+}
+response.setContentType("text/html");
+%>
 <html>
+<style>th { text-align:left; }</style>
 <body>
-<h1>courseattempt/get</h1>
-<p>Retrieve Course Attempt records</p>
+<h1>user/get</h1>
+<p>Retrieve a user profile record</p>
 <h3>Parameters</h3>
 <table border="1">
-<tr><td><b>startDateTime</b></td><td>the start of the date and time range for which to retrieve Course Attempt records, inclusive (yyyyMMddhhmm), e.g., 201201240000</td></tr>
-<tr><td><b>endDateTime</b></td><td>(optional) the end of the date and time range for which to retrieve Course Attempt records, exclusive (yyyyMMddhhmm), e.g., 201201250000</td></tr>
-<tr><td><b>ILSUSER</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
-<tr><td><b>ILSPASSWD</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
-<table>
+<tbody>
+<tr><th>userProfileID</th><td>User Profile ID</td></tr>
+<tr><th>loginID</th><td>User Login ID</td></tr>
+<tr><th>userData</th><td>3rd-party supplied record identifier</td></tr>
+<tr><td><b>detail</b></td><td>{extra - include group info}</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>
+</table>
 </body>
 </html>

Modified: branches/1.6/webapp/api/user/put/index.jsp
===================================================================
--- branches/1.6/webapp/api/user/put/index.jsp	2015-06-08 03:50:19 UTC (rev 1323)
+++ branches/1.6/webapp/api/user/put/index.jsp	2015-06-08 03:53:59 UTC (rev 1324)
@@ -10,24 +10,40 @@
 <%@ page import="org.apache.log4j.Logger" %>
 
 <%
-	String errorMsg = "";
+	// standard service header ---------------------------------------
+	response.setContentType("text/xml");
+	int errCode = 0;
 	Company company = Company.getCompany(request);
     
 	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
+	++errCode;
 	if (!apiEnabled) {
-		out.print("<error message=\"API not enabled in system management settings.\"/>");
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
 		return;
 	}
 
-	ILSSession ilsSession = null;
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
-	ilsSession    = ILSSession.login(company.getCompanyName(), userID, userPw);
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
 	if (ilsSession == null) {
-		out.print("<error messag=\"Your iLS sign in information is not valid.\"/>");
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
+	// end standard service header -----------------------------------
 
+
+	int userProfileID  = -1; try { userProfileID = Integer.parseInt(request.getParameter("userProfileID")); } catch(Exception e) {}
+	String loginID     = request.getParameter("loginID");
+	String userData    = request.getParameter("userData");
+
+
+// one of these must be supplied; otherwise, show usage info
+if (userProfileID != -1 || loginID != null || userData != null) {
+	String errMsg = "";
+
 	UserProfile adminUser = ilsSession.getCurrentUserProfile();
 
 	Logger logger         = Logger.getLogger(this.getClass());
@@ -36,31 +52,54 @@
 	SimpleDateFormat df   = new SimpleDateFormat("MM/dd/yyyy");
 	UserProfile current   = new UserProfile();
 	current.defaultAll();
+	// default access level is employee
+	current.setUserProfileAccessLevel(1);
+	current.setUserProfileHireDate(new Date());
 	int currentRoleID     = -1;
 	int currentLocationID = -1;
-	int profileID         = -1; try { profileID = Integer.parseInt(request.getParameter("profileID"); } catch(Exception e) {}
 	String roleName       = null;
 	String workgroupName  = null;
+	boolean createMode    = "create".equals(request.getParameter("action"));
 
-	if (profileID != -1) {
-		if ((adminUser.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
-			current = UserProfile.getUserProfile(ilsSession, profileID);
+	++errCode;
+	if ((adminUser.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER) || (adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW))) {
+		if (!createMode) {
+			if (userProfileID != -1) {
+				current = UserProfile.getUserProfile(ilsSession, userProfileID);
+			}
+			else if (loginID != null) {
+				current = UserProfile.getUserProfile(ilsSession, loginID);
+			}
+			else if (userData != null) {
+				current = UserProfile.getUserProfileByUserData(ilsSession, userData);
+			}
 		}
-		else {
-			out.print("<error messag=\"You don't have permission to edit this user.\"/>");
-			return;
-		}
 	}
+	else {
+		out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
+		return;
+	}
 
+	++errCode;
 	if (current == null) {
-		out.print("<error messag=\"User Profile ID not found.\"/>");
+		out.print("<error code=\""+errCode+"\" message=\"User Profile not found.\"/>");
 		return;
 	}
+	++errCode;
+	if (createMode && current.getUserProfileID() > 0) {
+		out.print("<error code=\""+errCode+"\" message=\"User Profile exists.\"/>");
+		return;
+	}
+	if (current.getUserProfileID() > 0 && adminUser.getUserProfileAccessLevel() <= UserProfile.ACCESS_MANAGER && !adminUser.hasAccess(UserProfile.ACCESS_MODE_USERPR_MODIFY_USER)) {
+		out.print("<error code=\""+errCode+"\" message=\"Permission denied to edit user profile.\"/>");
+		return;
+	}
 
-
 	boolean createGroupOnDemand = false; try { createGroupOnDemand = "true".equals(request.getParameter("createGroupOnDemand")); } catch (Exception e) {}
 	String val = request.getParameter("roleName");
 	int requestedRole = -1;
+
+	++errCode;
 	if (val != null && val.trim().length() > 0) {
 		for (int i = 0; i < 2; ++i) {
 			Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_ROLE, val);
@@ -80,12 +119,14 @@
 			        grp.saveNew(ilsSession);
 				}
 				else {
-					out.print("<error messasge=\"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=\"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.\"/>");
 					return;
 				}
 			}
 		}
 	}
+
+	++errCode;
 	val = request.getParameter("locationName");
 	int requestedLocation = -1;
 	if (val != null && val.trim().length() > 0) {
@@ -107,7 +148,7 @@
 			        grp.saveNew(ilsSession);
 				}
 				else {
-					out.print("<error 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=\"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.\"/>");
 					return;
 				}
 			}
@@ -115,11 +156,15 @@
 	}
 
 	UserProfile orig = (UserProfile)current.clone();
+
+	++errCode;
 	val = request.getParameter("loginID");
 	if (val != null && val.trim().length() > 0) {
 		UserProfile up = UserProfile.getUserProfile(ilsSession, val);
 		if ((up != null) && (up.getUserProfileID() != current.getUserProfileID())) {
-			errorMsg = "The Employee ID already exists.";
+			errMsg = "The Employee ID already exists.";
+			out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+			return;
 		}
 		else {
 			current.setUserProfileNum(val);
@@ -127,17 +172,19 @@
 	}
 
 	// set associated external data, typically used for API client to map this user back to their system
-	val = request.getParameter("userData");
-	if (val != null && val.trim().length() > 0) current.setValue("USERDATA", val);
+	if (userData != null && userData.length() > 0) current.setValue("USERDATA", userData);
 
 	val = request.getParameter("passwd");
 	if (val != null && val.trim().length() > 0) current.setUserProfilePasswd(val);
 	val = request.getParameter("statusID");
 	if (val != null && val.trim().length() > 0) current.setUserProfileStatusID(Integer.parseInt(val));
 
-	// default access level is employee
-	current.setUserProfileAccessLevel(1);
+	val = request.getParameter("accessLevel");
+	if (val != null && val.trim().length() > 0) current.setUserProfileAccessLevel(Integer.parseInt(val));
 
+	val = request.getParameter("accessMode");
+	if (val != null && val.trim().length() > 0) current.setUserProfileAccessMode(Integer.parseInt(val));
+
 	val = request.getParameter("firstName");
 	if (val != null && val.trim().length() > 0) current.setUserProfileFirstName(val);
 	val = request.getParameter("lastName");
@@ -161,16 +208,20 @@
 	val = request.getParameter("phone");
 	if (val != null && val.trim().length() > 0) current.setUserProfilePhone(val);
 	val = request.getParameter("hireDate");
-	current.setUserProfileHireDate(new Date());
+	++errCode;
 	if ((val != null) && (!val.startsWith("m"))) {
-	Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
-	if (v != null) {
-		current.setUserProfileHireDate(v);
+		Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
+		if (v != null) {
+			current.setUserProfileHireDate(v);
+		}
+		else {
+			errMsg = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
+			out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+			return;
+		}
 	}
-	else {
-		errorMsg = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
-	}
-	}
+
+	++errCode;
 	val = request.getParameter("termDate");
 	if ((val != null) && (!val.startsWith("m"))) {
 		Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
@@ -178,68 +229,124 @@
 			current.setUserProfileTermDate(v);
 		}
 		else {
-			errorMsg = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
+			errMsg = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
+			out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+			return;
 		}
 	}
+
 	if ((current.getUserProfilePasswd() == null) || (current.getUserProfilePasswd().trim().length() < 1)) {
 		current.setUserProfilePasswd("changeme");
 	}
 
-	if (errorMsg.length() > 0) {
-		// we already have an error
+	++errCode;
+	if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
+		errMsg = "You must supply a First Name (firstName)";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
-	else if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
-		errorMsg = "You must supply a First Name (firstName)";
+	++errCode;
+	if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
+		errMsg = "You must supply a Last Name (lastName)";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
-	else if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
-		errorMsg = "You must supply a Last Name (lastName)";
+	++errCode;
+	if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
+		errMsg = "You must supply an Login ID (loginID)";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
-	else if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
-		errorMsg = "You must supply an Login ID (loginID)";
+
+	++errCode;
+	/*
+	if (currentRoleID < 0 && requestedRole < 0) {
+		errMsg = "You must choose a Role for this employee";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
+	*/
+	++errCode;
 	/*
-	else if (currentRoleID < 0 && requestedRole < 0) {
-	errorMsg = "You must choose a Role for this employee";
+	if (currentLocationID < 0 && requestedLocation < 0) {
+		errMsg = "You must choose a Workgroup for this employee";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
-	else if (currentLocationID < 0 && requestedLocation < 0) {
-	errorMsg = "You must choose a Workgroup for this employee";
+	*/
+	++errCode;
+	/*
+	if (current.getUserProfileEmployeeTitleID() < 1) {
+		errMsg = "You must supply an Employee Title";
+		out.print("<error code=\""+errCode+"\" message=\""+errMsg+"\"/>");
+		return;
 	}
 	*/
-	//        else if (current.getUserProfileEmployeeTitleID() < 1) {
-	//            errorMsg = "You must supply an Employee Title";
-	//        }
-	if (errorMsg.length() < 1) {
+
+	if (orig.getUserProfileID() > 0) {
+		boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
+		HttpSession sendEmail = (emailNotice) ? session : null;
+		current.save(ilsSession, orig, sendEmail);
+	}
+	else {
+		current = current.saveNew(ilsSession, session, workgroupName, roleName);
+	}
+	if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
+		Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
+		Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
+		// modifying an existing user
 		if (orig.getUserProfileID() > 0) {
-			boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
-			HttpSession sendEmail = (emailNotice) ? session : null;
-			current.save(ilsSession, orig, sendEmail);
+			eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + adminUser.getUserProfileNum());
 		}
-		else {
-			current = current.saveNew(ilsSession, session, workgroupName, roleName);
-			profileID = current.getUserProfileID();
+	}
+	if ((requestedLocation != currentLocationID) && (requestedLocation > -1)) {
+		Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
+		Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
+		if (orig.getUserProfileID() > 0) {
+			eventsLogger.info("User " + current.getUserProfileNum() + " WORKGROUP changed from " + currentLocationID + " to " + requestedLocation + " by user: " + adminUser.getUserProfileNum());
 		}
-		if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
-			Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
-			Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
-			// modifying an existing user
-			if (orig.getUserProfileID() > 0) {
-				eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + adminUser.getUserProfileNum());
-			}
-		}
-		if ((requestedLocation != currentLocationID) && (requestedLocation > -1)) {
-			Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
-			Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
-			if (orig.getUserProfileID() > 0) {
-				eventsLogger.info("User " + current.getUserProfileNum() + " WORKGROUP changed from " + currentLocationID + " to " + requestedLocation + " by user: " + adminUser.getUserProfileNum());
-			}
-		}
+	}
 %>
 <success userProfileID="<%=current.getUserProfileID()%>"/>
 <%
-	}
-	else {
+	return;
+
+}
+response.setContentType("text/html");
 %>
-<error message="<%= errorMsg %>"/>
-<%
-	}
-%>
+<html>
+<style>th { text-align:left; }</style>
+<body>
+<h1>user/put</h1>
+<p>Create or modify a user profile record</p>
+<h3>Parameters</h3>
+<table border="1">
+<tbody>
+<tr><th>userProfileID</th><td>The record to modify.  Either this parameter, loginID, or userData can be supplied to update an existing record. This order of precedence is used. If more than one of these is supplied, the subsequent parameters are used as update fields for the record.</td></tr>
+<tr><th>action</th><td>(optional) [update|create] If not supplied, action is determined by: <ul><li>if userProfileID is supplied, action is update.</li><li>if a record is found by using loginID or userData, action is update.</li><li>otherwise, action is create.</li></ul></td></tr>
+<tr><th>loginID</th><td>User login ID</td></tr>
+<tr><th>userData</th><td>3rd-party supplied record identifier</td></tr>
+<tr><th>passwd</th><td>User Password</td></tr>
+<tr><th>firstName</th><td>First Name</td></tr>
+<tr><th>middleName</th><td>Middle Name</td></tr>
+<tr><th>lastName</th><td>Last Name</td></tr>
+<tr><th>employeeTitle</th><td>Employee Title ID {unfinished, will lookup by title string in the future}</td></tr>
+<tr><th>addr1</th><td>Address, Line 1</td></tr>
+<tr><th>addr2</th><td>Address, Line 2</td></tr>
+<tr><th>city</th><td>City</td></tr>
+<tr><th>state</th><td>State</td></tr>
+<tr><th>zip</th><td>Postal Code</td></tr>
+<tr><th>country</th><td>Country</td></tr>
+<tr><th>email</th><td>EMail Address</td></tr>
+<tr><th>phone</th><td>Phone Number</td></tr>
+<tr><th>hireDate</th><td>Date Hired</td></tr>
+<tr><th>termDate</th><td>Date Terminated</td></tr>
+<tr><th>accessLevel</th><td>User Access Level</td></tr>
+<tr><th>accessMode</th><td>User Access Mode</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>
+</table>
+</body>
+</html>
+




More information about the Ils-source mailing list