本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于org.apache.chemistry.opencmis.client.api包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDescendants
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
public FolderNode getDescendants(String folderId, int depth)
{
Session session = getCMISSession();
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Tree<FileableCmisObject>> res = f.getDescendants(depth, ctx);
FolderNode ret = (FolderNode)CMISNode.createNode(f);
for(Tree<FileableCmisObject> t : res)
{
addChildren(ret, t);
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例2: move
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
@Override
public void move(String pathOrigin, String documentNameOrigin, String pathDestination, String documentNameDestination, Session session) throws Exception {
// Disable cache
session.getDefaultContext().setCacheEnabled(false);
// Fetch the object
FileableCmisObject fileableCmisObject = (FileableCmisObject) FileUtils.getObject(pathOrigin + documentNameOrigin, session);
// ECM folder paths does not end with "/"
if (pathOrigin.endsWith("/")) pathOrigin = pathOrigin.substring(0, pathOrigin.length()-1);
if (pathDestination.endsWith("/")) pathDestination = pathDestination.substring(0, pathDestination.length()-1);
// Fetch source folder
CmisObject sourceObject = FileUtils.getObject(pathOrigin, session);
// Fetch the destination folder
// We need to make sure the target folder exists
createFolder(pathDestination);
CmisObject targetObject = FileUtils.getObject(pathDestination, session);
if (documentNameDestination != documentNameOrigin){
fileableCmisObject.rename(documentNameDestination, true);
}
// Move the object
fileableCmisObject.move(sourceObject, targetObject);
// Enable cache
session.getDefaultContext().setCacheEnabled(true);
}
示例3: updateDescriptorFile
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
@Override
public void updateDescriptorFile(String tenantId, String uuid, CMISEvidenceFile cmisFile) {
Session session = createSession();
Folder multitenantRootFolder = (Folder) session.getObjectByPath("/" + tenantId);
Folder uuidFolder = getUuidFolder(session, uuid, multitenantRootFolder, repoFolderNestingLevels, true);
for (CmisObject cmisObject : uuidFolder.getChildren()) {
if (cmisObject.getType().getId().equals(CMISEvidenceFile.PROPERTY_DOC_ID)) {
Document doc = (Document) cmisObject;
if (doc.getName().equals(cmisFile.getFileName())) {
Map<String, String> newDocProps = new HashMap<String, String>();
newDocProps.put(CMISEvidenceFile.PROPERTY_TRANSACTION_STATUS, cmisFile.getTransactionStatus());
doc.updateProperties(newDocProps);
// Recover mime type from stored content
ContentStream contentStream = new ContentStreamImpl(cmisFile.getFileName(), null, doc.getContentStreamMimeType(), cmisFile.getInputStream());
doc.setContentStream(contentStream, true);
} else {
log.warn("Found unexpected CMIS object type in descriptor folder: " + cmisObject.getName() + " - " + cmisObject.getType().getId() +
" (expected " + cmisFile.getFileName() + ")");
}
}
}
}
示例4: createDocument
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
private static Document createDocument(Folder target, String newDocName, Session session)
{
Map<String, String> props = new HashMap<String, String>();
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
props.put(PropertyIds.NAME, newDocName);
String content = "aegif Mind Share Leader Generating New Paradigms by aegif corporation.";
byte[] buf = null;
try
{
buf = content.getBytes("ISO-8859-1"); // set the encoding here for the content stream
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
ByteArrayInputStream input = new ByteArrayInputStream(buf);
ContentStream contentStream = session.getObjectFactory().createContentStream(newDocName, buf.length,
"text/plain; charset=UTF-8", input); // additionally set the charset here
// NOTE that we intentionally specified the wrong charset here (as UTF-8)
// because Alfresco does automatic charset detection, so we will ignore this explicit request
return target.createDocument(props, contentStream, VersioningState.MAJOR);
}
示例5: cmisSession
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
/**
* @return la session CMIS
*/
private Session cmisSession(){
if (url == null || url.equals("") || repository == null || repository.equals("") || user == null || user.equals("")){
return null;
}
try{
// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, user);
parameter.put(SessionParameter.PASSWORD, password);
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, url);
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
parameter.put(SessionParameter.REPOSITORY_ID, repository);
// create session
Session session = factory.createSession(parameter);
if (session == null){
logger.error("Stockage de fichier - Impossible de se connecter au serveur de fichier CMIS");
return null;
}else{
if (directoryExistCMIS(idFolderGestionnaire,session) && directoryExistCMIS(idFolderCandidat,session)){
return session;
}
}
return null;
}catch (Exception e){
logger.error("Stockage de fichier - Impossible de se connecter au serveur de fichier CMIS", e);
return null;
}
}
示例6: directoryExistCMIS
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
/** Verifie qu'un dossier existe en mode CMIS
* @param idFolder
* @return
*/
private Boolean directoryExistCMIS(String idFolder, Session cmisSession) {
if (idFolder == null || idFolder.equals("")) {
return false;
}
try{
CmisObject object = cmisSession.getObject(cmisSession.createObjectId(idFolder));
if (!(object instanceof Folder)){
logger.error("Stockage de fichier - CMIS : l'object CMIS "+idFolder+" n'est pas un dossier");
return false;
}
}catch(Exception e){
logger.error("Stockage de fichier - CMIS : erreur sur l'object CMIS "+idFolder, e);
return false;
}
return true;
}
示例7: deleteCampagneFolder
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
@Override
public Boolean deleteCampagneFolder(String codCampagne){
logger.debug("Suppression du dossier de campagne : "+codCampagne);
Session session = getCmisSession();
try{
/*Dossier de base pour les candidats*/
Folder master = getFolderCandidat();
/*Le dossier de la campagne*/
Folder folderCampagne = FileUtils.getFolder(master.getPath()+"/"+codCampagne, session);
logger.debug("Suppression du dossier de campagne, path="+folderCampagne.getPath()+", id="+folderCampagne.getId());
List<String> liste = folderCampagne.deleteTree(true, UnfileObject.DELETE, true);
if (liste !=null && liste.size()>0){
return false;
}
return true;
}catch(Exception e){
logger.error("Impossible de supprimer le dossier de campagne : "+codCampagne+", vous devez le supprimer à la main",e);
return false;
}
}
示例8: testCanConnectCMISUsingDefaultTenantImpl
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的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);
}
示例9: getATOMPUB_10_Session
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
protected Session getATOMPUB_10_Session()
{
try
{
Map<String, String> parameters = new HashMap<String, String>();
int port = getTestFixture().getJettyComponent().getPort();
parameters.put(SessionParameter.USER, ADMIN_USER);
parameters.put(SessionParameter.PASSWORD, ADMIN_PASSWORD);
parameters.put(SessionParameter.ATOMPUB_URL, MessageFormat.format(ATOMPUB_URL_OC, DEFAULT_HOSTNAME, String.valueOf(port)));
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
parameters.put(SessionParameter.REPOSITORY_ID, sessionFactory.getRepositories(parameters).get(0).getId());
return sessionFactory.createSession(parameters);
}
catch (Exception ex)
{
logger.error(ex);
}
return null;
}
示例10: getATOMPUB_11_Session
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
protected Session getATOMPUB_11_Session()
{
try
{
Map<String, String> parameters = new HashMap<String, String>();
int port = getTestFixture().getJettyComponent().getPort();
parameters.put(SessionParameter.USER, ADMIN_USER);
parameters.put(SessionParameter.PASSWORD, ADMIN_PASSWORD);
parameters.put(SessionParameter.ATOMPUB_URL, MessageFormat.format(ATOMPUB_URL_11, DEFAULT_HOSTNAME, String.valueOf(port)));
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
parameters.put(SessionParameter.REPOSITORY_ID, sessionFactory.getRepositories(parameters).get(0).getId());
return sessionFactory.createSession(parameters);
}
catch (Exception ex)
{
logger.error(ex);
}
return null;
}
示例11: getBROWSER_11_Session
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
protected Session getBROWSER_11_Session()
{
try
{
Map<String, String> parameter = new HashMap<String, String>();
int port = getTestFixture().getJettyComponent().getPort();
parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
parameter.put(SessionParameter.BROWSER_URL, MessageFormat.format(BROWSE_URL_11, DEFAULT_HOSTNAME, String.valueOf(port)));
parameter.put(SessionParameter.COOKIES, "true");
parameter.put(SessionParameter.USER, ADMIN_USER);
parameter.put(SessionParameter.PASSWORD, ADMIN_PASSWORD);
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
parameter.put(SessionParameter.REPOSITORY_ID, sessionFactory.getRepositories(parameter).get(0).getId());
return sessionFactory.createSession(parameter);
}
catch (Exception ex)
{
logger.error(ex);
}
return null;
}
示例12: create2TestACLs
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
/**
*
* @param session Session
* @return List<Ace>
*/
private List<Ace> create2TestACLs(Session session)
{
List<Ace> newACE = new ArrayList<Ace>();
LinkedList<String> permissions1 = new LinkedList<String>();
permissions1.add("{http://www.alfresco.org/model/system/1.0}base.ReadPermissions");
LinkedList<String> permissions2 = new LinkedList<String>();
permissions2.add("{http://www.alfresco.org/model/system/1.0}base.Unlock");
Ace ace1 = session.getObjectFactory().createAce("testUser1", permissions1);
Ace ace2 = session.getObjectFactory().createAce("testUser2", permissions2);
newACE.add(ace1);
newACE.add(ace2);
return newACE;
}
示例13: createCMISSession
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
/**
* Create a CMIS session using Enterprise AtomPub binding.
*
* @param repositoryId String
* @param username String
* @param password String
* @return CmisSession
*/
public CmisSession createCMISSession(String repositoryId, String username, String password)
{
// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameters = new HashMap<String, String>();
// user credentials
parameters.put(SessionParameter.USER, username);
parameters.put(SessionParameter.PASSWORD, password);
// connection settings
parameters.put(SessionParameter.ATOMPUB_URL, client.getCmisUrl(repositoryId, null));
parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
if(repositoryId != null)
{
parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
}
parameters.put(SessionParameter.OBJECT_FACTORY_CLASS, AlfrescoObjectFactoryImpl.class.getName());
// create session
Session session = factory.createSession(parameters);
CmisSession cmisSession = new CmisSession(session);
return cmisSession;
}
示例14: updatePropertiesWithAspects
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
private static void updatePropertiesWithAspects(Session pSession, Map<String, Object> pMapProperties,
String pStrDocTypeId, Collection<String> pCollectionAspects) {
// Creazione mappa proprietà secondo la versione CMIS del repository
if (pSession.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_1) {
pMapProperties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, pCollectionAspects);
} else {
// Creazione dell'elenco degli aspetti
StringBuilder lSBAspects = new StringBuilder(pStrDocTypeId);
for (String aspect : pCollectionAspects) {
lSBAspects.append(", ").append(aspect);
}
mLog.debug("[CMIS 1.0] Aspetti del documento: {}", lSBAspects.toString());
// XXX (Alessio): funziona senza usare l'estensione Chemistry per Alfresco? In generale,
// bisognerebbe prevedere la gestione secondo la versione CMIS in tutto l'AlfrescoHelper,
// per supportare le diverse versioni di Alfresco.
pMapProperties.put(PropertyIds.OBJECT_TYPE_ID, lSBAspects.toString());
}
}
示例15: createSession
import org.apache.chemistry.opencmis.client.api.Session; //导入依赖的package包/类
public static Session createSession(AlfrescoConfig config) {
mLog.debug("Start createSession()");
Map<String, String> lMapParameter = new HashMap<String, String>();
// I parametri di connessione vengono impostati per usare il binding AtomPub CMIS 1.1
lMapParameter.put(SessionParameter.USER, config.getUsername());
lMapParameter.put(SessionParameter.PASSWORD, config.getPassword());
lMapParameter.put(SessionParameter.ATOMPUB_URL, buildUrl(ATOMPUB_CMIS11_URL_TEMPLATE, config));
lMapParameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// creo la session factory
SessionFactory lSessionFactory = SessionFactoryImpl.newInstance();
// creo la sessione connessa al repository
Session lSession = lSessionFactory.getRepositories(lMapParameter).get(0).createSession();
mLog.debug("End createSession()");
return lSession;
}