OLD | NEW |
1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 func jobPage(ctx *router.Context) { | 31 func jobPage(ctx *router.Context) { |
32 c, w, r, p := ctx.Context, ctx.Writer, ctx.Request, ctx.Params | 32 c, w, r, p := ctx.Context, ctx.Writer, ctx.Request, ctx.Params |
33 | 33 |
34 projectID := p.ByName("ProjectID") | 34 projectID := p.ByName("ProjectID") |
35 jobName := p.ByName("JobName") | 35 jobName := p.ByName("JobName") |
36 cursor := r.URL.Query().Get("c") | 36 cursor := r.URL.Query().Get("c") |
37 | 37 |
38 // Grab the job from the datastore. | 38 // Grab the job from the datastore. |
39 job, err := config(c).Engine.GetVisibleJob(c, projectID+"/"+jobName) | 39 job, err := config(c).Engine.GetVisibleJob(c, projectID+"/"+jobName) |
40 » if err != nil { | 40 » switch { |
41 » » panic(err) | 41 » case err == engine.ErrNoSuchJob: |
42 » } | |
43 » if job == nil { | |
44 http.Error(w, "No such job or no access to it", http.StatusNotFo
und) | 42 http.Error(w, "No such job or no access to it", http.StatusNotFo
und) |
45 return | 43 return |
| 44 case err != nil: |
| 45 panic(err) |
46 } | 46 } |
47 | 47 |
48 // Grab latest invocations from the datastore. | 48 // Grab latest invocations from the datastore. |
49 invs, nextCursor, err := config(c).Engine.ListVisibleInvocations(c, job.
JobID, 50, cursor) | 49 invs, nextCursor, err := config(c).Engine.ListVisibleInvocations(c, job.
JobID, 50, cursor) |
50 if err != nil { | 50 if err != nil { |
51 panic(err) | 51 panic(err) |
52 } | 52 } |
53 | 53 |
54 // memcacheKey hashes cursor to reduce its length, since full cursor doe
sn't | 54 // memcacheKey hashes cursor to reduce its length, since full cursor doe
sn't |
55 // fit into memcache key length limits. Use 'v2' scheme for this ('v1' w
as | 55 // fit into memcache key length limits. Use 'v2' scheme for this ('v1' w
as |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 jobName := c.Params.ByName("JobName") | 178 jobName := c.Params.ByName("JobName") |
179 switch err := cb(projectID + "/" + jobName); { | 179 switch err := cb(projectID + "/" + jobName); { |
180 case err == engine.ErrNoOwnerPermission: | 180 case err == engine.ErrNoOwnerPermission: |
181 http.Error(c.Writer, "Forbidden", 403) | 181 http.Error(c.Writer, "Forbidden", 403) |
182 case err != nil: | 182 case err != nil: |
183 panic(err) | 183 panic(err) |
184 default: | 184 default: |
185 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s", pr
ojectID, jobName), http.StatusFound) | 185 http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s", pr
ojectID, jobName), http.StatusFound) |
186 } | 186 } |
187 } | 187 } |
OLD | NEW |