Mercurial > gemma
diff pkg/models/intservices.go @ 877:254cd247826d geo-style
The XSLT stuff is not need (Puh!).
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 30 Sep 2018 20:09:02 +0200 |
parents | 8b9bd9ccdd93 |
children | 876d1f5433be |
line wrap: on
line diff
--- a/pkg/models/intservices.go Sun Sep 30 19:42:16 2018 +0200 +++ b/pkg/models/intservices.go Sun Sep 30 20:09:02 2018 +0200 @@ -3,10 +3,8 @@ import ( "context" "database/sql" - "fmt" "log" "net/http" - "strings" "sync" "gemma.intevation.de/gemma/pkg/auth" @@ -31,45 +29,17 @@ updateStyleSQL = ` UPDATE sys_admin.published_services -SET style = xslt_process($1, $2, $3)::bytea -WHERE name IN (SELECT oid FROM pg_class WHERE relname = $4)` -) - -const ( - replaceNameXSLT = `<?xml version="1.0"?> -<xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:sld="http://www.opengis.net/sld" - xmlns:se="http://www.opengis.net/se"> - - <xsl:param name="name"/> - - <xsl:template - match="/sld:StyledLayerDescriptor/sld:NamedLayer/sld:Name/text()"> - <xsl:value-of select="$name"/> - </xsl:template> - - <xsl:template - match="/sld:StyledLayerDescriptor/sld:NamedLayer/se:Name/text()"> - <xsl:value-of select="$name"/> - </xsl:template> - - <xsl:template match="@*|node()"> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> - </xsl:template> -</xsl:stylesheet>` +SET style = $1::bytea +WHERE name IN (SELECT oid FROM pg_class WHERE relname = $2)` ) var InternalServices = &IntServices{} func UpdateInternalStyle(req *http.Request, name, style string) error { return auth.RunAsSessionUser(req, func(conn *sql.Conn) error { - param := fmt.Sprintf("name='%s'", strings.Replace(name, ",", "", -1)) _, err := conn.ExecContext( req.Context(), updateStyleSQL, - style, replaceNameXSLT, param, name) + style, name) if err == nil { InternalServices.Invalidate() }