Package org.graylog2.restclient.models.api.results

Examples of org.graylog2.restclient.models.api.results.MessageResult


    }


    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException {
        final UserResponse response;

        // we don't handle any other type, see constructor
        @SuppressWarnings("CastToConcreteClass")
        SessionIdAuthenticationToken token = (SessionIdAuthenticationToken) authToken;
        try {
View Full Code Here


        this.messagesService = messagesService;
    }

    public Result show(String index, String id) {
        try {
            MessageResult message = messagesService.getMessage(index, id);
            Node sourceNode = getSourceNode(message);
            Radio sourceRadio = getSourceRadio(message);

            List<Stream> messageInStreams = Lists.newArrayList();

            for (String streamId : message.getStreamIds()) {
                if (isPermitted(STREAMS_READ, streamId)) {
                    try {
                        messageInStreams.add(streamService.get(streamId));
                    } catch (APIException e) {
                        //  We get a 404 if the stream no longer exists.
View Full Code Here

        }
    }

    public Result partial(String index, String id) {
        try {
            MessageResult message = messagesService.getMessage(index, id);
            Node sourceNode = getSourceNode(message);
            Radio sourceRadio = getSourceRadio(message);
            List<Stream> messageInStreams = Lists.newArrayList();

            for (String streamId : message.getStreamIds()) {
                if (isPermitted(STREAMS_READ, streamId)) {
                    try {
                        messageInStreams.add(streamService.get(streamId));
                    } catch (APIException e) {
                        //  We get a 404 if the stream no longer exists.
View Full Code Here

    }

    public Result single(String index, String id, Boolean filtered) {
        try {

            MessageResult message = messagesService.getMessage(index, id);

            Map<String, Object> result = Maps.newHashMap();
            result.put("id", message.getId());
            result.put("index", message.getIndex());
            if (filtered)
                result.put("fields", message.getFilteredFields());
            else
                result.put("fields", message.getFields());

            return ok(Json.toJson(result));
        } catch (IOException e) {
            return status(500);
        } catch (APIException e) {
View Full Code Here

        }
    }

    public Result analyze(String index, String id, String field) {
        try {
            MessageResult message = messagesService.getMessage(index, id);

            String analyzeField = (String) message.getFilteredFields().get(field);
            if (analyzeField == null || analyzeField.isEmpty()) {
                return status(404, "Message does not have requested field " + field);
            }

            MessageAnalyzeResult result = messagesService.analyze(index, analyzeField);
View Full Code Here

    }

    public Result recentMessage(String nodeId, String inputId, Boolean filtered) {
        try {
            Node node = nodeService.loadNode(nodeId);
            MessageResult recentlyReceivedMessage = node.getInput(inputId).getRecentlyReceivedMessage(nodeId);

            if (recentlyReceivedMessage == null) {
                return notFound();
            }

            Map<String, Object> result = Maps.newHashMap();
            result.put("id", recentlyReceivedMessage.getId());
            result.put("index", recentlyReceivedMessage.getIndex());
            if (filtered)
                result.put("fields", recentlyReceivedMessage.getFilteredFields());
            else
                result.put("fields", recentlyReceivedMessage.getFields());

            return ok(Json.toJson(result));
        } catch (IOException e) {
            return status(500);
        } catch (APIException e) {
View Full Code Here

    public Result newExtractor(String nodeId, String inputId, String extractorType, String field, String exampleIndex, String exampleId) {
        try {
            Node node = nodeService.loadNode(nodeId);
            Input input = node.getInput(inputId);
            MessageResult exampleMessage = messagesService.getMessage(exampleIndex, exampleId);
            String example = exampleMessage.getFields().get(field).toString();

            return ok(views.html.system.inputs.extractors.new_extractor.render(
                            currentUser(),
                            standardBreadcrumbs(node, input),
                            node,
View Full Code Here

        } catch (InvalidRangeParametersException e) {
            return null; // cannot happen(tm)
        }
        List<MessageResult> messages = search.search().getMessages();

        MessageResult result;
        if (messages.size() > 0) {
            return messages.get(0);
        } else {
            return null;
        }
View Full Code Here

        return 0;
    }
    public MessageResult getMessage(String index, String id) throws IOException, APIException {
        final GetMessageResponse r = api.path(routes.MessageResource().search(index, id), GetMessageResponse.class)
                .execute();
    return new MessageResult(r.message, r.index, Maps.<String, List<HighlightRange>>newHashMap(), fieldMapper);
  }
View Full Code Here

        } catch (JClassAlreadyExistsException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        final ResourceRoutesParser parser = new ResourceRoutesParser("org.graylog2.rest.resources");

        final List<RouteClass> routeClassList = parser.buildClasses();

        final RouteClassGenerator generator = new RouteClassGenerator(packagePrefix, codeModel);

        final RouterGenerator routerGenerator = new RouterGenerator(router, generator);
        routerGenerator.build(routeClassList);

        // do the same for radio resources
        JDefinedClass radioRouter = null;
        try {
            radioRouter = codeModel._class(packagePrefix + ".Radio");
        } catch (JClassAlreadyExistsException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        final ResourceRoutesParser radioParser = new ResourceRoutesParser("org.graylog2.radio.rest.resources");
        final List<RouteClass> radioRouteClassList = radioParser.buildClasses();
        final RouteClassGenerator radioGenerator = new RouteClassGenerator(packagePrefix + ".radio", codeModel);
        final RouterGenerator radioRouterGenerator = new RouterGenerator(radioRouter, radioGenerator, JMod.PUBLIC);
        radioRouterGenerator.build(radioRouteClassList);

        JMethod radioMethod = router.method(JMod.PUBLIC | JMod.STATIC, radioRouter, "radio");
View Full Code Here

TOP

Related Classes of org.graylog2.restclient.models.api.results.MessageResult

Copyright © 2018 www.massapicom. 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.