Package org.apache.manifoldcf.core.common

Examples of org.apache.manifoldcf.core.common.XMLDoc


  {

    com.microsoft.schemas.sharepoint.soap.directory.GetUserCollectionFromRoleResponseGetUserCollectionFromRoleResult roleResp = userCall.getUserCollectionFromRole( roleName );
    org.apache.axis.message.MessageElement[] roleList = roleResp.get_any();

    XMLDoc doc = new XMLDoc( roleList[0].toString() );
    ArrayList nodeList = new ArrayList();

    doc.processPath(nodeList, "*", null);
    if (nodeList.size() != 1)
    {
      throw new ManifoldCFException("Bad xml - missing outer 'ns1:GetUserCollectionFromRole' node - there are "+Integer.toString(nodeList.size())+" nodes");
    }
    Object parent = nodeList.get(0);
    if (!doc.getNodeName(parent).equals("ns1:GetUserCollectionFromRole"))
      throw new ManifoldCFException("Bad xml - outer node is not 'ns1:GetUserCollectionFromRole'");

    nodeList.clear();
    doc.processPath(nodeList, "*", parent)// <ns1:Users>

    if ( nodeList.size() != 1 )
    {
      throw new ManifoldCFException( " No Users collection found." );
    }
    parent = nodeList.get(0);
    nodeList.clear();
    doc.processPath( nodeList, "*", parent ); // <ns1:User>

    ArrayList sidsList = new ArrayList();
    String[] sids = new String[0];
    int i = 0;
    while (i < nodeList.size())
    {
      Object o = nodeList.get( i++ );
      sidsList.add( doc.getValue( o, "Sid" ) );
    }
    sids = (String[])sidsList.toArray( (Object[])sids );
    return sids;
  }
