[Ils-source] r1580 - in trunk/webapp/api/group: . getactivity getuseractivity

scribe at crosswire.org scribe at crosswire.org
Tue Jun 26 04:59:19 MST 2018


Author: scribe
Date: 2018-06-26 04:59:19 -0700 (Tue, 26 Jun 2018)
New Revision: 1580

Added:
   trunk/webapp/api/group/getactivity/
   trunk/webapp/api/group/getactivity/index.jsp
   trunk/webapp/api/group/getuseractivity/
   trunk/webapp/api/group/getuseractivity/index.jsp
Log:
added new gropu activity endpoints to support activity reports


Added: trunk/webapp/api/group/getactivity/index.jsp
===================================================================
--- trunk/webapp/api/group/getactivity/index.jsp	                        (rev 0)
+++ trunk/webapp/api/group/getactivity/index.jsp	2018-06-26 11:59:19 UTC (rev 1580)
@@ -0,0 +1,73 @@
+<%@ page
+    language="java"
+    contentType="text/html;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="java.util.List" %>
+<%@ 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 -----------------------------------
+
+
+	String errorMsg = "";
+    
+	int groupTypeID = -1; try { groupTypeID = Integer.parseInt(request.getParameter("groupTypeID")); } catch (Exception e) {}
+
+	Logger logger = Logger.getLogger(this.getClass());
+	Logger eventsLogger = Logger.getLogger("EVENTS");
+	String statusMsg = "";
+
+	if (true) {
+		List<Group> groups = Group.getGroupsActivity(groupTypeID);
+		out.print("<groups count=\""+groups.size()+"\">\n");
+		for (Group g : groups) {
+			out.print(g.toXML());
+		}
+		out.print("</groups>\n");
+		return;
+	}
+
+	response.setContentType("text/html");
+%>
+<html>
+<style>th { text-align:left; }</style>
+<body>
+<h1>group/getactivity</h1>
+<p>Retrieve Activity for Groups</p>
+<h3>Parameters</h3>
+<table border="1">
+<tbody>
+<tr><th>groupTypeID</th><td>GroupTypeID to retrieve; required. default groups {1 - ROLE; 2 - WORKGROUP}</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>

Added: trunk/webapp/api/group/getuseractivity/index.jsp
===================================================================
--- trunk/webapp/api/group/getuseractivity/index.jsp	                        (rev 0)
+++ trunk/webapp/api/group/getuseractivity/index.jsp	2018-06-26 11:59:19 UTC (rev 1580)
@@ -0,0 +1,85 @@
+<%@ page
+    language="java"
+    contentType="text/html;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="java.util.Vector" %>
+<%@ page import="java.io.StringWriter" %>
+<%@ 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 -----------------------------------
+
+
+	String errorMsg = "";
+    
+	int groupID = -1; try { groupID = Integer.parseInt(request.getParameter("groupID")); } catch (Exception e) {}
+	String format = request.getParameter("format");
+
+	Logger logger = Logger.getLogger(this.getClass());
+	Logger eventsLogger = Logger.getLogger("EVENTS");
+	String statusMsg = "";
+
+	if (groupID != -1) {
+		if ("csv".equals(format)) {
+			StringWriter report = UserProfile.getGroupComplReport(ilsSession.getCompanyID(), groupID);
+
+			response.setContentType("text/csv");
+			response.setHeader("Content-Disposition", "attachment; filename=groupStudentActivityReport.csv");
+			out.write(report.toString());
+			return;
+		}
+		else if ("text".equals(format)) {
+			StringWriter report = UserProfile.getGroupComplReport(ilsSession.getCompanyID(), groupID);
+			response.setContentType("text/plain");
+			out.write(report.toString());
+			return;
+		}
+	}
+
+	response.setContentType("text/html");
+
+%>
+<html>
+<style>th { text-align:left; }</style>
+<body>
+<h1>group/getuseractivity</h1>
+<p>Retrieve User Activity for A Group</p>
+<h3>Parameters</h3>
+<table border="1">
+<tbody>
+<tr><th>groupID</th><td>GroupID to retrieve</td></tr>
+<tr><th>format</th><td>csv</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