CmisInvalidArgumentException错误的请求异常

时间:2014-09-19 13:25:48

标签: cmis

我在运行此程序时遇到错误 我正在使用SharePoint Server 2010,最近我在SharePoint服务器中为客户端环境安装了丹麦语言包。但在此之后,我在代码下运行  我正在低于例外

org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:453)
    at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:601)
    at org.apache.chemistry.opencmis.client.bindings.spi.atompub.NavigationServiceImpl.getChildren(NavigationServiceImpl.java:86)
    at org.apache.chemistry.opencmis.client.runtime.FolderImpl$2.fetchPage(FolderImpl.java:285)
    at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getCurrentPage(AbstractIterator.java:132)
    at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterator.getTotalNumItems(AbstractIterator.java:70)
    at org.apache.chemistry.opencmis.client.runtime.util.AbstractIterable.getTotalNumItems(AbstractIterable.java:94)
    at ShareTest1.main(ShareTest1.java:188)









public class ShareTest
{
    static Session session = null;
    static Map<String,Map<String, String>> allPropMap=new HashMap<String,Map<String, String>>();

    static void getSubTypes(Tree tree)
    {       
        ObjectType objType = (ObjectType) tree.getItem();
        if(objType instanceof DocumentType)
        {
            System.out.println("\n\nType name "+objType.getDisplayName());
            System.out.println("Type Id "+objType.getId());

            ObjectType typeDoc=session.getTypeDefinition(objType.getId());
            Map<String,PropertyDefinition<?>> mp=typeDoc.getPropertyDefinitions();
            for(String key:mp.keySet())
            {
                PropertyDefinition<?> propdef=mp.get(key);
                HashMap<String,String> propMap=new HashMap<String,String>();
                propMap.put("id",propdef.getId());
                propMap.put("displayName",propdef.getDisplayName());

                System.out.println("\nId="+propMap.get("id")+" DisplayName="+propMap.get("displayName"));
                System.out.println("Property Type = "+propdef.getPropertyType().toString());
                System.out.println("Property Name = "+propdef.getPropertyType().name());
                System.out.println("Property Local Namespace = "+propdef.getLocalNamespace());
                if(propdef.getChoices()!=null)
                {
                    System.out.println("Choices size "+propdef.getChoices().size());
                }
                if(propdef.getExtensions()!=null)
                {
                    System.out.println("Extensions "+propdef.getExtensions().size());
                }
                allPropMap.put(propdef.getId(),propMap);
            }

            List lstc=tree.getChildren();
            System.out.println("\nSize of list "+lstc.size());
            for (int i = 0; i < lstc.size(); i++) {
            getSubTypes((Tree) lstc.get(i));
            }
        }

}
    public static void main(String[] args)
    {
        /**
        * Get a CMIS session.
        */

        String user="parag.patel";
        String pwd="Admin123";  

        /*Repository : Abc*/
        String url="http://sharepointind1:34326/sites/DanishTest/_vti_bin/cmis/rest/6B4D3830-65E5-49C9-9A02-5D67DB1FE87B?getRepositoryInfo";
        String repositoryId="6B4D3830-65E5-49C9-9A02-5D67DB1FE87B";

        // Default factory implementation of client runtime.

        // default factory implementation
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Map<String, String> parameter = new HashMap<String, String>();

        // user credentials
        parameter.put(SessionParameter.USER, "parag.patel");
        parameter.put(SessionParameter.PASSWORD, "Admin123");

        // connection settings
        parameter.put(SessionParameter.ATOMPUB_URL, "http://sharepointind1:34326/sites/DanishTest/_vti_bin/cmis/rest/6B4D3830-65E5-49C9-9A02-5D67DB1FE87B?getRepositoryInfo");
        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        parameter.put(SessionParameter.REPOSITORY_ID, "6B4D3830-65E5-49C9-9A02-5D67DB1FE87B");

        parameter.put(SessionParameter.LOCALE_ISO3166_COUNTRY, "DK");
        parameter.put(SessionParameter.LOCALE_ISO639_LANGUAGE, "da");
        parameter.put(SessionParameter.LOCALE_VARIANT, "");

        parameter.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, CmisBindingFactory.STANDARD_AUTHENTICATION_PROVIDER);

        // create session
        Session session = factory.createSession(parameter);

