Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Say we have product p0001 that we want to append 2 pages from products p0002 and p0003
  2.  
  3.  
  4. ==== This is resources of p0001
  5.  
  6. [res00001] => Array
  7. (
  8. [prodId] => p0001
  9. [fqfn] => html/page001.html
  10. [mimeType] => text/html
  11. [label] => page_001
  12. [s3Obj] => ....html
  13. [id] => res00001
  14. [url] => https://....
  15. )
  16.  
  17. ===== This is resources of p0002
  18.  
  19. [res00002] => Array
  20. (
  21. [prodId] => p0002
  22. [fqfn] => html/page001.html
  23. [mimeType] => text/html
  24. [label] => page_001
  25. [s3Obj] => ....html
  26. [id] => res00002
  27. [url] => https://....
  28. )
  29.  
  30. ====== This is resources of p0003
  31.  
  32. [res00003] => Array
  33. (
  34. [prodId] => p0003
  35. [fqfn] => html/page001.html
  36. [mimeType] => text/html
  37. [label] => page_001
  38. [s3Obj] => ....html
  39. [id] => res00003
  40. [url] => https://....
  41. )
  42.  
  43. Pages json of `p001` look like this
  44.  
  45. "pages": [
  46. {
  47. "id": "page001",
  48. "title": "page_001",
  49. "html": {
  50. "id": "page001_html",
  51. "cont": "html\/page001.html"
  52. }
  53. }
  54.  
  55. We now copyResources of p0002 and p0003 to p0001
  56. All prodIds get overriden by `p0001` value
  57.  
  58. So we get following resource list for p0001
  59. [res00001] => Array
  60. (
  61. [prodId] => p0001
  62. [fqfn] => html/page001.html
  63. [mimeType] => text/html
  64. [label] => page_001
  65. [s3Obj] => ....html
  66. [id] => res00001
  67. [url] => https://....
  68. )
  69. [res00005] => Array
  70. (
  71. [prodId] => p0001
  72. [fqfn] => html/page001.html
  73. [mimeType] => text/html
  74. [label] => page_001
  75. [s3Obj] => ....html
  76. [id] => res00005
  77. [url] => https://....
  78. )
  79.  
  80. [res00006] => Array
  81. (
  82. [prodId] => p0001
  83. [fqfn] => html/page001.html
  84. [mimeType] => text/html
  85. [label] => page_001
  86. [s3Obj] => ....html
  87. [id] => res00006
  88. [url] => https://....
  89. )
  90.  
  91. And json for pages is
  92. "pages": [
  93. {
  94. "id": "page001",
  95. "title": "page_001",
  96. "html": {
  97. "id": "page001_html",
  98. "cont": "html\/page001.html"
  99. }
  100. } {
  101. "id": "clone_1",
  102. "title": "page_001",
  103. "html": {
  104. "id": "page001_html",
  105. "cont": "html\/page001.html"
  106. }
  107. } {
  108. "id": "clone_2",
  109. "title": "page_001",
  110. "html": {
  111. "id": "page001_html",
  112. "cont": "html\/page001.html"
  113. }
  114. }
  115.  
  116. You should see problem now. There are 3 html/page001.html from 3 different products but you can't tell from where
  117. And this is a simple issue. Actually colliding resources can be references from .html bodies, not just from TOC json, there could be few dozen of resources referenced by one page entry non-directly
  118.  
  119. So what I'm changing
  120. 1. when I drop a page from different product, I remember where page comes from, so pages json becomes like that:
  121.  
  122. "pages": [
  123. {
  124. "id": "page001",
  125. "title": "page_001",
  126. "html": {
  127. "id": "page001_html",
  128. "cont": "html\/page001.html"
  129. },
  130. productId: p0001,
  131. vcode: X0001
  132. } {
  133. "id": "clone_1",
  134. "title": "page_001",
  135. "html": {
  136. "id": "page001_html",
  137. "cont": "html\/page001.html"
  138. }
  139. productId: p0002,
  140. vcode: X0002
  141. } {
  142. "id": "clone_2",
  143. "title": "page_001",
  144. "html": {
  145. "id": "page001_html",
  146. "cont": "html\/page001.html"
  147. }
  148. productId: p0002,
  149. vcode: X0002
  150. }
  151.  
  152. But resource list is still bad
  153. So when I do 'please clone r0002 of product p0002 to p0001' I do:
  154. 1. Clone resource to new id, say r0005, set it's prodId = p0001
  155. 2 (NEW STEP) Add field to r0005 originalProdId = p0002
  156.  
  157. Now I have following resource list for p0001
  158.  
  159. [res00001] => Array
  160. (
  161. [prodId] => p0001
  162. [fqfn] => html/page001.html
  163. [mimeType] => text/html
  164. [label] => page_001
  165. [s3Obj] => ....html
  166. [id] => res00001
  167. [url] => https://....
  168. )
  169. [res00005] => Array
  170. (
  171. [prodId] => p0001
  172. [originalProdId] => p0002
  173. [fqfn] => html/page001.html
  174. [mimeType] => text/html
  175. [label] => page_001
  176. [s3Obj] => ....html
  177. [id] => res00005
  178. [url] => https://....
  179. )
  180. [res00006] => Array
  181. (
  182. [prodId] => p0001
  183. [originalProdId] => p0003
  184. [fqfn] => html/page001.html
  185. [mimeType] => text/html
  186. [label] => page_001
  187. [s3Obj] => ....html
  188. [id] => res00006
  189. [url] => https://....
  190. )
  191.  
  192. And I can easily identify what goes where
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement