Tabnine Logo
Document
Code IndexAdd Tabnine to your IDE (free)

How to use
Document
in
org.apache.chemistry.opencmis.client.api

Best Java code snippets using org.apache.chemistry.opencmis.client.api.Document (Showing top 20 results out of 315)

origin: mswiderski/jbpm-examples

public Object read(ObjectInputStream os) throws IOException, ClassNotFoundException {
  String objectId = os.readUTF();
  String canonicalName = os.readUTF();
  Session session = getRepositorySession(user, password, url, repository);
  try {
    org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document) findObjectForId(session, objectId);
    Document document = (Document) Class.forName(canonicalName).newInstance();
    
    document.setIdentifier(objectId);
    document.setName(doc.getName());
    document.addAttribute("location", getFolderName(doc.getParents()) + getPathAsString(doc.getPaths()));
    if (doc.getContentStream() != null) {
      ContentStream stream = doc.getContentStream();
      document.setContent(IOUtils.toByteArray(stream.getStream()));
      document.addAttribute("updated", "false");
      document.addAttribute("type", stream.getMimeType());				
    }
    return document;
  } catch(Exception e) {
    throw new RuntimeException("Cannot read document from CMIS", e);
  } finally {			
    session.clear();
  }
}
origin: jpotts/alfresco-api-java-examples

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);
origin: mswiderski/jbpm-examples

/**
 * Deletes document identified by objectId.
 * @param session
 * @param objectId
 */
protected void deleteDocument(Session session, String objectId) {
  Document document = (Document) session.getObject(objectId);
  document.delete(false);
}

origin: stackoverflow.com

 private void updateDoc(Database database, String documentId) {
  Document document = database.getDocument(documentId);
  try {
    // Update the document with more data
    Map<String, Object> updatedProperties = new HashMap<String, Object>();
    updatedProperties.putAll(document.getProperties());
    updatedProperties.put("eventDescription", "Everyone is invited!");
    updatedProperties.put("address", "123 Elm St.");
    // Save to the Couchbase local Couchbase Lite DB
    document.putProperties(updatedProperties);
  } catch (CouchbaseLiteException e) {
      Log.e(TAG, "Error putting", e);
  }
}
origin: stackoverflow.com

doc.getProperties().putValue("DocumentTitle", "New Document via Java API");
doc.set_MimeType("text/plain"); // if its your pdf then set mimetype for PDF
doc.save(RefreshMode.NO_REFRESH);
doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
doc.save(RefreshMode.NO_REFRESH);
origin: ModeShape/modeshape

@Override
public Collection<String> getDocumentPathsById( String id ) {
  CmisObject obj = session.getObject(id);
  // check that object exist
  if (obj instanceof Folder) {
    return Collections.singletonList(((Folder)obj).getPath());
  }
  if (obj instanceof org.apache.chemistry.opencmis.client.api.Document) {
    org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)obj;
    List<Folder> parents = doc.getParents();
    List<String> paths = new ArrayList<String>(parents.size());
    for (Folder parent : doc.getParents()) {
      paths.add(parent.getPath() + "/" + doc.getName());
    }
    return paths;
  }
  return Collections.emptyList();
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

Document doc = createDocument(session, testFolder, "contenttest.txt", CONTENT1);
Document workDoc = doc;
DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
if (!doc.getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM)) {
  if (!docType.isVersionable()) {
    addResult(createResult(SKIPPED,
        "The test document does not accept a new content stream. Test skipped!"));
    doc.delete(true);
    return;
  } else {
    workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC);
    checkedout = true;
    if (!workDoc.getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM)) {
      addResult(createResult(SKIPPED,
          "The test PWC does not accept a new content stream. Test skipped!"));
      workDoc.cancelCheckOut();
      doc.delete(true);
      return;
    ObjectId newObjectId = workDoc.deleteContentStream(true);
    addResult(assertNull(contentDoc.getContentStream(), null, f));
            + contentDoc.getContentStreamMimeType());
    addResult(assertNull(contentDoc.getContentStreamMimeType(), null, f));
            + contentDoc.getContentStreamLength());
origin: org.aperteworkflow/cmis-widget

  @Override
  public InputStream getStream() {
    ContentStream cs = doc.getContentStream();
    return cs.getStream();
  }
}, name, getApplication());
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
  doc.delete(true);
  return;
