manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1348813 - in /incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint: SPSProxyHelper.java SharePointRepository.java
Date Mon, 11 Jun 2012 12:21:07 GMT
Author: kwright
Date: Mon Jun 11 12:21:06 2012
New Revision: 1348813

URL: http://svn.apache.org/viewvc?rev=1348813&view=rev
Log:
Put in stub code for dealing with SharePoint 2010's broken DspSts service.

Modified:
    incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
    incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java

Modified: incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java?rev=1348813&r1=1348812&r2=1348813&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
(original)
+++ incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
Mon Jun 11 12:21:06 2012
@@ -1437,7 +1437,7 @@ public class SPSProxyHelper {
   * @param docId
   * @return set of the field values
   */
-  public Map getFieldValues( ArrayList fieldNames, String site, String docLibrary, String
docId )
+  public Map getFieldValues( ArrayList fieldNames, String site, String docLibrary, String
docId, boolean dspStsWorks )
     throws ManifoldCFException, ServiceInterruption
   {
     long currentTime;
@@ -1446,123 +1446,134 @@ public class SPSProxyHelper {
       HashMap result = new HashMap();
 
       if ( site.compareTo("/") == 0 ) site = ""; // root case
+      
+      if ( dspStsWorks )
+      {
         StsAdapterWS listService = new StsAdapterWS( baseUrl + site, userName, password,
myFactory, configuration, connectionManager );
-      StsAdapterSoapStub stub = (StsAdapterSoapStub)listService.getStsAdapterSoapHandler();
-
-      String[] vArray = new String[1];
-      vArray[0] = "1.0";
-      VersionsHeader myVersion = new VersionsHeader();
-      myVersion.setVersion( vArray );
+        StsAdapterSoapStub stub = (StsAdapterSoapStub)listService.getStsAdapterSoapHandler();
 
-      stub.setHeader( "http://schemas.microsoft.com/sharepoint/dsp", "versions", myVersion
);
+        String[] vArray = new String[1];
+        vArray[0] = "1.0";
+        VersionsHeader myVersion = new VersionsHeader();
+        myVersion.setVersion( vArray );
 
-      RequestHeader reqHeader = new RequestHeader();
-      reqHeader.setDocument( DocumentType.content );
-      reqHeader.setMethod(MethodType.query );
+        stub.setHeader( "http://schemas.microsoft.com/sharepoint/dsp", "versions", myVersion
);
 
-      stub.setHeader( "http://schemas.microsoft.com/sharepoint/dsp", "request", reqHeader
);
+        RequestHeader reqHeader = new RequestHeader();
+        reqHeader.setDocument( DocumentType.content );
+        reqHeader.setMethod(MethodType.query );
 
-      QueryRequest myRequest = new QueryRequest();
+        stub.setHeader( "http://schemas.microsoft.com/sharepoint/dsp", "request", reqHeader
);
 
-      DSQuery sQuery = new DSQuery();
-      sQuery.setSelect( "/list[@id='" + docLibrary + "']" );
-      sQuery.setResultContent(ResultContentType.dataOnly);
-      myRequest.setDsQuery( sQuery );
+        QueryRequest myRequest = new QueryRequest();
 
-      DspQuery spQuery = new DspQuery();
-      spQuery.setRowLimit( 1 );
-      // For the Requested Fields
-      if ( fieldNames.size() > 0 )
-      {
-        Fields spFields = new Fields();
-        Field[] fieldArray = new Field[0];
-        ArrayList fields = new ArrayList();
+        DSQuery sQuery = new DSQuery();
+        sQuery.setSelect( "/list[@id='" + docLibrary + "']" );
+        sQuery.setResultContent(ResultContentType.dataOnly);
+        myRequest.setDsQuery( sQuery );
 
-        Field spField = new Field();
-        //                      spField.setName( "ID" );
-        //                      spField.setAlias( "ID" );
-        //                      fields.add( spField );
-
-        for ( int k = 0; k < fieldNames.size(); k++ )
+        DspQuery spQuery = new DspQuery();
+        spQuery.setRowLimit( 1 );
+        // For the Requested Fields
+        if ( fieldNames.size() > 0 )
         {
-          spField = new Field();
-          spField.setName( (String)fieldNames.get(k) );
-          spField.setAlias( (String)fieldNames.get(k) );
-          fields.add( spField );
+          Fields spFields = new Fields();
+          Field[] fieldArray = new Field[0];
+          ArrayList fields = new ArrayList();
+
+          Field spField = new Field();
+          //                      spField.setName( "ID" );
+          //                      spField.setAlias( "ID" );
+          //                      fields.add( spField );
+
+          for ( int k = 0; k < fieldNames.size(); k++ )
+          {
+            spField = new Field();
+            spField.setName( (String)fieldNames.get(k) );
+            spField.setAlias( (String)fieldNames.get(k) );
+            fields.add( spField );
+          }
+          spFields.setField( (Field[]) fields.toArray( fieldArray ));
+          spQuery.setFields( spFields );
         }
-        spFields.setField( (Field[]) fields.toArray( fieldArray ));
-        spQuery.setFields( spFields );
-      }
-      // Of this document
-      DspQueryWhere spWhere = new DspQueryWhere();
+        // Of this document
+        DspQueryWhere spWhere = new DspQueryWhere();
 
-      org.apache.axis.message.MessageElement criterion = new org.apache.axis.message.MessageElement(
(String)null, "Contains" );
-      SOAPElement seFieldRef = criterion.addChildElement( "FieldRef" );
-      seFieldRef.addAttribute( SOAPFactory.newInstance().createName("Name") , "FileRef" );
-      SOAPElement seValue = criterion.addChildElement( "Value" );
-      seValue.addAttribute( SOAPFactory.newInstance().createName("Type") , "String" );
-      seValue.setValue( docId );
+        org.apache.axis.message.MessageElement criterion = new org.apache.axis.message.MessageElement(
(String)null, "Contains" );
+        SOAPElement seFieldRef = criterion.addChildElement( "FieldRef" );
+        seFieldRef.addAttribute( SOAPFactory.newInstance().createName("Name") , "FileRef"
);
+        SOAPElement seValue = criterion.addChildElement( "Value" );
+        seValue.addAttribute( SOAPFactory.newInstance().createName("Type") , "String" );
+        seValue.setValue( docId );
+
+        org.apache.axis.message.MessageElement[] criteria = { criterion };
+        spWhere.set_any( criteria );
+        spQuery.setWhere( (DspQueryWhere)spWhere );
+
+        // Set Criteria
+        myRequest.getDsQuery().setQuery(spQuery);
+
+        StsAdapterSoap call = stub;
+
+        // Make Request
+        QueryResponse resp = call.query( myRequest );
+        org.apache.axis.message.MessageElement[] list = resp.get_any();
 
-      org.apache.axis.message.MessageElement[] criteria = { criterion };
-      spWhere.set_any( criteria );
-      spQuery.setWhere( (DspQueryWhere)spWhere );
+        if (Logging.connectors.isDebugEnabled())
+        {
+          Logging.connectors.debug("SharePoint: list xml: '" + list[0].toString() + "'");
+        }
 
-      // Set Criteria
-      myRequest.getDsQuery().setQuery(spQuery);
+        XMLDoc doc = new XMLDoc( list[0].toString() );
+        ArrayList nodeList = new ArrayList();
 
-      StsAdapterSoap call = stub;
+        doc.processPath(nodeList, "*", null);
+        if (nodeList.size() != 1)
+        {
+          throw new ManifoldCFException("Bad xml - missing outer 'ns1:dsQueryResponse' node
- there are "+Integer.toString(nodeList.size())+" nodes");
+        }
 
-      // Make Request
-      QueryResponse resp = call.query( myRequest );
-      org.apache.axis.message.MessageElement[] list = resp.get_any();
+        Object parent = nodeList.get(0);
+        //System.out.println( "Outer NodeName = " + doc.getNodeName(parent) );
+        if (!doc.getNodeName(parent).equals("ns1:dsQueryResponse"))
+          throw new ManifoldCFException("Bad xml - outer node is not 'ns1:dsQueryResponse'");
+
+        nodeList.clear();
+        doc.processPath(nodeList, "*", parent);
+
+        parent = nodeList.get( 0 ); // <Shared_X0020_Documents />
+
+        nodeList.clear();
+        doc.processPath(nodeList, "*", parent);
+
+        // Process each result (Should only be one )
+        // Get each childs Value and add to return array
+        for ( int i= 0; i < nodeList.size(); i++ )
+        {
+          Object documentNode = nodeList.get( i );
+          ArrayList fieldList = new ArrayList();
 
-      if (Logging.connectors.isDebugEnabled())
-      {
-        Logging.connectors.debug("SharePoint: list xml: '" + list[0].toString() + "'");
+          doc.processPath( fieldList, "*", documentNode );
+          for ( int j =0; j < fieldList.size(); j++)
+          {
+            Object field = fieldList.get( j );
+            String fieldData = doc.getData(field);
+            String fieldName = doc.getNodeName(field);
+            // Right now this really only works right for single-valued fields.  For multi-valued
+            // fields, we'd need to know in advance that they were multivalued
+            // so that we could interpret commas as value separators.
+            result.put(fieldName,fieldData);
+          }
+        }
       }
-
-      XMLDoc doc = new XMLDoc( list[0].toString() );
-      ArrayList nodeList = new ArrayList();
-
-      doc.processPath(nodeList, "*", null);
-      if (nodeList.size() != 1)
+      else
       {
-        throw new ManifoldCFException("Bad xml - missing outer 'ns1:dsQueryResponse' node
- there are "+Integer.toString(nodeList.size())+" nodes");
+        // SharePoint 2010: Get field values some other way
+        
+        // MHL
+        
       }
-
-      Object parent = nodeList.get(0);
-      //System.out.println( "Outer NodeName = " + doc.getNodeName(parent) );
-      if (!doc.getNodeName(parent).equals("ns1:dsQueryResponse"))
-        throw new ManifoldCFException("Bad xml - outer node is not 'ns1:dsQueryResponse'");
-
-      nodeList.clear();
-      doc.processPath(nodeList, "*", parent);
-
-      parent = nodeList.get( 0 ); // <Shared_X0020_Documents />
-
-      nodeList.clear();
-      doc.processPath(nodeList, "*", parent);
-
-      // Process each result (Should only be one )
-      // Get each childs Value and add to return array
-      for ( int i= 0; i < nodeList.size(); i++ )
-      {
-        Object documentNode = nodeList.get( i );
-        ArrayList fieldList = new ArrayList();
-
-        doc.processPath( fieldList, "*", documentNode );
-        for ( int j =0; j < fieldList.size(); j++)
-        {
-          Object field = fieldList.get( j );
-          String fieldData = doc.getData(field);
-          String fieldName = doc.getNodeName(field);
-          // Right now this really only works right for single-valued fields.  For multi-valued
-          // fields, we'd need to know in advance that they were multivalued
-          // so that we could interpret commas as value separators.
-          result.put(fieldName,fieldData);
-        }
-      }
-
+      
       return result;
     }
     catch (javax.xml.soap.SOAPException e)

Modified: incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java?rev=1348813&r1=1348812&r2=1348813&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
(original)
+++ incubator/lcf/branches/CONNECTORS-470/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
Mon Jun 11 12:21:06 2012
@@ -671,7 +671,7 @@ public class SharePointRepository extend
                 // The document path includes the library, with no leading slash, and is
decoded.
                 int cutoff = decodedLibPath.lastIndexOf("/");
                 String decodedDocumentPathWithoutSite = decodedDocumentPath.substring(cutoff+1);
-                Map values = proxy.getFieldValues( metadataDescription, encodedSitePath,
libID, decodedDocumentPathWithoutSite);
+                Map values = proxy.getFieldValues( metadataDescription, encodedSitePath,
libID, decodedDocumentPathWithoutSite, dspStsWorks );
                 String modifyDate = (String)values.get("Last_x0020_Modified");
                 if (modifyDate != null)
                 {
@@ -1223,7 +1223,7 @@ public class SharePointRepository extend
                       }
 
                       int cutoff = decodedLibPath.lastIndexOf("/");
-                      Map values = proxy.getFieldValues( metadataDescription, encodePath(site),
documentLibID, decodedDocumentPath.substring(cutoff+1) );
+                      Map values = proxy.getFieldValues( metadataDescription, encodePath(site),
documentLibID, decodedDocumentPath.substring(cutoff+1), dspStsWorks );
                       if (values != null)
                       {
                         Iterator iter = values.keySet().iterator();



Mime
View raw message