You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/09/17 02:43:32 UTC

svn commit: r1523860 - in /manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint: SPSProxyHelper.java SharePointRepository.java

Author: kwright
Date: Tue Sep 17 00:43:31 2013
New Revision: 1523860

URL: http://svn.apache.org/r1523860
Log:
Set websBroken flag for AWS sharepoint installation

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

Modified: manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java?rev=1523860&r1=1523859&r2=1523860&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java (original)
+++ manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SPSProxyHelper.java Tue Sep 17 00:43:31 2013
@@ -768,6 +768,7 @@ public class SPSProxyHelper {
     }
   }
 
+
   /**
   *
   * @param parentSite
@@ -1944,7 +1945,7 @@ public class SPSProxyHelper {
   * @param parentSite the site to search for subsites, empty string for root
   * @return lists of sites as an arraylist of NameValue objects
   */
-  public ArrayList getSites( String parentSite )
+  public ArrayList getSites( String parentSite, boolean websBroken )
     throws ManifoldCFException, ServiceInterruption
   {
     long currentTime;
@@ -1952,59 +1953,119 @@ public class SPSProxyHelper {
     {
       ArrayList result = new ArrayList();
 
-      if ( parentSite.equals( "/") ) parentSite = "";
-        WebsWS webService = new WebsWS( baseUrl + parentSite, userName, password, configuration, httpClient );
-      WebsSoap webCall = webService.getWebsSoapHandler();
+      if ( websBroken )
+      {
+        // Call the plugin; the webs functionality is not working
+        MCPermissionsWS itemService = new MCPermissionsWS( baseUrl + parentSite, userName, password, configuration, httpClient );
+        com.microsoft.sharepoint.webpartpages.PermissionsSoap itemCall = itemService.getPermissionsSoapHandler( );
 
-      GetWebCollectionResponseGetWebCollectionResult webResp = webCall.getWebCollection();
-      org.apache.axis.message.MessageElement[] webList = webResp.get_any();
+        com.microsoft.sharepoint.webpartpages.GetSitesResponseGetSitesResult sitesResult = itemCall.getSites();
+          
+        MessageElement[] itemsList = sitesResult.get_any();
 
-      XMLDoc doc = new XMLDoc( webList[0].toString() );
-      ArrayList nodeList = new ArrayList();
+        if (Logging.connectors.isDebugEnabled()){
+          Logging.connectors.debug("SharePoint: getSites xml response: '" + itemsList[0].toString() + "'");
+        }
 
-      doc.processPath(nodeList, "*", null);
-      if (nodeList.size() != 1)
-      {
-        throw new ManifoldCFException("Bad xml - missing outer 'ns1:Webs' node - there are "+Integer.toString(nodeList.size())+" nodes");
+        if (itemsList.length != 1)
+          throw new ManifoldCFException("Bad response - expecting one outer 'GetSites' node, saw "+Integer.toString(itemsList.length));
+          
+        MessageElement items = itemsList[0];
+        if (!items.getElementName().getLocalName().equals("GetSites"))
+          throw new ManifoldCFException("Bad response - outer node should have been 'GetSites' node");
+          
+        Iterator iter = items.getChildElements();
+        while (iter.hasNext())
+        {
+          MessageElement child = (MessageElement)iter.next();
+          if (child.getElementName().getLocalName().equals("GetSitesResponse"))
+          {
+            Iterator resultIter = child.getChildElements();
+            while (resultIter.hasNext())
+            {
+              MessageElement result2 = (MessageElement)resultIter.next();
+              if (result2.getElementName().getLocalName().equals("GetSitesResult"))
+              {
+                String url = result2.getAttribute("URL");
+                String title = result2.getAttribute("Name");
+                // A full path to the site is tacked on the front of each one of these.  However, due to nslookup differences, we cannot guarantee that
+                // the server name part of the path will actually match what got passed in.  Therefore, we want to look only at the last path segment, whatever that is.
+                if (url != null && url.length() > 0)
+                {
+                  int lastSlash = url.lastIndexOf("/");
+                  if (lastSlash != -1)
+                  {
+                    String pathValue = url.substring(lastSlash + 1);
+                    if (pathValue.length() > 0)
+                    {
+                      if (title == null || title.length() == 0)
+                        title = pathValue;
+                      result.add(new NameValue(pathValue,title));
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
       }
-      Object parent = nodeList.get(0);
-      if (!doc.getNodeName(parent).equals("ns1:Webs"))
-        throw new ManifoldCFException("Bad xml - outer node is not 'ns1:Webs'");
+      else
+      {
+        // Call the webs service
+        if ( parentSite.equals( "/") ) parentSite = "";
+          WebsWS webService = new WebsWS( baseUrl + parentSite, userName, password, configuration, httpClient );
+        WebsSoap webCall = webService.getWebsSoapHandler();
 
-      nodeList.clear();
-      doc.processPath(nodeList, "*", parent);  // <ns1:Webs>
+        GetWebCollectionResponseGetWebCollectionResult webResp = webCall.getWebCollection();
+        org.apache.axis.message.MessageElement[] webList = webResp.get_any();
 
-      int i = 0;
-      while (i < nodeList.size())
-      {
-        Object o = nodeList.get( i++ );
-        //Logging.connectors.debug( i + ": " + o );
-        //System.out.println( i + ": " + o );
-        String url = doc.getValue( o, "Url" );
-        String title = doc.getValue( o, "Title" );
+        XMLDoc doc = new XMLDoc( webList[0].toString() );
+        ArrayList nodeList = new ArrayList();
 
-        // Leave here for now
-        if (Logging.connectors.isDebugEnabled())
-          Logging.connectors.debug("SharePoint: Subsite list: '"+url+"', '"+title+"'");
+        doc.processPath(nodeList, "*", null);
+        if (nodeList.size() != 1)
+        {
+          throw new ManifoldCFException("Bad xml - missing outer 'ns1:Webs' node - there are "+Integer.toString(nodeList.size())+" nodes");
+        }
+        Object parent = nodeList.get(0);
+        if (!doc.getNodeName(parent).equals("ns1:Webs"))
+          throw new ManifoldCFException("Bad xml - outer node is not 'ns1:Webs'");
 
-        // A full path to the site is tacked on the front of each one of these.  However, due to nslookup differences, we cannot guarantee that
-        // the server name part of the path will actually match what got passed in.  Therefore, we want to look only at the last path segment, whatever that is.
-        if (url != null && url.length() > 0)
+        nodeList.clear();
+        doc.processPath(nodeList, "*", parent);  // <ns1:Webs>
+
+        int i = 0;
+        while (i < nodeList.size())
         {
-          int lastSlash = url.lastIndexOf("/");
-          if (lastSlash != -1)
+          Object o = nodeList.get( i++ );
+          //Logging.connectors.debug( i + ": " + o );
+          //System.out.println( i + ": " + o );
+          String url = doc.getValue( o, "Url" );
+          String title = doc.getValue( o, "Title" );
+
+          // Leave here for now
+          if (Logging.connectors.isDebugEnabled())
+            Logging.connectors.debug("SharePoint: Subsite list: '"+url+"', '"+title+"'");
+
+          // A full path to the site is tacked on the front of each one of these.  However, due to nslookup differences, we cannot guarantee that
+          // the server name part of the path will actually match what got passed in.  Therefore, we want to look only at the last path segment, whatever that is.
+          if (url != null && url.length() > 0)
           {
-            String pathValue = url.substring(lastSlash + 1);
-            if (pathValue.length() > 0)
+            int lastSlash = url.lastIndexOf("/");
+            if (lastSlash != -1)
             {
-              if (title == null || title.length() == 0)
-                title = pathValue;
-              result.add(new NameValue(pathValue,title));
+              String pathValue = url.substring(lastSlash + 1);
+              if (pathValue.length() > 0)
+              {
+                if (title == null || title.length() == 0)
+                  title = pathValue;
+                result.add(new NameValue(pathValue,title));
+              }
             }
           }
         }
       }
-
+      
       return result;
     }
     catch (java.net.MalformedURLException e)

Modified: manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java?rev=1523860&r1=1523859&r2=1523860&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java (original)
+++ manifoldcf/branches/CONNECTORS-772/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java Tue Sep 17 00:43:31 2013
@@ -86,6 +86,7 @@ public class SharePointRepository extend
   private boolean supportsItemSecurity = false;
   private boolean dspStsWorks = true;
   private boolean fullListPaths = true;
+  private boolean websBroken = false;
   
   private String serverProtocol = null;
   private String serverUrl = null;
@@ -148,6 +149,7 @@ public class SharePointRepository extend
       supportsItemSecurity = !serverVersion.equals("2.0");
       dspStsWorks = !(serverVersion.equals("4.0") || serverVersion.equals("4.0AWS"));
       fullListPaths = !serverVersion.equals("4.0AWS");
+      websBroken = serverVersion.equals("4.0AWS");
 
       serverProtocol = params.getParameter( "serverProtocol" );
       if (serverProtocol == null)
@@ -1726,7 +1728,7 @@ public class SharePointRepository extend
             Logging.connectors.debug( "SharePoint: Document identifier is a site: '" + decodedSitePath + "'" );
 
           // Look at subsites
-          ArrayList subsites = proxy.getSites( encodePath(decodedSitePath) );
+          ArrayList subsites = proxy.getSites( encodePath(decodedSitePath), websBroken );
           if (subsites != null)
           {
             int j = 0;
@@ -5029,7 +5031,7 @@ public class SharePointRepository extend
     throws ServiceInterruption, ManifoldCFException
   {
     getSession();
-    return proxy.getSites( encodePath(parentSite) );
+    return proxy.getSites( encodePath(parentSite), websBroken );
   }
 
   /**