| 1 |
<resource resdir="__system" schema="dc"> |
| 2 |
<meta name="creationDate">2008-02-13T13:00:00</meta> |
| 3 |
<meta name="description">The central products table (which is where |
| 4 |
access restrictions, media types, and the like are kept and that |
| 5 |
maps accrefs to file system paths) and some helpers to fill it</meta> |
| 6 |
<meta name="subject">astronomy-web-services</meta> |
| 7 |
|
| 8 |
<STREAM id="basicColumns"> |
| 9 |
<column name="accref" type="text" tablehead="Product key" |
| 10 |
description="Access key for the data" |
| 11 |
verbLevel="1" displayHint="type=product" |
| 12 |
ucd="meta.ref.url" |
| 13 |
utype="Access.Reference"/> |
| 14 |
<column name="owner" type="text" tablehead="Owner" |
| 15 |
verbLevel="25" description="Owner of the data"/> |
| 16 |
<column name="embargo" type="date" |
| 17 |
unit="yr" |
| 18 |
tablehead="Embargo ends" |
| 19 |
verbLevel="25" |
| 20 |
description="Date the data will become/became public" |
| 21 |
displayHint="type=humanDate"/> |
| 22 |
<column name="mime" type="text" verbLevel="20" |
| 23 |
ucd="meta.code.mime" |
| 24 |
tablehead="Type" |
| 25 |
description="MIME type of the file served" |
| 26 |
utype="Access.Format"/> |
| 27 |
</STREAM> |
| 28 |
|
| 29 |
<table id="products" primary="accref" system="True" onDisk="True" |
| 30 |
dupePolicy="overwrite"> |
| 31 |
<meta name="description"> |
| 32 |
The products table keeps information on "products", i.e. datasets |
| 33 |
delivered to the users. |
| 34 |
|
| 35 |
It is normally fed through the `//products#define`_ rowfilter something |
| 36 |
like `the //products#table mixin`_ . |
| 37 |
|
| 38 |
/getproducts inspects this table before handing out data to enforce |
| 39 |
embargoes and similar restrictions, and this is also where it figures |
| 40 |
out where to go for previews. |
| 41 |
</meta> |
| 42 |
<index columns="sourceTable"/> |
| 43 |
|
| 44 |
<!-- Warning: column names and table structure are reflected at least |
| 45 |
in protocols.products, so be careful if you change things here. --> |
| 46 |
<FEED source="basicColumns"/> |
| 47 |
<column name="accessPath" type="text" tablehead="Path to access data" |
| 48 |
required="True" verbLevel="5" |
| 49 |
description="Inputs-relative filesystem path to the file"/> |
| 50 |
<column name="sourceTable" type="text" verbLevel="10" |
| 51 |
tablehead="Source Table" |
| 52 |
description="Name of table containing metadata" required="True"/> |
| 53 |
<column name="preview" type="text" |
| 54 |
description="Location of a preview; this can be NULL if no preview |
| 55 |
is available, 'AUTO' to make DaCHS try its luck itself, |
| 56 |
or a URL or a file path for pre-computed previews." |
| 57 |
verbLevel="40"/> |
| 58 |
<column name="datalink" type="text" |
| 59 |
description="Legacy column. Don't use this." |
| 60 |
verbLevel="40"/> |
| 61 |
<column name="preview_mime" type="text" |
| 62 |
description="MIME type of a preview (if any)" |
| 63 |
verbLevel="40"/> |
| 64 |
</table> |
| 65 |
|
| 66 |
<!-- as the result definition, use this: --> |
| 67 |
<table original="products" id="productsResult" onDisk="False"/> |
| 68 |
|
| 69 |
<data id="import"> |
| 70 |
<make table="products"/> |
| 71 |
</data> |
| 72 |
|
| 73 |
<rowmaker id="productsMaker"> |
| 74 |
<!-- the row maker for the products table itself --> |
| 75 |
<map dest="accref" src="prodtblAccref"/> |
| 76 |
<map dest="owner" src="prodtblOwner"/> |
| 77 |
<map dest="embargo" src="prodtblEmbargo"/> |
| 78 |
<map dest="accessPath" src="prodtblPath"/> |
| 79 |
<map dest="sourceTable" src="prodtblTable"/> |
| 80 |
<map dest="mime" src="prodtblMime"/> |
| 81 |
<map dest="preview" src="prodtblPreview"/> |
| 82 |
<map dest="preview_mime" src="prodtblPreviewMime"/> |
| 83 |
<map dest="datalink" src="prodtblDatalink"/> |
| 84 |
</rowmaker> |
| 85 |
|
| 86 |
<!-- material for tables mixing in products --> |
| 87 |
<STREAM id="tablecols"> |
| 88 |
<index columns="accref"/> |
| 89 |
<FEED source="//products#basicColumns"/> |
| 90 |
<column name="accsize" ucd="VOX:Image_FileSize" |
| 91 |
tablehead="File size" description="Size of the data in bytes" |
| 92 |
type="bigint" verbLevel="11" unit="byte" utype="Access.Size"> |
| 93 |
<values nullLiteral="-1"/> |
| 94 |
</column> |
| 95 |
</STREAM> |
| 96 |
|
| 97 |
<table id="instance"> |
| 98 |
<!-- actual sample columns for reference (this should not be necessary, |
| 99 |
really) --> |
| 100 |
<FEED source="tablecols"/> |
| 101 |
</table> |
| 102 |
|
| 103 |
<STREAM id="mapUserItems"> |
| 104 |
<doc> |
| 105 |
Standard mappings copying the standard `//products#define`_ rowdict items |
| 106 |
to their target columns in tables containing products. |
| 107 |
|
| 108 |
You only need this if you do not have "standard" products |
| 109 |
(as for siap, ssap, etc.) |
| 110 |
</doc> |
| 111 |
<map dest="accref" src="prodtblAccref"/> |
| 112 |
<map dest="accsize" src="prodtblFsize"/> |
| 113 |
<map dest="owner" src="prodtblOwner"/> |
| 114 |
<map dest="embargo" src="prodtblEmbargo"/> |
| 115 |
<map dest="mime" src="prodtblMime"/> |
| 116 |
</STREAM> |
| 117 |
|
| 118 |
<procDef type="rowfilter" id="define"> |
| 119 |
<doc> |
| 120 |
Enters the values defined by the product interface into |
| 121 |
a grammar's result. |
| 122 |
|
| 123 |
See the documentation on the //products#table mixin. In short: |
| 124 |
you will always have to touch table (to the name of the |
| 125 |
table this row is managed in). |
| 126 |
|
| 127 |
If you don't serve FITS images, you will also have to set |
| 128 |
mime. Use a media type like "image/jpeg" or "text/csv" here |
| 129 |
as appropriate. If not set, it defaults to |
| 130 |
application/fits (since DaCHS 2.10; before it was image/fits). |
| 131 |
|
| 132 |
Everything else is optional: You may want to set preview |
| 133 |
and preview_mime if DaCHS can't do previews of your stuff |
| 134 |
automatically. What's left is for special situations. |
| 135 |
|
| 136 |
This will create the keys prodblAccref, prodtblOwner, prodtblEmbargo, |
| 137 |
prodtblPath, prodtblFsize, prodtblTable, prodtblMime, prodtblPreview, |
| 138 |
prodtbleMime, and prodtblDatalink keys in rawdict -- you can |
| 139 |
refer to them in the usual @foo way, which is sometimes useful |
| 140 |
even outside products processing proper (in particular for |
| 141 |
prodtblAccref). |
| 142 |
</doc> |
| 143 |
<setup> |
| 144 |
<par key="table" description="the table this product is managed in. |
| 145 |
You must fill this in, and don't forget the quotes."/> |
| 146 |
<par late="True" key="accref" description="an access reference |
| 147 |
(this usually is the input-relative path; only file names |
| 148 |
well-behaved in URLs are accepted here by default for easier |
| 149 |
operation with ObsTAP)" |
| 150 |
>\inputRelativePath{True}</par> |
| 151 |
<par late="True" key="owner" description="for proprietary data, |
| 152 |
the owner as a gavo creds-created user">None</par> |
| 153 |
<par late="True" key="embargo" description="for proprietary data, |
| 154 |
the date the file will become public">None</par> |
| 155 |
<par late="True" key="path" description="the inputs-relative path |
| 156 |
to the product file (change at your peril)" |
| 157 |
>\inputRelativePath{True}</par> |
| 158 |
<par late="True" key="fsize" description="the size of the input in bytes" |
| 159 |
>\inputSize</par> |
| 160 |
<par late="True" key="mime" description="MIME-type for the product" |
| 161 |
>'application/fits'</par> |
| 162 |
<par late="True" key="preview" description="file path to a preview. |
| 163 |
Set to None if no preview is available. The default 'AUTO' will |
| 164 |
make DaCHS try to make a preview itself, which currently fails for |
| 165 |
anything but FITS and jpeg. You can also put in a URL if you have |
| 166 |
pre-computed. If using a local path, see `Precomputed Previews`_ |
| 167 |
before writing something yourself." |
| 168 |
>'AUTO'</par> |
| 169 |
<par late="True" key="preview_mime" |
| 170 |
description="MIME-type for the preview (if there is one).">None</par> |
| 171 |
<par key="datalink" description="Legacy. Do not use." |
| 172 |
late="True">None</par> |
| 173 |
</setup> |
| 174 |
<code> |
| 175 |
newVars = {} |
| 176 |
if path is None: |
| 177 |
path = accref |
| 178 |
row["prodtblAccref"] = accref |
| 179 |
row["prodtblOwner"] = owner |
| 180 |
row["prodtblEmbargo"] = embargo |
| 181 |
row["prodtblPath"] = path |
| 182 |
row["prodtblFsize"] = fsize |
| 183 |
row["prodtblTable"] = table |
| 184 |
row["prodtblMime"] = mime |
| 185 |
row["prodtblPreview"] = preview |
| 186 |
row["prodtblPreviewMime"] = preview_mime |
| 187 |
row["prodtblDatalink"] = datalink |
| 188 |
yield row |
| 189 |
</code> |
| 190 |
</procDef> |
| 191 |
|
| 192 |
<STREAM id="prodcolMaps"> |
| 193 |
<!-- this was an idiotic thing to do. Can I get rid of it again? --> |
| 194 |
<doc> |
| 195 |
Fragment for mapping the result of the define proc into a user table; |
| 196 |
this is replayed into every rowmaker making a table mixing in |
| 197 |
products. |
| 198 |
</doc> |
| 199 |
<map dest="accref" src="prodtblAccref"/> |
| 200 |
<map dest="owner" src="prodtblOwner"/> |
| 201 |
<map dest="embargo" src="prodtblEmbargo"/> |
| 202 |
<map dest="accsize" src="prodtblFsize"/> |
| 203 |
<map dest="mime" src="prodtblMime"/> |
| 204 |
</STREAM> |
| 205 |
|
| 206 |
<STREAM id="productsMake"> |
| 207 |
<make table="//products#products" rowmaker="//products#productsMaker"/> |
| 208 |
</STREAM> |
| 209 |
|
| 210 |
<STREAM id="tableRules"> |
| 211 |
<doc> |
| 212 |
These items need to end up in all tables managing things in the |
| 213 |
product table. |
| 214 |
|
| 215 |
Basically, they make sure that when products are deleted from the |
| 216 |
table they are managed in, they also disappear from the product |
| 217 |
table (yes, this sounds like something the database should do, but they |
| 218 |
way this is built, you can't have a foreign key here). |
| 219 |
|
| 220 |
If the managing table stores the accref somewhere else than in a column |
| 221 |
named accref, give the FEED an accrefName attribute. |
| 222 |
</doc> |
| 223 |
<DEFAULTS accrefName="accref"/> |
| 224 |
<script type="preIndex" lang="SQL" name="product cleanup" |
| 225 |
notify="False"> |
| 226 |
CREATE OR REPLACE RULE cleanupProducts AS ON DELETE TO \\curtable |
| 227 |
DO ALSO |
| 228 |
DELETE FROM dc.products WHERE accref=OLD.\accrefName |
| 229 |
</script> |
| 230 |
<script type="beforeDrop" lang="SQL" name="clean product table" |
| 231 |
notify="False"> |
| 232 |
DELETE FROM dc.products WHERE sourceTable='\\curtable' |
| 233 |
</script> |
| 234 |
</STREAM> |
| 235 |
|
| 236 |
<STREAM id="hackProductsData"> |
| 237 |
<doc> |
| 238 |
This defines a processLate proc that hacks data instances |
| 239 |
building tables with products such that the products table |
| 240 |
is fed and the products instance columns are assigned to. |
| 241 |
</doc> |
| 242 |
<!-- This sucks. We really need to re-think this now that we have |
| 243 |
active tags. --> |
| 244 |
<processLate> |
| 245 |
<setup imports="gavo.rscdef"/> |
| 246 |
<code><![CDATA[ |
| 247 |
if substrate.getProperty("products", None)=="ignore": |
| 248 |
# that's undocumented test instrumentation for now |
| 249 |
return |
| 250 |
|
| 251 |
if not substrate.onDisk: |
| 252 |
raise base.StructureError("Tables mixing in product must be" |
| 253 |
" onDisk, but %s is not"%substrate.id) |
| 254 |
|
| 255 |
# Now locate all DDs we are referenced in and... |
| 256 |
prodRD = base.caches.getRD("//products") |
| 257 |
for dd in substrate.rd.iterDDs(): |
| 258 |
for td in dd: |
| 259 |
if td.id==substrate.id: |
| 260 |
# ...feed instructions to make the row table to it and... |
| 261 |
dd._makes.feedObject(dd, rscdef.Make(dd, |
| 262 |
table=prodRD.getTableDefById("products"), |
| 263 |
rowmaker=prodRD.getById("productsMaker"), |
| 264 |
role="products")) |
| 265 |
|
| 266 |
# ...add some rules to ensure prodcut table cleanup, |
| 267 |
# and add mappings for the embedding table. |
| 268 |
for make in dd.makes: |
| 269 |
if make.table.id==substrate.id: |
| 270 |
# it was stupid to hack the host rowmaker from the mixin. |
| 271 |
# I need some exit strategy here. |
| 272 |
# Meanwhile: we're suppressing the hack if it'd fail |
| 273 |
# anyway. |
| 274 |
if "owner" in make.table.columns.nameIndex: |
| 275 |
base.feedTo(make.rowmaker, |
| 276 |
prodRD.getById("prodcolMaps").getEventSource(), context, |
| 277 |
True) |
| 278 |
]]></code> |
| 279 |
</processLate> |
| 280 |
</STREAM> |
| 281 |
|
| 282 |
<mixinDef id="table"> |
| 283 |
<doc> |
| 284 |
A mixin for tables containing "products". |
| 285 |
|
| 286 |
A "product" here is some kind of binary, typically a FITS file. |
| 287 |
The table receives the columns accref, accsize, owner, and embargo |
| 288 |
(which is defined in //products#prodcolUsertable). |
| 289 |
|
| 290 |
By default, the accref is the path to the file relative to the inputs |
| 291 |
directory; this is also what /getproduct expects for local products. |
| 292 |
You can of course enter URLs to other places. |
| 293 |
|
| 294 |
For local files, you are strongly encouraged to keep the accref URL- and |
| 295 |
shell-clean, the most important reason being your users' sanity. |
| 296 |
Another is that obscore in the current implementation does no |
| 297 |
URL escaping for local files. So, just don't use characters like |
| 298 |
like +, the ampersand, apostrophes and so on; the default |
| 299 |
accref parser will reject those anyway. Actually, try |
| 300 |
making do with alphanumerics, the underscore, the dash, and the dot, |
| 301 |
ok? |
| 302 |
|
| 303 |
owner and embargo let you introduce access control. Embargo is a |
| 304 |
date at which the product will become publicly available. As long |
| 305 |
as this date is in the future, only authenticated users belonging to |
| 306 |
the *group* owner are allowed to access the product. |
| 307 |
|
| 308 |
In addition, the mixin arranges for the products to be added to the |
| 309 |
system table products, which is important when delivering the files. |
| 310 |
|
| 311 |
Tables mixing this in should be fed from grammars using the |
| 312 |
`//products#define`_ row filter. |
| 313 |
|
| 314 |
</doc> |
| 315 |
|
| 316 |
<FEED source="//products#hackProductsData"/> |
| 317 |
<events> |
| 318 |
<FEED source="//products#tableRules"/> |
| 319 |
<FEED source="//products#tablecols"/> |
| 320 |
</events> |
| 321 |
|
| 322 |
</mixinDef> |
| 323 |
|
| 324 |
<productCore id="core" queriedTable="products"> |
| 325 |
<!-- core used for the product delivery service --> |
| 326 |
<condDesc> |
| 327 |
<inputKey original="accref" id="coreKey" type="raw" |
| 328 |
multiplicity="multiple"/> |
| 329 |
</condDesc> |
| 330 |
|
| 331 |
<outputTable id="pCoreOutput"> |
| 332 |
<column name="source" type="raw" |
| 333 |
tablehead="Access info" verbLevel="1"/> |
| 334 |
</outputTable> |
| 335 |
</productCore> |
| 336 |
|
| 337 |
<service id="getTar" allowed="form,get"> |
| 338 |
<!-- a standalone service that delivers selectable tars. |
| 339 |
--> |
| 340 |
<meta name="title">Tar deliverer</meta> |
| 341 |
|
| 342 |
<productCore original="core" limit="10000" id="forTar"> |
| 343 |
<inputTable id="forTarIn"> |
| 344 |
<!-- Input table for the tar making core; |
| 345 |
the accrefs are expected to be FatProductKeys or plain strings --> |
| 346 |
<inputKey original="products.accref" type="raw" |
| 347 |
multiplicity="multiple"/> |
| 348 |
<inputKey name="pattern" type="text" description="Product pattern |
| 349 |
in the form tablePattern#filePatterns, where both parts |
| 350 |
are interpreted as SQL patterns." multiplicity="single"/> |
| 351 |
</inputTable> |
| 352 |
</productCore> |
| 353 |
|
| 354 |
</service> |
| 355 |
|
| 356 |
<table id="parsedKeys"> |
| 357 |
<meta name="description">Used internally by the product core.</meta> |
| 358 |
<column original="products.accref"/> |
| 359 |
<column name="ra"/> |
| 360 |
<column name="dec"/> |
| 361 |
<column name="sra"/> |
| 362 |
<column name="sdec"/> |
| 363 |
</table> |
| 364 |
|
| 365 |
<service id="dl" allowed="dlmeta"> |
| 366 |
<meta name="description">A simple datalink service for everything |
| 367 |
that's in DaCHS' product table. This only exposes the dataset |
| 368 |
itself and its preview, if existing.</meta> |
| 369 |
<datalinkCore> |
| 370 |
<!-- the built-in links are good enough for us --> |
| 371 |
</datalinkCore> |
| 372 |
</service> |
| 373 |
|
| 374 |
<service id="p" core="core" allowed="get,form"> |
| 375 |
<!-- this service is the one mentioned in the standard PubDIDs that |
| 376 |
we produce. It must be published once you put out such PubDIDs, |
| 377 |
as all IVOIDs must resolve in the registry. --> |
| 378 |
|
| 379 |
<meta name="identifier">ivo://\getConfig{ivoa}{authority}/~</meta> |
| 380 |
<meta name="creationDate">\metaString{authority.creationDate}</meta> |
| 381 |
<meta name="shortName">\metaString{authority.shortName} DL</meta> |
| 382 |
<meta name="title" |
| 383 |
>\getConfig{web}{sitename} Dataset Delivery</meta> |
| 384 |
<meta name="description"> |
| 385 |
This service delivers (most of) the datasets held at |
| 386 |
\getConfig{web}{sitename}. In addition to the default (nonstandard) way |
| 387 |
of just appending accrefs to the get access URL, there is also a very |
| 388 |
simple datalink service here that, for each dataset, essentially just |
| 389 |
gives the dataset itself and possibly a preview. More advanced datalink |
| 390 |
services might be available. |
| 391 |
|
| 392 |
Some datasets may be embargoed, in which case the access yields |
| 393 |
a 403. Credentials for individual files may be obtained by contacting |
| 394 |
the site operators. |
| 395 |
</meta> |
| 396 |
<publish render="get" sets="ivo_managed"> |
| 397 |
<meta name="accessURL">\getConfig{web}{serverURL}/getproduct</meta> |
| 398 |
<meta name="urlUse">base</meta> |
| 399 |
</publish> |
| 400 |
<publish render="dlmeta" sets="ivo_managed" service="dl"/> |
| 401 |
</service> |
| 402 |
</resource> |