0

Have tried to search for this almost 'everywhere', but couldn't find a pointer as to how to implement this. Please kindly review my code and offer suggestions on how to set/update ALL documents properties in SharePoint using OpenCMIS. Have created the documents successfully using CMIS, however I'm not able to populate different values for different documents.

For example, a.pdf, b.pdf have different properties. So when I update them, i expect the value to be mapped from array of values assigned to them but at the moment, the same value are being append to all the documents...

Please see my code below, hopefully it will make things clearer:

            try {
                String [] nextLine =null;
                CSVReader reader = new CSVReader(new FileReader(indexFileLocation));
                List content = reader.readAll();

                for (Object o : content) {
                    nextLine = (String[]) o;
                    System.out.println("\n"+ nextLine[2] + "\n"+nextLine[7] + "\n"+ nextLine[6]);
                }
                //reader.close();
                Map <String, Object> newDocProps = new HashMap<String, Object>();
                newDocProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
                newDocProps.put(PropertyIds.NAME, ff.getName());
                Document doc = newFolder.createDocument(newDocProps, contentStream, VersioningState.NONE);

                CmisObject cmisobject = (Document) session.getObject(doc.getId());
                Map<String, Object> pp = new HashMap<String, Object>();
                //pp.put(PropertyIds.OBJECT_ID, "Name");

                pp.put("WorkflowNumber", nextLine[7]);
                pp.put("InvoiceDate", nextLine[2]);

                cmisobject.updateProperties(pp);

Any help is appreciated.

Albert
  • 23
  • 7

1 Answers1

0

@Albert, How are you creating session? It could be an issue with session creation. Please paste your code here to create session.

Sam
  • 244
  • 2
  • 5
  • 20
  • Hi Sam, Thanks for your response. As requested, this is the code I'm using in creating a Session Session session = sessionFactory.createSession(parameter); RepositoryInfo info = session.getRepositoryInfo(); – Albert Feb 11 '13 at 13:09
  • what Object factory parameter you are passing in map when creating session? It should be like map.put(SessionParameter.OBJECT_FACTORY_CLASS,) – Sam Feb 13 '13 at 01:16
  • Thanks Sam! I am using the cold below to create a session: repositories = sessionFactory.getRepositories(parameter); for (Repository r : repositories) { System.out.println("Found repository: " + r.getName()); } Repository repository = repositories.get(Integer.parseInt(repository_id)); parameter.put(SessionParameter.REPOSITORY_ID, repository.getId()); Session session = sessionFactory.createSession(parameter); – Albert Feb 16 '13 at 11:13
  • The main issue I'm facing is reading my csv property files. Seems I'm not reading it properly. Since I'm trying to fill the column name in SharePoint with the properties inside the CSV file. I used csvreader to read the csv, however when I pass in for instance, line[2], I expect the documents to be populated with the whole value of that positions of the documents. Can paste the code to make it clearer. Thanks for your help – Albert Feb 16 '13 at 11:16