Commit 1d0f615536520bf32f1acd061f7acf4a367e9bee
1 parent
f1f300b13c
Exists in
master
and in
1 other branch
can't fetch clob
Showing
4 changed files
with
51 additions
and
56 deletions
Show diff stats
auth_utility.go
... | ... | @@ -30,7 +30,7 @@ type TokenClaims struct { |
30 | 30 | jwt.StandardClaims |
31 | 31 | } |
32 | 32 | |
33 | -// CredentialsStruct is an instace of username/password values. | |
33 | +// CredentialsStruct is an instace of username/password values. | |
34 | 34 | type CredentialsStruct struct { |
35 | 35 | Username string `json:"username"` |
36 | 36 | Password string `json:"password"` | ... | ... |
json_utility.go
1 | 1 | package webutility |
2 | 2 | |
3 | 3 | import ( |
4 | + "fmt" | |
4 | 5 | "net/http" |
5 | 6 | "encoding/json" |
6 | 7 | "errors" |
7 | - "gopkg.in/rana/ora.v3" | |
8 | 8 | "io" |
9 | - "io/ioutil" | |
9 | + //"io/ioutil" | |
10 | 10 | "sync" |
11 | + | |
12 | + //"gopkg.in/rana/ora.v3" | |
13 | + "gopkg.in/rana/ora.v4" | |
11 | 14 | ) |
12 | 15 | |
13 | 16 | var mu = &sync.Mutex{} |
... | ... | @@ -140,10 +143,14 @@ func correlations(ptype string) []CorrelationField { |
140 | 143 | // InitTables loads all payloads in the payloads variable. |
141 | 144 | // Returns an error if it fails. |
142 | 145 | func InitTables(db *ora.Ses, project string) error { |
143 | - jsonbuf, _ := fetchJSON(db, EqualQuotes(project)) | |
146 | + jsonbuf, err := fetchJSON(db, project) | |
147 | + if err != nil { | |
148 | + return err | |
149 | + } | |
150 | + | |
144 | 151 | mu.Lock() |
145 | 152 | defer mu.Unlock() |
146 | - json.Unmarshal(jsonbuf, &payloads) | |
153 | + json.Unmarshal([]byte(jsonbuf), &payloads) | |
147 | 154 | if len(payloads) == 0 { |
148 | 155 | return errors.New("tables config is corrupt") |
149 | 156 | } |
... | ... | @@ -152,39 +159,27 @@ func InitTables(db *ora.Ses, project string) error { |
152 | 159 | |
153 | 160 | // fetchJSON returns a byte slice of JSON configuration file from TABLES_CONFIG table. |
154 | 161 | // Returns an error if it fails. |
155 | -func fetchJSON(db *ora.Ses, project string) ([]byte, error) { | |
156 | - stmt, err := db.Prep(`SELECT | |
157 | - JSON_CLOB | |
158 | - FROM TABLES_CONFIG | |
159 | - WHERE PROJEKAT` + project, ora.S) | |
162 | +func fetchJSON(db *ora.Ses, project string) (string, error) { | |
163 | + stmt, err := db.Prep(`SELECT JSON_CLOB FROM TABLES_CONFIG WHERE PROJEKAT` + EqualQuotes(project), ora.S) | |
160 | 164 | defer stmt.Close() |
161 | - | |
162 | 165 | if err != nil { |
163 | - return nil, err | |
166 | + return "", err | |
164 | 167 | } |
168 | + fmt.Println("prep passes") | |
165 | 169 | |
166 | 170 | rset, err := stmt.Qry() |
167 | 171 | if err != nil { |
168 | - return nil, err | |
172 | + fmt.Println(err) | |
173 | + return "", err | |
169 | 174 | } |
175 | + fmt.Println("query passes") | |
170 | 176 | |
171 | - bytes := make([]byte, 0) | |
177 | + var data string | |
172 | 178 | if rset.Next() { |
173 | - lob := rset.Row[0].(io.Reader) | |
174 | - if lob != nil { | |
175 | - bytes, err = ioutil.ReadAll(lob) | |
176 | - if err != nil { | |
177 | - // TODO: Find a fix for this. | |
178 | - // Some weird streaming read/write LOB error. | |
179 | - // Ignore for now. | |
180 | - //return nil, err | |
181 | - } | |
182 | - } else { | |
183 | - return nil, errors.New("json config is null") | |
184 | - } | |
179 | + data = rset.Row[0].(string) | |
185 | 180 | } |
186 | 181 | |
187 | - return bytes, nil | |
182 | + return data, nil | |
188 | 183 | } |
189 | 184 | |
190 | 185 | // DecodeJSON decodes JSON data from r to v. | ... | ... |
list_config.go
1 | 1 | package webutility |
2 | 2 | |
3 | -import "gopkg.in/rana/ora.v3" | |
3 | +//import "gopkg.in/rana/ora.v3" | |
4 | +import "gopkg.in/rana/ora.v4" | |
4 | 5 | |
5 | 6 | type ListOptions struct { |
6 | 7 | GlobalFilter bool `json:"globalFilter"` |
... | ... | @@ -139,7 +140,7 @@ func GetListConfigObjectIDField(db *ora.Ses, otype string) string { |
139 | 140 | resp = rset.Row[0].(string) |
140 | 141 | } |
141 | 142 | |
142 | - if rset.Err != nil { | |
143 | + if rset.Err() != nil { | |
143 | 144 | return "" |
144 | 145 | } |
145 | 146 | |
... | ... | @@ -207,8 +208,8 @@ func setListParams(db *ora.Ses, list *ListConfig, objType string) error { |
207 | 208 | list.LazyLoad = rset.Row[2].(uint32) != 0 |
208 | 209 | list.InlineEdit = rset.Row[3].(uint32) != 0 |
209 | 210 | } |
210 | - if rset.Err != nil { | |
211 | - return rset.Err | |
211 | + if rset.Err() != nil { | |
212 | + return rset.Err() | |
212 | 213 | } |
213 | 214 | return nil |
214 | 215 | } |
... | ... | @@ -246,8 +247,8 @@ func getListNavigation(db *ora.Ses, listObjType string) ([]ListNavNode, error) { |
246 | 247 | // RB is ignored |
247 | 248 | }) |
248 | 249 | } |
249 | - if rset.Err != nil { | |
250 | - return nil, rset.Err | |
250 | + if rset.Err() != nil { | |
251 | + return nil, rset.Err() | |
251 | 252 | } |
252 | 253 | |
253 | 254 | return resp, nil |
... | ... | @@ -283,8 +284,8 @@ func getListActions(db *ora.Ses, objType string) (ListActions, error) { |
283 | 284 | resp.Print = rset.Row[4].(uint32) != 0 |
284 | 285 | resp.Graph = rset.Row[5].(uint32) != 0 |
285 | 286 | } |
286 | - if rset.Err != nil { | |
287 | - return ListActions{}, rset.Err | |
287 | + if rset.Err() != nil { | |
288 | + return ListActions{}, rset.Err() | |
288 | 289 | } |
289 | 290 | return resp, nil |
290 | 291 | } |
... | ... | @@ -344,8 +345,8 @@ func getFilterFieldsAndPosition(db *ora.Ses, objType string) (map[string]uint32, |
344 | 345 | for rset.Next() { |
345 | 346 | filtersField[rset.Row[0].(string)] = rset.Row[1].(uint32) |
346 | 347 | } |
347 | - if rset.Err != nil { | |
348 | - return nil, rset.Err | |
348 | + if rset.Err() != nil { | |
349 | + return nil, rset.Err() | |
349 | 350 | } |
350 | 351 | return filtersField, nil |
351 | 352 | } |
... | ... | @@ -383,8 +384,8 @@ func getFiltersByFilterField(db *ora.Ses, filtersField string) ([]_filter, error |
383 | 384 | DefaultValues: rset.Row[2].(string), |
384 | 385 | }) |
385 | 386 | } |
386 | - if rset.Err != nil { | |
387 | - return resp, rset.Err | |
387 | + if rset.Err() != nil { | |
388 | + return resp, rset.Err() | |
388 | 389 | } |
389 | 390 | return resp, nil |
390 | 391 | } |
... | ... | @@ -415,8 +416,8 @@ func getFilterDropdownConfig(db *ora.Ses, filtersField string) (Dropdown, error) |
415 | 416 | resp.IDField = rset.Row[2].(string) |
416 | 417 | resp.LabelField = rset.Row[3].(string) |
417 | 418 | } |
418 | - if rset.Err != nil { | |
419 | - return resp, rset.Err | |
419 | + if rset.Err() != nil { | |
420 | + return resp, rset.Err() | |
420 | 421 | } |
421 | 422 | return resp, nil |
422 | 423 | } |
... | ... | @@ -467,8 +468,8 @@ func getListGraph(db *ora.Ses, objType string) ([]ListGraph, error) { |
467 | 468 | Label: rset.Row[4].(string), |
468 | 469 | }) |
469 | 470 | } |
470 | - if rset.Err != nil { | |
471 | - return resp, rset.Err | |
471 | + if rset.Err() != nil { | |
472 | + return resp, rset.Err() | |
472 | 473 | } |
473 | 474 | return resp, nil |
474 | 475 | } |
... | ... | @@ -505,8 +506,8 @@ func getListOptions(db *ora.Ses, objType string) (ListOptions, error) { |
505 | 506 | resp.Detail = rset.Row[6].(uint32) != 0 |
506 | 507 | resp.Total = rset.Row[7].(uint32) != 0 |
507 | 508 | } |
508 | - if rset.Err != nil { | |
509 | - return ListOptions{}, rset.Err | |
509 | + if rset.Err() != nil { | |
510 | + return ListOptions{}, rset.Err() | |
510 | 511 | } |
511 | 512 | return resp, nil |
512 | 513 | } |
... | ... | @@ -538,8 +539,8 @@ func getListParent(db *ora.Ses, objType string) ([]ListParentNode, error) { |
538 | 539 | FilterField: rset.Row[2].(string), |
539 | 540 | }) |
540 | 541 | } |
541 | - if rset.Err != nil { | |
542 | - return nil, rset.Err | |
542 | + if rset.Err() != nil { | |
543 | + return nil, rset.Err() | |
543 | 544 | } |
544 | 545 | |
545 | 546 | return resp, nil |
... | ... | @@ -573,8 +574,8 @@ func getListPivot(db *ora.Ses, objType string) ([]ListPivot, error) { |
573 | 574 | Value: rset.Row[3].(string), |
574 | 575 | }) |
575 | 576 | } |
576 | - if rset.Err != nil { | |
577 | - return nil, rset.Err | |
577 | + if rset.Err() != nil { | |
578 | + return nil, rset.Err() | |
578 | 579 | } |
579 | 580 | |
580 | 581 | return resp, nil |
... | ... | @@ -606,8 +607,8 @@ func getListDetails(db *ora.Ses, objType string) (ListDetails, error) { |
606 | 607 | resp.ParentFilterField = rset.Row[2].(string) |
607 | 608 | resp.SingleDetail = rset.Row[3].(uint32) != 0 |
608 | 609 | } |
609 | - if rset.Err != nil { | |
610 | - return resp, rset.Err | |
610 | + if rset.Err() != nil { | |
611 | + return resp, rset.Err() | |
611 | 612 | } |
612 | 613 | |
613 | 614 | return resp, nil | ... | ... |
select_config.go
1 | 1 | package webutility |
2 | 2 | |
3 | -import ( | |
4 | - "gopkg.in/rana/ora.v3" | |
5 | -) | |
3 | +//import "gopkg.in/rana/ora.v3" | |
4 | +import "gopkg.in/rana/ora.v4" | |
6 | 5 | |
7 | 6 | type SelectConfig struct { |
8 | 7 | ListObjType string `json:"listObjectType"` |
... | ... | @@ -45,8 +44,8 @@ func GetSelectConfig(db *ora.Ses, otype string) ([]SelectConfig, error) { |
45 | 44 | ValueField: rset.Row[5].(string), |
46 | 45 | }) |
47 | 46 | } |
48 | - if rset.Err != nil { | |
49 | - return nil, rset.Err | |
47 | + if rset.Err() != nil { | |
48 | + return nil, rset.Err() | |
50 | 49 | } |
51 | 50 | |
52 | 51 | return resp, nil | ... | ... |