Search in sources :

Example 26 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class SPSProxyHelper method getSites.

/**
 * Gets a list of sites given a parent site
 * @param parentSite the site to search for subsites, empty string for root
 * @return lists of sites as an arraylist of NameValue objects
 */
public List<NameValue> getSites(String parentSite) throws ManifoldCFException, ServiceInterruption {
    if (Logging.connectors.isDebugEnabled())
        Logging.connectors.debug("SharePoint: In getSites; parentSite='" + parentSite + "'");
    long currentTime;
    try {
        ArrayList<NameValue> result = new ArrayList<NameValue>();
        // Call the webs service
        if (parentSite.equals("/"))
            parentSite = "";
        WebsWS webService = new WebsWS(baseUrl + parentSite, userName, password, configuration, httpClient);
        WebsSoap webCall = webService.getWebsSoapHandler();
        GetWebCollectionResponseGetWebCollectionResult webResp = webCall.getWebCollection();
        org.apache.axis.message.MessageElement[] webList = webResp.get_any();
        final String xmlResponse = webList[0].toString();
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: getSites xml response: " + xmlResponse);
        final XMLDoc doc;
        try {
            doc = new XMLDoc(xmlResponse);
        } catch (ManifoldCFException e) {
            return null;
        }
        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();
        // <ns1:Webs>
        doc.processPath(nodeList, "*", parent);
        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 + "'");
            // 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));
                    }
                }
            }
        }
        return result;
    } catch (java.net.MalformedURLException e) {
        throw new ManifoldCFException("Bad SharePoint url: " + e.getMessage(), e);
    } catch (javax.xml.rpc.ServiceException e) {
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got a service exception getting subsites for site " + parentSite + " - retrying", e);
        currentTime = System.currentTimeMillis();
        throw new ServiceInterruption("Service exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true);
    } catch (org.apache.axis.AxisFault e) {
        // Bad XML can come from Microsoft.
        if (e.getCause() != null && (e.getCause() instanceof org.xml.sax.SAXParseException)) {
            return null;
        }
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
            if (elem != null) {
                elem.normalize();
                String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                // 302 is what SharePoint returns for external sites
                if (httpErrorCode.equals("404") || httpErrorCode.equals("302"))
                    return null;
                else if (httpErrorCode.equals("403"))
                    throw new ManifoldCFException("Remote procedure exception: " + e.getMessage(), e);
                else if (httpErrorCode.equals("401")) {
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: Crawl user does not have sufficient privileges to get subsites of site " + parentSite + " - skipping", e);
                    return null;
                }
                throw new ManifoldCFException("Unexpected http error code " + httpErrorCode + " accessing SharePoint at " + baseUrl + parentSite + ": " + e.getMessage(), e);
            }
            throw new ManifoldCFException("Unknown http error occurred: " + e.getMessage(), e);
        }
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
            String exceptionName = e.getFaultString();
            if (exceptionName.equals("java.lang.InterruptedException"))
                throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
        }
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got a remote exception getting subsites for site " + parentSite + " - retrying", e);
        currentTime = System.currentTimeMillis();
        throw new ServiceInterruption("Remote procedure exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
    } catch (java.rmi.RemoteException e) {
        throw new ManifoldCFException("Unexpected remote exception occurred: " + e.getMessage(), e);
    }
}
Also used : MessageElement(org.apache.axis.message.MessageElement) ArrayList(java.util.ArrayList) XMLDoc(org.apache.manifoldcf.core.common.XMLDoc) ServiceInterruption(org.apache.manifoldcf.agents.interfaces.ServiceInterruption) QName(javax.xml.namespace.QName) MessageElement(org.apache.axis.message.MessageElement) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException)

Example 27 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class SPSProxyHelper method buildMatchQuery.

/**
 * Build a query XML object that matches a specified field and value pair.
 */
