Exemple #1
0
        public void Connection()
        {
            try
            {
                CMISConnection.GetParameters();
                String baseUrl = CMISConnection.BaseUrl as String; //"http://127.0.0.1:8080/alfresco";

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters[SessionParameter.BindingType] = BindingType.AtomPub;
                //parameters[SessionParameter.AtomPubUrl] = baseUrl + "/cmisatom";
                parameters[SessionParameter.AtomPubUrl] = baseUrl + "/api/-default-/public/cmis/versions/1.1/atom";
                parameters[SessionParameter.User]       = CMISConnection.User;     //"admin";
                parameters[SessionParameter.Password]   = CMISConnection.Password; //"admin";

                //this._documentRepository = CMISConnection.DocumentRepository;
                //this._externalApplicationProperty = CMISConnection.ExternalApplicationProperty;

                SessionFactory factory = SessionFactory.NewInstance();
                // Connexion à Alfresco (on se connecte toujours au 1er Repository : il n'y en a qu'un seul)
                Session = factory.GetRepositories(parameters)[0].CreateSession();
            }
            catch
            {
                throw new Exception("Veuillez vérifier la connection aux entrepôts Alfresco: " + CMISConnection.BaseUrl + ". Impossible de se connecter à Alfresco.");
            }
        }
Exemple #2
0
        public void Connection()
        {
            String baseUrl = string.Empty;

            try
            {
                Log.Debug("Get parameters...");
                CMISConnection.GetParameters();
                Log.Debug("Parameters retrieved");
                baseUrl = CMISConnection.BaseUrl as String; //"http://127.0.0.1:8080/alfresco";

                Dictionary <string, string> parameters = new Dictionary <string, string>();
                parameters[SessionParameter.BindingType] = BindingType.AtomPub;
                //parameters[SessionParameter.AtomPubUrl] = baseUrl + "/cmisatom";
                parameters[SessionParameter.AtomPubUrl] = baseUrl;                 // + "/api/-default-/public/cmis/versions/1.1/atom";
                parameters[SessionParameter.User]       = CMISConnection.User;     //"admin";
                parameters[SessionParameter.Password]   = CMISConnection.Password; //"admin";

                //this._documentRepository = CMISConnection.DocumentRepository;
                //this._externalApplicationProperty = CMISConnection.ExternalApplicationProperty;
                Log.Debug("Create SessionFactory instance");
                SessionFactory factory = SessionFactory.NewInstance();
                Log.Debug("SessionFactory instance created");
                // Connexion à Alfresco (on se connecte toujours au 1er Repository : il n'y en a qu'un seul)
                string paramList = string.Join(";", parameters.Select(x => x.Key + "=" + x.Value));
                Log.DebugFormat("Get list of repositories using parameters :  {0}", paramList);
                IList <IRepository> repos = factory.GetRepositories(parameters);
                Log.Debug("List of repositories retrieved");
                if (repos.Count == 0)
                {
                    throw new Exception("No repository found.");
                }
                Log.Debug("Open session for repo");
                Session = repos[0].CreateSession();
                Log.Debug("Session opened");
            }
            catch (Exception ex)
            {
                Log.Error("Cannot connect to <" + baseUrl + ">. ", ex);
                throw new Exception("Veuillez vérifier la connection aux entrepôts Alfresco: " + CMISConnection.BaseUrl + ". Impossible de se connecter à Alfresco.", ex);
            }
        }