Examples of StreamRule


Examples of org.graylog2.plugin.streams.StreamRule

        assertFalse(matcher.match(msg, rule));
    }

    @Test
    public void testMissedMatchMissingField() {
        StreamRule rule = getSampleRule();
        rule.setValue("42");

        Message msg = getSampleMessage();
        msg.addField("someother", "50");

        StreamRuleMatcher matcher = getMatcher(rule);
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

        assertFalse(matcher.match(msg, rule));
    }

    @Test
    public void testMissedInvertedMatchMissingField() {
        StreamRule rule = getSampleRule();
        rule.setValue("42");
        rule.setInverted(true);

        Message msg = getSampleMessage();
        msg.addField("someother", "30");

        StreamRuleMatcher matcher = getMatcher(rule);
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

        StreamRuleMatcher matcher = getMatcher(rule);
        assertFalse(matcher.match(msg, rule));
    }

    protected StreamRule getSampleRule() {
        StreamRule rule = super.getSampleRule();
        rule.setType(StreamRuleType.GREATER);

        return rule;
    }
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

public class RegexMatcherTest extends MatcherTest {

    @Test
    public void testSuccessfulMatch() {
        StreamRule rule = getSampleRule();
        rule.setValue("^foo");

        Message msg = getSampleMessage();
        msg.addField("something", "foobar");

        StreamRuleMatcher matcher = getMatcher(rule);
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

        assertTrue(matcher.match(msg, rule));
    }

    @Test
    public void testSuccessfulInvertedMatch() {
        StreamRule rule = getSampleRule();
        rule.setValue("^foo");
        rule.setInverted(true);

        Message msg = getSampleMessage();
        msg.addField("something", "zomg");

        StreamRuleMatcher matcher = getMatcher(rule);
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

            streamService.load(streamid);
        } catch (NotFoundException e) {
            throw new javax.ws.rs.NotFoundException("Stream not found!");
        }

        final StreamRule streamRule = streamRuleService.create(streamid, cr);

        final String id;
        try {
            id = streamService.save(streamRule);
        } catch (ValidationException e) {
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

    public SingleStreamRuleSummaryResponse update(@ApiParam(name = "streamid", value = "The stream id this rule belongs to.", required = true) @PathParam("streamid") String streamid,
                           @ApiParam(name = "streamRuleId", value = "The stream rule id we are updating", required = true) @PathParam("streamRuleId") String streamRuleId,
                           @ApiParam(name = "JSON body", required = true) CreateStreamRuleRequest cr) {
        checkPermission(RestPermissions.STREAMS_EDIT, streamid);

        final StreamRule streamRule;
        try {
            streamRule = streamRuleService.load(loadObjectId(streamRuleId));
            if (!streamRule.getStreamId().equals(streamid)) {
                throw new NotFoundException();
            }
        } catch (org.graylog2.database.NotFoundException e) {
            throw new javax.ws.rs.NotFoundException(e);
        }

        final StreamRuleType streamRuleType = StreamRuleType.fromInteger(cr.type);
        if(null == streamRuleType) {
            throw new BadRequestException("Unknown stream rule type " + cr.type);
        }

        streamRule.setField(cr.field);
        streamRule.setType(streamRuleType);
        streamRule.setInverted(cr.inverted);
        streamRule.setValue(cr.value);

        String id;
        try {
            streamRuleService.save(streamRule);
            id = streamRule.getId();
        } catch (ValidationException e) {
            LOG.error("Validation error.", e);
            throw new BadRequestException(e);
        }
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

        final String id = streamService.save(stream);

        if (cr.rules != null && cr.rules.size() > 0) {
            for (CreateStreamRuleRequest request : cr.rules) {
                StreamRule streamRule = streamRuleService.create(id, request);
                streamRuleService.save(streamRule);
            }
        }

        Map<String, Object> result = Maps.newHashMap();
View Full Code Here

Examples of org.graylog2.plugin.streams.StreamRule

    @Produces(MediaType.APPLICATION_JSON)
    public StreamRule get(@ApiParam(name = "streamid", value = "The id of the stream whose stream rule we want.", required = true) @PathParam("streamid") String streamid,
                      @ApiParam(name = "streamRuleId", value = "The stream rule id we are getting", required = true) @PathParam("streamRuleId") String streamRuleId) {
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        final StreamRule streamRule;
        try {
            streamRule = streamRuleService.load(loadObjectId(streamRuleId));
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }
View Full Code Here

Examples of org.graylog2.restclient.models.StreamRule

        CreateStreamRuleResponse response = null;

        try {
            CreateStreamRuleRequest csrr = form.get();
            response = streamRuleService.create(streamId, csrr);
            StreamRule streamRule = streamRuleService.get(streamId, response.streamrule_id);
            return created(views.html.partials.streamrules.list_item.render(streamRule));
        } catch (APIException e) {
            String message = "Could not create stream rule. We expected HTTP 201, but got a HTTP " + e.getHttpCode() + ".";
            return status(504, message);
        } catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.