String[] propertiesToCheck = new String[doc.getType().getPropertyDefinitions().size()];
for (String propId : doc.getType().getPropertyDefinitions().keySet()) {
  propertiesToCheck[i++] = propId;
for (Property<?> property : doc.getProperties()) {
  if (property.getDefinition().getUpdatability() == Updatability.READWRITE) {
    writableProperties.put(property.getId(), property.getValue());
ObjectId pwcId = doc.checkOut();
Document pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
addResult(checkVersionSeries(session, pwc.getAllVersions(SELECT_ALL_NO_CACHE_OC), propertiesToCheck,
    "Test version series after check out"));
pwc.cancelCheckOut();
doc.refresh();
checkCheckedIn(doc);
pwcId = doc.checkOut();
pwc = (Document) session.getObject(pwcId, SELECT_ALL_NO_CACHE_OC);
ObjectId newVersionId = pwc.checkIn(true, null, null, "Test Version 2");
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

  documents.put(newDocument.getId(), newDocument);
  versionSeriesIds.add(newDocument.getVersionSeriesId());
  if (!childrenIds.contains(document.getId())) {
    addResult(createResult(FAILURE, "Created document not found in test folder children! Id: "
        + document.getId()));
if (Boolean.TRUE.equals(((DocumentType) documents.values().iterator().next().getType()).isVersionable())) {
  f = createResult(FAILURE,
      "Although the created documents are independent, some documents share a Version Series Id!");
  ContentStream contentStream = document.getContentStream();
  if (contentStream == null || contentStream.getStream() == null) {
    addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId()));
    continue;
    f = createResult(FAILURE, "Unexpected document content! Id: " + document.getId());
    addResult(assertEquals(CONTENT, contentStr, null, f));
    f = createResult(FAILURE, "Unexpected document content! Id: " + document.getId());
    addResult(assertEquals(CONTENT, contentStr2, null, f));
    List<String> paths = document.getPaths();
            + document.getId());
    addResult(assertIsTrue(paths != null && paths.size() > 0, null, f));
    f = createResult(FAILURE, "Unexpected document content! Id: " + document.getId());
    addResult(assertEquals(CONTENT, contentStr3, null, f));
origin: mswiderski/jbpm-examples

document.setName(doc.getName());
document.setLastModified(doc.getLastModificationDate().getTime());
document.setSize(doc.getContentStreamLength());
document.addAttribute("location", getFolderName(doc.getParents()) + getPathAsString(doc.getPaths()));
if (doc.getContentStream() != null && contentUrl == null) {
  ContentStream stream = doc.getContentStream();
  document.setContent(IOUtils.toByteArray(stream.getStream()));                
  document.addAttribute("updated", "false");
origin: Alfresco/alfresco-repository

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);
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

DocumentTypeDefinition docType = (DocumentTypeDefinition) doc.getType();
  workDoc = (Document) session.getObject(doc.checkOut(), SELECT_ALL_NO_CACHE_OC);
  checkedout = true;
  OutputStream out1 = workDoc.createOverwriteOutputStream("appendstreamtest", "text/plain", bufferSize);
  workDoc.refresh();
  String content1 = getStringFromContentStream(workDoc.getContentStream());
  OutputStream out2 = workDoc.createAppendOutputStream(bufferSize);
  workDoc.refresh();
  String content2 = getStringFromContentStream(workDoc.getContentStream());
    workDoc.cancelCheckOut();
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

addResult(assertEquals(DOC_NAME1, doc1.getName(), null, f));
DocumentTypeDefinition type = (DocumentTypeDefinition) doc1.getType();
PropertyDefinition<?> namePropDef = type.getPropertyDefinitions().get(PropertyIds.NAME);
if (namePropDef.getUpdatability() == Updatability.WHENCHECKEDOUT
    || (!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;
properties.put(PropertyIds.NAME, DOC_NAME2);
ObjectId newId = workDoc.updateProperties(properties, false);
Document doc2 = (Document) session.getObject(newId, SELECT_ALL_NO_CACHE_OC);
addResult(assertEquals(DOC_NAME2, doc2.getName(), null, f));
if (!workDoc.getId().equals(doc2.getId())) {
  deleteObject(doc2);
  workDoc.cancelCheckOut();
if (!doc1.getId().equals(doc2.getId())) {
  if (exists(doc1)) {
    deleteObject(doc1);
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

String versionSeriesId = doc.getVersionSeriesId();
List<Document> versions = doc.getAllVersions(SELECT_ALL_NO_CACHE_OC);
  Document lastestVersion = doc.getObjectOfLatestVersion(false, SELECT_ALL_NO_CACHE_OC);
  addResult(results, checkObject(session, lastestVersion, properties,
      "Latest version check: " + lastestVersion.getId()));
  f = createResult(FAILURE, "Latest version is not flagged as latest version! ID: " + lastestVersion.getId());
  addResult(results, assertIsTrue(lastestVersion.isLatestVersion(), null, f));
    lastestMajorVersion = doc.getObjectOfLatestVersion(true, SELECT_ALL_NO_CACHE_OC);
        "Latest major version check: " + lastestMajorVersion.getId()));
        + lastestMajorVersion.getId());
    addResult(results, assertIsTrue(lastestMajorVersion.isLatestMajorVersion(), null, f));
    addResult(results, checkObject(session, version, properties, "Version check: " + version.getId()));
      if (version.isVersionSeriesCheckedOut()) {
        f = createResult(WARNING,
            "Version series is checked-out and the PWC is not the latest version! ID: "
                + version.getId()
                + " (Note: The words of the CMIS specification define that the PWC is the latest version."
                + " But that is not the intention of the spec and will be changed in CMIS 1.1."
                + " Thus this a warning, not an error.)");
        addResult(results, assertIsTrue(version.isLatestVersion(), null, f));
      } else {
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

String path = doc.getPaths().get(0);
doc2 = (Document) session.getObjectByPath(path, SELECT_ALL_NO_CACHE_OC);
addResult(checkObject(session, doc2, getAllProperties(doc2), "New document object spec compliance"));
assertEquals(NAMES[i], doc2.getName(), null, f);
ContentStream contentStream = doc.getContentStream();
    doc.delete(true);
  } catch (Exception e) {
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

if (doc.getChangeToken() == null) {
  addResult(createResult(SKIPPED,
      "Repository does not provide change tokens for documents. Test skipped!"));
if (!doc.getAllowableActions().getAllowableActions().contains(Action.CAN_SET_CONTENT_STREAM)) {
  addResult(createResult(SKIPPED, "Document content can't be changed. Test skipped!"));
  return;
    BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes));
ObjectId newId = doc.setContentStream(contentStream, true, false);
  if (Boolean.TRUE.equals(((DocumentTypeDefinition) doc.getType()).isVersionable())) {
    List<Document> versions = doc.getAllVersions();
    if (versions == null || versions.size() < 1) {
      addResult(createResult(FAILURE, "Repository returned an empty list of document versions!"));
  if (!doc.getId().equals(newId.getId())) {
  } else {
    try {
      doc.setContentStream(contentStream, true, false);
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

DocumentTypeDefinition type = (DocumentTypeDefinition) doc.getType();
boolean hasContentProperties = (doc.getContentStreamFileName() != null) || (doc.getContentStreamId() != null)
    || (doc.getContentStreamLength() > -1) || (doc.getContentStreamMimeType() != null);
ContentStream contentStream = doc.getContentStream();
  if (hasContentProperties && doc.getContentStreamLength() > 0) {
    addResult(results,
        createResult(FAILURE, "Content properties have values but the document has no content!"));
addResult(results, assertEquals(doc.getContentStreamFileName(), contentStream.getFileName(), null, f));
if (doc.getContentStreamLength() > -1 && contentStream.getLength() > -1) {
  f = createResult(FAILURE, "Content lengths don't match!");
  addResult(results, assertEquals(doc.getContentStreamLength(), contentStream.getLength(), null, f));
String docMimeType = doc.getContentStreamMimeType();
if (docMimeType != null) {
  int x = docMimeType.indexOf(';');
  if (contentMimeType.equals(docMimeType)) {
    f = createResult(WARNING, "Content MIME types don't match!");
    addResult(results, assertEquals(doc.getContentStreamMimeType(), contentStream.getMimeType(), null, f));
List<ContentStreamHash> hashes = doc.getContentStreamHashes();
List<MessageDigest> messageDigests = null;
List<String> algorithms = null;
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

  addResult(assertEquals(name, result.getName(), null, f));
  addResult(assertEquals((long) contentBytes.length, result.getContentStreamLength(), null, f));
  List<ContentStreamHash> hashes = result.getContentStreamHashes();
  if (docType.getPropertyDefinitions() != null
      && docType.getPropertyDefinitions().containsKey(PropertyIds.CONTENT_STREAM_HASH)) {
    ContentStream contentStream = result.getContentStream();
    addResult(assertEquals(result.getContentStreamFileName(), contentStream.getFileName(), null, f));
    String fetchedContent = getStringFromContentStream(result.getContentStream());
    if (!content.equals(fetchedContent)) {
      addResult(createResult(FAILURE,
List<Folder> parents = result.getParents(SELECT_ALL_NO_CACHE_OC);
boolean found = false;
for (Folder folder : parents) {
origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

  this.filename = doc.getContentStreamFileName();
} else {
  this.filename = filename;
  this.mimeType = doc.getContentStreamMimeType();
} else {
  this.mimeType = mimeType;
this.documentId = doc.getId();
this.changeToken = doc.getChangeToken();
this.overwrite = overwrite;
this.buffer = new byte[bufferSize];
org.apache.chemistry.opencmis.client.apiDocument

Javadoc

CMIS document interface.

Most used methods

  • getContentStream
    Retrieves the content stream of this document.
  • getId
  • delete
  • setContentStream
    Sets a new content stream for the document. If the repository created a new version, the object ID o
  • checkIn
    If this is a PWC (private working copy) it performs a check in. If this is not a PWC it an exception
  • getParents
  • getPaths
  • getProperties
  • getVersionSeriesId
  • cancelCheckOut
    If this is a PWC (private working copy) the check out will be reversed. If this is not a PWC it an e
  • checkOut
    Checks out the document and returns the object ID of the PWC (private working copy).
  • getChangeToken
  • checkOut,
  • getChangeToken,
  • getContentStreamFileName,
  • getContentStreamMimeType,
  • getName,
  • getProperty,
  • getType,
  • refresh,
  • deleteContentStream,
  • getAllVersions

Popular in Java

  • Making http requests using okhttp
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Notification (javax.management)
  • JList (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now