Mercurial > gemma
annotate pkg/controllers/importconfig.go @ 5721:0500d76e074b uploadwg
Fixed eraseObsoleteGaugesSQL by reintroducing matching on users CC.
The condition was removed when introducing file upload, but that leads
to too many gauges being removed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Fri, 19 Apr 2024 16:52:14 +0200 |
parents | e09e003948c7 |
children |
rev | line source |
---|---|
1582
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package controllers |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "database/sql" |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
18 "encoding/json" |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
19 "fmt" |
1582
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 "net/http" |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
21 "strconv" |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
22 |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
23 "github.com/gorilla/mux" |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
24 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
25 "gemma.intevation.de/gemma/pkg/auth" |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
26 "gemma.intevation.de/gemma/pkg/common" |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
27 "gemma.intevation.de/gemma/pkg/imports" |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
28 "gemma.intevation.de/gemma/pkg/scheduler" |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
29 |
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
30 mw "gemma.intevation.de/gemma/pkg/middleware" |
1583
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
31 ) |
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
32 |
5376
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
33 // RolesRequierer enforces roles when storing schedules. |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
34 type RolesRequierer interface { |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
35 RequiresRoles() auth.Roles |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
36 } |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
37 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
38 func runImportConfig(req *http.Request) (jr mw.JSONResult, err error) { |
1730
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
39 |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
40 id, _ := strconv.ParseInt(mux.Vars(req)["id"], 10, 64) |
1730
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
41 |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
42 ctx := req.Context() |
1748
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1739
diff
changeset
|
43 |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
44 var jobID int64 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
45 if jobID, err = imports.RunConfiguredImportContext(ctx, mw.JSONConn(req), id); err != nil { |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
46 return |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
47 } |
1730
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
48 |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
49 var result = struct { |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
50 ID int64 `json:"id"` |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
51 }{ |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
52 ID: jobID, |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
53 } |
1730
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
54 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
55 jr = mw.JSONResult{ |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
56 Code: http.StatusCreated, |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
57 Result: &result, |
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
58 } |
1730
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
59 return |
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
60 } |
7c54babe10f7
Configured imports: Added GET /imports/config/{id:[0-9]+}/run" to run a configured import.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1727
diff
changeset
|
61 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
62 func modifyImportConfig(req *http.Request) (jr mw.JSONResult, err error) { |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
63 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
64 ctx := req.Context() |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
65 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
66 raw := mw.JSONInput(req).(*json.RawMessage) |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
67 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
68 id, _ := strconv.ParseInt(mux.Vars(req)["id"], 10, 64) |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
69 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
70 conn := mw.JSONConn(req) |
4242
1458c9b0fdaa
Made the sql.Conn in function accessible via the context of the request.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3975
diff
changeset
|
71 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
72 var pc *imports.PersistentConfig |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
73 pc, err = imports.LoadPersistentConfigContext(ctx, conn, id) |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
74 switch { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
75 case err == sql.ErrNoRows: |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
76 err = mw.JSONError{ |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
77 Code: http.StatusNotFound, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
78 Message: fmt.Sprintf("No configuration %d found", id), |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
79 } |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
80 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
81 case err != nil: |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
82 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
83 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
84 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
85 kind := imports.JobKind(pc.Kind) |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
86 ctor := imports.ImportModelForJobKind(kind) |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
87 if ctor == nil { |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
88 err = mw.JSONError{ |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
89 Code: http.StatusInternalServerError, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
90 Message: fmt.Sprintf("No constructor for kind '%s' found", pc.Kind), |
1704
897d4d8316ad
Import configuration: Made extra attributes updatable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1702
diff
changeset
|
91 } |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
92 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
93 } |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
94 config := ctor() |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
95 if err = json.Unmarshal(*raw, config); err != nil { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
96 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
97 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
98 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
99 _, oldCron := pc.Attributes.Get("cron") |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
100 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
101 session, _ := auth.GetSession(req) |
3552
ffc8fb059d1a
refactor password persistence for import configurations.
Thomas Junk <thomas.junk@intevation.de>
parents:
3549
diff
changeset
|
102 // When a password is stored it doesn't get retransmitted to the client |
ffc8fb059d1a
refactor password persistence for import configurations.
Thomas Junk <thomas.junk@intevation.de>
parents:
3549
diff
changeset
|
103 // in order to prevent password leakage |
ffc8fb059d1a
refactor password persistence for import configurations.
Thomas Junk <thomas.junk@intevation.de>
parents:
3549
diff
changeset
|
104 // When the user changes the import configuration without a new password |
ffc8fb059d1a
refactor password persistence for import configurations.
Thomas Junk <thomas.junk@intevation.de>
parents:
3549
diff
changeset
|
105 // the old password should be conserved |
3554
efa468653d48
only write password attribute, when available previous
Thomas Junk <thomas.junk@intevation.de>
parents:
3552
diff
changeset
|
106 oldPasswd, ok := pc.Attributes["password"] |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
107 pc.User = session.User |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
108 pc.Attributes = common.Attributes{} |
3975
8af156928a2d
Removed stupid bool == true comparision.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3554
diff
changeset
|
109 if ok { |
3554
efa468653d48
only write password attribute, when available previous
Thomas Junk <thomas.junk@intevation.de>
parents:
3552
diff
changeset
|
110 pc.Attributes["password"] = oldPasswd |
efa468653d48
only write password attribute, when available previous
Thomas Junk <thomas.junk@intevation.de>
parents:
3552
diff
changeset
|
111 } |
3552
ffc8fb059d1a
refactor password persistence for import configurations.
Thomas Junk <thomas.junk@intevation.de>
parents:
3549
diff
changeset
|
112 pc.Attributes.Marshal(config) // Marshal only overwrites keys present in config |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
113 cron, newCron := pc.Attributes.Get("cron") |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
114 |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
115 var tx *sql.Tx |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
116 if tx, err = conn.BeginTx(ctx, nil); err != nil { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
117 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
118 } |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
119 defer tx.Rollback() |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
120 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
121 if err = pc.UpdateContext(ctx, tx); err != nil { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
122 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
123 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
124 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
125 if oldCron { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
126 scheduler.UnbindByID(id) |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
127 } |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
128 |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
129 if newCron { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
130 if err = scheduler.BindAction( |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
131 string(pc.Kind), |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
132 cron, |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
133 id, |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
134 ); err != nil { |
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
135 return |
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
136 } |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
137 } |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
138 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
139 if err = tx.Commit(); err != nil { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
140 return |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
141 } |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
142 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
143 var result = struct { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
144 ID int64 `json:"id"` |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
145 }{ |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
146 ID: id, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
147 } |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
148 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
149 jr = mw.JSONResult{Result: &result} |
1592
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
150 return |
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
151 } |
c12cec1d7692
Added PATCH /imports/scheduler/{id:[0-9]+} to modify a single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1591
diff
changeset
|
152 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
153 func infoImportConfig(req *http.Request) (jr mw.JSONResult, err error) { |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
154 |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
155 ctx := req.Context() |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
156 |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
157 id, _ := strconv.ParseInt(mux.Vars(req)["id"], 10, 64) |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
158 |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
159 var cfg *imports.PersistentConfig |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
160 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
161 cfg, err = imports.LoadPersistentConfigContext(ctx, mw.JSONConn(req), id) |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
162 switch { |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
163 case err != nil: |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
164 return |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
165 case cfg == nil: |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
166 err = mw.JSONError{ |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
167 Code: http.StatusNotFound, |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
168 Message: fmt.Sprintf("No schedule %d found", id), |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
169 } |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
170 return |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
171 } |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
172 |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
173 kind := imports.JobKind(cfg.Kind) |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
174 |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
175 ctor := imports.ImportModelForJobKind(kind) |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
176 if ctor == nil { |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
177 err = mw.JSONError{ |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
178 Code: http.StatusInternalServerError, |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
179 Message: fmt.Sprintf("No constructor for kind '%s' found", cfg.Kind), |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
180 } |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
181 return |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
182 } |
2047
78002c5e838c
Imports: Code simplification.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2046
diff
changeset
|
183 |
3515
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
184 // Remove `password` from the attributes to be delivered to the client. |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
185 // Even a priviledged user shall not be able to see the password. |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
186 // (See config.ListAllPersistentConfigurationsContext() for the other |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
187 // place where this is done.) |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
188 filteredAttributes := make(common.Attributes) |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
189 for key, value := range cfg.Attributes { |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
190 if key != "password" { |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
191 filteredAttributes[key] = value |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
192 } |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
193 } |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
194 |
3515
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
195 what := ctor() |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2052
diff
changeset
|
196 if err = filteredAttributes.Unmarshal(what); err != nil { |
2047
78002c5e838c
Imports: Code simplification.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2046
diff
changeset
|
197 return |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
198 } |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
199 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
200 jr = mw.JSONResult{Result: &imports.ImportConfigOut{ |
2046
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
201 ID: id, |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
202 Kind: imports.ImportKind(cfg.Kind), |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
203 Config: what, |
725884a4c89a
Imports: Re-enabled /imports/config/{id} GET-
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
204 }} |
1591
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
205 return |
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
206 } |
2d53065c95af
Added GET /imports/scheduler/{id:[0-9]+} to show infos about single import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1590
diff
changeset
|
207 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
208 func deleteImportConfig(req *http.Request) (jr mw.JSONResult, err error) { |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
209 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
210 ctx := req.Context() |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
211 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
212 id, _ := strconv.ParseInt(mux.Vars(req)["id"], 10, 64) |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
213 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
214 var tx *sql.Tx |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
215 if tx, err = mw.JSONConn(req).BeginTx(ctx, nil); err != nil { |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
216 return |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
217 } |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
218 defer tx.Rollback() |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
219 |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
220 err = imports.DeletePersistentConfigurationContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
221 ctx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
222 tx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
223 id, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
224 ) |
1704
897d4d8316ad
Import configuration: Made extra attributes updatable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1702
diff
changeset
|
225 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
226 switch { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
227 case err == sql.ErrNoRows: |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
228 err = mw.JSONError{ |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
229 Code: http.StatusNotFound, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
230 Message: fmt.Sprintf("No configuration %d found", id), |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
231 } |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
232 return |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
233 case err != nil: |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
234 return |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
235 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
236 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
237 // Remove from running scheduler. |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
238 scheduler.UnbindByID(id) |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
239 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
240 if err = tx.Commit(); err != nil { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
241 return |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
242 } |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
243 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
244 var result = struct { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
245 ID int64 `json:"id"` |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
246 }{ |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
247 ID: id, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
248 } |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
249 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
250 jr = mw.JSONResult{Result: &result} |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
251 |
1590
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
252 return |
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
253 } |
2fdd8e57542d
Added DELETE /imports/scheduler/{id:[0-9]+} to delete a schedule from the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1589
diff
changeset
|
254 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
255 func addImportConfig(req *http.Request) (jr mw.JSONResult, err error) { |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
256 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
257 cfg := mw.JSONInput(req).(*imports.ImportConfigIn) |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
258 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
259 kind := imports.JobKind(cfg.Kind) |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
260 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
261 ctor := imports.ImportModelForJobKind(kind) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
262 if ctor == nil { |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
263 err = mw.JSONError{ |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
264 Code: http.StatusBadRequest, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
265 Message: fmt.Sprintf("No kind %s found", string(cfg.Kind)), |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
266 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
267 return |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
268 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
269 config := ctor() |
5376
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
270 |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
271 session, _ := auth.GetSession(req) |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
272 |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
273 if r, ok := config.(RolesRequierer); ok { |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
274 if roles := r.RequiresRoles(); len(roles) > 0 && !session.Roles.HasAny(roles...) { |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
275 err = mw.JSONError{ |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
276 Code: http.StatusUnauthorized, |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
277 Message: fmt.Sprintf( |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
278 "Not allowed to add config for kind %s", string(cfg.Kind)), |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
279 } |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
280 return |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
281 } |
e09e003948c7
Decouple and enforce roles in creating scheduled imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5374
diff
changeset
|
282 } |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
283 if err = json.Unmarshal(cfg.Config, config); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
284 return |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
285 } |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
286 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
287 pc := imports.PersistentConfig{ |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
288 User: session.User, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
289 Kind: string(cfg.Kind), |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
290 Attributes: common.Attributes{}, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
291 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
292 pc.Attributes.Marshal(config) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
293 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
294 ctx := req.Context() |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
295 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
296 var tx *sql.Tx |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
297 if tx, err = mw.JSONConn(req).BeginTx(ctx, nil); err != nil { |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
298 return |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
299 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
300 defer tx.Rollback() |
1702
49b89575ab31
Import configuration: [WIP] Added table for extra configuration attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1654
diff
changeset
|
301 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
302 var id int64 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
303 if id, err = pc.StoreContext(ctx, tx); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
304 return |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
305 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
306 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
307 // Need to start a scheduler job right away? |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
308 if cron, ok := pc.Attributes.Get("cron"); ok { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
309 if err = scheduler.BindAction(string(cfg.Kind), cron, id); err != nil { |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
310 return |
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
311 } |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
312 } |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
313 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
314 if err = tx.Commit(); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
315 scheduler.UnbindByID(id) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
316 return |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
317 } |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
318 |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
319 var result = struct { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
320 ID int64 `json:"id"` |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
321 }{ |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
322 ID: id, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
323 } |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
324 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
325 jr = mw.JSONResult{ |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
326 Code: http.StatusCreated, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
327 Result: &result, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
328 } |
1589
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
329 return |
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
330 } |
e0bd82f6ee14
Added PUT /api/imports/scheduler to add a import configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1583
diff
changeset
|
331 |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
332 func listImportConfigs(req *http.Request) (jr mw.JSONResult, err error) { |
1583
caedd9b176f2
Added GET to /api/imports/scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1582
diff
changeset
|
333 |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
334 ctx := req.Context() |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
335 configs := []*imports.ImportConfigOut{} |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
336 |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
337 if err = imports.ListAllPersistentConfigurationsContext( |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
338 ctx, mw.JSONConn(req), |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
339 func(config *imports.ImportConfigOut) error { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
340 configs = append(configs, config) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
341 return nil |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
342 }, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
343 ); err != nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
344 return |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2048
diff
changeset
|
345 } |
4244
4394daeea96a
Moved JSONHandler into middleware package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4243
diff
changeset
|
346 jr = mw.JSONResult{Result: configs} |
1582
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
347 return |
dc727824183a
Started with REST API for scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
348 } |