parag patel
parag patel

Reputation: 63

CmisInvalidArgumentException bad request exception

i am getting below error while run this program i am using SharePoint server 2010 and recently i am install danish language pack in SharePoint server for client environment . but after this when ever i am run below code i am getting below exceptions

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

here it is my lib which i used in above code . chemistry-opencmis-client-api-0.9.0 chemistry-opencmis-client-bindings-0.9.0 chemistry-opencmis-client-impl-0.9.0 chemistry-opencmis-commons-api-0.9.0 chemistry-opencmis-commons-impl-0.9.0 log4j-1.2.14 slf4j-api-1.6.1 slf4j-log4j12-1.6.1

it works fine when i am trying to connect repository (url) which is created in english language . but when try to connect with the danish .repository then getting error.

Upvotes: 0

Views: 2049

Answers (1)

Florian M&#252;ller
Florian M&#252;ller

Reputation: 3235

The best thing you can do is to increase the SharePoint log level for CMIS. Sometimes the logs provide a clue.

The SharePoint 2010 CMIS implementaion isn't a 100% spec compliant. OpenCMIS 0.12.0 contains a few workarounds for SharePoint 2010 and 2013. Most of them a little things like an extra requied URL parameter that isn't in the spec. I wouldn't be supprised if this is something similar.

Upvotes: 1

Related Questions