protected static GetListItemsQuery buildMatchQuery(String fieldName, String type, String value) throws ManifoldCFException {
    try {
        GetListItemsQuery rval = new GetListItemsQuery();
        MessageElement queryNode = new MessageElement((String) null, "Query");
        rval.set_any(new MessageElement[] { queryNode });
        MessageElement whereNode = new MessageElement((String) null, "Where");
        queryNode.addChild(whereNode);
        MessageElement eqNode = new MessageElement((String) null, "Eq");
        whereNode.addChild(eqNode);
        MessageElement fieldRefNode = new MessageElement((String) null, "FieldRef");
        eqNode.addChild(fieldRefNode);
        fieldRefNode.addAttribute(null, "Name", fieldName);
        MessageElement valueNode = new MessageElement((String) null, "Value");
        eqNode.addChild(valueNode);
        valueNode.addAttribute(null, "Type", type);
        valueNode.addTextNode(value);
        return rval;
    } catch (javax.xml.soap.SOAPException e) {
        throw new ManifoldCFException(e.getMessage(), e);
    }
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) MessageElement(org.apache.axis.message.MessageElement) javax.xml.soap(javax.xml.soap) com.microsoft.schemas.sharepoint.soap(com.microsoft.schemas.sharepoint.soap)

Example 28 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class SPSProxyHelper method getDocumentACLs.

/**
 * Get the acls for a document.
 * NOTE that this function only works for SharePoint 2007+ with the MCPermissions web service installed.
 * @param site is the encoded subsite path
 * @param file is the encoded file url (not including protocol or server or location, but including encoded subsite, library and folder/file path)
 * @return array of document SIDs
 * @throws ManifoldCFException
 * @throws ServiceInterruption
 */
