Thursday 22 December 2011

Retrieve list of libraries on SharePoint site

Retrieve list of libraries on SharePoint site
This task use Java WSDL for SharePoint to retrieve list of libraries on SharePoint site.
Retrieve list of libraries on SharePoint site using Lists webservice
private List<String> getLibraries(String site, String username, String password) {
    List<String> tag = new ArrayList<String>();
    try {
        ListsSoapStub stub = SharePointWSDL.newLists(new URL(site + "/_vti_bin/Lists.asmx"), new ListsLocator());
        stub.setUsername(username);
        stub.setPassword(password);
        com.microsoft.schemas.sharepoint.soap.GetListCollectionResponseGetListCollectionResult lcr = stub.getListCollection();
        if (lcr.get_any().length > 0) {
            NodeList children = lcr.get_any()[0].getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                Node node = children.item(i);
                String baseType = node.getAttributes().getNamedItem("BaseType").getNodeValue();
                if (!"1".equals(baseType)) continue;
                String template = node.getAttributes().getNamedItem("ServerTemplate").getNodeValue();
                String title = node.getAttributes().getNamedItem("Title").getNodeValue();
                if ("|101|115|109|".indexOf("|" + template + "|") < 0) continue;
                tag.add(title);
            }
        }
    } catch (Exception e) {
        logger.error("", e);
    }
    return tag;
}
    

  Protected by Copyscape Online Copyright Protection

No comments:

Post a Comment