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.

587 lines
16 KiB

  1. -- Script: uddi.v2.update_rc1_to_rc2.sql
  2. -- Description: Updates a UDDI Services RC1 database to RC2
  3. -- Note: This file is best viewed and edited with a tab width of 2.
  4. -- =============================================
  5. -- Section: Stored Procedure fixes
  6. -- =============================================
  7. -- =============================================
  8. -- Name: net_serviceProjection_repl_save
  9. -- Fix: uddi bug 2454
  10. -- =============================================
  11. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_serviceProjection_repl_save' and type = 'P')
  12. DROP PROCEDURE net_serviceProjection_repl_save
  13. GO
  14. CREATE PROCEDURE net_serviceProjection_repl_save
  15. @serviceKey uniqueidentifier,
  16. @businessKey uniqueidentifier,
  17. @businessKey2 uniqueidentifier,
  18. @lastChange bigint
  19. WITH ENCRYPTION
  20. AS
  21. BEGIN
  22. DECLARE
  23. @RC int,
  24. @error int,
  25. @context nvarchar(4000)
  26. SET @RC = 0
  27. -- IMPORTANT: This sproc should only ever be called for replication. As per IN 60, we have to process service projection
  28. -- change records even if they refer to business services that no longer exist. Both businesses referenced
  29. -- by the service projection must exist.
  30. -- businessKey validation must occur during save since its not always known at validate time
  31. IF NOT EXISTS(SELECT * FROM [UDC_businessEntities] WHERE [businessKey] = @businessKey)
  32. BEGIN
  33. SET @error = 60210 -- E_invalidKey
  34. SET @context = 'businessKey = ' + dbo.UUIDSTR(@businessKey)
  35. GOTO errorLabel
  36. END
  37. --
  38. -- Commenting out the following check to comply with IN60 as per UDDI bug 2454
  39. -- Which states that service projections that refer to a deleted service must be successfully saved
  40. -- From this we can imply that service projections that refer to a deleted business must also be successfully saved
  41. --
  42. --IF NOT EXISTS(SELECT * FROM [UDC_businessEntities] WHERE [businessKey] = @businessKey2)
  43. --BEGIN
  44. --SET @error = 60210 -- E_invalidKey
  45. --SET @context = 'businessKey = ' + dbo.UUIDSTR(@businessKey2)
  46. --GOTO errorLabel
  47. --END
  48. -- Add service projection if it doesn't already exist
  49. IF NOT EXISTS(SELECT * FROM [UDC_serviceProjections] WHERE ([businessKey] = @businessKey) AND ([serviceKey] = @serviceKey))
  50. BEGIN
  51. INSERT [UDC_serviceProjections](
  52. [businessKey],
  53. [serviceKey],
  54. [businessKey2],
  55. [lastChange])
  56. VALUES(
  57. @businessKey,
  58. @serviceKey,
  59. @businessKey2,
  60. @lastChange)
  61. END
  62. RETURN 0
  63. errorLabel:
  64. RAISERROR (@error, 16, 1, @context)
  65. RETURN 1
  66. END -- net_serviceProjection_repl_save
  67. GO
  68. -- =============================================
  69. -- Name: VS_AWR_businesses_get
  70. -- =============================================
  71. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'VS_AWR_businesses_get' AND type = 'P')
  72. DROP PROCEDURE VS_AWR_businesses_get
  73. GO
  74. CREATE PROCEDURE VS_AWR_businesses_get
  75. @businessName nvarchar(450)
  76. WITH ENCRYPTION
  77. AS
  78. BEGIN
  79. DECLARE
  80. @typesTModelKey uniqueidentifier,
  81. @wsdlKeyValue nvarchar(255),
  82. @services cursor,
  83. @serviceID bigint,
  84. @serviceKey uniqueidentifier,
  85. @businessID bigint,
  86. @businessName2 nvarchar(450),
  87. @businessKey uniqueidentifier,
  88. @serviceName nvarchar(450)
  89. --
  90. -- Get a list of tModel keys for tModels categorized as a wsdlSpec
  91. --
  92. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  93. SET @wsdlKeyValue = 'wsdlSpec'
  94. DECLARE @wsdlTModelKeys TABLE (
  95. [tModelKey] uniqueidentifier)
  96. INSERT @wsdlTModelKeys
  97. SELECT DISTINCT
  98. TM.[tModelKey]
  99. FROM
  100. [UDC_tModels] TM
  101. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  102. WHERE
  103. (CB.[tModelKey] = @typesTModelKey) AND
  104. (CB.[keyValue] = @wsdlKeyValue)
  105. --
  106. -- Setup temporary table for staging results
  107. --
  108. DECLARE @results TABLE(
  109. [businessName] nvarchar(450),
  110. [businessKey] uniqueidentifier,
  111. [serviceName] nvarchar(450),
  112. [serviceKey] uniqueidentifier)
  113. --
  114. -- Cursor through every service that:
  115. -- 1. Has a tModelInstance that references a wsdlTModelKey
  116. -- 2. Is owned by a business that meets the name search criteria
  117. -- Build results from this list of services
  118. --
  119. SET @services = CURSOR LOCAL READ_ONLY FORWARD_ONLY FOR
  120. SELECT
  121. BS.[serviceID],
  122. BS.[serviceKey],
  123. BS.[businessID]
  124. FROM
  125. [UDC_businessServices] BS
  126. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  127. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  128. WHERE
  129. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys)) AND
  130. (BS.[businessID] IN (SELECT DISTINCT BN.[businessID] FROM [UDC_names_BE] BN WHERE (BN.[name] LIKE @businessName + '%')))
  131. OPEN @services
  132. FETCH NEXT FROM @services INTO
  133. @serviceID,
  134. @serviceKey,
  135. @businessID
  136. WHILE @@FETCH_STATUS = 0
  137. BEGIN
  138. --
  139. -- Retrieve the name of the business that owns the service
  140. --
  141. SET @businessName2 = (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE (BN.[businessID] = @businessID))
  142. --
  143. -- Retrieve the key of the business that owns the service
  144. --
  145. SET @businessKey = dbo.businessKey(@businessID)
  146. --
  147. -- Retrieve the name of the service
  148. --
  149. SET @serviceName = (SELECT TOP 1 SN.[name] FROM [UDC_names_BS] SN WHERE (SN.[serviceID] = @serviceID))
  150. --
  151. -- Add results to results table
  152. --
  153. INSERT @results VALUES(
  154. @businessName2,
  155. @businessKey,
  156. @serviceName,
  157. @serviceKey)
  158. FETCH NEXT FROM @services INTO
  159. @serviceID,
  160. @serviceKey,
  161. @businessID
  162. END
  163. CLOSE @services
  164. --
  165. -- Return results
  166. --
  167. SELECT * FROM @results
  168. END
  169. GO
  170. -- =============================================
  171. -- Section: New Stored Procedures
  172. -- =============================================
  173. -- =============================================
  174. -- Name: net_taxonomyValues_get
  175. -- =============================================
  176. IF EXISTS (SELECT name FROM sysobjects WHERE name = N'net_taxonomyValues_get' AND type = 'P')
  177. DROP PROCEDURE net_taxonomyValues_get
  178. GO
  179. CREATE PROCEDURE net_taxonomyValues_get
  180. @tModelKey uniqueidentifier
  181. AS
  182. BEGIN
  183. DECLARE
  184. @error int,
  185. @context nvarchar(4000),
  186. @taxonomyID bigint
  187. SET @taxonomyID = dbo.taxonomyID(@tModelKey)
  188. IF @taxonomyID IS NULL
  189. BEGIN
  190. SET @error = 60210
  191. SET @context = 'uuid:' + dbo.UUIDSTR(@tModelKey)
  192. GOTO errorLabel
  193. END
  194. SELECT
  195. [keyValue],
  196. [parentKeyValue],
  197. [keyName],
  198. [valid]
  199. FROM
  200. [UDT_taxonomyValues]
  201. WHERE
  202. ([taxonomyID] = @taxonomyID)
  203. ORDER BY
  204. [parentKeyValue],
  205. [keyValue]
  206. RETURN 0
  207. errorLabel:
  208. RAISERROR (@error, 16, 1, @context)
  209. RETURN 1
  210. END
  211. GO
  212. -- =============================================
  213. -- Name: net_bindingTemplate_get_batch
  214. -- =============================================
  215. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_bindingTemplate_get_batch' and type = 'P')
  216. DROP PROCEDURE net_bindingTemplate_get_batch
  217. GO
  218. CREATE PROCEDURE net_bindingTemplate_get_batch
  219. @bindingKey uniqueidentifier,
  220. @serviceKey uniqueidentifier OUTPUT,
  221. @URLTypeID tinyint OUTPUT,
  222. @accessPoint nvarchar(4000) OUTPUT,
  223. @hostingRedirector uniqueidentifier OUTPUT
  224. WITH ENCRYPTION
  225. AS
  226. BEGIN
  227. DECLARE
  228. @error int,
  229. @context nvarchar(4000)
  230. SELECT
  231. @serviceKey = dbo.serviceKey([serviceID]),
  232. @URLTypeID = [URLTypeID],
  233. @accessPoint = [accessPoint],
  234. @hostingRedirector = [hostingRedirector]
  235. FROM
  236. [UDC_bindingTemplates]
  237. WHERE
  238. ([bindingID] = dbo.bindingID(@bindingKey))
  239. IF @@ROWCOUNT = 0
  240. BEGIN
  241. SET @error = 60210 -- E_invalidKey
  242. SET @context = 'bindingKey = ' + dbo.UUIDSTR(@bindingKey)
  243. GOTO errorLabel
  244. END
  245. -- Retrieve the contained objects
  246. EXEC net_bindingTemplate_descriptions_get @bindingKey
  247. EXEC net_bindingTemplate_tModelInstanceInfos_get @bindingKey
  248. RETURN 0
  249. errorLabel:
  250. RAISERROR (@error, 16, 1, @context)
  251. RETURN 1
  252. END -- net_bindingTemplate_get_batch
  253. GO
  254. -- =============================================
  255. -- Name: net_bindingTemplate_tModelInstanceInfo_get_batch
  256. -- =============================================
  257. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_bindingTemplate_tModelInstanceInfo_get_batch' and type = 'P')
  258. DROP PROCEDURE net_bindingTemplate_tModelInstanceInfo_get_batch
  259. GO
  260. CREATE PROCEDURE net_bindingTemplate_tModelInstanceInfo_get_batch
  261. @instanceID bigint
  262. WITH ENCRYPTION
  263. AS
  264. BEGIN
  265. EXEC net_bindingTemplate_tModelInstanceInfo_descriptions_get @instanceID
  266. EXEC net_bindingTemplate_instanceDetails_descriptions_get @instanceID
  267. EXEC net_bindingTemplate_instanceDetails_overviewDoc_descriptions_get @instanceID
  268. RETURN 0
  269. END -- net_bindingTemplate_tModelInstanceInfo_get_batch
  270. GO
  271. -- =============================================
  272. -- Name: net_businessEntity_get_batch
  273. -- =============================================
  274. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_businessEntity_get_batch' and type = 'P')
  275. DROP PROCEDURE net_businessEntity_get_batch
  276. GO
  277. CREATE PROCEDURE net_businessEntity_get_batch
  278. @businessKey uniqueidentifier,
  279. @operatorName nvarchar(450) OUTPUT,
  280. @authorizedName nvarchar(4000) OUTPUT
  281. WITH ENCRYPTION
  282. AS
  283. BEGIN
  284. DECLARE
  285. @error int,
  286. @context nvarchar(4000)
  287. SELECT
  288. @operatorName = dbo.publisherOperatorName([publisherID]),
  289. @authorizedName = ISNULL([authorizedName],dbo.publisherName([publisherID]))
  290. FROM
  291. [UDC_businessEntities]
  292. WHERE
  293. [businessKey] = @businessKey
  294. IF @@ROWCOUNT = 0
  295. BEGIN
  296. SET @error = 60210
  297. SET @context = 'businessKey = ' + dbo.UUIDSTR(@businessKey)
  298. GOTO errorLabel
  299. END
  300. -- Retrieve the contained objects
  301. EXEC net_businessEntity_descriptions_get @businessKey
  302. EXEC net_businessEntity_names_get @businessKey
  303. EXEC net_businessEntity_discoveryURLs_get @businessKey
  304. EXEC net_businessEntity_contacts_get @businessKey
  305. EXEC net_businessEntity_IdentifierBag_get @businessKey
  306. EXEC net_businessEntity_CategoryBag_get @businessKey
  307. EXEC net_businessEntity_BusinessServices_get @businessKey
  308. RETURN 0
  309. errorLabel:
  310. RAISERROR (@error, 16, 1, @context)
  311. RETURN 1
  312. END -- net_businessEntity_get_batch
  313. GO
  314. -- =============================================
  315. -- Name: net_businessInfo_get_batch
  316. -- =============================================
  317. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_businessInfo_get_batch' and type = 'P')
  318. DROP PROCEDURE net_businessInfo_get_batch
  319. GO
  320. CREATE PROCEDURE net_businessInfo_get_batch
  321. @businessKey uniqueidentifier,
  322. @getServiceInfos bit
  323. WITH ENCRYPTION
  324. AS
  325. BEGIN
  326. -- Retrieve the contained objects needed for a BusinessInfo
  327. EXEC net_businessEntity_descriptions_get @businessKey
  328. EXEC net_businessEntity_names_get @businessKey
  329. IF @getServiceInfos = 1
  330. BEGIN
  331. EXEC net_businessEntity_BusinessServices_get @businessKey
  332. END
  333. RETURN 0
  334. END -- net_businessEntity_get_batch
  335. GO
  336. -- =============================================
  337. -- Name: net_businessEntity_contact_get_batch
  338. -- =============================================
  339. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_businessEntity_contact_get_batch' and type = 'P')
  340. DROP PROCEDURE net_businessEntity_contact_get_batch
  341. GO
  342. CREATE PROCEDURE net_businessEntity_contact_get_batch
  343. @contactID bigint
  344. WITH ENCRYPTION
  345. AS
  346. BEGIN
  347. -- Get all contained objects in a contact
  348. EXEC net_contact_descriptions_get @contactID
  349. EXEC net_contact_phones_get @contactID
  350. EXEC net_contact_emails_get @contactID
  351. EXEC net_contact_addresses_get @contactID
  352. END -- net_businessEntity_contact_get_batch
  353. GO
  354. -- =============================================
  355. -- Name: net_businessService_get_batch
  356. -- =============================================
  357. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_businessService_get_batch' and type = 'P')
  358. DROP PROCEDURE net_businessService_get_batch
  359. GO
  360. CREATE PROCEDURE net_businessService_get_batch
  361. @serviceKey uniqueidentifier,
  362. @businessKey uniqueidentifier OUTPUT
  363. WITH ENCRYPTION
  364. AS
  365. BEGIN
  366. DECLARE
  367. @error int,
  368. @context nvarchar(4000)
  369. SELECT
  370. @businessKey = dbo.businessKey([businessID])
  371. FROM
  372. [UDC_businessServices]
  373. WHERE
  374. [serviceKey] = @serviceKey
  375. IF @@ROWCOUNT = 0
  376. BEGIN
  377. SET @error = 60210 -- E_invalidKey
  378. SET @context = 'serviceKey = ' + dbo.UUIDSTR(@serviceKey)
  379. GOTO errorLabel
  380. END
  381. -- Retrieve the contained objects
  382. EXEC net_businessService_descriptions_get @serviceKey
  383. EXEC net_businessService_names_get @serviceKey
  384. EXEC net_businessService_bindingTemplates_get @serviceKey
  385. EXEC net_businessService_categoryBag_get @serviceKey
  386. RETURN 0
  387. errorLabel:
  388. RAISERROR (@error, 16, 1, @context)
  389. RETURN 1
  390. END -- net_businessService_get_batch
  391. GO
  392. -- =============================================
  393. -- Name: net_serviceInfo_get_batch
  394. -- =============================================
  395. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_serviceInfo_get_batch' and type = 'P')
  396. DROP PROCEDURE net_serviceInfo_get_batch
  397. GO
  398. CREATE PROCEDURE net_serviceInfo_get_batch
  399. @serviceKey uniqueidentifier,
  400. @businessKey uniqueidentifier OUTPUT
  401. WITH ENCRYPTION
  402. AS
  403. BEGIN
  404. DECLARE
  405. @error int,
  406. @context nvarchar(4000)
  407. SELECT
  408. @businessKey = dbo.businessKey([businessID])
  409. FROM
  410. [UDC_businessServices]
  411. WHERE
  412. [serviceKey] = @serviceKey
  413. IF @@ROWCOUNT = 0
  414. BEGIN
  415. SET @error = 60210 -- E_invalidKey
  416. SET @context = 'serviceKey = ' + dbo.UUIDSTR(@serviceKey)
  417. GOTO errorLabel
  418. END
  419. -- Retrieve the contained objects
  420. EXEC net_businessService_names_get @serviceKey
  421. RETURN 0
  422. errorLabel:
  423. RAISERROR (@error, 16, 1, @context)
  424. RETURN 1
  425. END -- net_businessService_get_batch
  426. GO
  427. -- =============================================
  428. -- Name: net_tModel_get_batch
  429. -- =============================================
  430. IF EXISTS (SELECT * FROM sysobjects WHERE name = 'net_tModel_get_batch' and type = 'P')
  431. DROP PROCEDURE net_tModel_get_batch
  432. GO
  433. CREATE PROCEDURE net_tModel_get_batch
  434. @tModelKey uniqueidentifier,
  435. @operatorName nvarchar(450) OUTPUT,
  436. @authorizedName nvarchar(4000) OUTPUT,
  437. @name nvarchar(450) OUTPUT,
  438. @overviewURL nvarchar(4000) OUTPUT
  439. WITH ENCRYPTION
  440. AS
  441. BEGIN
  442. DECLARE
  443. @error int,
  444. @context nvarchar(4000)
  445. SELECT
  446. @operatorName = dbo.publisherOperatorName([publisherID]),
  447. @authorizedName = ISNULL([authorizedName],dbo.publisherName([publisherID])),
  448. @name = [name],
  449. @overviewURL = [overviewURL]
  450. FROM
  451. [UDC_tModels]
  452. WHERE
  453. ([tModelKey] = @tModelKey)
  454. IF @@ROWCOUNT = 0
  455. BEGIN
  456. SET @error = 60210 -- E_invalidKey
  457. SET @context = 'tModelKey = ' + dbo.addURN(@tModelKey)
  458. GOTO errorLabel
  459. END
  460. -- Get contained objects
  461. EXEC net_tModel_descriptions_get @tModelKey
  462. EXEC net_tModel_overviewDoc_descriptions_get @tModelKey
  463. EXEC net_tModel_identifierBag_get @tModelKey
  464. EXEC net_tModel_categoryBag_get @tModelKey
  465. RETURN 0
  466. errorLabel:
  467. RAISERROR (@error, 16, 1, @context)
  468. RETURN 1
  469. END -- net_tModel_get_batch
  470. GO
  471. -- =============================================
  472. -- Section: Security
  473. -- =============================================
  474. GRANT EXEC ON net_taxonomyValues_get to UDDIAdmin, UDDIService
  475. GRANT EXEC ON net_bindingTemplate_get_batch TO UDDIAdmin, UDDIService
  476. GRANT EXEC ON net_bindingTemplate_tModelInstanceInfo_get_batch TO UDDIAdmin, UDDIService
  477. GRANT EXEC ON net_businessEntity_get_batch TO UDDIAdmin, UDDIService
  478. GRANT EXEC ON net_businessInfo_get_batch TO UDDIAdmin, UDDIService
  479. GRANT EXEC ON net_businessEntity_contact_get_batch TO UDDIAdmin, UDDIService
  480. GRANT EXEC ON net_businessService_get_batch TO UDDIAdmin, UDDIService
  481. GRANT EXEC ON net_serviceInfo_get_batch TO UDDIAdmin, UDDIService
  482. GRANT EXEC ON net_serviceProjection_repl_save TO UDDIAdmin, UDDIService
  483. GRANT EXEC ON net_tModel_get_batch TO UDDIAdmin, UDDIService
  484. GRANT EXEC ON VS_AWR_businesses_get TO UDDIAdmin, UDDIService
  485. GO
  486. -- =============================================
  487. -- Section: Update Version(s)
  488. -- =============================================
  489. EXEC net_config_save 'Site.Version', '5.2.3664.0' -- TODO: Update this to proper RC2 site.version
  490. EXEC net_config_save 'Database.Version', '2.0.0001.2'
  491. GO