| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package hierarchy | 5 package hierarchy |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "crypto/sha256" | 8 "crypto/sha256" |
| 9 "encoding/base64" | 9 "encoding/base64" |
| 10 "encoding/hex" | 10 "encoding/hex" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 PathBase: types.StreamPath(r.PathBase), | 202 PathBase: types.StreamPath(r.PathBase), |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Validate our PathBase component. | 205 // Validate our PathBase component. |
| 206 if err := l.PathBase.ValidatePartial(); err != nil { | 206 if err := l.PathBase.ValidatePartial(); err != nil { |
| 207 return nil, fmt.Errorf("invalid stream path base %q: %v", l.Path
Base, err) | 207 return nil, fmt.Errorf("invalid stream path base %q: %v", l.Path
Base, err) |
| 208 } | 208 } |
| 209 | 209 |
| 210 // Enter the supplied Project namespace. This will assert the the user h
as | 210 // Enter the supplied Project namespace. This will assert the the user h
as |
| 211 // access to the project. | 211 // access to the project. |
| 212 » if err := coordinator.WithProjectNamespace(&c, l.Project); err != nil { | 212 » if err := coordinator.WithProjectNamespace(&c, l.Project, coordinator.Na
mespaceAccessREAD); err != nil { |
| 213 return nil, err | 213 return nil, err |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Determine our ancestor component. | 216 // Determine our ancestor component. |
| 217 di := ds.Get(c) | 217 di := ds.Get(c) |
| 218 | 218 |
| 219 q := ds.NewQuery("_StreamNameComponent") | 219 q := ds.NewQuery("_StreamNameComponent") |
| 220 q = q.Eq("p", componentEntityParent(l.PathBase)) | 220 q = q.Eq("p", componentEntityParent(l.PathBase)) |
| 221 if r.StreamOnly { | 221 if r.StreamOnly { |
| 222 q = q.Eq("s", true) | 222 q = q.Eq("s", true) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 return di.NewKey("_StreamNameComponent", string(d), 0, nil), nil | 267 return di.NewKey("_StreamNameComponent", string(d), 0, nil), nil |
| 268 } | 268 } |
| 269 | 269 |
| 270 // cursorForKey returns a cursor for the supplied componentID. This cursor will | 270 // cursorForKey returns a cursor for the supplied componentID. This cursor will |
| 271 // start new queries at the component immediately following this ID. | 271 // start new queries at the component immediately following this ID. |
| 272 func cursorForKey(di ds.Interface, e *componentEntity) string { | 272 func cursorForKey(di ds.Interface, e *componentEntity) string { |
| 273 key := di.KeyForObj(e) | 273 key := di.KeyForObj(e) |
| 274 return base64.URLEncoding.EncodeToString([]byte(key.StringID())) | 274 return base64.URLEncoding.EncodeToString([]byte(key.StringID())) |
| 275 } | 275 } |
| OLD | NEW |