예제 #1
0
        /// <summary>
        /// Try to find the CMIS server associated to any URL.
        /// Users can provide the URL of the web interface, and we have to return the CMIS URL
        /// Returns the list of repositories as well.
        /// </summary>
        static public Tuple<CmisServer, Exception> GetRepositoriesFuzzy(ServerCredentials credentials)
        {
            Dictionary<string, string> repositories = null;
            Exception firstException = null;

            // Try the given URL, maybe user directly entered the CMIS AtomPub endpoint URL.
            try
            {
                repositories = GetRepositories(credentials);
            }
            catch (CmisRuntimeException e)
            {
                if (e.Message == "ConnectFailure")
                    return new Tuple<CmisServer, Exception>(new CmisServer(credentials.Address, null), new ServerNotFoundException(e.Message, e));
                firstException = e;
            }
            catch (Exception e)
            {
                // Save first Exception and try other possibilities.
                firstException = e;
            }
            if (repositories != null)
            {
                // Found!
                return new Tuple<CmisServer, Exception>(new CmisServer(credentials.Address, repositories), null);
            }

            // Extract protocol and server name or IP address
            string prefix = credentials.Address.GetLeftPart(UriPartial.Authority);

            // See https://github.com/aegif/CmisSync/wiki/What-address for the list of ECM products prefixes
            // Please send us requests to support more CMIS servers: https://github.com/aegif/CmisSync/issues
            string[] suffixes = {
                "/alfresco/api/-default-/public/cmis/versions/1.1/atom", // Alfresco 4.2 CMIS 1.1
                "/alfresco/api/-default-/public/cmis/versions/1.0/atom", // Alfresco 4.2 CMIS 1.0
                "/alfresco/cmisatom", // Alfresco 4.0 and 4.1
                "/alfresco/service/cmis", // Alfresco 3.x
                "/cmis/atom11", // OpenDataSpace
                "/rest/private/cmisatom/", // eXo Platform
                "/xcmis/rest/cmisatom", // xCMIS
                "/files/basic/cmis/my/servicedoc", // IBM Connections
                "/p8cmis/resources/Service", // IBM FileNet
                "/_vti_bin/cmis/rest?getRepositories", // Microsoft SharePoint
                "/nemakiware/atom/bedroom", // NemakiWare  TODO: different port, typically 8080 for Web UI and 3000 for CMIS
                "/nuxeo/atom/cmis", // Nuxeo
                "/cmis/atom",
                "/cmis/resources/", // EMC Documentum
                "/emc-cmis-ea/resources/", // EMC Documentum
                "/emc-cmis-weblogic/resources/", // EMC Documentum
                "/emc-cmis-wls/resources/", // EMC Documentum
                "/emc-cmis-was61/resources/", // EMC Documentum
                "/emc-cmis-wls1030/resources/", // EMC Documentum
                "/docushare/ds_mobile_connector/atom", // Xerox DocuShare
                "/documents/ds_mobile_connector/atom" // Xerox DocuShare  TODO: can be anything instead of "documents"
            };
            string bestUrl = null;
            // Try all suffixes
            for (int i=0; i < suffixes.Length; i++)
            {
                string fuzzyUrl = prefix + suffixes[i];
                Logger.Info("Sync | Trying with " + fuzzyUrl);
                try
                {
                    ServerCredentials cred = new ServerCredentials()
                    {
                        UserName = credentials.UserName,
                        Password = credentials.Password.ToString(),
                        Address = new Uri(fuzzyUrl)
                    };
                    repositories = GetRepositories(cred);
                }
                catch (CmisPermissionDeniedException e)
                {
                    firstException = new PermissionDeniedException(e.Message, e);
                    bestUrl = fuzzyUrl;
                }
                catch (Exception e)
                {
                    // Do nothing, try other possibilities.
                    Logger.Debug(e.Message);
                }
                if (repositories != null)
                {
                    // Found!
                    return new Tuple<CmisServer, Exception>( new CmisServer(new Uri(fuzzyUrl), repositories), null);
                }
            }

            // Not found. Return also the first exception to inform the user correctly
            return new Tuple<CmisServer,Exception>(new CmisServer(bestUrl==null?credentials.Address:new Uri(bestUrl), null), firstException);
        }
