diff --git a/pom.xml b/pom.xml index cb7f96b..fc887eb 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.graylog.plugins.aggregates graylog-plugin-aggregates - 0.0.13 + 0.0.14 jar ${project.artifactId} diff --git a/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java b/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java index d743520..8e2ec33 100644 --- a/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java +++ b/src/main/java/org/graylog/plugins/aggregates/AggregatesMetaData.java @@ -34,7 +34,7 @@ public URI getURL() { @Override public Version getVersion() { - return new Version(0, 0, 13); + return new Version(0, 0, 14); } @Override diff --git a/src/main/java/org/graylog/plugins/aggregates/rule/RuleService.java b/src/main/java/org/graylog/plugins/aggregates/rule/RuleService.java index c4311ce..c79d174 100644 --- a/src/main/java/org/graylog/plugins/aggregates/rule/RuleService.java +++ b/src/main/java/org/graylog/plugins/aggregates/rule/RuleService.java @@ -1,10 +1,13 @@ package org.graylog.plugins.aggregates.rule; +import java.io.UnsupportedEncodingException; import java.util.List; import org.graylog.plugins.aggregates.rule.rest.models.requests.AddRuleRequest; import org.graylog.plugins.aggregates.rule.rest.models.requests.UpdateRuleRequest; +import com.mongodb.MongoException; + public interface RuleService { long count(); @@ -14,7 +17,7 @@ public interface RuleService { List all(); - int destroy(String ruleName); + int destroy(String ruleName) throws MongoException, UnsupportedEncodingException; Rule fromRequest(AddRuleRequest request); diff --git a/src/main/java/org/graylog/plugins/aggregates/rule/rest/RuleResource.java b/src/main/java/org/graylog/plugins/aggregates/rule/rest/RuleResource.java index 78acd15..07b9883 100644 --- a/src/main/java/org/graylog/plugins/aggregates/rule/rest/RuleResource.java +++ b/src/main/java/org/graylog/plugins/aggregates/rule/rest/RuleResource.java @@ -4,6 +4,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Supplier; +import com.mongodb.MongoException; + import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -41,6 +43,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import java.io.UnsupportedEncodingException; import java.util.List; @Api(value = "Aggregates", description = "Management of Aggregation rules.") @@ -93,10 +97,10 @@ public Response create( public Response update(@ApiParam(name = "name", required = true) @PathParam("name") String name, @ApiParam(name = "JSON body", required = true) @Valid @NotNull UpdateRuleRequest request - ) { + ) throws UnsupportedEncodingException { final Rule rule = ruleService.fromRequest(request); - ruleService.update(name, rule); + ruleService.update(java.net.URLDecoder.decode(name, "UTF-8"), rule); return Response.accepted().build(); } @@ -112,7 +116,7 @@ public Response update(@ApiParam(name = "name", required = true) }) public void delete(@ApiParam(name = "name", required = true) @PathParam("name") String name - ) throws NotFoundException { - ruleService.destroy(name); + ) throws NotFoundException, MongoException, UnsupportedEncodingException { + ruleService.destroy(java.net.URLDecoder.decode(name, "UTF-8")); } } \ No newline at end of file diff --git a/src/web/aggregates/AggregatesStore.js b/src/web/aggregates/AggregatesStore.js index b75264b..eb226b5 100644 --- a/src/web/aggregates/AggregatesStore.js +++ b/src/web/aggregates/AggregatesStore.js @@ -29,7 +29,6 @@ const AggregatesStore = Reflux.createStore({ AggregatesActions.list.promise(promise); }, create(newRule) { - console.log(JSON.stringify(newRule)); const url = URLUtils.qualifyUrl(this.sourceUrl); const method = 'PUT'; @@ -61,7 +60,7 @@ const AggregatesStore = Reflux.createStore({ }, update(name, updatedRule) { - const url = URLUtils.qualifyUrl(this.sourceUrl+'/' + name); + const url = URLUtils.qualifyUrl(this.sourceUrl+'/' + encodeURIComponent(name)); const method = 'POST'; const request = { @@ -92,10 +91,9 @@ const AggregatesStore = Reflux.createStore({ }, deleteByName(ruleName) { - const url = URLUtils.qualifyUrl(this.sourceUrl + '/' + ruleName); + const url = URLUtils.qualifyUrl(this.sourceUrl + '/' + encodeURIComponent(ruleName)); const method = 'DELETE'; - //const request; - + const promise = fetch(method, url) .then(() => { UserNotification.success('Rule successfully deleted');