private void correctionButton_Click(object sender, System.EventArgs e) { if (false == ValidatePublisher()) { return; } try { ConnectionManager.BeginTransaction(); // // Deserialize into a change record object // StringReader reader = new StringReader(correctionTextBox.Text); ChangeRecordCorrection changeRecordCorrection = ( ChangeRecordCorrection )correctionSerializer.Deserialize(reader); // // Validate what we created. // SchemaCollection.Validate(changeRecordCorrection); // // Create a new change record to hold the correction. // ChangeRecord changeRecord = new ChangeRecord(changeRecordCorrection); changeRecord.Process(); ConnectionManager.Commit(); // // If we made it this far, we were able to process the correction // MessageBox.Show("Correction processed!"); // // Refresh our display. // ShowChangeRecord(); } catch (Exception exception) { ConnectionManager.Abort(); MessageBox.Show("An exception occurred when trying to process the correction:\r\n\r\n" + exception.ToString()); } }
static int Main(string[] args) { int retCode = 1; // assume error // // Check if CurrentUICulture needs to be overridden // UDDI.Localization.SetConsoleUICulture(); Console.WriteLine(FormatFromResource("BOOTSTRAP_COPYRIGHT_1")); Console.WriteLine(FormatFromResource("BOOTSTRAP_COPYRIGHT_2")); Console.WriteLine(); // // parse the command line // if (!ProcessCommandLine(args)) { return(1); } WindowsPrincipal prin = new WindowsPrincipal(WindowsIdentity.GetCurrent()); try { ConnectionManager.Open(true, true); } catch { Console.WriteLine(FormatFromResource("BOOTSTRAP_DB_CONNECT_FAILED")); return(1); } try { // // Setup the UDDI user credentials // Context.User.SetRole(prin); // // Verify that the user is a member of the administrators group // if (!Context.User.IsAdministrator) { // // 735728 - Show an error to the user and exit the program. // Console.WriteLine(FormatFromResource("BOOTSTRAP_ACCESS_DENIED")); Console.WriteLine(FormatFromResource("BOOTSTRAP_ADMIN_GROUP_ONLY")); Console.WriteLine(FormatFromResource("BOOTSTRAP_USER_NOT_ADMIN", WindowsIdentity.GetCurrent().Name)); return(1); } if (null != username && 0 != username.Length) { // // The /u option was specified // Context.User.SetPublisherRole(username); if (!Context.User.IsRegistered) { // // 735728 - Show an error to the user and exit the program. // Console.WriteLine(FormatFromResource("BOOTSTRAP_USER_NOT_REGISTERED", username)); return(1); } // // If the current user is not the same as the publisher, set up impersonation // if (Context.User.ID != WindowsIdentity.GetCurrent().Name) { Context.User.ImpersonatorID = WindowsIdentity.GetCurrent().Name; } } else { // // Default is to save data under the default publisher // Context.User.ID = UDDI.Utility.GetDefaultPublisher(); } // // If user is not system publisher, a temporary operator must be added to support pre-assigned key behavior // string operatorkey = System.Guid.NewGuid().ToString(); if (Context.User.ID != UDDI.Utility.GetDefaultPublisher()) { Context.User.SetAllowPreassignedKeys(true); } XmlSerializer serializer = new XmlSerializer(typeof(UDDI.API.Extensions.Resources)); // // Load the XML file. // Console.WriteLine(FormatFromResource("BOOTSTRAP_PROCESSING_MSG", filename, Context.User.ID)); FileStream strm = new FileStream(filename, FileMode.Open, FileAccess.Read); Resources.Validate(strm); Resources resources = (Resources)serializer.Deserialize(strm); strm.Close(); // // Save the TModel // Console.WriteLine(FormatFromResource("BOOTSTRAP_SAVING")); // // Determine the number of tModels that we imported. // int tModelCount = 0; if (null != resources.TModelDetail) { tModelCount += resources.TModelDetail.TModels.Count; } if (null != resources.CategorizationSchemes) { foreach (CategorizationScheme scheme in resources.CategorizationSchemes) { if (null != scheme.TModel) { tModelCount++; } } } Console.WriteLine(FormatFromResource("BOOTSTRAP_TMODELS", tModelCount)); if (null != resources.CategorizationSchemes) { Console.WriteLine(FormatFromResource("BOOTSTRAP_CATEGORIZATION_SCHEMES", resources.CategorizationSchemes.Count)); } else { Console.WriteLine(FormatFromResource("BOOTSTRAP_CATEGORIZATION_SCHEMES", 0)); } if (null != resources.BusinessDetail) { Console.WriteLine(FormatFromResource("BOOTSTRAP_PROVIDERS", resources.BusinessDetail.BusinessEntities.Count)); } else { Console.WriteLine(FormatFromResource("BOOTSTRAP_PROVIDERS", 0)); } if (null != resources.ServiceDetail) { Console.WriteLine(FormatFromResource("BOOTSTRAP_SERVICES", resources.ServiceDetail.BusinessServices.Count)); } else { Console.WriteLine(FormatFromResource("BOOTSTRAP_SERVICES", 0)); } if (null != resources.BindingDetail) { Console.WriteLine(FormatFromResource("BOOTSTRAP_BINDINGS", resources.BindingDetail.BindingTemplates.Count)); } else { Console.WriteLine(FormatFromResource("BOOTSTRAP_BINDINGS", 0)); } resources.Save(); Console.WriteLine(FormatFromResource("BOOTSTRAP_COMPLETE")); ConnectionManager.Commit(); retCode = 0; // no error } catch (Exception e) { Console.WriteLine(); Console.WriteLine(FormatFromResource("BOOTSTRAP_FAILED", e.Message)); // // 735713 - Output an additional message if the user did not have permissions to modify an entity. // SqlException sqlException = e as SqlException; if (null != sqlException) { if (sqlException.Number - UDDI.Constants.ErrorTypeSQLOffset == ( int )ErrorType.E_userMismatch) { Console.WriteLine(FormatFromResource("ERROR_USER_MISMATCH")); } } ConnectionManager.Abort(); } finally { ConnectionManager.Close(); } return(retCode); }
public override void ProcessMessage(SoapMessage message) { Debug.Enter(); #if DEBUG string info = "log: " + data.log.ToString() + "; https: " + data.https.ToString() + "; validate: " + data.validate.ToString() + "; performance: " + data.performance.ToString() + "; authenticate: " + data.authenticate.ToString() + "; transaction: " + data.transaction.ToString() + "; messageType: " + data.messageType; Debug.Write(SeverityType.Info, CategoryType.Soap, info); #endif try { switch (message.Stage) { // // First Event // case SoapMessageStage.BeforeDeserialize: // // Initialize our context. // Context.Current.Initialize(); Config.CheckForUpdate(); // // TODO: Since we are using DispositionReport.ThrowFinal() I don't think this is // needed anymore. // // // Check to make sure the authenticated user has user credentials // Debug.Verify("1" != HttpContext.Current.Request.ServerVariables["Exception"], "UDDI_ERROR_FATALERROR_VERSIONCHECKERROR", UDDI.ErrorType.E_fatalError); Debug.Write(SeverityType.Info, CategoryType.Soap, "URL: " + message.Url); Debug.Write(SeverityType.Info, CategoryType.Soap, "SOAPAction: " + HttpContext.Current.Request.Headers["SOAPAction"]); string contentType = HttpContext.Current.Request.ContentType.ToLower(); bool validEncoding = (contentType.IndexOf("charset=\"utf-8\"") >= 0) || (contentType.IndexOf("charset=utf-8") >= 0); Debug.Verify(validEncoding, "UDDI_ERROR_UNSUPPORTED_CONTENTTYPEHEADERMISSING", ErrorType.E_unsupported); if (data.performance) { PublishMethodBegin(message); } if (data.https) { CheckForHttps(message); } // // Validation has been moved into the other SOAP extension // // if( data.validate ) // Validate( message ); break; // // Second Event // case SoapMessageStage.AfterDeserialize: ConnectionManager.Open(data.transaction, data.transaction); if (data.certificate) { CheckCertificate(message); } if (data.authenticate) { Authenticate(message); } else if (0 != (Config.GetInt("Security.AuthenticationMode", (int)AuthenticationMode.Both) & (int)AuthenticationMode.AuthenticatedRead)) { // // Authenticated reads are turned on and this is a read request // Make sure the caller is authenticated using Windows and is at least a user // WindowsIdentity identity = (WindowsIdentity)HttpContext.Current.User.Identity; WindowsAuthenticator wa = new WindowsAuthenticator(); wa.Authenticate("", 0 /* not used */); Debug.Write(SeverityType.Info, CategoryType.Soap, "Authenticated user: using Windows based authentication Identity is " + identity.Name); // // Check to make sure the authenticated user has user credentials // Debug.Verify(Context.User.IsUser, "UDDI_ERROR_FATALERROR_NOUSERCREDS", UDDI.ErrorType.E_fatalError, Context.User.ID); } break; // // Third Event // case SoapMessageStage.BeforeSerialize: break; // // Last Event // case SoapMessageStage.AfterSerialize: // // Cleanup the connection and commit the database activity // if (data.transaction && (null != (object)ConnectionManager.GetConnection()) && (null != (object)ConnectionManager.GetTransaction())) { if (null == (object)message.Exception) { ConnectionManager.Commit(); } else { ConnectionManager.Abort(); } } ConnectionManager.Close(); try { if (data.performance) { PublishMethodEnd(message); } } catch { Debug.OperatorMessage( SeverityType.Warning, CategoryType.None, OperatorMessageType.UnableToPublishCounter, "An error occurred while trying to publish a performance counter, the system will continue"); } break; default: throw new UDDIException(ErrorType.E_fatalError, "UDDI_ERROR_FATALERROR_UNKNOWNEXTSTAGE"); } } catch (Exception e) { DispositionReport.Throw(e); } Debug.Leave(); }
static void FixDefaultURLs() { // // Get a list of business keys that have non-default discovery URLs. // ArrayList businessEntities = GetBusinessEntities(); int total = businessEntities.Count; int current = 1; int numberFixed = 0; foreach (BusinessEntity businessEntity in businessEntities) { // // Get values for this business. // businessEntity.Get(); // // BusinessEntity.Get() may add the default one, we don't want it. // DiscoveryUrlCollection originalList = new DiscoveryUrlCollection(); originalList.Get(businessEntity.BusinessKey); businessEntity.DiscoveryUrls = originalList; Log("*** Processing " + current++ + "/" + total + " *** "); LogStartBusinessEntity(businessEntity); DiscoveryUrlCollection filteredList = GetFilterList(businessEntity); if (filteredList.Count < businessEntity.DiscoveryUrls.Count) { try { numberFixed++; LogFixStart(filteredList); ConnectionManager.BeginTransaction(); // // Remove duplicate discovery URLs // businessEntity.DiscoveryUrls = filteredList; // // Fix change records // FixChangeRecords(businessEntity); // // Fix data. Saving the BusinessEntity will also create a ChangeRecordNew data in our replication stream. // Other operators will consume this change record, which will update their databases. // FixData(businessEntity); #if never ChangeRecordNewData changeRecordNewData = new ChangeRecordNewData(businessEntity); ChangeRecord fixData = new ChangeRecord(changeRecordNewData); fixData.Process(); #endif ConnectionManager.Commit(); LogFixEnd(businessEntity); } catch (Exception e) { WriteException(e); ConnectionManager.Abort(); } } LogDoneBusinessEntity(businessEntity); } Log("BusinessEntities fixed: " + numberFixed); }