// Create the Document Object
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
properties.put(PropertyIds.NAME, filename);
ObjectId id = newFolder.createDocument(properties, contentStream, VersioningState.NONE);
// Did it work?
// Get the contents of the document by id
System.out.println("Getting object by id : " + id.getId());
Document doc = (Document) session.getObject(id);