public String[] getDocumentACLs(String site, String file, boolean activeDirectoryAuthority) throws ManifoldCFException, ServiceInterruption {
    long currentTime;
    try {
        // root case
        if (site.compareTo("/") == 0)
            site = "";
        // Calculate the full server-relative path of the file
        String encodedRelativePath = serverLocation + file;
        if (encodedRelativePath.startsWith("/"))
            encodedRelativePath = encodedRelativePath.substring(1);
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: In getDocumentACLs for site '" + site + "', file '" + file + "': Encoded relative path is '" + encodedRelativePath + "'");
        UserGroupWS userService = new UserGroupWS(baseUrl + site, userName, password, configuration, httpClient);
        com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall = userService.getUserGroupSoapHandler();
        MCPermissionsWS aclService = new MCPermissionsWS(baseUrl + site, userName, password, configuration, httpClient);
        com.microsoft.sharepoint.webpartpages.PermissionsSoap aclCall = aclService.getPermissionsSoapHandler();
        com.microsoft.sharepoint.webpartpages.GetPermissionCollectionResponseGetPermissionCollectionResult aclResult = aclCall.getPermissionCollection(encodedRelativePath, "Item");
        if (aclResult == null) {
            Logging.connectors.debug("SharePoint: getDocumentACLs: document acls were null");
            return null;
        }
        org.apache.axis.message.MessageElement[] aclList = aclResult.get_any();
        final String xmlResponse = aclList[0].toString();
        if (Logging.connectors.isDebugEnabled()) {
            Logging.connectors.debug("SharePoint: getDocumentACLs xml response: " + xmlResponse);
        }
        final XMLDoc doc;
        try {
            doc = new XMLDoc(xmlResponse);
        } catch (ManifoldCFException e) {
            return null;
        }
        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);
        Set<String> sids = new HashSet<String>();
        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, activeDirectoryAuthority);
                    sids.add(userSid);
                } else {
                    // Role
                    List<String> roleSids;
                    String roleName = doc.getValue(node, "RoleName");
                    if (roleName.length() == 0) {
                        roleName = doc.getValue(node, "GroupName");
                        roleSids = getSidsForGroup(userCall, roleName, activeDirectoryAuthority);
                    } else {
                        roleSids = getSidsForRole(userCall, roleName, activeDirectoryAuthority);
                    }
                    for (String sid : roleSids) {
                        sids.add(sid);
                    }
                }
            }
        }
        return sids.toArray(new String[0]);
    } catch (java.net.MalformedURLException e) {
        throw new ManifoldCFException("Bad SharePoint url: " + e.getMessage(), e);
    } catch (javax.xml.rpc.ServiceException e) {
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got a service exception getting the acls for site " + site + " file " + file + " - retrying", e);
        currentTime = System.currentTimeMillis();
        throw new ServiceInterruption("Service exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true);
    } catch (org.apache.axis.AxisFault e) {
        // Bad XML can come from Microsoft.
        if (e.getCause() != null && (e.getCause() instanceof org.xml.sax.SAXParseException)) {
            return null;
        }
        currentTime = System.currentTimeMillis();
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
            if (elem != null) {
                elem.normalize();
                String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                // 302 is what SharePoint returns for external sites
                if (httpErrorCode.equals("404") || httpErrorCode.equals("302")) {
                    // Page did not exist
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The page at " + baseUrl + site + " did not exist or was external; skipping library");
                    return null;
                } else if (httpErrorCode.equals("401")) {
                    // User did not have permissions for this library to get the acls
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The crawl user did not have access to the MCPermissions service for " + baseUrl + site + "; skipping documents within");
                    return null;
                } else if (httpErrorCode.equals("403"))
                    throw new ManifoldCFException("Http error " + httpErrorCode + " while reading from " + baseUrl + site + " - check IIS and SharePoint security settings! " + e.getMessage(), e);
                else
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode + " accessing SharePoint at " + baseUrl + site + ": " + e.getMessage(), e);
            }
            throw new ManifoldCFException("Unknown http error occurred: " + e.getMessage(), e);
        } else if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/", "errorcode"));
            if (elem != null) {
                elem.normalize();
                String sharepointErrorCode = elem.getFirstChild().getNodeValue().trim();
                if (sharepointErrorCode.equals("0x82000006")) {
                    // List did not exist
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The file " + file + " in site " + site + " did not exist or was external; skipping file");
                    return null;
                } else {
                    if (Logging.connectors.isDebugEnabled()) {
                        org.w3c.dom.Element elem2 = e.lookupFaultDetail(new javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/", "errorstring"));
                        String errorString = "";
                        if (elem != null)
                            errorString = elem2.getFirstChild().getNodeValue().trim();
                        Logging.connectors.debug("SharePoint: Getting permissions for the file " + file + " in site " + site + " failed with unexpected SharePoint error code " + sharepointErrorCode + ": " + errorString + " - Skipping", e);
                    }
                    return null;
                }
            }
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("SharePoint: Unknown SharePoint server error getting the acls for site " + site + " file " + file + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString() + " - retrying", e);
            throw new ServiceInterruption("Unknown SharePoint server error: " + e.getMessage() + " - retrying", e, currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
        }
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
            String exceptionName = e.getFaultString();
            if (exceptionName.equals("java.lang.InterruptedException"))
                throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
        }
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got an unknown remote exception getting the acls for site " + site + " file " + file + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString() + " - retrying", e);
        throw new ServiceInterruption("Remote procedure exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
    } catch (java.rmi.RemoteException e) {
        // So, fail hard if we see it.
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got an unexpected remote exception getting the acls for site " + site + " file " + file, e);
        throw new ManifoldCFException("Unexpected remote procedure exception: " + e.getMessage(), e);
    }
}
Also used : MessageElement(org.apache.axis.message.MessageElement) ArrayList(java.util.ArrayList) XMLDoc(org.apache.manifoldcf.core.common.XMLDoc) ServiceInterruption(org.apache.manifoldcf.agents.interfaces.ServiceInterruption) HashSet(java.util.HashSet) QName(javax.xml.namespace.QName) MessageElement(org.apache.axis.message.MessageElement) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) QName(javax.xml.namespace.QName)

Example 29 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class SPSProxyHelper method getVersions.

/**
 * @param site
 * @param docPath
 * @return an XML document
 * @throws ManifoldCFException
 * @throws ServiceInterruption
 */