예제 #2
0
        /// <summary>
        /// Try to find the CMIS server associated to any URL.
        /// Users can provide the URL of the web interface, and we have to return the CMIS URL
        /// Returns the list of repositories as well.
        /// </summary>
        static public Tuple<CmisServer, Exception> GetRepositoriesFuzzy(Uri url, string user, string password)
        {
            Dictionary<string, string> repositories = null;
            Exception firstException = null;

            // Try the given URL, maybe user directly entered the CMIS AtomPub endpoint URL.
            try
            {
                repositories = GetRepositories(url, user, password);
            }
            catch (CmisRuntimeException e)
            {
                if (e.Message == "ConnectFailure")
                    return new Tuple<CmisServer, Exception>(new CmisServer(url, null), new ServerNotFoundException(e.Message, e));
                firstException = e;

            }
            catch (Exception e)
            {
                // Save first Exception and try other possibilities.
                firstException = e;
            }
            if (repositories != null)
            {
                // Found!
                return new Tuple<CmisServer, Exception>(new CmisServer(url, repositories), null);
            }

            // Extract protocol and server name or IP address
            string prefix = url.GetLeftPart(UriPartial.Authority);

            // See https://github.com/nicolas-raoul/CmisSync/wiki/What-address for the list of ECM products prefixes
            // Please send us requests to support more CMIS servers: https://github.com/nicolas-raoul/CmisSync/issues
            string[] suffixes = {
                "/cmis/atom",
                "/alfresco/cmisatom",
                "/alfresco/service/cmis",
                "/cmis/resources/",
                "/emc-cmis-ea/resources/",
                "/emc-cmis-weblogic/resources/",
                "/emc-cmis-wls/resources/",
                "/emc-cmis-was61/resources/",
                "/emc-cmis-wls1030/resources/",
                "/xcmis/rest/cmisatom",
                "/files/basic/cmis/my/servicedoc",
                "/p8cmis/resources/Service",
                "/_vti_bin/cmis/rest?getRepositories",
                "/Nemaki/atom/bedroom",
                "/nuxeo/atom/cmis"
            };
            string bestUrl = null;
            // Try all suffixes
            for (int i=0; i < suffixes.Length; i++)
            {
                string fuzzyUrl = prefix + suffixes[i];
                Logger.Info("Sync | Trying with " + fuzzyUrl);
                try
                {
                    repositories = GetRepositories(new Uri(fuzzyUrl), user, password);
                }
                catch (CmisPermissionDeniedException e)
                {
                    firstException = new PermissionDeniedException(e.Message, e);
                    bestUrl = fuzzyUrl;
                }
                catch (Exception e)
                {
                    // Do nothing, try other possibilities.
                    Logger.Info(e.Message);
                }
                if (repositories != null)
                {
                    // Found!
                    return new Tuple<CmisServer, Exception>( new CmisServer(new Uri(fuzzyUrl), repositories), null);
                }
            }

            // Not found. Return also the first exception to inform the user correctly
            return new Tuple<CmisServer,Exception>(new CmisServer(bestUrl==null?url:new Uri(bestUrl), null), firstException);
        }
예제 #3
0
        /// <summary>
        /// Try to find the CMIS server associated to any URL.
        /// Users can provide the URL of the web interface, and we have to return the CMIS URL
        /// Returns the list of repositories as well.
        /// </summary>
        static public Tuple <CmisServer, Exception> GetRepositoriesFuzzy(Uri url, string user, string password)
        {
            Dictionary <string, string> repositories = null;
            Exception firstException = null;

            // Try the given URL, maybe user directly entered the CMIS AtomPub endpoint URL.
            try
            {
                repositories = GetRepositories(url, user, password);
            }
            catch (CmisRuntimeException e)
            {
                if (e.Message == "ConnectFailure")
                {
                    return(new Tuple <CmisServer, Exception>(new CmisServer(url, null), new ServerNotFoundException(e.Message, e)));
                }
                firstException = e;
            }
            catch (Exception e)
            {
                // Save first Exception and try other possibilities.
                firstException = e;
            }
            if (repositories != null)
            {
                // Found!
                return(new Tuple <CmisServer, Exception>(new CmisServer(url, repositories), null));
            }

            // Extract protocol and server name or IP address
            string prefix = url.GetLeftPart(UriPartial.Authority);

            // See https://github.com/nicolas-raoul/CmisSync/wiki/What-address for the list of ECM products prefixes
            // Please send us requests to support more CMIS servers: https://github.com/nicolas-raoul/CmisSync/issues
            string[] suffixes =
            {
                "/cmis/atom",

                /* We don't need all these for oris4
                 * "/alfresco/cmisatom",
                 * "/alfresco/service/cmis",
                 * "/cmis/resources/",
                 * "/emc-cmis-ea/resources/",
                 * "/emc-cmis-weblogic/resources/",
                 * "/emc-cmis-wls/resources/",
                 * "/emc-cmis-was61/resources/",
                 * "/emc-cmis-wls1030/resources/",
                 * "/xcmis/rest/cmisatom",
                 * "/files/basic/cmis/my/servicedoc",
                 * "/p8cmis/resources/Service",
                 * "/_vti_bin/cmis/rest?getRepositories",
                 * "/Nemaki/atom/bedroom",
                 * "/nuxeo/atom/cmis"
                 */
            };
            string bestUrl = null;

            // Try all suffixes
            for (int i = 0; i < suffixes.Length; i++)
            {
                string fuzzyUrl = prefix + suffixes[i];
                Logger.Info("Sync | Trying with " + fuzzyUrl);
                try
                {
                    repositories = GetRepositories(new Uri(fuzzyUrl), user, password);
                }
                catch (CmisPermissionDeniedException e)
                {
                    firstException = new PermissionDeniedException(e.Message, e);
                    bestUrl        = fuzzyUrl;
                }
                catch (Exception e)
                {
                    // Do nothing, try other possibilities.
                    Logger.Info(e.Message);
                }
                if (repositories != null)
                {
                    // Found!
                    return(new Tuple <CmisServer, Exception>(new CmisServer(new Uri(fuzzyUrl), repositories), null));
                }
            }

            // Not found. Return also the first exception to inform the user correctly
            return(new Tuple <CmisServer, Exception>(new CmisServer(bestUrl == null?url:new Uri(bestUrl), null), firstException));
        }
