manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1855643 - /manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
Date Sat, 16 Mar 2019 13:23:08 GMT
Author: kwright
Date: Sat Mar 16 13:23:08 2019
New Revision: 1855643

URL: http://svn.apache.org/viewvc?rev=1855643&view=rev
Log:
Add search functionality

Modified:
    manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java

Modified: manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java?rev=1855643&r1=1855642&r2=1855643&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
(original)
+++ manifoldcf/branches/CONNECTORS-1566/connectors/csws/connector/src/main/java/org/apache/manifoldcf/csws/CswsSession.java
Sat Mar 16 13:23:08 2019
@@ -62,6 +62,11 @@ import com.opentext.livelink.service.doc
 import com.opentext.livelink.service.docman.NodeRights;
 import com.opentext.livelink.service.memberservice.User;
 import com.opentext.livelink.service.memberservice.Member;
+import com.opentext.livelink.service.searchservices.SResultPage;
+import com.opentext.livelink.service.searchservices.SNode;
+import com.opentext.livelink.service.searchservices.SGraph;
+import com.opentext.livelink.service.searchservices.SingleSearchRequest;
+import com.opentext.livelink.service.searchservices.SingleSearchResponse;
 
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
@@ -313,6 +318,77 @@ public class CswsSession
     }
   }
   
+  // Node searching
+  
+  /**
+  * Return a set of IDs matching the specification.
+  * @param searchSpec is the search specification, e.g. "where1=(\"OTSubType\":0 OR \"OTSubType\":1
OR \"OTSubType\":144) AND \"OTParentID\":2000 AND \"OTModifyDate\":<20190312"
+  *  For reference:
+  * OTSubType Details 
+  * 0 - Folder 
+  * 1 - Alias [Shortcut] 
+  * 131 - Category 
+  * 136 - Compound Document 
+  * 140 - URL 
+  * 144 - Document 
+  * 202 - Project 
+  * 204 - Task List
+  * 207 - Channel 
+  * 215 - Discussion 
+  * 299 - LiveReport
+  * @param sortOrderSpec is the sort order specification, or null, e.g. "sortByRegion=OTName&sortDirection=ascending"
+  * @param start is the ID of the result to return (0-based)
+  * @param count is the maximum number of IDs to return
+  * @return an array of IDs corresponding to documents or categories requested
+  */
+  public long[] searchFor(final String searchSpec, final String sortOrderSpec, final int
start, final int count)
+    throws ManifoldCFException, ServiceInterruption {
+    try {
+      final SingleSearchRequest singleSrchReq = new SingleSearchRequest();
+      singleSrchReq.setDataCollectionSpec("'LES Enterprise'");//Livelink Enterprise Server
+      singleSrchReq.setQueryLanguage("Livelink Search API V1"); //Search Query Language API
+      singleSrchReq.setFirstResultToRetrieve(start + 1);
+      singleSrchReq.setNumResultsToRetrieve(count);
+      if (sortOrderSpec != null) {
+        singleSrchReq.setResultOrderSpec(sortOrderSpec);
+      }
+      singleSrchReq.setResultSetSpec(searchSpec);
+      // We only ever want to get IDs back
+      singleSrchReq.getResultTransformationSpec().add("OTDataID");
+      // Fire off the query
+      final SingleSearchResponse results = getSearchServiceHandle().search(singleSrchReq,
"", getOTAuthentication());
+      if (results == null) {
+        return null;
+      }
+      // Get the result page from the results
+      final SResultPage srp = results.getResults();
+      if (srp == null) {
+        return null;
+      }
+      // Get the list of actual result rows (?)
+      final List<? extends SGraph> items = srp.getItem();
+      if (items == null) {
+        return null;
+      }
+      // Create the output array
+      final long[] rval = new long[items.size()];
+      int i = 0;
+      for (final SGraph sg : items) {
+        // Get the SNodes for the graph element; there should be exactly one because that's
what we asked for
+        final List<? extends SNode> nodes = sg.getN();
+        if (nodes == null || nodes.size() != 1) {
+          throw new ManifoldCFException("Unexpected result row size back from search: "+(nodes
== null)?"null":nodes.size());
+        }
+        final SNode node = nodes.get(0);
+        // I have no idea what field I ought to get from the node for OTDataID.  String?
 Integer??  And these come back as lists too!!  Please clarify.
+        // MHL
+        rval[i++] = new Long(node.getI().get(0)).longValue();
+      }
+    } catch (SOAPFaultException e) {
+      processSOAPFault(e);
+    }
+  }
+                                                
   // Construct authentication token argument, which must be passed as last argument for every
method
   
   /**



Mime
View raw message