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.

217 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Abstract:
  4. @doc
  5. @module stswriter.h | Declaration of the Sharepoint Team Services wrier
  6. @end
  7. Author:
  8. Brian Berkowitz [brianb] 10/12/2001
  9. TBD:
  10. Add comments.
  11. Revision History:
  12. Name Date Comments
  13. brianb 10/12/2001 created
  14. --*/
  15. ////////////////////////////////////////////////////////////////////////
  16. // Standard foo for file name aliasing. This code block must be after
  17. // all includes of VSS header files.
  18. //
  19. #ifdef VSS_FILE_ALIAS
  20. #undef VSS_FILE_ALIAS
  21. #endif
  22. #define VSS_FILE_ALIAS "INCSTSWH"
  23. //
  24. ////////////////////////////////////////////////////////////////////////
  25. #ifndef __STSWRITER_H_
  26. #define __STSWRITER_H_
  27. class CSTSSites;
  28. // enumeration of reasons why a site may not be used for
  29. // backup or restore
  30. typedef enum STSSITEPROBLEM
  31. {
  32. STSP_SUCCESS = 0,
  33. STSP_SYNTAXERROR, // syntax error in component name
  34. STSP_SITENOTFOUND, // instance id of site is not a valid IIS Virtual server
  35. STSP_SITENAMEMISMATCH, // site name does not match server comment for IIS Virtual Server
  36. STSP_SITEDSNINVALID, // site database DSN is not valid
  37. STSP_SQLSERVERNOTLOCAL, // sql server used by site is not on the local machine
  38. STSP_CONTENTNOTLOCAL, // content root used by the site is not on the local machine
  39. STSP_CONFIGNOTLOCAL // configuration root used ty the site is not on the local machine
  40. };
  41. // declaration of STS writer class
  42. class CSTSWriter :
  43. public CVssWriter
  44. {
  45. public:
  46. // constructor
  47. STDMETHODCALLTYPE CSTSWriter() :
  48. m_bSubscribed(false),
  49. m_rgiSites(NULL), m_pSites(NULL), m_cSites(0), m_bVolumeBackup(false)
  50. {
  51. }
  52. // destructor
  53. STDMETHODCALLTYPE ~CSTSWriter();
  54. // callbacks for writer events
  55. bool STDMETHODCALLTYPE OnIdentify(IVssCreateWriterMetadata *pMetadata);
  56. bool STDMETHODCALLTYPE OnPrepareBackup(IN IVssWriterComponents *pComponents);
  57. bool STDMETHODCALLTYPE OnPrepareSnapshot();
  58. bool STDMETHODCALLTYPE OnFreeze();
  59. bool STDMETHODCALLTYPE OnThaw();
  60. bool STDMETHODCALLTYPE OnAbort();
  61. bool STDMETHODCALLTYPE OnPreRestore(IVssWriterComponents *pMetadata);
  62. // initialize and subscribe the writer
  63. HRESULT STDMETHODCALLTYPE Initialize();
  64. // unsubscribe the writer
  65. HRESULT STDMETHODCALLTYPE Uninitialize();
  66. private:
  67. // determine if a database is on a snapshotted device. If it is partially
  68. // on a snapshotted device throw VSS_E_WRITERERROR_INCONSISTENTSNAPSHOT
  69. bool IsDatabaseAffected(LPCWSTR wszInstance, LPCWSTR wszDb);
  70. // translate writer error
  71. void TranslateWriterError(HRESULT hr);
  72. // lockdown all sites on volumes that are being backed up.
  73. void LockdownAffectedSites();
  74. // determine if a site is on the set of volumes being snapshotted
  75. bool IsSiteSnapshotted(DWORD iSite);
  76. // parse dsn
  77. bool ParseDsn
  78. (
  79. LPWSTR wszDSN,
  80. LPWSTR &wszServer,
  81. LPWSTR &wszInstance,
  82. LPWSTR &wszDb
  83. );
  84. // validate site validity to be backed up and restored. This means
  85. // that all files and the database are local to the current machine
  86. bool ValidateSiteValidity(DWORD iSite, STSSITEPROBLEM &problem);
  87. // parse and validate a compnent name
  88. bool ParseComponentName(LPCWSTR wszComponentName, DWORD &iSite, STSSITEPROBLEM &problem);
  89. // indicate that a site cannot be restored because the site referred to is invalid
  90. void SetSiteInvalid
  91. (
  92. IVssComponent *pComponent,
  93. LPCWSTR wszSiteName,
  94. STSSITEPROBLEM problem
  95. );
  96. // indicate that a site cannot be restored because its DSN, content, or config roots mismatch
  97. void SetSiteMetadataMismatch
  98. (
  99. IVssComponent *pComponent,
  100. LPWSTR wszMetadataBackup,
  101. LPWSTR wszMetadataRestore
  102. );
  103. // compare a string within the metadata
  104. bool compareNextMetadataString
  105. (
  106. IVssComponent *pComponent,
  107. LPWSTR &pwcB,
  108. LPWSTR &pwcR,
  109. LPCWSTR wszMetadataComponent
  110. );
  111. // indicate that a site could not be restored because its content root
  112. // could not be completely deleted.
  113. void SetRemoveFailure
  114. (
  115. IVssComponent *pComponent,
  116. LPCWSTR wszConentRoot,
  117. HRESULT hr
  118. );
  119. // indicate a general failure that causes the PreRestore of a component
  120. // to fail
  121. void SetPreRestoreFailure(IVssComponent *pComponent, HRESULT hr);
  122. // build metadata stored in backup components document for site
  123. VSS_PWSZ BuildSiteMetadata(DWORD iSite);
  124. // validate that a server name refers to a local machine
  125. bool ValidateServerIsLocal(LPCWSTR wszServer);
  126. // validate that a path is local
  127. bool ValidatePathIsLocal(LPCWSTR wszPath);
  128. // sites structure
  129. CSTSSites *m_pSites;
  130. // is the writer subscribed
  131. bool m_bSubscribed;
  132. // mask indicating which sites are being backed up or restored
  133. DWORD *m_rgiSites;
  134. // number of sites in sites array
  135. DWORD m_cSites;
  136. // is this volume or component oriented backup
  137. bool m_bVolumeBackup;
  138. };
  139. // wrapper class used to create and destroy the writer
  140. // used by coordinator
  141. class CVssStsWriterWrapper
  142. {
  143. public:
  144. // constructor
  145. CVssStsWriterWrapper();
  146. // destructor
  147. ~CVssStsWriterWrapper();
  148. // create the writer and subscribe it
  149. HRESULT CreateStsWriter();
  150. // unsubscribe the writer (used at process teardown)
  151. void DestroyStsWriter();
  152. private:
  153. // initialization function
  154. static DWORD InitializeThreadFunc(VOID *pv);
  155. // snapshot object
  156. CSTSWriter *m_pStsWriter;
  157. // result of initialization
  158. HRESULT m_hrInitialize;
  159. };
  160. #endif // _STSWRITER_H_