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 2012/08/08 00:41:31 UTC

svn commit: r1370578 - /manifoldcf/branches/CONNECTORS-497/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java

Author: kwright
Date: Tue Aug  7 22:41:30 2012
New Revision: 1370578

URL: http://svn.apache.org/viewvc?rev=1370578&view=rev
Log:
Fix the metadata UI

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

Modified: manifoldcf/branches/CONNECTORS-497/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-497/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java?rev=1370578&r1=1370577&r2=1370578&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-497/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java (original)
+++ manifoldcf/branches/CONNECTORS-497/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/sharepoint/SharePointRepository.java Tue Aug  7 22:41:30 2012
@@ -390,7 +390,54 @@ public class SharePointRepository extend
           sitePath = remainder.substring(index+1);
         }
         
-        Map fieldSet = getFieldList(sitePath,library);
+        Map fieldSet = getLibFieldList(sitePath,library);
+        Iterator iter = fieldSet.keySet().iterator();
+        while (iter.hasNext())
+        {
+          String fieldName = (String)iter.next();
+          String displayName = (String)fieldSet.get(fieldName);
+          ConfigurationNode node = new ConfigurationNode("field");
+          ConfigurationNode child;
+          child = new ConfigurationNode("name");
+          child.setValue(fieldName);
+          node.addChild(node.getChildCount(),child);
+          child = new ConfigurationNode("display_name");
+          child.setValue(displayName);
+          node.addChild(node.getChildCount(),child);
+          output.addChild(output.getChildCount(),node);
+        }
+      }
+      catch (ServiceInterruption e)
+      {
+        ManifoldCF.createServiceInterruptionNode(output,e);
+      }
+      catch (ManifoldCFException e)
+      {
+        ManifoldCF.createErrorNode(output,e);
+      }
+    }
+    else if (command.startsWith("listfields/"))
+    {
+      String listName;
+      String sitePath;
+      
+      String remainder = command.substring("listfields/".length());
+      
+      try
+      {
+        int index = remainder.indexOf("/");
+        if (index == -1)
+        {
+          listName = remainder;
+          sitePath = "";
+        }
+        else
+        {
+          listName = remainder.substring(0,index);
+          sitePath = remainder.substring(index+1);
+        }
+        
+        Map fieldSet = getListFieldList(sitePath,listName);
         Iterator iter = fieldSet.keySet().iterator();
         while (iter.hasNext())
         {
@@ -3384,11 +3431,15 @@ public class SharePointRepository extend
         int index = metaPathLibrary.lastIndexOf("/");
         String site = metaPathLibrary.substring(0,index);
         String libOrList = metaPathLibrary.substring(index+1);
-        System.out.println("libOrList is '"+libOrList+"'");
         Map metaFieldList = null;
         try
         {
-          metaFieldList = getFieldList(site,libOrList);
+          if (metaPathState.equals("library"))
+            metaFieldList = getLibFieldList(site,libOrList);
+          else if (metaPathState.equals("list"))
+            metaFieldList = getListFieldList(site,libOrList);
+          else
+            throw new ManifoldCFException("Unknown state; please contact ManifoldCF developer group");
         }
         catch (ManifoldCFException e)
         {
@@ -4151,7 +4202,6 @@ public class SharePointRepository extend
         }
         else if (pathop.equals("AppendList"))
         {
-          System.out.println("In AppendList");
           String path = variableContext.getParameter("metapath");
           String addon = variableContext.getParameter("metalist");
           if (addon != null && addon.length() > 0)
@@ -4162,10 +4212,7 @@ public class SharePointRepository extend
               path = path + "/" + addon;
             currentContext.save("metapathstate","list");
             currentContext.save("metapathlibrary",path);
-            System.out.println("metapathlibrary set to '"+path+"'");
           }
-          else
-            System.out.println("metalist was null");
           currentContext.save("metapath",path);
         }
         else if (pathop.equals("AppendText"))
@@ -4804,14 +4851,27 @@ public class SharePointRepository extend
   /**
   * Gets a list of field names of the given document library or list.
   * @param parentSite - parent site path
-  * @param docLibraryOrList
+  * @param docLibrary name
+  * @return list of the fields
+  */
+  public Map getLibFieldList( String parentSite, String docLibrary )
+    throws ServiceInterruption, ManifoldCFException
+  {
+    getSession();
+    return proxy.getFieldList( encodePath(parentSite), proxy.getDocLibID( encodePath(parentSite), parentSite, docLibrary) );
+  }
+
+  /**
+  * Gets a list of field names of the given document library or list.
+  * @param parentSite - parent site path
+  * @param docLibrary name
   * @return list of the fields
   */
-  public Map getFieldList( String parentSite, String docLibraryOrList )
+  public Map getListFieldList( String parentSite, String listName )
     throws ServiceInterruption, ManifoldCFException
   {
     getSession();
-    return proxy.getFieldList( encodePath(parentSite), proxy.getDocLibID( encodePath(parentSite), parentSite, docLibraryOrList) );
+    return proxy.getFieldList( encodePath(parentSite), proxy.getListID( encodePath(parentSite), parentSite, listName) );
   }
 
   /**