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

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

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

origin: mswiderski/jbpm-examples

/**
 * Finds Object (document or folder) by unique id. If not could exceptions is thrown
 * @param session
 * @param id
 * @return
 * @throws CmisObjectNotFoundException
 */
protected CmisObject findObjectForId(Session session, String id) {
  return  session.getObject(id);
}

origin: mswiderski/jbpm-examples

/**
 * Finds folder by path and if not found returns null.
 * @param session
 * @param path
 * @return
 */
protected Folder findFolderForPath(Session session, String path) {
  try {
  return (Folder) session.getObjectByPath(path);
  } catch (CmisObjectNotFoundException e) {
    return null;
  }
}
origin: org.jbpm/jbpm-console-ng-documents-backend

  @Override
  public Boolean testConnection() {
    Session session = getSession();

    if (session != null) {
      if (session.getRootFolder() != null) {
        return true;
      }
    }

    return false;
  }
}
origin: bluesoft-rnd/aperte-workflow-core

public Folder getFolderById(String id) {
  try {
    return (Folder) session.getObject(session.createObjectId(id));
  }
  catch (CmisObjectNotFoundException e) { //great idea Chemistry developers - use RUNTIME exceptions to control the flow
    return null;
  }
}
origin: stackoverflow.com

Folder root = session.getRootFolder();
String name = "testCreateRelationship " + System.currentTimeMillis();
newFolderProps.put(PropertyIds.NAME, name);
Folder folder = root.createFolder(newFolderProps, null, null, null, session.getDefaultContext());
System.out.println(folder.getName());
newDocProps1.put(PropertyIds.NAME, "Test Doc 1");
ContentStream contentStream1 = new ContentStreamImpl("xyz.txt", null, "plain/text", new ByteArrayInputStream("some content".getBytes()));
Document doc1 = folder.createDocument(newDocProps1, contentStream1, VersioningState.MAJOR, null, null, null, session.getDefaultContext());
newDocProps2.put(PropertyIds.NAME, "Test Doc 2");
ContentStream contentStream2 = new ContentStreamImpl("xyz.txt", null, "plain/text", new ByteArrayInputStream("some content".getBytes()));
Document doc2 = folder.createDocument(newDocProps2, contentStream2, VersioningState.MAJOR, null, null, null, session.getDefaultContext());
relProps.put("cmis:targetId", doc2.getId()); 
relProps.put("cmis:objectTypeId", "R:cmiscustom:assoc");
session.createRelationship(relProps, null, null, null);
CmisObject object = session.getObject(doc1,operationContext);
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

  ContentStream contentStream = session.getObjectFactory().createContentStream(name, size, mimetype, in);
  TypeDefinition type = session.getTypeDefinition(objectTypeId);
  if (!(type instanceof DocumentTypeDefinition)) {
    addResult(createResult(FAILURE, "Type is not a document type! Type: " + objectTypeId, true));
  ObjectId id = session.createDocument(properties, testFolder, contentStream, versioningState);
  Document doc = (Document) session.getObject(id, SELECT_ALL_NO_CACHE_OC);
  addResult(assertIsTrue(paths != null && paths.size() > 0, null, f));
  session.deleteByPath(paths.get(0));
} finally {
origin: org.mule.modules/mule-module-cmis

public ObjectId createFolder(String folderName, String parentObjectId) {
  ObjectId returnId = null;
  Session session = this.getSession(this.connectionParameters);
  if (session != null) {
    if (StringUtils.isEmpty(parentObjectId)) {
      parentObjectId = session.getRootFolder().getId();
    }
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put(PropertyIds.NAME, folderName);
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    try {
      returnId = session.createFolder(properties, session.getObject(session.createObjectId(parentObjectId)));
    } catch (CmisContentAlreadyExistsException e) {
      logger.debug("CMIS Content Already Exists ", e);
      CmisObject object = session.getObject(session.createObjectId(parentObjectId));
      if (!(object instanceof Folder)) {
        throw new IllegalArgumentException(parentObjectId + " is not a folder");
      }
      Folder folder = (Folder) object;
      for (CmisObject o : folder.getChildren()) {
        if (o.getName().equals(folderName)) {
          return session.createObjectId(o.getId());
        }
      }
    }
  }
  return returnId;
  // End createFolder
}
origin: org.jbpm/jbpm-console-ng-documents-backend

@Override
public List<CMSContentSummary> getChildren(String id) {
  Session session = getSession();
  if (session != null) {
    Folder folder = null;
    if (id == null || id.isEmpty()) {
      folder = session.getRootFolder();
    } else {
      folder = (Folder) session.getObject(id);
    }
    ItemIterable<CmisObject> children = folder.getChildren();
    Iterator<CmisObject> childrenItems = children.iterator();
    List<CmisObject> documents = new ArrayList<CmisObject>();
    while (childrenItems.hasNext()) {
      CmisObject item = childrenItems.next();
      documents.add(item);
    }
    return this.transform(documents, folder);
  }
  return new ArrayList<CMSContentSummary>();
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

  type = session.getTypeDefinition(objectTypeId);
} catch (CmisObjectNotFoundException e) {
  addResult(createResult(UNEXPECTED_EXCEPTION,
  relId = session.createRelationship(properties);
  result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
} catch (Exception e) {
  addResult(createResult(UNEXPECTED_EXCEPTION,
origin: Alfresco/alfresco-repository

Folder rootFolder = session.getRootFolder();
session.getObject(doc1);
  props.put(PropertyIds.TARGET_ID, doc2.getId()); 
session.createRelationship(props); 
origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-impl

@Override
public ContentStream getContentStream() {
  if (objectId == null || getStreamId() == null) {
    return null;
  }
  ContentStream contentStream;
  try {
    contentStream = session.getBinding().getObjectService()
        .getContentStream(session.getRepositoryInfo().getId(), objectId, getStreamId(), null, null, null);
  } catch (CmisConstraintException e) {
    // no content stream
    return null;
  }
  if (contentStream == null) {
    return null;
  }
  String filename = contentStream.getFileName();
  if (filename == null) {
    filename = getTitle();
  }
  BigInteger bigLength = contentStream.getBigLength();
  if (bigLength == null) {
    bigLength = getBigLength();
  }
  long length = bigLength == null ? -1 : bigLength.longValue();
  return session.getObjectFactory().createContentStream(filename, length, contentStream.getMimeType(),
      contentStream.getStream());
}
origin: jpotts/alfresco-api-java-examples

ContentStream contentStream = cmisSession.getObjectFactory().
     createContentStream(
      fileName,
  System.out.println("Created new document: " + document.getId());
} catch (CmisContentAlreadyExistsException ccaee) {
  document = (Document) cmisSession.getObjectByPath(parentFolder.getPath() + "/" + fileName);
  System.out.println("Document already exists: " + fileName);
origin: mswiderski/jbpm-examples

Document document = (Document) session.getObject(objectId);
InputStream input = new ByteArrayInputStream(content);
ContentStream contentStream = session.getObjectFactory().createContentStream(document.getName(), content.length, type, input);
try {
  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 {
      ObjectId newObjectId = pwc.checkIn(major, null, contentStream, "Document update from process");
      return (Document) session.getObject(newObjectId);
    } catch (CmisBaseException e) {			        
      pwc.cancelCheckOut();
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

Acl basicAcl = session.getAcl(doc, true);
  aces.add(session.getObjectFactory().createAce(principal, Collections.singletonList("cmis:write")));
  session.applyAcl(doc, aces, null, null);
  if (session.getRepositoryInfo().getAclCapabilities().getAclPropagation() != AclPropagation.REPOSITORYDETERMINED) {
    aces.add(session.getObjectFactory().createAce(principal, Collections.singletonList("cmis:all")));
    session.setAcl(doc, aces);
origin: org.mule.modules/mule-module-cmis

public RepositoryInfo repositoryInfo() {
  RepositoryInfo repoInfo = null;
  Session session = this.getSession(this.connectionParameters);
  if (session != null) {
    repoInfo = session.getRepositoryInfo();
  }
  return repoInfo;
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-impl

@Override
public Future<CmisObject> getObject(ObjectId objectId) {
  return getObject(objectId, session.getDefaultContext());
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-impl

  @Override
  public ObjectType call() throws Exception {
    return session.getTypeDefinition(typeId);
  }
}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-test-tck

private void doQuery(Session session, String stmt) {
  for (QueryResult qr : session.query(stmt, false)) {
    qr.getPropertyByQueryName("cmis:name");
  }
}
origin: stackoverflow.com

 public static void main(String args[]) {
String serverUrl = args[0];
String username = args[1];
String password = args[2];
Session session = getSession(serverUrl, username, password);
Folder root = session.getRootFolder();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_
DOCUMENT.value());
String name = "New Document (" + System.currentTimeMillis() +
").txt";
properties.put(PropertyIds.NAME, name);
List<Ace> addAces = new LinkedList<Ace>();
List<Ace> removeAces = new LinkedList<Ace>();
List<Policy> policies = new LinkedList<Policy>();
String content = "The quick brown fox jumps over the lazy dog.";
ContentStream contentStream = new ContentStreamImpl("text.txt",
BigInteger.valueOf(content.length()),
"text/plain", new ByteArrayInputStream(content.
getBytes()));
Document newDocument = root.createDocument(properties,
contentStream, VersioningState.MAJOR, policies, addAces, removeAces,
session.getDefaultContext());
System.out.println(newDocument.getId());}
origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

ObjectFactory of = session.getObjectFactory();
  relationships = new ArrayList<Relationship>();
  for (ObjectData rod : objectData.getRelationships()) {
    CmisObject relationship = of.convertObject(rod, session.getDefaultContext());
    if (relationship instanceof Relationship) {
      relationships.add((Relationship) relationship);
org.apache.chemistry.opencmis.client.apiSession

Javadoc

A session is a connection to a CMIS repository with a specific user.

CMIS itself is stateless. OpenCMIS uses the concept of a session to cache data across calls and to deal with user authentication. The session object is also used as entry point to all CMIS operations and objects. Because a session is only a client side concept, the session object needs not to be closed or released when it's not needed anymore.

Not all operations provided by this API might be supported by the connected repository. Either OpenCMIS or the repository will throw an exception if an unsupported operation is called. The capabilities of the repository can be discovered by evaluating the repository info (see #getRepositoryInfo()).

Almost all methods might throw exceptions derived from CmisBaseException which is a runtime exception. See the CMIS specification for a list of all operations and their exceptions. Note that some incompliant repositories might throw other exception than you expect.

Refer to the CMIS 1.0 specification or the CMIS 1.1 specification for details about the domain model, terms, concepts, base types, properties, IDs and query names, query language, etc.

Most used methods

  • getObject
    Returns a CMIS object from the session cache. If the object is not in the cache or the given Operati
  • getObjectByPath
    Returns a CMIS object from the session cache. If the object is not in the cache or the given Operati
  • getRootFolder
    Gets the root folder of the repository with the given OperationContext.
  • getObjectFactory
    Gets a factory object that provides methods to create the objects used by this API.
  • getRepositoryInfo
    Returns the repository info of the repository associated with this session.
  • getDefaultContext
    Returns the current default operation parameters for filtering, paging and caching.Please note: The
  • getTypeDefinition
    Gets the definition of a type.
  • query
    Sends a query to the repository using the given OperationContext. (See CMIS spec "2.1.10 Query".)
  • createRelationship
    Creates a new relationship.
  • createDocument
    Creates a new document. The stream in contentStream is consumed but not closed by this method.
  • getBinding
    Returns the underlying binding object.
  • getTypeDescendants
    Gets the type descendants of a type.
  • getBinding,
  • getTypeDescendants,
  • applyAcl,
  • createFolder,
  • createObjectId,
  • createPolicy,
  • createType,
  • delete,
  • deleteType,
  • getContentStream

Popular in Java

  • Running tasks concurrently on multiple threads
  • findViewById (Activity)
  • getApplicationContext (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • JPanel (javax.swing)
  • Top Vim plugins
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