try { document = parentFolder.createDocument(props, contentStream, null); System.out.println("Created new document: " + document.getId()); } catch (CmisContentAlreadyExistsException ccaee) { document = (Document) cmisSession.getObjectByPath(parentFolder.getPath() + "/" + fileName);
this.documentId = doc.getId(); this.changeToken = doc.getChangeToken(); this.overwrite = overwrite;
@Override public void createDocument(DocumentSummary doc) { Session session = getSession(); if (session != null) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); properties.put(PropertyIds.NAME, doc.getName()); InputStream stream = new ByteArrayInputStream(doc.getContent()); ContentStream contentStream = new ContentStreamImpl(doc.getName(), BigInteger.valueOf(doc.getContent().length), MimeTypes.getMIMEType(doc.getName()), stream); Document createdDoc = ((Folder) session.getObjectByPath(doc.getPath())).createDocument( properties, contentStream, VersioningState.NONE); doc.setId(createdDoc.getId()); } else { throw new IllegalStateException("Could not get CMIS session"); } }
private Document createVersion(Session session, Document doc, String content, int version) { CmisTestResult f; // check out ObjectId pwcId = doc.checkOut(); Document pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); addResult(checkObject(session, pwc, getAllProperties(pwc), "PWC " + version + " compliance")); // check in byte[] contentBytes = IOUtils.toUTF8Bytes(content); ContentStream contentStream = new ContentStreamImpl(doc.getName(), BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes)); ObjectId newVersionId = pwc.checkIn(true, null, contentStream, "test version " + version); IOUtils.closeQuietly(contentStream); Document newVersion = (Document) session.getObject(newVersionId, SELECT_ALL_NO_CACHE_OC); addResult(checkObject(session, newVersion, getAllProperties(newVersion), "Version " + version + " compliance")); // check version history List<Document> versions = doc.getAllVersions(); f = createResult(FAILURE, "Version series should have " + version + " versions but has " + versions.size() + "!"); addResult(assertEquals(version, versions.size(), null, f)); if (!versions.isEmpty()) { f = createResult(FAILURE, "Newly created version " + version + " is not the latest version!"); addResult(assertEquals(newVersion.getId(), versions.get(0).getId(), null, f)); if (versions.size() > 1) { f = createResult(FAILURE, "The previous version of version " + version + " is not the document it has been created from!"); addResult(assertEquals(doc.getId(), versions.get(1).getId(), null, f)); } } return newVersion; }
document.setIdentifier(doc.getId()); document.addAttribute("updated", "true"); } else { org.apache.chemistry.opencmis.client.api.Document doc = updateDocument(session, document.getIdentifier(), type, document.getContent(), mode); document.setIdentifier(doc.getId()); document.addAttribute("updated", "false");
if (!orgDoc.getId().equals(newObjectId.getId())) { if (checkedout) { addResult(createResult(FAILURE, operation + " created a new version from a PWC!")); addResult(createResult(FAILURE, operation + " created a new version but the version history is empty!")); } else if (!orgDoc.getId().equals(versions.get(0).getId())) { result = (Document) session.getObject(versions.get(0), SELECT_ALL_NO_CACHE_OC); addResult(checkObject(session, result, getAllProperties(result), "Version created by " + operation
document.setIdentifier(doc.getId()); document.addAttribute("updated", "false"); } else { org.apache.chemistry.opencmis.client.api.Document doc = updateDocument(session, document.getIdentifier(), type, document.getContent(), mode); document.setIdentifier(doc.getId()); document.addAttribute("updated", "false");
return ObjectId.toString(ObjectId.Type.OBJECT, parent.createFolder(params).getId()); case CMIS_DOCUMENT: return ObjectId.toString(ObjectId.Type.OBJECT, parent.createDocument(params, null, VersioningState.NONE).getId()); default: return null;
ObjectId newId = doc.updateProperties(properties2, false); if (!doc.getId().equals(newId.getId())) {
topLevelDocs.add(newDocument.getId());
public void testDownloadEvent() throws InterruptedException { Repository repository = getRepository("admin", "admin"); Session session = repository.createSession(); Folder rootFolder = session.getRootFolder(); String docname = "mydoc-" + GUID.generate() + ".txt"; Map<String, String> props = new HashMap<String, String>(); { props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document"); props.put(PropertyIds.NAME, docname); } // content byte[] byteContent = "Hello from Download testing class".getBytes(); InputStream stream = new ByteArrayInputStream(byteContent); ContentStream contentStream = new ContentStreamImpl(docname, BigInteger.valueOf(byteContent.length), "text/plain", stream); Document doc1 = rootFolder.createDocument(props, contentStream, VersioningState.MAJOR); NodeRef doc1NodeRef = cmisIdToNodeRef(doc1.getId()); ContentStream content = doc1.getContentStream(); assertNotNull(content); //range request content = doc1.getContentStream(BigInteger.valueOf(2),BigInteger.valueOf(4)); assertNotNull(content); }
private void checkCheckedOut(Document pwc) { CmisTestResult f; f = createResult(FAILURE, "Version series has a PWC but cmis:isVersionSeriesCheckedOut is not TRUE!"); addResult(assertIsTrue(pwc.isVersionSeriesCheckedOut(), null, f)); if (pwc.getVersionSeriesCheckedOutId() == null) { addResult(createResult(WARNING, "cmis:versionSeriesCheckedOutId is not set!")); } else { f = createResult(FAILURE, "PWC id and cmis:versionSeriesCheckedOutId don't match!"); addResult(assertEquals(pwc.getId(), pwc.getVersionSeriesCheckedOutId(), null, f)); } f = createResult(WARNING, "PWC does not have a value for cmis:versionSeriesCheckedOutBy!"); addResult(assertStringNotEmpty(pwc.getVersionSeriesCheckedOutBy(), null, f)); }
NodeRef doc1NodeRef = cmisIdToNodeRef(doc1.getId()); NodeRef doc1WorkingCopy = cociService.getWorkingCopy(doc1NodeRef);
assertNotNull(content); NodeRef doc1NodeRef = cmisIdToNodeRef(document.getId()); FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef); Map<QName, Serializable> properties = fileInfo.getProperties();
.getBinding() .getObjectService() .getObject(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, Boolean.FALSE, null); .getBinding() .getNavigationService() .getObjectParents(repositoryId, testDocument.getId(), filter, Boolean.FALSE, IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);