[Ils-source] r1620 - in branches/1.6: . webapp/WEB-INF/classes webapp/api/user/get
scribe at crosswire.org
scribe at crosswire.org
Tue Aug 21 13:01:12 MST 2018
Author: scribe
Date: 2018-08-21 13:01:11 -0700 (Tue, 21 Aug 2018)
New Revision: 1620
Modified:
branches/1.6/
branches/1.6/webapp/WEB-INF/classes/versions.properties
branches/1.6/webapp/api/user/get/index.jsp
Log:
Reverted mistakenly committed new API rendition of user/get API.
Property changes on: branches/1.6
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk:796-1502,1504-1505,1507,1509-1510,1512,1514-1515,1517-1563,1565,1567,1569-1608,1610,1613-1614
+ /trunk:796-1502,1504-1505,1507,1509-1510,1512,1514-1515,1517-1563,1565,1567,1569-1608,1610,1613-1614,1619
Modified: branches/1.6/webapp/WEB-INF/classes/versions.properties
===================================================================
--- branches/1.6/webapp/WEB-INF/classes/versions.properties 2018-08-21 19:56:44 UTC (rev 1619)
+++ branches/1.6/webapp/WEB-INF/classes/versions.properties 2018-08-21 20:01:11 UTC (rev 1620)
@@ -1 +1 @@
-LMS=V1.82.0
+LMS=V1.82.1
Modified: branches/1.6/webapp/api/user/get/index.jsp
===================================================================
--- branches/1.6/webapp/api/user/get/index.jsp 2018-08-21 19:56:44 UTC (rev 1619)
+++ branches/1.6/webapp/api/user/get/index.jsp 2018-08-21 20:01:11 UTC (rev 1620)
@@ -1,87 +1,98 @@
<%@ page language="java" contentType="text/xml;charset=utf-8" %>
<%@ page trimDirectiveWhitespaces="true" %>
-
-<%@ page import="java.util.List" %>
-<%@ page import="java.util.ArrayList" %>
+<%@ 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="org.apache.log4j.Logger" %>
-<%@ page import="javax.validation.constraints.NotNull" %>
-<%@ page import="javax.validation.constraints.Pattern" %>
-<%@ page import="org.crosswire.webtools.annotation.*" %>
-<%@ page import="org.crosswire.webtools.Serializer" %>
-<%@ page import="com.resolutions.ils.ILSParameters" %>
-<%@ page import="com.resolutions.ils.data.UserProfile" %>
+<%
+ // 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;
+ }
-<%!
- @Description(value = "Retrieve a user profile record", name = "user/get")
- public static class MyParameters extends ILSParameters<MyParameters> {
+ 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 -----------------------------------
- @Description(value = "User Profile ID", example = "27")
- public Integer userProfileID = null;
- @Description(value = "User Login ID", example = "joe at ils.com")
- public String loginID = null;
- @Description(value = "3rd-party supplied record identifier", example = "badgeID-4150")
- public String userData = null;
- @Description(value = "Detail level of result. 'extra' - includes group info", defaultValue = "complete")
- @Pattern(regexp = "^(complete|extra)$", message = "Valid detail options: \"complete\", \"extra\".")
- public String detail = null;
- @Override
- protected void customValidation() {
- if (userProfileID == null && loginID == null && userData == null) {
- addError(-101, "You need to supply at least one of userProfileID, loginID, or userData to retrieve a user");
- }
- if (getILSSession().getCurrentUserProfile().getUserProfileAccessLevel() <= UserProfile.ACCESS_MANAGER && !getILSSession().getCurrentUserProfile().hasAccess(UserProfile.ACCESS_MODE_USERPR_SEARCH_VIEW)) {
- addError(-102, "Permission denied. AccessLevel: " + getILSSession().getCurrentUserProfile().getUserProfileAccessLevel());
- }
- }
- private int detailLevel = UserProfile.DETAIL_COMPLETE;
- @Override
- protected void afterValidate() {
- if ("extra".equals(detail)) detailLevel = UserProfile.DETAIL_EXTRA;
- }
- @Override
- protected String[] getExamples() {
- return new String[] {
- "get userProfileID " + getILSSession().getUserID() + ": <a href=\"?userProfileID=" + getILSSession().getUserID() +"\">user/get/?userProfileID= "+ getILSSession().getUserID() + "</a>",
- "get user loginID " + getILSSession().getUserName() + " with extra group information: <a href=\"?loginID=" + getILSSession().getUserName() +"&detail=extra\">user/get/?loginID="+ getILSSession().getUserName() + "&detail=extra</a>",
- };
- }
- protected String[] getReturns() { return new String[] {
- "A userProfile object"
- };
- }
+ int userProfileID = -1; try { userProfileID = Integer.parseInt(request.getParameter("userProfileID")); } catch(Exception e) {}
+ String loginID = request.getParameter("loginID");
+ String userData = request.getParameter("userData");
- }
-%>
-<%
- MyParameters params = new MyParameters().loadFromRequest(request, response);
- if (params.getErrors().isEmpty()) {
- UserProfile foundUserProfile = null;
+// one of these must be supplied; otherwise, show usage info
+if (userProfileID != -1 || loginID != null || userData != null) {
- if (params.userProfileID != null) {
- foundUserProfile = UserProfile.getUserProfile(params.getILSSession(), params.userProfileID);
+ Logger logger = Logger.getLogger(this.getClass());
+ Logger eventsLogger = Logger.getLogger("EVENTS");
+
+ UserProfile current = null;
+
+ ++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);
}
- else if (params.loginID != null) {
- foundUserProfile = UserProfile.getUserProfile(params.getILSSession(), params.loginID);
+ else if (loginID != null) {
+ current = UserProfile.getUserProfile(ilsSession, loginID);
}
- else if (params.userData != null) {
- foundUserProfile = UserProfile.getUserProfileByUserData(params.getILSSession(), params.userData);
+ else if (userData != null) {
+ current = UserProfile.getUserProfileByUserData(ilsSession, userData);
}
- if (foundUserProfile == null) {
- params.addError(-103, "User Profile not found.");
- }
- else {
- // To facilitate results of multiple UserProfiles in the future
- // our response is an array
- List<UserProfile> results = new ArrayList<UserProfile>();
- results.add(foundUserProfile);
+ }
+ else {
+ out.print("<error code=\""+errCode+"\" message=\"Permission denied.\"/>");
+ return;
+ }
-params.getLogger().info("detaillevel: " + params.detailLevel);
- Serializer.output(response, out, params, results, null, params.detailLevel);
- return;
- }
+ ++errCode;
+ if (current == null) {
+ out.print("<error code=\""+errCode+"\" message=\"User Profile not found.\"/>");
+ return;
}
- Serializer.reportErrors(request, response, out, params);
+
+ 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>user/get</h1>
+<p>Retrieve a user profile record</p>
+<h3>Parameters</h3>
+<table border="1">
+<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>
More information about the Ils-source
mailing list