public ObjectId checkOut(CmisObject document, String documentId) { validateObjectOrId(document, documentId); validateRedundantIdentifier(document, documentId); CmisObject target = getCmisObject(document, documentId); if (target != null && target instanceof Document) { return ((Document) target).checkOut(); } return null; }
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; }
workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC); checkedout = true;
private void createDocumentAndAttachSecondaryType(Session session, Folder testFolder, ObjectType secondaryTestType) { Document doc = createDocument(session, testFolder, "createandattach.txt", "Secondary Type Test"); Document workDoc = doc; try { // test if check out is required boolean checkedout = false; if (needsCheckOut(doc)) { workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC); checkedout = true; } // attach secondary type ObjectId newId = workDoc.updateProperties(null, Collections.singletonList(secondaryTestType.getId()), null); Document newDoc = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC); // check if the secondary type is there boolean found = checkSecondaryType(newDoc, secondaryTestType); // -- detach secondary type if (found) { detachSecondaryType(session, newDoc, secondaryTestType); } // cancel a possible check out if (checkedout) { workDoc.cancelCheckOut(); } } finally { deleteObject(doc); } }
if (((DocumentType)(document.getType())).isVersionable() && (mode.equals(UpdateMode.MAJOR) || mode.equals(UpdateMode.MINOR))) { Document pwc = (Document) session.getObject(document.checkOut()); boolean major = mode.equals(UpdateMode.MAJOR); try {
|| (!doc1.getAllowableActions().getAllowableActions().contains(Action.CAN_UPDATE_PROPERTIES) && Boolean.TRUE .equals(type.isVersionable()))) { workDoc = (Document) session.getObject(doc1.checkOut(), SELECT_ALL_NO_CACHE_OC); checkedout = true;
ObjectId pwcId = doc.checkOut(); Document pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwcId = doc.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwcId = newVersion.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwcId = thirdVersion.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwcId = fourthVersion.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwcId = doc.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC); pwc.cancelCheckOut();
addResult(createResult(WARNING, "Test type is not versionable. Check out skipped!")); } else { ObjectId pwcId = doc.checkOut(); pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
return; } else { workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC); checkedout = true;