예제 #4
0
        /// <summary>
        /// Try to find the CMIS server associated to any URL.
        /// Users can provide the URL of the web interface, and we have to return the CMIS URL
        /// Returns the list of repositories as well.
        /// </summary>
        static public Tuple <CmisServer, Exception> GetRepositoriesFuzzy(ServerCredentials credentials)
        {
            Dictionary <string, string> repositories = null;
            Exception firstException = null;

            // Try the given URL, maybe user directly entered the CMIS AtomPub endpoint URL.
            try
            {
                repositories = GetRepositories(credentials);
            }
            catch (CmisRuntimeException e)
            {
                if (e.Message == "ConnectFailure")
                {
                    return(new Tuple <CmisServer, Exception>(new CmisServer(credentials.Address, null), new ServerNotFoundException(e.Message, e)));
                }
                firstException = e;
            }
            catch (Exception e)
            {
                // Save first Exception and try other possibilities.
                firstException = e;
            }
            if (repositories != null)
            {
                // Found!
                return(new Tuple <CmisServer, Exception>(new CmisServer(credentials.Address, repositories), null));
            }

            // Extract protocol and server name or IP address
            string prefix = credentials.Address.GetLeftPart(UriPartial.Authority);

            // See https://github.com/aegif/CmisSync/wiki/What-address for the list of ECM products prefixes
            // Please send us requests to support more CMIS servers: https://github.com/aegif/CmisSync/issues
            string[] suffixes =
            {
                "/alfresco/api/-default-/public/cmis/versions/1.1/atom", // Alfresco 4.2 CMIS 1.1
                "/alfresco/api/-default-/public/cmis/versions/1.0/atom", // Alfresco 4.2 CMIS 1.0
                "/alfresco/cmisatom",                                    // Alfresco 4.0 and 4.1
                "/alfresco/service/cmis",                                // Alfresco 3.x
                "/cmis/atom11",                                          // OpenDataSpace
                "/rest/private/cmisatom/",                               // eXo Platform
                "/xcmis/rest/cmisatom",                                  // xCMIS
                "/files/basic/cmis/my/servicedoc",                       // IBM Connections
                "/p8cmis/resources/Service",                             // IBM FileNet
                "/logicaldoc/service/cmis",                              // LogicalDOC
                "/_vti_bin/cmis/rest?getRepositories",                   // Microsoft SharePoint
                "/nemakiware/atom/bedroom",                              // NemakiWare  TODO: different port, typically 8080 for Web UI and 3000 for CMIS
                "/nuxeo/atom/cmis",                                      // Nuxeo
                "/cmis/atom",
                "/cmis/resources/",                                      // EMC Documentum
                "/emc-cmis-ea/resources/",                               // EMC Documentum
                "/emc-cmis-weblogic/resources/",                         // EMC Documentum
                "/emc-cmis-wls/resources/",                              // EMC Documentum
                "/emc-cmis-was61/resources/",                            // EMC Documentum
                "/emc-cmis-wls1030/resources/",                          // EMC Documentum
                "/docushare/ds_mobile_connector/atom",                   // Xerox DocuShare
                "/documents/ds_mobile_connector/atom"                    // Xerox DocuShare  TODO: can be anything instead of "documents"
            };
            string bestUrl = null;

            // Try all suffixes
            for (int i = 0; i < suffixes.Length; i++)
            {
                string fuzzyUrl = prefix + suffixes[i];
                Logger.Info("Sync | Trying with " + fuzzyUrl);
                try
                {
                    ServerCredentials cred = new ServerCredentials()
                    {
                        UserName = credentials.UserName,
                        Password = credentials.Password.ToString(),
                        Address  = new Uri(fuzzyUrl)
                    };
                    repositories = GetRepositories(cred);
                }
                catch (CmisPermissionDeniedException e)
                {
                    firstException = new PermissionDeniedException(e.Message, e);
                    bestUrl        = fuzzyUrl;
                }
                catch (Exception e)
                {
                    // Do nothing, try other possibilities.
                    Logger.Debug(e.Message);
                }
                if (repositories != null)
                {
                    // Found!
                    return(new Tuple <CmisServer, Exception>(new CmisServer(new Uri(fuzzyUrl), repositories), null));
                }
            }

            // Not found. Return also the first exception to inform the user correctly
            return(new Tuple <CmisServer, Exception>(new CmisServer(bestUrl == null?credentials.Address:new Uri(bestUrl), null), firstException));
        }