View Full Code Here


      GetAttachmentCollectionResponseGetAttachmentCollectionResult listResponse =
        listCall.getAttachmentCollection( listName, itemID );
      org.apache.axis.message.MessageElement[] List = listResponse.get_any();

      XMLDoc doc = new XMLDoc( List[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer node - there are "+Integer.toString(nodeList.size())+" nodes");
      }

      Object attachments = nodeList.get(0);
      if ( !doc.getNodeName(attachments).equals("ns1:Attachments") )
        throw new ManifoldCFException( "Bad xml - outer node '" + doc.getNodeName(attachments) + "' is not 'ns1:Attachments'");

      nodeList.clear();
      doc.processPath(nodeList, "*", attachments);

      int i = 0;
      while (i < nodeList.size())
      {
        Object o = nodeList.get( i++ );
        if ( !doc.getNodeName(o).equals("ns1:Attachment") )
          throw new ManifoldCFException( "Bad xml - inner node '" + doc.getNodeName(o) + "' is not 'ns1:Attachment'");
        String attachmentURL = doc.getData( o );
        if (attachmentURL != null)
        {
          int index = attachmentURL.lastIndexOf("/");
          if (index == -1)
            throw new ManifoldCFException("Unexpected attachment URL form: '"+attachmentURL+"'");
View Full Code Here

      ListsSoap listCall = listService.getListsSoapHandler();

      GetListResponseGetListResult listResponse = listCall.getList( listName );
      org.apache.axis.message.MessageElement[] List = listResponse.get_any();

      XMLDoc doc = new XMLDoc( List[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer node - there are "+Integer.toString(nodeList.size())+" nodes");
      }

      Object parent = nodeList.get(0);
      if (!doc.getNodeName(parent).equals("ns1:List"))
        throw new ManifoldCFException("Bad xml - outer node is '" + doc.getNodeName(parent) + "' not 'ns1:List'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent)// <ns1:Fields>

      Object fields = nodeList.get(0);
      if ( !doc.getNodeName(fields).equals("ns1:Fields") )
        throw new ManifoldCFException( "Bad xml - child node 0 '" + doc.getNodeName(fields) + "' is not 'ns1:Fields'");

      nodeList.clear();
      doc.processPath(nodeList, "*", fields);

      int i = 0;
      while (i < nodeList.size())
      {
        Object o = nodeList.get( i++ );
        // Logging.connectors.debug( i + ": " + o );
        String name = doc.getValue( o, "DisplayName" );
        String fieldName = doc.getValue( o, "Name" );
        String hidden = doc.getValue( o, "Hidden" );
        // System.out.println( "Hidden :" + hidden );
        if ( name.length() != 0 && fieldName.length() != 0 && ( !hidden.equalsIgnoreCase( "true") ) )
        {
          // make sure we don't include the same field more than once.
          // This may happen if the Library has more than one view.
View Full Code Here

        if (Logging.connectors.isDebugEnabled())
        {
          Logging.connectors.debug("SharePoint: list xml: '" + list[0].toString() + "'");
        }

        XMLDoc doc = new XMLDoc( list[0].toString() );
        ArrayList nodeList = new ArrayList();

        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");
        }

        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);
          }
        }
      }
      else
      {
        // SharePoint 2010: Get field values some other way
        // Sharepoint 2010; use Lists service instead
        ListsWS lservice = new ListsWS(baseUrl + site, userName, password, configuration, httpClient );
        ListsSoapStub stub1 = (ListsSoapStub)lservice.getListsSoapHandler();
       
        String sitePlusDocId = serverLocation + site + docId;
        if (sitePlusDocId.startsWith("/"))
          sitePlusDocId = sitePlusDocId.substring(1);
       
        GetListItemsQuery q = buildMatchQuery("FileRef","Text",sitePlusDocId);
        GetListItemsViewFields viewFields = buildViewFields(fieldNames);

        GetListItemsResponseGetListItemsResult items =  stub1.getListItems(docLibrary, "", q, viewFields, "1", buildNonPagingQueryOptions(), null);
        if (items == null)
          return result;

        MessageElement[] list = items.get_any();

        if (Logging.connectors.isDebugEnabled()){
          Logging.connectors.debug("SharePoint: getListItems for '"+docId+"' using FileRef value '"+sitePlusDocId+"' xml response: '" + list[0].toString() + "'");
        }

        ArrayList nodeList = new ArrayList();
        XMLDoc doc = new XMLDoc(list[0].toString());

        doc.processPath(nodeList, "*", null);
        if (nodeList.size() != 1)
          throw new ManifoldCFException("Bad xml - expecting one outer 'ns1:listitems' node - there are " + Integer.toString(nodeList.size()) + " nodes");

        Object parent = nodeList.get(0);
        if (!"ns1:listitems".equals(doc.getNodeName(parent)))
          throw new ManifoldCFException("Bad xml - outer node is not 'ns1:listitems'");

        nodeList.clear();
        doc.processPath(nodeList, "*", parent);

        if (nodeList.size() != 1)
          throw new ManifoldCFException("Expected rsdata result but no results found.");

        Object rsData = nodeList.get(0);

        int itemCount = Integer.parseInt(doc.getValue(rsData, "ItemCount"));
        if (itemCount == 0)
          return result;
         
        // Now, extract the files from the response document
        ArrayList nodeDocs = new ArrayList();

        doc.processPath(nodeDocs, "*", rsData);

        if (nodeDocs.size() != itemCount)
          throw new ManifoldCFException("itemCount does not match with nodeDocs.size()");

        if (itemCount != 1)
          throw new ManifoldCFException("Expecting only one item, instead saw '"+itemCount+"'");
       
        Object o = nodeDocs.get(0);
       
        // Look for all the specified attributes in the record
        for (Object attrName : fieldNames)
        {
          String attrValue = doc.getValue(o,"ows_"+(String)attrName);
          if (attrValue != null)
          {
            result.put(attrName.toString(),valueMunge(attrValue));
          }
        }
View Full Code Here

      WebsSoap webCall = webService.getWebsSoapHandler();

      GetWebCollectionResponseGetWebCollectionResult webResp = webCall.getWebCollection();
      org.apache.axis.message.MessageElement[] webList = webResp.get_any();

      XMLDoc doc = new XMLDoc( webList[0].toString() );
      ArrayList nodeList = new ArrayList();

      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'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent)// <ns1:Webs>

      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" );

        // Leave here for now
        if (Logging.connectors.isDebugEnabled())
          Logging.connectors.debug("SharePoint: Subsite list: '"+url+"', '"+title+"'");
       
View Full Code Here

      GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
      org.apache.axis.message.MessageElement[] lists = listResp.get_any();

      //if ( parentSite.compareTo("/Sample2") == 0) System.out.println( lists[0].toString() );

      XMLDoc doc = new XMLDoc( lists[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer 'ns1:Lists' node - there are "+Integer.toString(nodeList.size())+" nodes");
      }
      Object parent = nodeList.get(0);
      if (!doc.getNodeName(parent).equals("ns1:Lists"))
        throw new ManifoldCFException("Bad xml - outer node is not 'ns1:Lists'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent)// <ns1:Lists>

      String prefixPath = decodedServerLocation + parentSiteDecoded + "/";

      int i = 0;
      while (i < nodeList.size())
      {
        Object o = nodeList.get( i++ );

        String baseType = doc.getValue( o, "BaseType");
        if ( baseType.equals( "1" ) )
        {
          // We think it's a library

          // This is how we display it, so this has the right path extension
          String urlPath = doc.getValue( o, "DefaultViewUrl" );
          // This is the pretty name
          String title = doc.getValue( o, "Title" );

          // Leave this in for the moment
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Library list: '"+urlPath+"', '"+title+"'");

View Full Code Here

      GetListCollectionResponseGetListCollectionResult listResp = listsCall.getListCollection();
      org.apache.axis.message.MessageElement[] lists = listResp.get_any();

      //if ( parentSite.compareTo("/Sample2") == 0) System.out.println( lists[0].toString() );

      XMLDoc doc = new XMLDoc( lists[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer 'ns1:Lists' node - there are "+Integer.toString(nodeList.size())+" nodes");
      }
      Object parent = nodeList.get(0);
      if (!doc.getNodeName(parent).equals("ns1:Lists"))
        throw new ManifoldCFException("Bad xml - outer node is not 'ns1:Lists'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent)// <ns1:Lists>

      String prefixPath = decodedServerLocation + parentSiteDecoded + "/";

      int i = 0;
      while (i < nodeList.size())
      {
        Object o = nodeList.get( i++ );

        String baseType = doc.getValue( o, "BaseType");
        if ( baseType.equals( "0" ) )
        {
          // We think it's a list

          // This is how we display it, so this has the right path extension
          String urlPath = doc.getValue( o, "DefaultViewUrl" );
          // This is the pretty name
          String title = doc.getValue( o, "Title" );

          // Leave this in for the moment
          if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: List: '"+urlPath+"', '"+title+"'");

View Full Code Here

      com.microsoft.schemas.sharepoint.soap.directory.PermissionsSoap aclCall = aclService.getPermissionsSoapHandler( );

      com.microsoft.schemas.sharepoint.soap.directory.GetPermissionCollectionResponseGetPermissionCollectionResult aclResult = aclCall.getPermissionCollection( guid, "List" );
      org.apache.axis.message.MessageElement[] aclList = aclResult.get_any();

      XMLDoc doc = new XMLDoc( aclList[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer 'ns1:GetPermissionCollection' node - there are "+Integer.toString(nodeList.size())+" nodes");
      }
      Object parent = nodeList.get(0);
      if (!doc.getNodeName(parent).equals("ns1:GetPermissionCollection"))
        throw new ManifoldCFException("Bad xml - outer node is not 'ns1:GetPermissionCollection'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent);

      if ( nodeList.size() != 1 )
      {
        throw new ManifoldCFException( " No results found." );
      }
      parent = nodeList.get(0);
      nodeList.clear();
      doc.processPath( nodeList, "*", parent );
      java.util.HashSet sids = new java.util.HashSet();
      int i = 0;
      for (; i< nodeList.size(); i++ )
      {
        Object node = nodeList.get( i );
        String mask = doc.getValue( node, "Mask" );
        long maskValue = new Long(mask).longValue();
        if ((maskValue & 1L) == 1L)
        {
          // Permission to view
          String isUser = doc.getValue( node, "MemberIsUser" );

          if ( isUser.compareToIgnoreCase("True") == 0 )
          {
            // Use AD user or group
            String userLogin = doc.getValue( node, "UserLogin" );
            String userSid = getSidForUser( userCall, userLogin );
            sids.add( userSid );
          }
          else
          {
            // Role
            String[] roleSids;
            String roleName = doc.getValue( node, "RoleName" );
            if ( roleName.length() == 0)
            {
              roleName = doc.getValue(node,"GroupName");
              roleSids = getSidsForGroup(userCall, roleName);
            }
            else
            {
              roleSids = getSidsForRole(userCall, roleName);
View Full Code Here

      if (Logging.connectors.isDebugEnabled())
      {
        Logging.connectors.debug("SharePoint: document acls xml: '" + aclList[0].toString() + "'");
      }

      XMLDoc doc = new XMLDoc( aclList[0].toString() );
      ArrayList nodeList = new ArrayList();

      doc.processPath(nodeList, "*", null);
      if (nodeList.size() != 1)
      {
        throw new ManifoldCFException("Bad xml - missing outer 'ns1:GetPermissionCollection' node - there are "+Integer.toString(nodeList.size())+" nodes");
      }
      Object parent = nodeList.get(0);
      if (!doc.getNodeName(parent).equals("GetPermissionCollection"))
        throw new ManifoldCFException("Bad xml - outer node is not 'GetPermissionCollection'");

      nodeList.clear();
      doc.processPath(nodeList, "*", parent);

      if ( nodeList.size() != 1 )
      {
        throw new ManifoldCFException( " No results found." );
      }
      parent = nodeList.get(0);
      nodeList.clear();
      doc.processPath( nodeList, "*", parent );
      java.util.HashSet sids = new java.util.HashSet();
      int i = 0;
      for (; i< nodeList.size(); i++ )
      {
        Object node = nodeList.get( i );
        String mask = doc.getValue( node, "Mask" );
        long maskValue = new Long(mask).longValue();
        if ((maskValue & 1L) == 1L)
        {
          // Permission to view
          String isUser = doc.getValue( node, "MemberIsUser" );

          if ( isUser.compareToIgnoreCase("True") == 0 )
          {
            // Use AD user or group
            String userLogin = doc.getValue( node, "UserLogin" );
            String userSid = getSidForUser( userCall, userLogin );
            sids.add( userSid );
          }
          else
          {
            // Role
            String[] roleSids;
            String roleName = doc.getValue( node, "RoleName" );
            if ( roleName.length() == 0)
            {
              roleName = doc.getValue(node,"GroupName");
              roleSids = getSidsForGroup(userCall, roleName);
            }
            else
            {
              roleSids = getSidsForRole(userCall, roleName);
View Full Code Here

        if (Logging.connectors.isDebugEnabled())
        {
          Logging.connectors.debug("SharePoint: list xml: '" + list[0].toString() + "'");
        }

        XMLDoc doc = new XMLDoc( list[0].toString() );

        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");
        }

        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);

        if ( nodeList.size() != 2 )
        {
          throw new ManifoldCFException( " No results found." );
        }

        // Now, extract the files from the response document
        XMLDoc docs = doc;
        ArrayList nodeDocs = new ArrayList();

        docs.processPath( nodeDocs, "*", null );
        parent = nodeDocs.get(0);                // ns1:dsQueryResponse
        nodeDocs.clear();
        docs.processPath(nodeDocs, "*", parent);
        Object documents = nodeDocs.get(1);
        nodeDocs.clear();
        docs.processPath(nodeDocs, "*", documents);

        StringBuilder sb = new StringBuilder();
        for( int j =0; j < nodeDocs.size(); j++)
        {
          Object node = nodeDocs.get(j);
          Logging.connectors.debug( node.toString() );
          String relPath = docs.getData( docs.getElement( node, "FileRef" ) );
          fileStream.addFile( relPath );
        }
      }
      else
      {
View Full Code Here

TOP

Related Classes of org.apache.manifoldcf.core.common.XMLDoc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.