当前位置: 首页>>代码示例>>Java>>正文


Java Repository类代码示例

本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Repository的典型用法代码示例。如果您正苦于以下问题:Java Repository类的具体用法?Java Repository怎么用?Java Repository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Repository类属于org.apache.chemistry.opencmis.client.api包,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRepository

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
private Repository getRepository(String user, String password)
{
    // default factory implementation
    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> parameters = new HashMap<String, String>();

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

    // connection settings
    parameters.put(SessionParameter.BINDING_TYPE, BindingType.LOCAL.value());
    parameters.put(SessionParameter.LOCAL_FACTORY, "org.alfresco.opencmis.OpenCmisLocalTest$TestCmisServiceFactory");

    // create session
    List<Repository> repositories = sessionFactory.getRepositories(parameters);
    return repositories.size() > 0 ? repositories.get(0) : null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:OpenCmisLocalTest.java

示例2: testCanConnectCMISUsingDefaultTenantImpl

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
private void testCanConnectCMISUsingDefaultTenantImpl(Binding binding, String cmisVersion)
{
    String url = httpClient.getPublicApiCmisUrl(TenantUtil.DEFAULT_TENANT, binding, cmisVersion, null);
    
    Map<String, String> parameters = new HashMap<String, String>();
    
    // user credentials
    parameters.put(SessionParameter.USER, "admin");
    parameters.put(SessionParameter.PASSWORD, "admin");
    
    parameters.put(SessionParameter.ATOMPUB_URL, url);
    parameters.put(SessionParameter.BROWSER_URL, url);
    parameters.put(SessionParameter.BINDING_TYPE, binding.getOpenCmisBinding().value());
    
    SessionFactory factory = SessionFactoryImpl.newInstance();
    // perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding}
    List<Repository> repositories = factory.getRepositories(parameters);
    
    assertTrue(repositories.size() > 0);
    
    parameters.put(SessionParameter.REPOSITORY_ID, TenantUtil.DEFAULT_TENANT);
    Session session = factory.createSession(parameters);
    // perform request : http://host:port/alfresco/api/-default-/public/cmis/versions/${cmisVersion}/${binding}/type?id=cmis:document
    ObjectType objectType = session.getTypeDefinition("cmis:document");
    
    assertNotNull(objectType);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:TestCMIS.java

示例3: getSession

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
private static Session getSession(String user, String pwd)
{
    String url = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom";
    
    SessionFactory factory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<String, String>();
    parameter.put(SessionParameter.USER, user);
    parameter.put(SessionParameter.PASSWORD, pwd);
    parameter.put(SessionParameter.ATOMPUB_URL, url);
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    
    List<Repository> repositories = factory.getRepositories(parameter);
    Session session = repositories.get(0).createSession();
    
    return session;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:17,代码来源:CMISDataCreatorTest.java

示例4: connect

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
@Override
public ScriptCMISRepository connect(final String serverId, final ScriptCMISOperationContext ctx)
{
    // TODO GET the information form configuration file
    final Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(SessionParameter.USER, "admin");
    parameters.put(SessionParameter.PASSWORD, "admin");
    parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS, CertificateNotValidatingAuthenticationProvider.class.getName());
    parameters.put(SessionParameter.BROWSER_URL, "http://cmis.alfresco.com/cmisbrowser");
    parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());

    final SessionFactoryImpl sessionFactory = SessionFactoryImpl.newInstance();
    final List<Repository> repositories = sessionFactory.getRepositories(parameters);
    final Repository mainRepository = repositories.get(0);
    parameters.put(SessionParameter.REPOSITORY_ID, mainRepository.getId());

    final Session session = sessionFactory.createSession(parameters);
    session.setDefaultContext(DefaultTypeConverter.INSTANCE.convert(OperationContext.class, ctx));

    final RhinoCMISRepositoryImpl scriptCMISRepository = new RhinoCMISRepositoryImpl(session);
    return scriptCMISRepository;
}
 
开发者ID:AFaust,项目名称:alfresco-cmis-documentlist,代码行数:23,代码来源:RhinoCMISConnectorImpl.java

示例5: CmisHelper

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
public CmisHelper(String username, String password, String baseUrl) {
	logger.debug("Creating cmis client");
    
	this.username = username;
    this.password = password;
    this.cmisUrl = baseUrl;
    // create a session
    SessionFactory factory = SessionFactoryImpl.newInstance();
    Map<String, String> parameterMap = new HashMap<String, String>();
    parameterMap.put(SessionParameter.USER, username);
    parameterMap.put(SessionParameter.PASSWORD, password);
    parameterMap.put(SessionParameter.ATOMPUB_URL, baseUrl);
    parameterMap.put(SessionParameter.BINDING_TYPE,
            BindingType.ATOMPUB.value());
    // Use the first repository
    List<Repository> repositories = factory.getRepositories(parameterMap);
    Session session = repositories.get(0).createSession();
    logger.info("Repo Id: " + repositories.get(0).getId());
    
    this.session = session;
    session.getDefaultContext().setCacheEnabled(false);
}
 
开发者ID:kylefernandadams,项目名称:cmis-jmeter-test,代码行数:23,代码来源:CmisHelper.java

示例6: doInBackground

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
@Override
protected CmisResult<Session> doInBackground(Bundle... b) {
    Session session = null;
    Exception exception = null;
    try {
        if (b != null && b[0] != null) {
            retrieveBundleValues(b[0]);
        }

        SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
        Map<String, String> parameter = new HashMap<String, String>();
        parameter.put(SessionParameter.USER, username);
        parameter.put(SessionParameter.PASSWORD, password);
        parameter.put(SessionParameter.ATOMPUB_URL, url);
        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        Repository repository = sessionFactory.getRepositories(parameter).get(0);
        parameter.put(SessionParameter.REPOSITORY_ID, repository.getId());
        session = sessionFactory.createSession(parameter);
    } catch (Exception e) {
        exception = e;
    }

    return new CmisResult<Session>(exception, session);

}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:26,代码来源:SessionTask.java

示例7: createSession

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
private Session createSession() {
  Map<String, String> parameter = new HashMap<String, String>();

  // user credentials
  parameter.put(SessionParameter.USER, _username);
  parameter.put(SessionParameter.PASSWORD, _password);

  // connection settings
  parameter.put(SessionParameter.ATOMPUB_URL, _url.toExternalForm());
  parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

  // create session
  SessionFactory factory = SessionFactoryImpl.newInstance();

  List<Repository> repositories = factory.getRepositories(parameter);

  Repository repository = repositories.get(0);

  return repository.createSession();
}
 
开发者ID:Redpill-Linpro,项目名称:artifact-upload-maven-plugin,代码行数:21,代码来源:CmisUploadMojo.java

示例8: DISABLED_testBasicFileOps

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:OpenCmisLocalTest.java

示例9: testDownloadEvent

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:OpenCmisLocalTest.java

示例10: testEncodingForCreateContentStream

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
public void testEncodingForCreateContentStream()
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    FileFolderService ffs = serviceRegistry.getFileFolderService();
    // Authenticate as system
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) ctx
            .getBean(BEAN_NAME_AUTHENTICATION_COMPONENT);
    authenticationComponent.setSystemUserAsCurrentUser();
    try
    {
        /* Create the document using openCmis services */
        Repository repository = getRepository("admin", "admin");
        Session session = repository.createSession();
        Folder rootFolder = session.getRootFolder();
        Document document = createDocument(rootFolder, "test_file_" + GUID.generate() + ".txt", session);

        ContentStream content = document.getContentStream();
        assertNotNull(content);

        content = document.getContentStream(BigInteger.valueOf(2), BigInteger.valueOf(4));
        assertNotNull(content);

        NodeRef doc1NodeRef = cmisIdToNodeRef(document.getId());
        FileInfo fileInfo = ffs.getFileInfo(doc1NodeRef);
        Map<QName, Serializable> properties = fileInfo.getProperties();
        ContentDataWithId contentData = (ContentDataWithId) properties
                .get(QName.createQName("{http://www.alfresco.org/model/content/1.0}content"));
        String encoding = contentData.getEncoding();

        assertEquals("ISO-8859-1", encoding);
    }
    finally
    {
        authenticationComponent.clearCurrentSecurityContext();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:OpenCmisLocalTest.java

示例11: getCMISRepositories

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
/**
 * Get CMIS repositories (Enterprise AtomPub CMIS binding)
 *
 * @return List<Repository>
 */
public List<Repository> getCMISRepositories()
{
    List<Repository> repositories = null;

    RequestContext rc = getRequestContext();
    if(rc == null)
    {
        throw new RuntimeException("Must set a request context");
    }

    UserData userData = findUser(rc.getRunAsUser());
    if(userData != null)
    {
        // default factory implementation
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Map<String, String> parameters = new HashMap<String, String>();

        // user credentials
        parameters.put(SessionParameter.USER, rc.getRunAsUser());
        parameters.put(SessionParameter.PASSWORD, userData.getPassword());

        // connection settings
        parameters.put(SessionParameter.ATOMPUB_URL, client.getCmisUrl(null, null));
        parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

        repositories = factory.getRepositories(parameters);
    }

    return repositories;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:36,代码来源:PublicApiClient.java

示例12: getCMISSession

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
public CmisSession getCMISSession(Repository respository)
{
    RequestContext rc = getRequestContext();
    if(rc == null)
    {
        throw new RuntimeException("Must set a request context");
    }

    CmisSession session = createCMISSession(respository.getId(), rc);
    return session;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:12,代码来源:PublicApiClient.java

示例13: getNetworkIds

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
public List<String> getNetworkIds(String version)
{
    RequestContext rc = getRequestContext();

    UserData userData = findUser(rc.getRunAsUser());
    if(userData == null)
    {
        throw new RuntimeException("Must provide a valid username");
    }

    SessionFactory factory = SessionFactoryImpl.newInstance();

    Map<String, String> parameters = new HashMap<String, String>();

    // connection settings
    parameters.put(SessionParameter.ATOMPUB_URL, client.getPublicApiCmisUrl(null, Binding.atom, version, null));
    parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

    // user credentials
    parameters.put(SessionParameter.USER, rc.getRunAsUser());
    parameters.put(SessionParameter.PASSWORD, userData.getPassword());
    List<Repository> repositories = factory.getRepositories(parameters);

    List<String> repositoryIds = new ArrayList<String>(repositories.size());
    for(Repository repository : repositories)
    {
        repositoryIds.add(repository.getId());
    }

    return repositoryIds;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:32,代码来源:PublicApiClient.java

示例14: createSession

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
protected Session createSession() {
    SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<String, String>();
    parameter.put(SessionParameter.ATOMPUB_URL, getUrl());
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());

    Repository repository = sessionFactory.getRepositories(parameter).get(0);
    return repository.createSession();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:CMISTestSupport.java

示例15: afterPropertiesSet

import org.apache.chemistry.opencmis.client.api.Repository; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:11,代码来源:CmisSessionFactory.java


注:本文中的org.apache.chemistry.opencmis.client.api.Repository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。