Sample JSP search scripts

DocuShare Server versions 4.0.1 and 5.0

To use a script-based search method with DocuShare Server versions 4.0.1 and 5.0, deploy JSP script based on the following sample:

<%--
/**
 * dsfindas.jsp
 */
--%>
<%@ page import="com.xerox.docushare.*" %>
<%@ page import="com.xerox.docushare.object.*" %>
<%@ page import="com.xerox.docushare.config.*" %>
<%@ page import="com.xerox.docushare.monitor.*" %>
<%@ page import="com.xerox.docushare.impl.*" %>
<html>
<head>
<title>
DocuShare
</title>
</head>
<body>
<% 
    try
    {
    	DSSession dssession = (DSSession)request.getAttribute("DSSession");
    	DSUser dsUser = (DSUser)dssession.getLoginPrincipal();

    	DSHandle handle = new DSHandle(request.getParameter("Collection"));
    	DSCollection collection = (DSCollection) dssession.getObject(handle);
   
    	DSObjectIterator iter = collection.children(null);

    	String tofindtype  = request.getParameter("Type");
    	String tofindtitle = request.getParameter("Title");
	byte[] utf8 = tofindtitle.getBytes();
	tofindtitle = new String(utf8, "UTF-8");
    	int nMaxHits = Integer.parseInt(request.getParameter("MaxHits"));

    	int i=0;
    	int nHits=0;

	for (i=0; i<iter.size(); i++)
    	{
    	   DSObject child = iter.nextObject();

           if (tofindtype.equals(child.getDSClass().getOriginalClassName()) && tofindtitle.equalsIgnoreCase(child.getTitle()))
	   {
%>
	      <input type="hidden" id="<%= child.getHandle() %>" name="dsfind">
	      <%= child.getTitle() %> <%= request.getParameter("Date") %>
	      </input>
<%	
	      nHits++;
	      if (nHits >= nMaxHits)
	      {
		   i = iter.size();
	      }
	   }
	
       }
    } catch (Exception e) {
%>

	      <input type="hidden" id="Failed: Operation Aborted" name="dsfind">
	      Failed: Operation Aborted
	      </input>
<%
    }
%>
</body>
</html>
	 

DocuShare Server version 6.0 CPX

To use a script-based search method with DocuShare Server version 6.0 CPX, deploy JSP script based on the following sample:

<%--
/**
 * dsfindas.jsp
 */
--%>
<%@ page import="com.xerox.docushare.*" %>
<%@ page import="com.xerox.docushare.object.*" %>
<%@ page import="com.xerox.docushare.config.*" %>
<%@ page import="com.xerox.docushare.monitor.*" %>
<%@ page import="com.xerox.docushare.impl.*" %>
<html>
<head>
<title>
DocuShare
</title>
</head>
<body>
<% 
    try
    {
	DSSession dssession = (DSSession)request.getAttribute("DSSession");
	DSUser dsUser = (DSUser)dssession.getLoginPrincipal();

    	DSHandle handle = new DSHandle(request.getParameter("Collection"));
    	DSObject container = dssession.getObject(handle);
    	DSObjectIterator iter;
	if (container instanceof DSCollection) {
	    DSCollection collection = (DSCollection)container;
	    iter = collection.children(null);
	} else {
	    // Assume workspace, expect exception if not.
	    DSWorkspace workspace = (DSWorkspace)container;
	    iter = workspace.children(null);
	}

    	String tofindtype  = request.getParameter("Type");
    	String tofindtitle = request.getParameter("Title");
	byte[] utf8 = tofindtitle.getBytes();
	tofindtitle = new String(utf8, "UTF-8");
    	int nMaxHits = Integer.parseInt(request.getParameter("MaxHits"));

    	int i=0;
    	int nHits=0;

	for (i=0; i<iter.size(); i++)
    	{
    	   DSObject child = iter.nextObject();

           if (tofindtype.equals(child.getDSClass().getOriginalClassName()) && tofindtitle.equalsIgnoreCase(child.getTitle()))
	   {
%>
	      <input type="hidden" id="<%= child.getHandle() %>" name="dsfind">
	      <%= child.getTitle() %> <%= request.getParameter("Date") %>
	      </input>
<%	
	      nHits++;
	      if (nHits >= nMaxHits)
	      {
		      i = iter.size();
	      }
	   }
	
    }
  } catch (Exception e) {
%>
	      <input type="hidden" id="Failed: Operation Aborted" name="dsfind">
	      Failed: Operation Aborted
	      </input>
<%
   }
%>
</body>
</html>