public XMLDoc getVersions(String site, String docPath) throws ServiceInterruption, ManifoldCFException {
    if (Logging.connectors.isDebugEnabled())
        Logging.connectors.debug("SharePoint: In getVersions; site='" + site + "', docPath='" + docPath + "'");
    long currentTime;
    try {
        // root case
        if (site.compareTo("/") == 0)
            site = "";
        VersionsWS versionsService = new VersionsWS(baseUrl + site, userName, password, configuration, httpClient);
        VersionsSoap versionsCall = versionsService.getVersionsSoapHandler();
        GetVersionsResponseGetVersionsResult versionsResp = versionsCall.getVersions(docPath);
        org.apache.axis.message.MessageElement[] lists = versionsResp.get_any();
        final String xmlResponse = lists[0].toString();
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: getVersions response: " + xmlResponse);
        final XMLDoc doc;
        try {
            doc = new XMLDoc(xmlResponse);
        } catch (ManifoldCFException e) {
            return null;
        }
        ArrayList nodeList = new ArrayList();
        doc.processPath(nodeList, "*", null);
        if (nodeList.size() != 1) {
            throw new ManifoldCFException("Bad xml - missing outer 'results' node - there are " + Integer.toString(nodeList.size()) + " nodes");
        }
        Object parent = nodeList.get(0);
        if (!doc.getNodeName(parent).equals("results"))
            throw new ManifoldCFException("Bad xml - outer node is not 'results'");
        return doc;
    } catch (java.net.MalformedURLException e) {
        throw new ManifoldCFException("Bad SharePoint url: " + e.getMessage(), e);
    } catch (javax.xml.rpc.ServiceException e) {
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got a service exception getting versions for site " + site + " docpath " + docPath + " - retrying", e);
        currentTime = System.currentTimeMillis();
        throw new ServiceInterruption("Service exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 12 * 60 * 60000L, -1, true);
    } catch (org.apache.axis.AxisFault e) {
        // Bad XML can come from Microsoft.
        if (e.getCause() != null && (e.getCause() instanceof org.xml.sax.SAXParseException)) {
            return null;
        }
        currentTime = System.currentTimeMillis();
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HTTP"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName("http://xml.apache.org/axis/", "HttpErrorCode"));
            if (elem != null) {
                elem.normalize();
                String httpErrorCode = elem.getFirstChild().getNodeValue().trim();
                // 302 is what SharePoint returns for external sites
                if (httpErrorCode.equals("404") || httpErrorCode.equals("302")) {
                    // Page did not exist
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The page at " + baseUrl + site + " did not exist or was external; skipping library");
                    return null;
                } else if (httpErrorCode.equals("401")) {
                    // User did not have permissions for this library to get the acls
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The crawl user did not have access to get versions for " + baseUrl + site + "; skipping");
                    return null;
                } else if (httpErrorCode.equals("403"))
                    throw new ManifoldCFException("Http error " + httpErrorCode + " while reading from " + baseUrl + site + " - check IIS and SharePoint security settings! " + e.getMessage(), e);
                else
                    throw new ManifoldCFException("Unexpected http error code " + httpErrorCode + " accessing SharePoint at " + baseUrl + site + ": " + e.getMessage(), e);
            }
            throw new ManifoldCFException("Unknown http error occurred: " + e.getMessage(), e);
        } else if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server"))) {
            org.w3c.dom.Element elem = e.lookupFaultDetail(new javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/", "errorcode"));
            if (elem != null) {
                elem.normalize();
                String sharepointErrorCode = elem.getFirstChild().getNodeValue().trim();
                if (sharepointErrorCode.equals("0x82000006")) {
                    // List did not exist
                    if (Logging.connectors.isDebugEnabled())
                        Logging.connectors.debug("SharePoint: The docpath " + docPath + " in site " + site + " did not exist or was external; skipping library");
                    return null;
                } else {
                    if (Logging.connectors.isDebugEnabled()) {
                        org.w3c.dom.Element elem2 = e.lookupFaultDetail(new javax.xml.namespace.QName("http://schemas.microsoft.com/sharepoint/soap/", "errorstring"));
                        String errorString = "";
                        if (elem != null)
                            errorString = elem2.getFirstChild().getNodeValue().trim();
                        Logging.connectors.debug("SharePoint: Getting versions for the docpath " + docPath + " in site " + site + " failed with unexpected SharePoint error code " + sharepointErrorCode + ": " + errorString + " - Skipping", e);
                    }
                    return null;
                }
            }
            if (Logging.connectors.isDebugEnabled())
                Logging.connectors.debug("SharePoint: Unknown SharePoint server error getting versions for site " + site + " docpath " + docPath + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString() + " - retrying", e);
            throw new ServiceInterruption("Unknown SharePoint server error: " + e.getMessage() + " - retrying", e, currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
        }
        if (e.getFaultCode().equals(new javax.xml.namespace.QName("http://schemas.xmlsoap.org/soap/envelope/", "Server.userException"))) {
            String exceptionName = e.getFaultString();
            if (exceptionName.equals("java.lang.InterruptedException"))
                throw new ManifoldCFException("Interrupted", ManifoldCFException.INTERRUPTED);
        }
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got an unknown remote exception getting versions for site " + site + " docpath " + docPath + " - axis fault = " + e.getFaultCode().getLocalPart() + ", detail = " + e.getFaultString() + " - retrying", e);
        throw new ServiceInterruption("Remote procedure exception: " + e.getMessage(), e, currentTime + 300000L, currentTime + 3 * 60 * 60000L, -1, false);
    } catch (java.rmi.RemoteException e) {
        // So, fail hard if we see it.
        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("SharePoint: Got an unexpected remote exception getting versions for site " + site + " docpath " + docPath, e);
        throw new ManifoldCFException("Unexpected remote procedure exception: " + e.getMessage(), e);
    }
}
Also used : MessageElement(org.apache.axis.message.MessageElement) ArrayList(java.util.ArrayList) XMLDoc(org.apache.manifoldcf.core.common.XMLDoc) ServiceInterruption(org.apache.manifoldcf.agents.interfaces.ServiceInterruption) QName(javax.xml.namespace.QName) MessageElement(org.apache.axis.message.MessageElement) ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) QName(javax.xml.namespace.QName)

