Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1634 lines
39 KiB

  1. using System;
  2. using System.Collections;
  3. using System.Collections.Specialized;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Xml.Serialization;
  7. using UDDI.Replication;
  8. using UDDI;
  9. using UDDI.API;
  10. using UDDI.Diagnostics;
  11. namespace UDDI.API.Business
  12. {
  13. /// ********************************************************************
  14. /// public class PublisherAssertion
  15. /// --------------------------------------------------------------------
  16. /// <summary>
  17. /// </summary>
  18. /// ********************************************************************
  19. ///
  20. public class PublisherAssertion
  21. {
  22. [XmlElement( "fromKey" )]
  23. public string FromKey
  24. {
  25. get
  26. {
  27. return fromkey;
  28. }
  29. set
  30. {
  31. if( null == value )
  32. fromkey = null;
  33. else
  34. fromkey = value.Trim();
  35. }
  36. }
  37. string fromkey;
  38. [XmlElement( "toKey" )]
  39. public string ToKey
  40. {
  41. get
  42. {
  43. return tokey;
  44. }
  45. set
  46. {
  47. if( null == value )
  48. tokey = null;
  49. else
  50. tokey = value.Trim();
  51. }
  52. }
  53. string tokey;
  54. //
  55. // Element: keyedReference
  56. //
  57. private KeyedReference keyedReference;
  58. [XmlElement( "keyedReference" )]
  59. public KeyedReference KeyedReference
  60. {
  61. get
  62. {
  63. if( null == keyedReference )
  64. keyedReference = new KeyedReference();
  65. return keyedReference;
  66. }
  67. set { keyedReference = value; }
  68. }
  69. /// ****************************************************************
  70. /// public PublisherAssertion [constructor]
  71. /// ----------------------------------------------------------------
  72. /// <summary>
  73. /// </summary>
  74. /// ****************************************************************
  75. ///
  76. public PublisherAssertion()
  77. {
  78. }
  79. /// ****************************************************************
  80. /// public PublisherAssertion [constructor]
  81. /// ----------------------------------------------------------------
  82. /// <summary>
  83. /// </summary>
  84. /// ----------------------------------------------------------------
  85. /// <param name="assertion">
  86. /// </param>
  87. /// ****************************************************************
  88. ///
  89. public PublisherAssertion( PublisherAssertion assertion )
  90. {
  91. this.FromKey = assertion.FromKey;
  92. this.ToKey = assertion.ToKey;
  93. this.KeyedReference = assertion.KeyedReference;
  94. }
  95. /// ****************************************************************
  96. /// public PublisherAssertion [constructor]
  97. /// ----------------------------------------------------------------
  98. /// <summary>
  99. /// </summary>
  100. /// ----------------------------------------------------------------
  101. /// <param name="fromKey">
  102. /// </param>
  103. ///
  104. /// <param name="toKey">
  105. /// </param>
  106. ///
  107. /// <param name="keyedReference">
  108. /// </param>
  109. /// ****************************************************************
  110. ///
  111. public PublisherAssertion( string fromKey, string toKey, KeyedReference keyedReference )
  112. {
  113. this.FromKey = fromKey;
  114. this.ToKey = toKey;
  115. this.KeyedReference = keyedReference;
  116. }
  117. /// ****************************************************************
  118. /// public PublisherAssertion [constructor]
  119. /// ----------------------------------------------------------------
  120. /// <summary>
  121. /// </summary>
  122. /// ----------------------------------------------------------------
  123. /// <param name="fromKey">
  124. /// </param>
  125. ///
  126. /// <param name="toKey">
  127. /// </param>
  128. ///
  129. /// <param name="keyedReference">
  130. /// </param>
  131. /// ****************************************************************
  132. ///
  133. public PublisherAssertion( string fromKey, string toKey, string keyName, string keyValue, string tModelKey )
  134. {
  135. this.FromKey = fromKey;
  136. this.ToKey = toKey;
  137. this.KeyedReference = new KeyedReference( keyName, keyValue, tModelKey );
  138. }
  139. public void Save()
  140. {
  141. Save( CompletionStatusType.Uninitialized );
  142. }
  143. public void Save( CompletionStatusType status )
  144. {
  145. Debug.Enter();
  146. Validate();
  147. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor( "net_publisher_assertion_save" );
  148. sp.Parameters.Add( "@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID );
  149. sp.Parameters.Add( "@fromKey", SqlDbType.UniqueIdentifier );
  150. sp.Parameters.Add( "@toKey", SqlDbType.UniqueIdentifier );
  151. sp.Parameters.Add( "@keyName", SqlDbType.NVarChar, UDDI.Constants.Lengths.KeyName );
  152. sp.Parameters.Add( "@keyValue", SqlDbType.NVarChar, UDDI.Constants.Lengths.KeyValue );
  153. sp.Parameters.Add( "@tModelKey", SqlDbType.UniqueIdentifier );
  154. sp.Parameters.Add( "@flag", SqlDbType.Int, ParameterDirection.InputOutput );
  155. sp.Parameters.SetString( "@PUID", Context.User.ID );
  156. sp.Parameters.SetGuidFromString( "@fromKey", FromKey );
  157. sp.Parameters.SetGuidFromString( "@toKey", ToKey );
  158. sp.Parameters.SetString( "@keyName", KeyedReference.KeyName );
  159. sp.Parameters.SetString( "@keyValue", KeyedReference.KeyValue );
  160. sp.Parameters.SetGuidFromKey( "@tModelKey", KeyedReference.TModelKey );
  161. if( CompletionStatusType.Uninitialized == status )
  162. sp.Parameters.SetNull( "@flag" );
  163. else
  164. sp.Parameters.SetInt( "@flag", (int)status );
  165. try
  166. {
  167. sp.ExecuteNonQuery();
  168. int flag = sp.Parameters.GetInt( "@flag" );
  169. if( Context.LogChangeRecords )
  170. {
  171. ChangeRecord changeRecord = new ChangeRecord();
  172. changeRecord.Payload = new ChangeRecordPublisherAssertion( this, (CompletionStatusType)flag );
  173. changeRecord.Log();
  174. }
  175. }
  176. catch( SqlException sqlException )
  177. {
  178. //
  179. // As per IN 60, we have to silently ignore assertions that reference keys to businesses that no longer
  180. // exist.
  181. //
  182. if( sqlException.Number - UDDI.Constants.ErrorTypeSQLOffset == ( int ) ErrorType.E_invalidKeyPassed &&
  183. Context.ContextType == ContextType.Replication )
  184. {
  185. //
  186. // Set our exception source
  187. //
  188. Context.ExceptionSource = ExceptionSource.PublisherAssertion;
  189. }
  190. else
  191. {
  192. Context.ExceptionSource = ExceptionSource.Other;
  193. }
  194. //
  195. // Re-throw the exception so replication can properly log it.
  196. //
  197. throw sqlException;
  198. }
  199. Debug.Leave();
  200. }
  201. public void Delete()
  202. {
  203. Delete( CompletionStatusType.Uninitialized );
  204. }
  205. public void Delete( CompletionStatusType status )
  206. {
  207. Debug.Enter();
  208. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor( "net_publisher_assertion_delete" );
  209. sp.Parameters.Add( "@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID );
  210. sp.Parameters.Add( "@fromKey", SqlDbType.UniqueIdentifier );
  211. sp.Parameters.Add( "@toKey", SqlDbType.UniqueIdentifier );
  212. sp.Parameters.Add( "@keyName", SqlDbType.NVarChar, UDDI.Constants.Lengths.KeyName );
  213. sp.Parameters.Add( "@keyValue", SqlDbType.NVarChar, UDDI.Constants.Lengths.KeyValue );
  214. sp.Parameters.Add( "@tModelKey", SqlDbType.UniqueIdentifier );
  215. sp.Parameters.Add( "@flag", SqlDbType.Int, ParameterDirection.InputOutput );
  216. sp.Parameters.SetString( "@PUID", Context.User.ID );
  217. sp.Parameters.SetGuidFromString( "@fromKey", FromKey );
  218. sp.Parameters.SetGuidFromString( "@toKey", ToKey );
  219. sp.Parameters.SetString( "@keyName", KeyedReference.KeyName );
  220. sp.Parameters.SetString( "@keyValue", KeyedReference.KeyValue );
  221. sp.Parameters.SetGuidFromKey( "@tModelKey", KeyedReference.TModelKey );
  222. if( CompletionStatusType.Uninitialized == status )
  223. sp.Parameters.SetNull( "@flag" );
  224. else
  225. sp.Parameters.SetInt( "@flag", (int)status );
  226. try
  227. {
  228. sp.ExecuteNonQuery();
  229. int flag = sp.Parameters.GetInt( "@flag" );
  230. if( Context.LogChangeRecords )
  231. {
  232. ChangeRecord changeRecord = new ChangeRecord();
  233. changeRecord.Payload = new ChangeRecordDeleteAssertion( this, (CompletionStatusType)flag );
  234. changeRecord.Log();
  235. }
  236. }
  237. catch( SqlException sqlException )
  238. {
  239. //
  240. // As per IN 60, we have to silently ignore assertions that reference keys to businesses that no longer
  241. // exist, or assertions that don't exist at all.
  242. //
  243. int exceptionNumber = sqlException.Number - UDDI.Constants.ErrorTypeSQLOffset;
  244. if( ( exceptionNumber == ( int ) ErrorType.E_invalidKeyPassed || exceptionNumber == ( int ) ErrorType.E_assertionNotFound ) &&
  245. Context.ContextType == ContextType.Replication )
  246. {
  247. //
  248. // Set our exception source
  249. //
  250. Context.ExceptionSource = ExceptionSource.PublisherAssertion;
  251. }
  252. else
  253. {
  254. Context.ExceptionSource = ExceptionSource.Other;
  255. }
  256. //
  257. // Re-throw the exception so replication can properly log it.
  258. //
  259. throw sqlException;
  260. }
  261. Debug.Leave();
  262. }
  263. internal void Validate()
  264. {
  265. //
  266. // Check to make sure publisher's limit allows save of this
  267. // entity. If this is an update, we won't check since they
  268. // are simply replacing an existing entity. We also won't
  269. // check if the limit is 0, since this indicates unlimited
  270. // publishing rights.
  271. //
  272. int limit = Context.User.AssertionLimit;
  273. int count = Context.User.AssertionCount;
  274. if( 0 != limit && Utility.StringEmpty( FromKey ) )
  275. {
  276. //
  277. // Verify that the publisher has not exceeded their limit.
  278. //
  279. if( count >= limit )
  280. {
  281. throw new UDDIException(
  282. ErrorType.E_accountLimitExceeded,
  283. "UDDI_ERROR_ACCOUNTLIMITEXCEEDED_ASSERTION",
  284. limit,
  285. count
  286. );
  287. }
  288. }
  289. KeyedReference.Validate( null, KeyedReferenceType.Assertion );
  290. }
  291. }
  292. /// ********************************************************************
  293. /// public class PublisherAssertionCollection
  294. /// --------------------------------------------------------------------
  295. /// <summary>
  296. /// </summary>
  297. /// ********************************************************************
  298. ///
  299. public class PublisherAssertionCollection : CollectionBase
  300. {
  301. public string Get()
  302. {
  303. string AuthorizedName;
  304. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor( "net_publisher_assertions_get" );
  305. sp.Parameters.Add( "@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID );
  306. sp.Parameters.Add( "@authorizedName", SqlDbType.NVarChar, UDDI.Constants.Lengths.AuthorizedName, ParameterDirection.Output);
  307. sp.Parameters.SetString( "@PUID", Context.User.ID );
  308. SqlDataReaderAccessor reader = sp.ExecuteReader();
  309. try
  310. {
  311. while( reader.Read() )
  312. {
  313. Add(
  314. reader.GetGuidString( "fromKey" ),
  315. reader.GetGuidString( "toKey" ),
  316. reader.GetGuidString( "keyName" ),
  317. reader.GetGuidString( "keyValue" ),
  318. reader.GetKeyFromGuid( "tModelKey" ) );
  319. }
  320. }
  321. finally
  322. {
  323. reader.Close();
  324. }
  325. AuthorizedName = sp.Parameters.GetString( "@authorizedName" );
  326. return AuthorizedName;
  327. }
  328. public void Delete()
  329. {
  330. Debug.Enter();
  331. foreach( PublisherAssertion assertion in this )
  332. assertion.Delete();
  333. Debug.Leave();
  334. }
  335. public void Save()
  336. {
  337. Debug.Enter();
  338. Validate();
  339. foreach( PublisherAssertion assertion in this )
  340. assertion.Save();
  341. Debug.Leave();
  342. }
  343. internal void Validate()
  344. {
  345. foreach( PublisherAssertion assertion in this )
  346. assertion.Validate();
  347. }
  348. public PublisherAssertion this[ int index ]
  349. {
  350. get { return (PublisherAssertion)List[index]; }
  351. set { List[ index ] = value; }
  352. }
  353. public int Add()
  354. {
  355. return List.Add( new PublisherAssertion() );
  356. }
  357. public int Add( PublisherAssertion value )
  358. {
  359. return List.Add( value );
  360. }
  361. public int Add( string fromKey, string toKey, KeyedReference keyedReference )
  362. {
  363. return List.Add( new PublisherAssertion( fromKey, toKey, keyedReference ) );
  364. }
  365. public int Add( string fromKey, string toKey, string keyName, string keyValue, string tModelKey )
  366. {
  367. return List.Add( new PublisherAssertion( fromKey, toKey, keyName, keyValue, tModelKey ) );
  368. }
  369. public void Insert( int index, PublisherAssertion value )
  370. {
  371. List.Insert( index, value );
  372. }
  373. public int IndexOf( PublisherAssertion value )
  374. {
  375. return List.IndexOf( value );
  376. }
  377. public bool Contains( PublisherAssertion value )
  378. {
  379. return List.Contains( value );
  380. }
  381. public void Remove( PublisherAssertion value )
  382. {
  383. List.Remove( value );
  384. }
  385. public void CopyTo( PublisherAssertion[] array, int index )
  386. {
  387. List.CopyTo( array, index );
  388. }
  389. }
  390. /// ********************************************************************
  391. /// public class PublisherAssertionDetail
  392. /// --------------------------------------------------------------------
  393. /// <summary>
  394. /// </summary>
  395. /// ********************************************************************
  396. ///
  397. [XmlRoot( "publisherAssertions", Namespace=UDDI.API.Constants.Namespace )]
  398. public class PublisherAssertionDetail
  399. {
  400. //
  401. // Attribute: generic
  402. //
  403. private string generic = Constants.Version;
  404. [XmlAttribute( "generic" )]
  405. public string Generic
  406. {
  407. get { return generic; }
  408. set { generic = value; }
  409. }
  410. //
  411. // Attribute: operator
  412. //
  413. [XmlAttribute( "operator" )]
  414. public string OperatorName = Config.GetString( "Operator" );
  415. //
  416. // Attribute: authorizedName
  417. //
  418. [XmlAttribute( "authorizedName" )]
  419. public string AuthorizedName;
  420. //
  421. // Element: publisherAssertion
  422. //
  423. private PublisherAssertionCollection publisherAssertions;
  424. [XmlElement( "publisherAssertion" )]
  425. public PublisherAssertionCollection PublisherAssertions
  426. {
  427. get
  428. {
  429. if( null == publisherAssertions )
  430. publisherAssertions = new PublisherAssertionCollection();
  431. return publisherAssertions;
  432. }
  433. set { publisherAssertions = value; }
  434. }
  435. public PublisherAssertionDetail()
  436. {
  437. }
  438. public void Get()
  439. {
  440. AuthorizedName = PublisherAssertions.Get();
  441. }
  442. }
  443. /// ********************************************************************
  444. /// public class AssertionStatusReport
  445. /// --------------------------------------------------------------------
  446. /// <summary>
  447. /// </summary>
  448. /// ********************************************************************
  449. ///
  450. [XmlRoot( "assertionStatusReport", Namespace=UDDI.API.Constants.Namespace )]
  451. public class AssertionStatusReport
  452. {
  453. //
  454. // Attribute: generic
  455. //
  456. private string generic = Constants.Version;
  457. [XmlAttribute( "generic" )]
  458. public string Generic
  459. {
  460. get { return generic; }
  461. set { generic = value; }
  462. }
  463. //
  464. // Attribute: operator
  465. //
  466. [XmlAttribute( "operator" )]
  467. public string OperatorName = Config.GetString( "Operator" );
  468. //
  469. // Element: assertionStatusItem
  470. //
  471. private AssertionStatusItemCollection assertionStatusItems;
  472. [XmlElement( "assertionStatusItem" )]
  473. public AssertionStatusItemCollection AssertionStatusItems
  474. {
  475. get
  476. {
  477. if( null == assertionStatusItems )
  478. assertionStatusItems = new AssertionStatusItemCollection();
  479. return assertionStatusItems;
  480. }
  481. set { assertionStatusItems = value; }
  482. }
  483. public AssertionStatusReport()
  484. {
  485. }
  486. public void Get( CompletionStatusType completionStatus )
  487. {
  488. AssertionStatusItems.Get( completionStatus );
  489. }
  490. }
  491. /// ********************************************************************
  492. /// public class AssertionStatusItem
  493. /// --------------------------------------------------------------------
  494. /// <summary>
  495. /// </summary>
  496. /// ********************************************************************
  497. ///
  498. public class AssertionStatusItem
  499. {
  500. //
  501. // Attribute: completionStatus
  502. //
  503. [XmlAttribute( "completionStatus" )]
  504. public CompletionStatusType CompletionStatus;
  505. //
  506. // Element: fromKey
  507. //
  508. [XmlElement( "fromKey" )]
  509. public string FromKey;
  510. //
  511. // Element: toKey
  512. //
  513. [XmlElement( "toKey" )]
  514. public string ToKey;
  515. //
  516. // Element: keyedReference
  517. //
  518. private KeyedReference keyedReference;
  519. [XmlElement( "keyedReference" )]
  520. public KeyedReference KeyedReference
  521. {
  522. get { return keyedReference; }
  523. set { keyedReference = value; }
  524. }
  525. //
  526. // Element: keysOwned
  527. //
  528. private KeysOwned keysOwned;
  529. [XmlElement( "keysOwned" )]
  530. public KeysOwned KeysOwned
  531. {
  532. get
  533. {
  534. if( null == keysOwned )
  535. keysOwned = new KeysOwned();
  536. return keysOwned;
  537. }
  538. set { keysOwned = value; }
  539. }
  540. public AssertionStatusItem()
  541. {
  542. }
  543. public AssertionStatusItem( CompletionStatusType completionStatus, string fromKey, string toKey, KeyedReference keyedReference, KeysOwned keysOwned )
  544. {
  545. this.CompletionStatus = completionStatus;
  546. this.FromKey = fromKey;
  547. this.ToKey = toKey;
  548. this.KeyedReference = keyedReference;
  549. this.KeysOwned = keysOwned;
  550. }
  551. }
  552. /// ********************************************************************
  553. /// public class AssertionStatusItemCollection
  554. /// --------------------------------------------------------------------
  555. /// <summary>
  556. /// </summary>
  557. /// ********************************************************************
  558. ///
  559. public class AssertionStatusItemCollection : CollectionBase
  560. {
  561. public void Get( CompletionStatusType completionStatus )
  562. {
  563. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor( "net_publisher_assertionStatus_get" );
  564. sp.Parameters.Add( "@PUID", SqlDbType.NVarChar, UDDI.Constants.Lengths.UserID );
  565. sp.Parameters.SetString( "@PUID", Context.User.ID );
  566. if( CompletionStatusType.Uninitialized != completionStatus )
  567. {
  568. //
  569. // If the completion status was not specified get all
  570. // of the assertions by not specifying a completionStatus value
  571. // in the stored procedure.
  572. //
  573. sp.Parameters.Add( "@completionStatus", SqlDbType.Int );
  574. sp.Parameters.SetInt( "@completionStatus", (int)completionStatus );
  575. }
  576. SqlDataReaderAccessor reader = sp.ExecuteReader();
  577. try
  578. {
  579. while( reader.Read() )
  580. {
  581. KeyedReference keyedReference = new KeyedReference(
  582. reader.GetString( "keyName" ),
  583. reader.GetString( "keyValue" ),
  584. reader.GetKeyFromGuid( "tModelKey" ) );
  585. CompletionStatusType status =
  586. (CompletionStatusType)reader.GetInt( "flag" );
  587. string fromKey = reader.GetGuidString( "fromKey" );
  588. string toKey = reader.GetGuidString( "toKey" );
  589. int ownerFlag = reader.GetInt( "ownerFlag" );
  590. KeysOwned keysOwned = new KeysOwned();
  591. if( 0x02 == ( ownerFlag & 0x02 ) )
  592. keysOwned.FromKey = fromKey;
  593. if( 0x01 == ( ownerFlag & 0x01 ) )
  594. keysOwned.ToKey = toKey;
  595. this.Add(
  596. new AssertionStatusItem(
  597. status,
  598. fromKey,
  599. toKey,
  600. keyedReference,
  601. keysOwned ) );
  602. }
  603. }
  604. finally
  605. {
  606. reader.Close();
  607. }
  608. }
  609. public AssertionStatusItem this[ int index ]
  610. {
  611. get { return (AssertionStatusItem)List[index]; }
  612. set { List[ index ] = value; }
  613. }
  614. public int Add()
  615. {
  616. return List.Add( new AssertionStatusItem() );
  617. }
  618. public int Add( AssertionStatusItem value )
  619. {
  620. return List.Add( value );
  621. }
  622. public void Insert( int index, AssertionStatusItem value )
  623. {
  624. List.Insert( index, value );
  625. }
  626. public int IndexOf( AssertionStatusItem value )
  627. {
  628. return List.IndexOf( value );
  629. }
  630. public bool Contains( AssertionStatusItem value )
  631. {
  632. return List.Contains( value );
  633. }
  634. public void Remove( AssertionStatusItem value )
  635. {
  636. List.Remove( value );
  637. }
  638. public void CopyTo( AssertionStatusItem[] array, int index )
  639. {
  640. List.CopyTo( array, index );
  641. }
  642. }
  643. /// ********************************************************************
  644. /// public class KeysOwned
  645. /// --------------------------------------------------------------------
  646. /// <summary>
  647. /// </summary>
  648. /// ********************************************************************
  649. ///
  650. public class KeysOwned
  651. {
  652. //
  653. // Element: fromKey
  654. //
  655. [XmlElement( "fromKey" )]
  656. public string FromKey;
  657. //
  658. // Element: toKey
  659. //
  660. [XmlElement( "toKey" )]
  661. public string ToKey;
  662. public KeysOwned()
  663. {
  664. }
  665. public KeysOwned( string fromKey, string toKey )
  666. {
  667. this.FromKey = fromKey;
  668. this.ToKey = toKey;
  669. }
  670. }
  671. public enum DirectionType
  672. {
  673. [XmlEnum( "fromKey" )]
  674. FromKey,
  675. [XmlEnum( "toKey" )]
  676. ToKey
  677. }
  678. public class RelatedBusinessInfo
  679. {
  680. //
  681. // Element: businessKey
  682. //
  683. [XmlElement( "businessKey" )]
  684. public string BusinessKey;
  685. //
  686. // Element: name
  687. //
  688. private NameCollection names;
  689. [XmlElement( "name" )]
  690. public NameCollection Names
  691. {
  692. get
  693. {
  694. if( null == names )
  695. names = new NameCollection();
  696. return names;
  697. }
  698. set { names = value; }
  699. }
  700. //
  701. // Element: description
  702. //
  703. private DescriptionCollection descriptions;
  704. [XmlElement( "description" )]
  705. public DescriptionCollection Descriptions
  706. {
  707. get
  708. {
  709. if( null == descriptions )
  710. descriptions = new DescriptionCollection();
  711. return descriptions;
  712. }
  713. set { descriptions = value; }
  714. }
  715. //
  716. // Element: sharedRelationships
  717. //
  718. [XmlIgnore()]
  719. public SharedRelationships SharedRelationshipsFrom = new SharedRelationships();
  720. [XmlIgnore()]
  721. public SharedRelationships SharedRelationshipsTo = new SharedRelationships();
  722. [XmlElement( "sharedRelationships" )]
  723. public string sharedRelationshipEmptyTag
  724. {
  725. get
  726. {
  727. if( 0 == SharedRelationshipsSerialize.Count )
  728. return "";
  729. else
  730. return null;
  731. }
  732. }
  733. [XmlElement( "sharedRelationships" )]
  734. public SharedRelationshipsCollection SharedRelationshipsSerialize
  735. {
  736. get
  737. {
  738. SharedRelationshipsCollection col = new SharedRelationshipsCollection();
  739. if( !SharedRelationshipsFrom.IsEmpty() )
  740. col.Add( SharedRelationshipsFrom );
  741. if( !SharedRelationshipsTo.IsEmpty() )
  742. col.Add( SharedRelationshipsTo );
  743. return col;
  744. }
  745. set
  746. {
  747. foreach( SharedRelationships sr in value )
  748. {
  749. switch( sr.Direction )
  750. {
  751. case DirectionType.FromKey:
  752. SharedRelationshipsFrom = sr;
  753. break;
  754. case DirectionType.ToKey:
  755. SharedRelationshipsTo = sr;
  756. break;
  757. }
  758. }
  759. }
  760. }
  761. public RelatedBusinessInfo()
  762. {
  763. }
  764. public RelatedBusinessInfo( string businessKey )
  765. {
  766. this.BusinessKey = businessKey;
  767. }
  768. public void Get( string otherKey )
  769. {
  770. Names.Get( BusinessKey, EntityType.BusinessEntity );
  771. Descriptions.Get( BusinessKey, EntityType.BusinessEntity );
  772. //
  773. // Get the shared relationships.
  774. //
  775. SharedRelationshipsFrom.Direction = DirectionType.FromKey;
  776. SharedRelationshipsFrom.Get( otherKey, BusinessKey );
  777. SharedRelationshipsTo.Direction = DirectionType.ToKey;
  778. SharedRelationshipsTo.Get( BusinessKey, otherKey );
  779. }
  780. }
  781. public class RelatedBusinessInfoCollection : CollectionBase
  782. {
  783. public RelatedBusinessInfo this[ int index ]
  784. {
  785. get { return (RelatedBusinessInfo)List[index]; }
  786. set { List[ index ] = value; }
  787. }
  788. public int Add()
  789. {
  790. return List.Add( new RelatedBusinessInfo() );
  791. }
  792. public int Add( RelatedBusinessInfo relatedBusinessInfo )
  793. {
  794. return List.Add( relatedBusinessInfo );
  795. }
  796. public int Add( string businessKey )
  797. {
  798. return List.Add( new RelatedBusinessInfo( businessKey ) );
  799. }
  800. public void Insert( int index, RelatedBusinessInfo relatedBusinessInfo )
  801. {
  802. List.Insert( index, relatedBusinessInfo );
  803. }
  804. public int IndexOf( RelatedBusinessInfo relatedBusinessInfo )
  805. {
  806. return List.IndexOf( relatedBusinessInfo );
  807. }
  808. public bool Contains( RelatedBusinessInfo relatedBusinessInfo )
  809. {
  810. return List.Contains( relatedBusinessInfo );
  811. }
  812. public void Remove( RelatedBusinessInfo relatedBusinessInfo )
  813. {
  814. List.Remove( relatedBusinessInfo );
  815. }
  816. public void CopyTo( RelatedBusinessInfo[] array, int index )
  817. {
  818. List.CopyTo( array, index );
  819. }
  820. }
  821. public class SharedRelationshipsCollection : CollectionBase
  822. {
  823. public SharedRelationships this[ int index ]
  824. {
  825. get { return (SharedRelationships)List[index]; }
  826. set { List[ index ] = value; }
  827. }
  828. public int Add()
  829. {
  830. return List.Add( new SharedRelationships() );
  831. }
  832. public int Add( SharedRelationships SharedRelationships )
  833. {
  834. return List.Add( SharedRelationships );
  835. }
  836. public int Add( string businessKey )
  837. {
  838. return List.Add( new SharedRelationships() );
  839. }
  840. public void Insert( int index, SharedRelationships SharedRelationships )
  841. {
  842. List.Insert( index, SharedRelationships );
  843. }
  844. public int IndexOf( SharedRelationships SharedRelationships )
  845. {
  846. return List.IndexOf( SharedRelationships );
  847. }
  848. public bool Contains( SharedRelationships SharedRelationships )
  849. {
  850. return List.Contains( SharedRelationships );
  851. }
  852. public void Remove( SharedRelationships SharedRelationships )
  853. {
  854. List.Remove( SharedRelationships );
  855. }
  856. public void CopyTo( SharedRelationships[] array, int index )
  857. {
  858. List.CopyTo( array, index );
  859. }
  860. }
  861. public class SharedRelationships
  862. {
  863. //
  864. // Attribute: direction
  865. //
  866. [XmlAttribute( "direction" )]
  867. public DirectionType Direction;
  868. //
  869. // Element: keyedReference
  870. //
  871. private KeyedReferenceCollection keyedReferences;
  872. [XmlIgnore]
  873. public KeyedReferenceCollection KeyedReferences
  874. {
  875. get
  876. {
  877. if( null == keyedReferences )
  878. keyedReferences = new KeyedReferenceCollection();
  879. return keyedReferences;
  880. }
  881. set { keyedReferences = value; }
  882. }
  883. [XmlElement( "keyedReference" )]
  884. public KeyedReferenceCollection KeyedReferencesSerialize
  885. {
  886. get
  887. {
  888. return keyedReferences;
  889. }
  890. set { keyedReferences = value; }
  891. }
  892. public bool IsEmpty()
  893. {
  894. return (keyedReferences == null);
  895. }
  896. public SharedRelationships()
  897. {
  898. }
  899. public void Get( string fromKey, string toKey )
  900. {
  901. SqlStoredProcedureAccessor sp = new SqlStoredProcedureAccessor();
  902. sp.ProcedureName = "net_businessEntity_assertions_get";
  903. sp.Parameters.Add( "@fromKey", SqlDbType.UniqueIdentifier );
  904. sp.Parameters.Add( "@toKey", SqlDbType.UniqueIdentifier );
  905. sp.Parameters.Add( "@completionStatus", SqlDbType.Int );
  906. sp.Parameters.SetGuidFromString( "@fromKey", fromKey );
  907. sp.Parameters.SetGuidFromString( "@toKey", toKey );
  908. sp.Parameters.SetInt( "@completionStatus", (int)CompletionStatusType.Complete );
  909. SqlDataReaderAccessor reader = sp.ExecuteReader();
  910. try
  911. {
  912. while( reader.Read() )
  913. {
  914. KeyedReferences.Add(
  915. reader.GetString( "keyName" ),
  916. reader.GetString( "keyValue" ),
  917. reader.GetKeyFromGuid( "tModelKey" ) );
  918. }
  919. }
  920. finally
  921. {
  922. reader.Close();
  923. }
  924. }
  925. }
  926. [XmlRoot( "relatedBusinessesList", Namespace=UDDI.API.Constants.Namespace )]
  927. public class RelatedBusinessList
  928. {
  929. //
  930. // Attribute: generic
  931. //
  932. [XmlAttribute( "generic" )]
  933. public string Generic = Constants.Version;
  934. //
  935. // Attribute: operator
  936. //
  937. [XmlAttribute( "operator" )]
  938. public string OperatorName = Config.GetString( "Operator" );
  939. //
  940. // Attribute: truncated
  941. //
  942. [XmlAttribute( "truncated" )]
  943. public Truncated Truncated;
  944. //
  945. // Element: businessKey
  946. //
  947. [XmlElement( "businessKey" )]
  948. public string BusinessKey;
  949. //
  950. // Element: relatedBusinessInfos
  951. //
  952. private RelatedBusinessInfoCollection relatedBusinessInfos;
  953. [ XmlArray( "relatedBusinessInfos" ), XmlArrayItem( "relatedBusinessInfo" ) ]
  954. public RelatedBusinessInfoCollection RelatedBusinessInfos
  955. {
  956. get
  957. {
  958. if( null == relatedBusinessInfos )
  959. relatedBusinessInfos = new RelatedBusinessInfoCollection();
  960. return relatedBusinessInfos;
  961. }
  962. set { relatedBusinessInfos = value; }
  963. }
  964. }
  965. /// ********************************************************************
  966. /// public class AddPublisherAssertions
  967. /// --------------------------------------------------------------------
  968. /// <summary>
  969. /// </summary>
  970. /// ********************************************************************
  971. ///
  972. [XmlRoot( "add_publisherAssertions", Namespace=UDDI.API.Constants.Namespace )]
  973. public class AddPublisherAssertions : IAuthenticateable, IMessage
  974. {
  975. //
  976. // Attribute: generic
  977. //
  978. private string generic;
  979. [XmlAttribute( "generic" )]
  980. public string Generic
  981. {
  982. get { return generic; }
  983. set { generic = value; }
  984. }
  985. //
  986. // Element: authInfo
  987. //
  988. private string authInfo;
  989. [XmlElement( "authInfo" )]
  990. public string AuthInfo
  991. {
  992. get { return authInfo; }
  993. set { authInfo = value; }
  994. }
  995. //
  996. // Element: publisherAssertion
  997. //
  998. private PublisherAssertionCollection publisherAssertions;
  999. [XmlElement( "publisherAssertion" )]
  1000. public PublisherAssertionCollection PublisherAssertions
  1001. {
  1002. get
  1003. {
  1004. if( null == publisherAssertions )
  1005. publisherAssertions = new PublisherAssertionCollection();
  1006. return publisherAssertions;
  1007. }
  1008. set { publisherAssertions = value; }
  1009. }
  1010. public AddPublisherAssertions()
  1011. {
  1012. }
  1013. public void Save()
  1014. {
  1015. PublisherAssertions.Save();
  1016. }
  1017. }
  1018. /// ********************************************************************
  1019. /// public class DeletePublisherAssertions
  1020. /// --------------------------------------------------------------------
  1021. /// <summary>
  1022. /// </summary>
  1023. /// ********************************************************************
  1024. ///
  1025. [XmlRoot( "delete_publisherAssertions", Namespace=UDDI.API.Constants.Namespace )]
  1026. public class DeletePublisherAssertions : IAuthenticateable, IMessage
  1027. {
  1028. //
  1029. // Attribute: generic
  1030. //
  1031. private string generic;
  1032. [XmlAttribute( "generic" )]
  1033. public string Generic
  1034. {
  1035. get { return generic; }
  1036. set { generic = value; }
  1037. }
  1038. //
  1039. // Element: authInfo
  1040. //
  1041. private string authInfo;
  1042. [XmlElement( "authInfo" )]
  1043. public string AuthInfo
  1044. {
  1045. get { return authInfo; }
  1046. set { authInfo = value; }
  1047. }
  1048. //
  1049. // Element: publisherAssertion
  1050. //
  1051. private PublisherAssertionCollection publisherAssertions;
  1052. [XmlElement( "publisherAssertion" )]
  1053. public PublisherAssertionCollection PublisherAssertions
  1054. {
  1055. get
  1056. {
  1057. if( null == publisherAssertions )
  1058. publisherAssertions = new PublisherAssertionCollection();
  1059. return publisherAssertions;
  1060. }
  1061. set { publisherAssertions = value; }
  1062. }
  1063. public DeletePublisherAssertions()
  1064. {
  1065. }
  1066. public void Delete()
  1067. {
  1068. PublisherAssertions.Delete();
  1069. }
  1070. }
  1071. /// ********************************************************************
  1072. /// public class FindRelatedBusinesses
  1073. /// --------------------------------------------------------------------
  1074. /// <summary>
  1075. /// </summary>
  1076. /// ********************************************************************
  1077. ///
  1078. [XmlRoot( "find_relatedBusinesses", Namespace=UDDI.API.Constants.Namespace )]
  1079. public class FindRelatedBusinesses : IMessage
  1080. {
  1081. //
  1082. // Attribute: generic
  1083. //
  1084. private string generic;
  1085. [XmlAttribute( "generic" )]
  1086. public string Generic
  1087. {
  1088. get { return generic; }
  1089. set { generic = value; }
  1090. }
  1091. //
  1092. // Attribute: maxRows
  1093. //
  1094. private int maxRows = Config.GetInt( "Find.MaxRowsDefault" );
  1095. [XmlAttribute("maxRows")]
  1096. public int MaxRows
  1097. {
  1098. get
  1099. {
  1100. return maxRows;
  1101. }
  1102. set
  1103. {
  1104. maxRows = Math.Min( Config.GetInt( "Find.MaxRowsDefault" ), value );
  1105. }
  1106. }
  1107. //
  1108. // Element: findQualifiers/findQualifier
  1109. //
  1110. private FindQualifierCollection findQualifiers;
  1111. [XmlArray( "findQualifiers" ), XmlArrayItem( "findQualifier" )]
  1112. public FindQualifierCollection FindQualifiers
  1113. {
  1114. get
  1115. {
  1116. if( null == findQualifiers )
  1117. findQualifiers = new FindQualifierCollection();
  1118. return findQualifiers;
  1119. }
  1120. set { findQualifiers = value; }
  1121. }
  1122. //
  1123. // Element: businessKey
  1124. //
  1125. [XmlElement( "businessKey" )]
  1126. public string BusinessKey;
  1127. //
  1128. // Element: keyedReference
  1129. //
  1130. [XmlElement( "keyedReference" )]
  1131. public KeyedReference KeyedReference;
  1132. /// ****************************************************************
  1133. /// public FindRelatedBusinesses [constructor]
  1134. /// ----------------------------------------------------------------
  1135. /// <summary>
  1136. /// </summary>
  1137. /// ****************************************************************
  1138. ///
  1139. public FindRelatedBusinesses()
  1140. {
  1141. }
  1142. /// ****************************************************************
  1143. /// public Find
  1144. /// ----------------------------------------------------------------
  1145. /// <summary>
  1146. /// </summary>
  1147. /// ****************************************************************
  1148. ///
  1149. public RelatedBusinessList Find()
  1150. {
  1151. if( MaxRows < 0 )
  1152. {
  1153. throw new UDDIException(
  1154. ErrorType.E_fatalError,
  1155. "UDDI_ERROR_FATALERROR_FINDRELATEDBE_MAXROWSLESSTHANZERO" );
  1156. }
  1157. RelatedBusinessList relatedBusinessList = new RelatedBusinessList();
  1158. //
  1159. // Process each find constraint.
  1160. //
  1161. FindBuilder find = new FindBuilder( EntityType.BusinessEntity, FindQualifiers );
  1162. //
  1163. // If no search arguments are specified, return an empty result
  1164. // set.
  1165. //
  1166. //
  1167. // Validate find parameters.
  1168. //
  1169. Utility.IsValidKey( EntityType.BusinessEntity, BusinessKey );
  1170. // TODO: Override may be better for these calls to KeyedReference.Validate because no parent key is used
  1171. //
  1172. // TODO: This not an Assertion so we should not pass KeyedReferenceType.Assertion.
  1173. //
  1174. if( null != KeyedReference )
  1175. KeyedReference.Validate( "", KeyedReferenceType.IdentifierBag );
  1176. try
  1177. {
  1178. //
  1179. // Read in the find results.
  1180. //
  1181. SqlDataReaderAccessor reader;
  1182. SqlStoredProcedureAccessor sp;
  1183. sp = find.FindRelatedBusinesses(
  1184. BusinessKey,
  1185. KeyedReference,
  1186. MaxRows);
  1187. reader = sp.ExecuteReader();
  1188. try
  1189. {
  1190. while( reader.Read() )
  1191. {
  1192. relatedBusinessList.RelatedBusinessInfos.Add(
  1193. reader.GetString( "entityKey" ) );
  1194. }
  1195. }
  1196. finally
  1197. {
  1198. reader.Close();
  1199. }
  1200. if( sp.Parameters.GetBool( "@truncated" ) )
  1201. relatedBusinessList.Truncated = Truncated.True;
  1202. else
  1203. relatedBusinessList.Truncated = Truncated.False;
  1204. relatedBusinessList.BusinessKey = BusinessKey;
  1205. foreach( RelatedBusinessInfo relatedBusinessInfo in relatedBusinessList.RelatedBusinessInfos )
  1206. relatedBusinessInfo.Get( BusinessKey );
  1207. }
  1208. catch( Exception )
  1209. {
  1210. find.Abort();
  1211. throw;
  1212. }
  1213. return relatedBusinessList;
  1214. }
  1215. }
  1216. /// ********************************************************************
  1217. /// public class GetAssertionStatusReport
  1218. /// --------------------------------------------------------------------
  1219. /// <summary>
  1220. /// </summary>
  1221. /// ********************************************************************
  1222. ///
  1223. [XmlRoot( "get_assertionStatusReport", Namespace=UDDI.API.Constants.Namespace )]
  1224. public class GetAssertionStatusReport : IAuthenticateable, IMessage
  1225. {
  1226. //
  1227. // Attribute: generic
  1228. //
  1229. private string generic;
  1230. [XmlAttribute( "generic" )]
  1231. public string Generic
  1232. {
  1233. get { return generic; }
  1234. set { generic = value; }
  1235. }
  1236. //
  1237. // Element: authInfo
  1238. //
  1239. private string authInfo;
  1240. [XmlElement( "authInfo" )]
  1241. public string AuthInfo
  1242. {
  1243. get { return authInfo; }
  1244. set { authInfo = value; }
  1245. }
  1246. //
  1247. // Element: completionStatus
  1248. //
  1249. private CompletionStatusType completionStatus;
  1250. [XmlElement( "completionStatus" )]
  1251. public CompletionStatusType CompletionStatus
  1252. {
  1253. get { return completionStatus; }
  1254. set
  1255. {
  1256. try
  1257. {
  1258. completionStatus = value;
  1259. }
  1260. catch( ArgumentException )
  1261. {
  1262. throw new UDDIException(
  1263. ErrorType.E_invalidCompletionStatus,
  1264. "UDDI_ERROR_INVALIDCOMPLETIONSTATUS_GETASSERTIONSTATUSREPORT" );
  1265. }
  1266. }
  1267. }
  1268. public GetAssertionStatusReport()
  1269. {
  1270. }
  1271. }
  1272. /// ********************************************************************
  1273. /// public class GetPublisherAssertions
  1274. /// --------------------------------------------------------------------
  1275. /// <summary>
  1276. /// </summary>
  1277. /// ********************************************************************
  1278. ///
  1279. [XmlRoot( "get_publisherAssertions", Namespace=UDDI.API.Constants.Namespace )]
  1280. public class GetPublisherAssertions : IAuthenticateable, IMessage
  1281. {
  1282. //
  1283. // Attribute: generic
  1284. //
  1285. private string generic;
  1286. [XmlAttribute( "generic" )]
  1287. public string Generic
  1288. {
  1289. get { return generic; }
  1290. set { generic = value; }
  1291. }
  1292. //
  1293. // Element: authInfo
  1294. //
  1295. private string authInfo;
  1296. [XmlElement( "authInfo" )]
  1297. public string AuthInfo
  1298. {
  1299. get { return authInfo; }
  1300. set { authInfo = value; }
  1301. }
  1302. public GetPublisherAssertions()
  1303. {
  1304. }
  1305. }
  1306. /// ********************************************************************
  1307. /// public class SetPublisherAssertions
  1308. /// --------------------------------------------------------------------
  1309. /// <summary>
  1310. /// </summary>
  1311. /// ********************************************************************
  1312. ///
  1313. [XmlRoot( "set_publisherAssertions", Namespace=UDDI.API.Constants.Namespace )]
  1314. public class SetPublisherAssertions : IAuthenticateable, IMessage
  1315. {
  1316. //
  1317. // Attribute: generic
  1318. //
  1319. private string generic;
  1320. [XmlAttribute( "generic" )]
  1321. public string Generic
  1322. {
  1323. get { return generic; }
  1324. set { generic = value; }
  1325. }
  1326. //
  1327. // Element: authInfo
  1328. //
  1329. private string authInfo;
  1330. [XmlElement( "authInfo" )]
  1331. public string AuthInfo
  1332. {
  1333. get { return authInfo; }
  1334. set { authInfo = value; }
  1335. }
  1336. //
  1337. // Element: publisherAssertion
  1338. //
  1339. private PublisherAssertionCollection publisherAssertions;
  1340. [XmlElement( "publisherAssertion" )]
  1341. public PublisherAssertionCollection PublisherAssertions
  1342. {
  1343. get
  1344. {
  1345. if( null == publisherAssertions )
  1346. publisherAssertions = new PublisherAssertionCollection();
  1347. return publisherAssertions;
  1348. }
  1349. set { publisherAssertions = value; }
  1350. }
  1351. public SetPublisherAssertions()
  1352. {
  1353. }
  1354. public PublisherAssertionDetail Set()
  1355. {
  1356. //
  1357. // Remove all existing assertions for the publisher.
  1358. //
  1359. PublisherAssertionCollection existing = new PublisherAssertionCollection();
  1360. //
  1361. // TODO: This Get() call is unecessary. A stored proc that accepts the PUID could do this easily.
  1362. // In a scenario where a large number of assertions are used, returning all the assertions could get expensive.
  1363. //
  1364. //
  1365. // We need to save this to use it in the PublisherAssertionDetail return structure
  1366. //
  1367. string authorizedName = existing.Get();
  1368. existing.Delete();
  1369. //
  1370. // Save each of the assertions specified by the set_publisherAssertions
  1371. // message.
  1372. //
  1373. PublisherAssertions.Save();
  1374. //
  1375. // Get a list of all the current assertions for this publisher.
  1376. //
  1377. PublisherAssertionDetail detail = new PublisherAssertionDetail();
  1378. detail.AuthorizedName = authorizedName;
  1379. detail.PublisherAssertions = PublisherAssertions;
  1380. return detail;
  1381. }
  1382. }
  1383. }