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

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

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

origin: stackoverflow.com

 // User credentials.
parameters.put(SessionParameter.USER, "admin");
parameters.put(SessionParameter.PASSWORD, "admin");

// Connection settings.
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis"); // URL to your CMIS server.
parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true" );
parameters.put(SessionParameter.COOKIES, "true" );

// Create session.
// Alfresco only provides one repository.
Repository repository = sessionFactory.getRepositories(parameters).get(0);
Session session = repository.createSession();
origin: org.appverse.web.framework.modules.backend.ecm.cmis/appverse-web-modules-backend-ecm-cmis

@Override
public void afterPropertiesSet() throws Exception {
  String defaultRepositoryId = (String)cmisSessionInitProperties.get(SessionParameter.REPOSITORY_ID);
  if (defaultRepositoryId == null){
    // If not repository is specified, the first repository is taken as default
    List<Repository> repositories = sessionFactory.getRepositories(cmisSessionInitProperties);
    Repository repository = repositories.get(0);
    cmisSessionInitProperties.put(SessionParameter.REPOSITORY_ID, repository.getId());
  }
}
origin: org.mule.modules/mule-module-cmis

public static String getRepositoryID(Map<String, String> parameters, String baseURL) {
  String repoID = null;
  try {
    logger.debug("Attempting to dynamically obtain the repository ID.");
    List<Repository> repositoryList = SessionFactoryImpl.newInstance().getRepositories(parameters);
    if (repositoryList.isEmpty()) {
      logger.error("No repositories were returned at the CMIS server URL \"" + baseURL + "\". " + "The connector is currently non-functional.");
    } else {
      // Get the first repo in the list.
      Repository firstRepo = repositoryList.get(0);
      // Extract the ID of this repo, and add it to the parameters list.
      repoID = firstRepo.getId();
      logger.debug("The repository ID that will be used is " + repoID + ".");
    }
  } catch (Exception repoIDEx) {
    throw new CMISConnectorConnectionException("An error occurred while attempting to dynamically obtain a repository ID: " + repoIDEx.getMessage()
        + ". The connector is currently non-functional. ", repoIDEx);
  }
  return repoID;
  // end getRepositoryID
}
origin: deas/alfresco

/**
 * @see org.apache.commons.pool.PoolableObjectFactory#makeObject()
 */
@Override
public Object makeObject() throws Exception
{
  if (repository == null)
  {
    throw new RepositoryUnavailableException(lastException);
  }
  return repository.createSession();
}
origin: jbarrez/Activiti-KickStart

protected Session getCmisSession() {
  if (cachedSession == null) {
    synchronized (this) {
      if (cachedSession == null) {
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put(SessionParameter.USER, cmisUser);
        parameters.put(SessionParameter.PASSWORD, cmisPassword);
        parameters.put(SessionParameter.ATOMPUB_URL, cmisAtompubUrl);
        parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        
        // We're using the Alfresco extensions
        parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
        // First need to fetch the repository info to know the repo id
        SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
        List<Repository> repositories = sessionFactory.getRepositories(parameters);
        String repositoryId = repositories.get(0).getId();
        parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
        
        cachedSession = sessionFactory.createSession(parameters);
      }
    }
  }
  return cachedSession;
}
origin: jpotts/alfresco-api-java-examples

/**
 * Gets a CMIS Session by connecting to the Alfresco Cloud.
 *
 * @param accessToken
 * @return Session
 */
public Session getCmisSession() {
  // default factory implementation
  SessionFactory factory = SessionFactoryImpl.newInstance();
  Map<String, String> parameter = new HashMap<String, String>();
  // connection settings
  parameter.put(SessionParameter.ATOMPUB_URL, ATOMPUB_URL);
  parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
  parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true");
  parameter.put(SessionParameter.USER, USER_NAME);
  parameter.put(SessionParameter.PASSWORD, PASSWORD);
  parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
  List<Repository> repositories = factory.getRepositories(parameter);
  return repositories.get(0).createSession();
}
origin: jpotts/alfresco-api-java-examples

/**
 * Gets a CMIS Session by connecting to the Alfresco Cloud.
 *
 * @param accessToken
 * @return Session
 */