Example 30 with ManifoldCFException

use of org.apache.manifoldcf.core.interfaces.ManifoldCFException in project manifoldcf by apache.

the class SPSProxyHelper method getSidForUser.

/**
 * @param userCall
 * @param userLogin
 */
private String getSidForUser(com.microsoft.schemas.sharepoint.soap.directory.UserGroupSoap userCall, String userLogin, boolean activeDirectoryAuthority) throws ManifoldCFException, java.net.MalformedURLException, javax.xml.rpc.ServiceException, java.rmi.RemoteException {
    String rval;
    if (!activeDirectoryAuthority) {
        // Do we want to return user ID via getUserInfo?  A:No; user login is the right thing to return.
        rval = "U" + userLogin;
    } else {
        com.microsoft.schemas.sharepoint.soap.directory.GetUserInfoResponseGetUserInfoResult userResp = userCall.getUserInfo(userLogin);
        org.apache.axis.message.MessageElement[] userList = userResp.get_any();
        if (userList.length != 1)
            throw new ManifoldCFException("Bad response - expecting one outer 'GetUserInfo' node, saw " + Integer.toString(userList.length));
        MessageElement users = userList[0];
        if (!users.getElementName().getLocalName().equals("GetUserInfo"))
            throw new ManifoldCFException("Bad response - outer node should have been 'GetUserInfo' node");
        String userID = null;
        Iterator userIter = users.getChildElements();
        while (userIter.hasNext()) {
            MessageElement child = (MessageElement) userIter.next();
            if (child.getElementName().getLocalName().equals("User")) {
                userID = child.getAttribute("Sid");
            }
        }
        if (userID == null)
            throw new ManifoldCFException("Could not find user login '" + userLogin + "' so could not get SID");
        rval = userID;
    }
    return rval;
}
Also used : ManifoldCFException(org.apache.manifoldcf.core.interfaces.ManifoldCFException) Iterator(java.util.Iterator) MessageElement(org.apache.axis.message.MessageElement)

Aggregations

ManifoldCFException (org.apache.manifoldcf.core.interfaces.ManifoldCFException)174 IOException (java.io.IOException)81 InterruptedIOException (java.io.InterruptedIOException)71 ServiceInterruption (org.apache.manifoldcf.agents.interfaces.ServiceInterruption)32 ArrayList (java.util.ArrayList)27 MessageElement (org.apache.axis.message.MessageElement)23 RemoteException (java.rmi.RemoteException)22 InputStream (java.io.InputStream)18 SpecificationNode (org.apache.manifoldcf.core.interfaces.SpecificationNode)17 QName (javax.xml.namespace.QName)15 Date (java.util.Date)14 RepositoryDocument (org.apache.manifoldcf.agents.interfaces.RepositoryDocument)14 XMLDoc (org.apache.manifoldcf.core.common.XMLDoc)12 MalformedURLException (java.net.MalformedURLException)11 UnknownHostException (java.net.UnknownHostException)11 SmbFile (jcifs.smb.SmbFile)9 Iterator (java.util.Iterator)8 ConfigurationNode (org.apache.manifoldcf.core.interfaces.ConfigurationNode)8 HashMap (java.util.HashMap)7 CmisConnectionException (org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException)7