        if(repositoryId!=null)
        {
            parameter.put(SessionParameter.REPOSITORY_ID, repositoryId);
            session=factory.createSession(parameter);   

            RepositoryInfo repInfo=session.getRepositoryInfo();
            System.out.println("Repository Id "+repInfo.getId());
            System.out.println("Repository Name "+repInfo.getName());
            System.out.println("Repository cmis version supported "+repInfo.getCmisVersionSupported());
            System.out.println("Sharepoint product "+repInfo.getProductName());
            System.out.println("Sharepoint version "+repInfo.getProductVersion());
            System.out.println("Root folder id "+repInfo.getRootFolderId());

            try
            {
                AclCapabilities cap=session.getRepositoryInfo().getAclCapabilities();
                OperationContext operationContext = session.createOperationContext();
                int maxItemsPerPage=5;
                //operationContext.setMaxItemsPerPage(maxItemsPerPage);
                int documentCount=0;
                session.setDefaultContext(operationContext);
                CmisObject object = session.getObject(new ObjectIdImpl(repInfo.getRootFolderId()));
                Folder folder = (Folder) object;
                System.out.println("======================= Root folder "+folder.getName());
                ItemIterable<CmisObject> children = folder.getChildren();
                long to=folder.getChildren().getTotalNumItems();
                System.out.println("Total Children "+to);
                Iterator<CmisObject> iterator = children.iterator();
                while (iterator.hasNext()) {
                    CmisObject child = iterator.next();                 
                    System.out.println("\n\nChild Id "+child.getId());
                    System.out.println("Child Name "+child.getName());
                    if (child.getBaseTypeId().value().equals(ObjectType.FOLDER_BASETYPE_ID))
                    {
                        System.out.println("Type : Folder");
                        Folder ftemp=(Folder) child;
                        long tot=ftemp.getChildren().getTotalNumItems();
                        System.out.println("Total Children "+tot);
                        ItemIterable<CmisObject> ftempchildren = ftemp.getChildren();

                        Iterator<CmisObject> ftempIt = ftempchildren.iterator();
                        int folderDoc=0;
                        while (ftempIt.hasNext()) {
                            CmisObject subchild = ftempIt.next();
                            if(subchild.getBaseTypeId().value().equals(ObjectType.DOCUMENT_BASETYPE_ID))
                            {
                                System.out.println("============ SubDoc "+subchild.getName());
                                folderDoc++;
                                documentCount++;
                            }
                        }
                        System.out.println("Folder "+child.getName()+" No of documents="+(folderDoc));
                    }                   
                    else
                    {
                        System.out.println("Type : Document "+child.getName());
                        documentCount++;
                    }
                }
                System.out.println("\n\nTotal no of documents "+documentCount);


            }
            catch(CmisPermissionDeniedException pd)
            {
                System.out.println("Error ********** Permission Denied ***************** ");
                pd.printStackTrace();
            }
            catch (CmisObjectNotFoundException co) {
                System.out.println("Error ******** Root folder not found ***************");
                co.printStackTrace();
            }
            catch (Exception e) {
                e.printStackTrace();
            }

        }
        else
        {
            System.out.println("Else");
            Repository soleRepository=factory.getRepositories(
                    parameter).get(0);
            session = soleRepository.createSession();           
        }
    }
}

这里是我在上面代码中使用的lib。 化学-opencmis客户端的API-0.9.0 化学-opencmis-客户绑定-0.9.0 化学-opencmis-客户IMPL-0.9.0 化学-opencmis公地-API-0.9.0 化学-opencmis-公地IMPL-0.9.0 log4j的-1.2.14 SLF4J-API-1.6.1 SLF4J-log4j12-1.6.1

当我尝试连接用英语创建的存储库(url)时,它工作正常。 但是当试图与丹麦.repository连接然后得到错误。

1 个答案:

答案 0 :(得分:1)

您可以做的最好的事情是增加CMIS的SharePoint日志级别。有时日志提供了线索。

SharePoint 2010 CMIS实现不符合100%规范。 OpenCMIS 0.12.0包含一些适用于SharePoint 2010和2013的解决方法。其中大部分都是一些小问题,例如一个不在规范中的额外需要的URL参数。如果这是类似的话,我不会被侮辱。