}           //

        /// <summary>
        /// Retrieve an envelop from the registry and do import
        /// </summary>
        /// <param name="envelopeId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool ImportByEnvelopeId(string envelopeId, SaveStatus status)
        {
            //this is currently specific, assumes envelop contains a credential
            //can use the hack fo GetResourceType to determine the type, and then call the appropriate import method

            if (string.IsNullOrWhiteSpace(envelopeId))
            {
                status.AddError("ImportByEnvelope - a valid envelope id must be provided");
                return(false);
            }

            string statusMessage = "";
            //EntityServices mgr = new EntityServices();
            string ctdlType = "";

            try
            {
                ReadEnvelope envelope = RegistryServices.GetEnvelope(envelopeId, ref statusMessage, ref ctdlType);
                if (envelope != null && !string.IsNullOrWhiteSpace(envelope.EnvelopeIdentifier))
                {
                    return(ProcessEnvelope(envelope, status));
                }
                else
                {
                    return(false);
                }
            } catch (Exception ex)
            {
                LoggingHelper.LogError(ex, "ImportCredential.ImportByEnvelopeId()");
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Retrieve an envelop from the registry and do import
        /// </summary>
        /// <param name="envelopeId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool ImportByEnvelopeId(string envelopeId, SaveStatus status)
        {
            //this is currently specific, assumes envelop contains a credential
            //can use the hack fo GetResourceType to determine the type, and then call the appropriate import method

            if (string.IsNullOrWhiteSpace(envelopeId))
            {
                status.AddError(thisClassName + ".ImportByEnvelope - a valid envelope id must be provided");
                return(false);
            }

            string statusMessage = "";
            //EntityServices mgr = new EntityServices();
            string ctdlType = "";

            try
            {
                ReadEnvelope envelope = RegistryServices.GetEnvelope(envelopeId, ref statusMessage, ref ctdlType);
                if (envelope != null && !string.IsNullOrWhiteSpace(envelope.EnvelopeIdentifier))
                {
                    return(CustomProcessEnvelope(envelope, status));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, thisClassName + ".ImportByEnvelopeId()");
                status.AddError(ex.Message);
                if (ex.Message.IndexOf("Path '@context', line 1") > 0)
                {
                    status.AddWarning("The referenced registry document is using an old schema. Please republish it with the latest schema!");
                }
                return(false);
            }
        }
        /// <summary>
        /// Retrieve an envelop from the registry and do import
        /// </summary>
        /// <param name="envelopeId"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public bool ImportByEnvelopeId(string envelopeId, SaveStatus status)
        {
            //this is currently specific, assumes envelop contains a credential
            //can use the hack for GetResourceType to determine the type, and then call the appropriate import method

            if (string.IsNullOrWhiteSpace(envelopeId))
            {
                status.AddError("ImportByEnvelope - a valid envelope id must be provided");
                return(false);
            }

            string statusMessage = "";
            string ctdlType      = "";

            try
            {
                ReadEnvelope envelope = RegistryServices.GetEnvelope(envelopeId, ref statusMessage, ref ctdlType);
                if (envelope == null || string.IsNullOrWhiteSpace(envelope.EnvelopeType))
                {
                    string defCommunity = UtilityManager.GetAppKeyValue("defaultCommunity");
                    string community    = UtilityManager.GetAppKeyValue("additionalCommunity");
                    if (defCommunity != community)
                    {
                        envelope = RegistryServices.GetEnvelope(envelopeId, ref statusMessage, ref ctdlType, community);
                    }
                }

                if (envelope != null && !string.IsNullOrWhiteSpace(envelope.EnvelopeIdentifier))
                {
                    LoggingHelper.DoTrace(4, string.Format("RegistryServices.ImportByEnvelopeId ctdlType: {0}, EnvelopeId: {1} ", ctdlType, envelopeId));
                    ctdlType = ctdlType.Replace("ceterms:", "");

                    switch (ctdlType.ToLower())
                    {
                    case "credentialorganization":
                    case "qacredentialorganization":     //what distinctions do we need for QA orgs?
                    case "organization":
                        return(new ImportOrganization().CustomProcessEnvelope(envelope, status));

                    //break;CredentialOrganization
                    case "assessmentprofile":
                        return(new ImportAssessment().CustomProcessEnvelope(envelope, status));

                    //break;
                    case "learningopportunityprofile":
                        return(new ImportLearningOpportunties().CustomProcessEnvelope(envelope, status));

                    //break;
                    case "conditionmanifest":
                        return(new ImportAssessment().CustomProcessEnvelope(envelope, status));

                    //break;
                    case "costmanifest":
                        return(new ImportLearningOpportunties().CustomProcessEnvelope(envelope, status));

                    //break;
                    default:
                        //default to credential
                        return(new ImportCredential().CustomProcessRequest(envelope, status));
                        //break;
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(ex, string.Format("RegistryServices`.ImportByEnvelopeId(). ctdlType: {0}", ctdlType));
                status.AddError(ex.Message);
                if (ex.Message.IndexOf("Path '@context', line 1") > 0)
                {
                    status.AddWarning("The referenced registry document is using an old schema. Please republish it with the latest schema!");
                }
                return(false);
            }
        }