changeset 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 e58affd956c5
children 63c25eb9c07c a5dccbc5920d
files pkg/geoserver/boot.go
diffstat 1 files changed, 18 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/geoserver/boot.go	Fri Sep 06 14:39:21 2019 +0200
+++ b/pkg/geoserver/boot.go	Fri Sep 06 16:17:36 2019 +0200
@@ -507,28 +507,26 @@
 
 	// Third associate with layer
 
-	if create {
-		req, err := http.NewRequest(
-			http.MethodPost,
-			geoURL+"/rest/layers/"+
-				url.PathEscape(workspaceName+":"+entry.Name)+
-				"/styles?default=true",
-			toStream(&styleFilename))
-		if err != nil {
-			return err
-		}
-		auth(req)
-		asJSON(req)
+	req, err = http.NewRequest(
+		http.MethodPost,
+		geoURL+"/rest/layers/"+
+			url.PathEscape(workspaceName+":"+entry.Name)+
+			"/styles?default=true",
+		toStream(&styleFilename))
+	if err != nil {
+		return err
+	}
+	auth(req)
+	asJSON(req)
 
-		resp, err = http.DefaultClient.Do(req)
-		if err != nil {
-			return err
-		}
+	resp, err = http.DefaultClient.Do(req)
+	if err != nil {
+		return err
+	}
 
-		if resp.StatusCode != http.StatusCreated {
-			return fmt.Errorf("cannot connect style %s with layer (%s)",
-				entry.Name, http.StatusText(resp.StatusCode))
-		}
+	if resp.StatusCode != http.StatusCreated {
+		return fmt.Errorf("cannot connect style %s with layer (%s)",
+			entry.Name, http.StatusText(resp.StatusCode))
 	}
 
 	return nil