Esempio n. 1
0
        /// <summary>
        /// Connect to user home server and get the latest info about this collection
        /// </summary>
        public static CatalogInfo GetCatalogInfoItem(string CollectionID, string UserID, string DomainID)
        {
            CatalogInfo catInfo = null;

            try
            {
                //lock (collectionList)
                {
                    Store localStore = Store.GetStore();
                    //ArrayList CollectionArray;

                    Domain domain = localStore.GetDomain(DomainID);
                    // skip local domain
                    if (!domain.Name.Equals(Store.LocalDomainName))
                    {
                        DomainAgent da = new DomainAgent();
                        if (!da.IsDomainRemoved(domain.ID))
                        {
                            Member cmember = domain.GetCurrentMember();
                            if (cmember == null)
                            {
                                log.Debug("CetCollectionInfoItem : Member is null in local store");
                                throw new Exception("Member NULL");
                            }
                            HostNode masterNode = cmember.HomeServer; //HostNode.GetMaster(DomainID);//cmember.HomeServer;

                            try
                            {
                                log.Debug("GetCollectionInfoItem - Try ");

                                SimiasConnection smConn = new SimiasConnection(DomainID, cmember.UserID,
                                                                               SimiasConnection.AuthType.BASIC,
                                                                               masterNode);

                                DiscoveryService dService            = new DiscoveryService();
                                DomainAgent      dAgent              = new DomainAgent();
                                bool             activeDomain        = dAgent.IsDomainActive(domain.ID);
                                bool             authenticatedDomain = dAgent.IsDomainAuthenticated(domain.ID);

                                if (activeDomain)
                                {
                                    if (!authenticatedDomain)
                                    {
                                        new EventPublisher().RaiseEvent(new NeedCredentialsEventArgs(domain.ID));
                                        throw new Exception("Domain Not Authenticated");
                                    }
                                    dService.Url = masterNode.PrivateUrl;

                                    smConn.Authenticate();
                                    smConn.InitializeWebClient(dService, "DiscoveryService.asmx");

                                    catInfo = dService.GetCatalogInfoForCollection(CollectionID);
                                }
                            }
                            catch (Exception e)
                            {
                                // If DiscoveryWs is N/A  or not running , we skip.
                                log.Debug("GetCatalogInfoItem : Skipping Domain : {0} ID : {1} Trace : {2}",
                                          domain.Name, domain.ID, e.ToString());
                                throw e;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Final Exception : " + ex.ToString());
                throw ex;
            }
            return(catInfo);
        }