@@ -362,11 +362,11 @@ func (pw *PageWriter) Done() {
362
362
363
363
if pw .Info .RootPath == "" {
364
364
checked := ""
365
- if pw .Info .HasFlag ("export " ) {
365
+ if pw .Info .HasFlag ("compact " ) {
366
366
checked = " checked"
367
367
}
368
- options += " <div class=export >\n " +
369
- " <input id=export type='checkbox'" + checked + "/>export \n " +
368
+ options += " <div class=compact >\n " +
369
+ " <input id=compact type='checkbox'" + checked + "/>compact \n " +
370
370
" </div>\n "
371
371
372
372
if options != "" { // Wrapper if any
@@ -405,16 +405,13 @@ func (pw *PageWriter) Done() {
405
405
// Process inlines
406
406
407
407
// check to see if the currently selected inlines are the default
408
- // ones based on any variant of 'export'
408
+ // ones based on presence of '/ export'
409
409
defaultInlines := false
410
410
if pw .Info .RootPath == "export" {
411
411
defaultInlines = (len (pw .Info .Inlines ) == 3 &&
412
412
pw .Info .IsInlineSet (NewPPP ("capabilities" ).DB ()) &&
413
413
pw .Info .IsInlineSet (NewPPP ("model" ).DB ()) &&
414
414
pw .Info .IsInlineSet (NewPPP ("*" ).DB ()))
415
- } else if pw .Info .RootPath == "" && pw .Info .HasFlag ("export" ) {
416
- defaultInlines = (len (pw .Info .Inlines ) == 1 &&
417
- pw .Info .IsInlineSet (NewPPP ("*" ).DB ()))
418
415
}
419
416
420
417
if pw .Info .RootPath == "" || pw .Info .RootPath == "export" {
@@ -695,7 +692,7 @@ func (pw *PageWriter) Done() {
695
692
font-weight: bold ;
696
693
margin-left: 3px ;
697
694
}
698
- .export {
695
+ .compact {
699
696
margin-top: 5px ;
700
697
font-size: 13px ;
701
698
font-family: courier ;
@@ -860,8 +857,8 @@ function apply() {
860
857
if (structureswitch) loc += "$structure"
861
858
loc += "?ui"
862
859
863
- ex = document.getElementById("export ")
864
- if (ex != null && ex.checked) loc += "&export "
860
+ ex = document.getElementById("compact ")
861
+ if (ex != null && ex.checked) loc += "&compact "
865
862
866
863
var filters = document.getElementById("filters").value
867
864
var lines = filters.split("\n")
@@ -1131,7 +1128,12 @@ FROM FullTree WHERE RegSID=? AND `
1131
1128
v , err := readNextEntity (info .tx , results )
1132
1129
1133
1130
if v != nil && v .Type == ENTITY_META {
1134
- // Skip the "meta" subobject
1131
+ // Skip the "meta" subobject, but first grab the
1132
+ // "defaultversionid if we don't already have it,
1133
+ // which should only be true in the xref case
1134
+ if vID == "" {
1135
+ vID = v .GetAsString ("defaultversionid" )
1136
+ }
1135
1137
continue
1136
1138
}
1137
1139
@@ -1282,7 +1284,7 @@ func HTTPGet(info *RequestInfo) error {
1282
1284
// response body or not (meaning, the hasDoc doc)
1283
1285
metaInBody := (info .ResourceModel == nil ) ||
1284
1286
(info .ResourceModel .GetHasDocument () == false || info .ShowStructure ||
1285
- info .HasFlag ("export " ) ||
1287
+ info .HasFlag ("compact " ) ||
1286
1288
(len (info .Parts ) == 5 && info .Parts [4 ] == "meta" ))
1287
1289
1288
1290
// Return the Resource's document
@@ -1316,14 +1318,11 @@ func SerializeQuery(info *RequestInfo, paths []string, what string,
1316
1318
info .AddInline ("capabilities" )
1317
1319
info .AddInline ("model" )
1318
1320
}
1319
- if info .RootPath == "" && info .HasFlag ("export" ) && len (info .Inlines ) == 0 {
1320
- info .AddInline ("*" )
1321
- }
1322
1321
1323
- doExport := info .HasFlag ("export " ) || info .RootPath == "export"
1322
+ doCompact := info .HasFlag ("compact " ) || info .RootPath == "export"
1324
1323
1325
1324
query , args , err := GenerateQuery (info .Registry , what , paths , filters ,
1326
- doExport )
1325
+ doCompact )
1327
1326
results , err := Query (info .tx , query , args ... )
1328
1327
defer results .Close ()
1329
1328
@@ -1345,6 +1344,27 @@ func SerializeQuery(info *RequestInfo, paths []string, what string,
1345
1344
// Collections will need to print the {}, so don't error for them
1346
1345
if what != "Coll" {
1347
1346
if jw .Entity == nil {
1347
+ // Special case, if the URL is ../rID/versions/vID?compact then
1348
+ // check to see if Resource has xref set, if so then the error
1349
+ // is 400, not 404
1350
+ if info .VersionUID != "" && info .HasFlag ("compact" ) {
1351
+ path := strings .Join (info .Parts [:len (info .Parts )- 2 ], "/" )
1352
+ path += "/meta"
1353
+ entity , err := RawEntityFromPath (info .tx , info .Registry .DbSID ,
1354
+ path , false )
1355
+ if err != nil {
1356
+ return err
1357
+ }
1358
+
1359
+ // Assume that if we cant' find the Resource's meta object
1360
+ // then the Resource doesn't exist, so a 404 really is the
1361
+ // best response in those cases, so skip the 400
1362
+ if entity != nil && ! IsNil (entity .Object ["xref" ]) {
1363
+ info .StatusCode = http .StatusBadRequest
1364
+ return fmt .Errorf ("'compact' flag not allowed on xref'd Versions" )
1365
+ }
1366
+ }
1367
+
1348
1368
info .StatusCode = http .StatusNotFound
1349
1369
return fmt .Errorf ("Not found" )
1350
1370
}
@@ -1367,14 +1387,15 @@ func SerializeQuery(info *RequestInfo, paths []string, what string,
1367
1387
}
1368
1388
}
1369
1389
1370
- // Another special case... .../rID/versions?export when rID has xref set
1371
- if jw .Entity == nil && info .HasFlag ("export" ) && len (info .Parts ) == 5 && info .Parts [4 ] == "versions" {
1390
+ // GROUPS/gID/RESOURCES/rID/versions
1391
+ // Another special case .../rID/versions?compact when rID has xref
1392
+ if jw .Entity == nil && info .HasFlag ("compact" ) && len (info .Parts ) == 5 && info .Parts [4 ] == "versions" {
1372
1393
// Should be our case since "versions" can never be empty except
1373
1394
// when xref is set. If this is not longer true then we'll need to
1374
1395
// check this Resource's xref to see if it's set.
1375
1396
// Can copy the RawEntityFromPath... stuff above
1376
- info .StatusCode = http .StatusNotFound
1377
- return fmt .Errorf ("Not found " )
1397
+ info .StatusCode = http .StatusBadRequest
1398
+ return fmt .Errorf ("'compact' flag not allowed on xref'd Versions " )
1378
1399
}
1379
1400
1380
1401
info .AddHeader ("Content-Type" , "application/json" )
0 commit comments