public Session getCmisSession() throws Exception {
  if (cmisSession == null) {
    // default factory implementation
    SessionFactory factory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<String, String>();
    // connection settings
    parameter.put(SessionParameter.ATOMPUB_URL, ATOMPUB_URL);
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    parameter.put(SessionParameter.AUTH_HTTP_BASIC, "false");
    parameter.put(SessionParameter.HEADER + ".0", "Authorization: Bearer " + getAccessToken());
    parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
    List<Repository> repositories = factory.getRepositories(parameter);
    this.cmisSession = repositories.get(0).createSession();
  }
  return this.cmisSession;
}
origin: jpotts/alfresco-api-java-examples

/**
 * Gets a CMIS Session by connecting to the Alfresco Cloud.
 *
 * @param accessToken
 * @return Session
 */
public Session getCmisSession() {
  if (cmisSession == null) {
    String accessToken = getCredential().getAccessToken();
    System.out.println("Access token:" + accessToken);
    // default factory implementation
    SessionFactory factory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<String, String>();
    // connection settings
    parameter.put(SessionParameter.ATOMPUB_URL, this.getAtomPubURL());
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    parameter.put(SessionParameter.AUTH_HTTP_BASIC, "false");
    parameter.put(SessionParameter.HEADER + ".0", "Authorization: Bearer " + accessToken);
    parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
    List<Repository> repositories = factory.getRepositories(parameter);
    cmisSession = repositories.get(0).createSession();
  }
  return cmisSession;
}
origin: jpotts/alfresco-api-java-examples

/**
 * Gets a CMIS Session by connecting to the local Alfresco server.
 *
 * @return Session
 */
public Session getCmisSession() {
  if (cmisSession == null) {
    // default factory implementation
    SessionFactory factory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<String, String>();
    // connection settings
    parameter.put(SessionParameter.ATOMPUB_URL, getAtomPubURL(getRequestFactory()));
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    parameter.put(SessionParameter.AUTH_HTTP_BASIC, "true");
    parameter.put(SessionParameter.USER, getUsername());
    parameter.put(SessionParameter.PASSWORD, getPassword());
    parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
    List<Repository> repositories = factory.getRepositories(parameter);
    cmisSession = repositories.get(0).createSession();
  }
  return this.cmisSession;
}
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

@Override
public void run() throws Exception {
  Session session;
  SessionParameterMap parameters = new SessionParameterMap(getParameters());
  if (!parameters.containsKey(SessionParameter.USER_AGENT)) {
    parameters.setUserAgent(TCK_USER_AGENT);
  }
  String repId = parameters.get(SessionParameter.REPOSITORY_ID);
  if (repId != null && repId.length() > 0) {
    session = factory.createSession(parameters);
  } else {
    session = factory.getRepositories(parameters).get(0).createSession();
  }
  // switch off the cache
  session.getDefaultContext().setCacheEnabled(false);
  try {
    run(session);
  } catch (Exception e) {
    if (!(e instanceof FatalTestException)) {
      addResult(createResult(UNEXPECTED_EXCEPTION, "Exception: " + e, e, true));
    }
  } catch (Error err) {
    addResult(createResult(UNEXPECTED_EXCEPTION, "Error: " + err, err, true));
  } finally {
    testFolder = null;
  }
}
origin: Alfresco/alfresco-repository

Session session = repository.createSession();
Folder rootFolder = session.getRootFolder();
origin: Alfresco/alfresco-repository

public void DISABLED_testBasicFileOps()
{
  Repository repository = getRepository("admin", "admin");
  Session session = repository.createSession();
  Folder rootFolder = session.getRootFolder();
  // create folder
  Map<String,String> folderProps = new HashMap<String, String>();
  {
    folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate());
  }
  Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext());
  
  Map<String, String> fileProps = new HashMap<String, String>();
  {
    fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
  }
  ContentStreamImpl fileContent = new ContentStreamImpl();
  {
    ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt"));
    writer.putContent("Ipsum and so on");
    ContentReader reader = writer.getReader();
    fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    fileContent.setStream(reader.getContentInputStream());
  }
  folder.createDocument(fileProps, fileContent, VersioningState.MAJOR);
}
 
origin: Alfresco/alfresco-repository

public void testALF10085() throws InterruptedException
  Session session = repository.createSession();
  Folder rootFolder = session.getRootFolder();
origin: Alfresco/alfresco-repository

Session session = repository.createSession();
Folder rootFolder = session.getRootFolder();
Document document = createDocument(rootFolder, "test_file_" + GUID.generate() + ".txt", session);
org.apache.chemistry.opencmis.client.apiRepository

Javadoc

Represents a repository.

Most used methods

  • createSession
    Creates a session for this repository.
  • getId

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Github Copilot alternatives
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