Mercurial > gemma
comparison pkg/geoserver/boot.go @ 4342:6a1fef54d49f
Always associate style with layer
Even if the uploaded style existed before, the layer might not be
associated with it (e.g. because the layer was re-created without
style). Thus always (re-)create the association.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 06 Sep 2019 16:17:36 +0200 |
parents | 2de644208706 |
children | 69c54e2def2d a5dccbc5920d |
comparison
equal
deleted
inserted
replaced
4341:e58affd956c5 | 4342:6a1fef54d49f |
---|---|
505 entry.Name, http.StatusText(resp.StatusCode)) | 505 entry.Name, http.StatusText(resp.StatusCode)) |
506 } | 506 } |
507 | 507 |
508 // Third associate with layer | 508 // Third associate with layer |
509 | 509 |
510 if create { | 510 req, err = http.NewRequest( |
511 req, err := http.NewRequest( | 511 http.MethodPost, |
512 http.MethodPost, | 512 geoURL+"/rest/layers/"+ |
513 geoURL+"/rest/layers/"+ | 513 url.PathEscape(workspaceName+":"+entry.Name)+ |
514 url.PathEscape(workspaceName+":"+entry.Name)+ | 514 "/styles?default=true", |
515 "/styles?default=true", | 515 toStream(&styleFilename)) |
516 toStream(&styleFilename)) | 516 if err != nil { |
517 if err != nil { | 517 return err |
518 return err | 518 } |
519 } | 519 auth(req) |
520 auth(req) | 520 asJSON(req) |
521 asJSON(req) | 521 |
522 | 522 resp, err = http.DefaultClient.Do(req) |
523 resp, err = http.DefaultClient.Do(req) | 523 if err != nil { |
524 if err != nil { | 524 return err |
525 return err | 525 } |
526 } | 526 |
527 | 527 if resp.StatusCode != http.StatusCreated { |
528 if resp.StatusCode != http.StatusCreated { | 528 return fmt.Errorf("cannot connect style %s with layer (%s)", |
529 return fmt.Errorf("cannot connect style %s with layer (%s)", | 529 entry.Name, http.StatusText(resp.StatusCode)) |
530 entry.Name, http.StatusText(resp.StatusCode)) | |
531 } | |
532 } | 530 } |
533 | 531 |
534 return nil | 532 return nil |
535 } | 533 } |
536 | 534 |