Projects >> sumo-java-client >>5b44d63f26c44d2a32c39b958c7e462d0656462a

Chunk
Conflicting content
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.sumologic.client.model.LogMessage;
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
import com.sumologic.client.model.SearchRequest;
import com.sumologic.client.model.SearchResponse;
=======
import com.sumologic.client.model.SearchQuery;
import com.sumologic.client.model.SearchResult;
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
Solution content
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.JsonParser;
import com.sumologic.client.model.LogMessage;
import com.sumologic.client.model.SearchRequest;
import com.sumologic.client.model.SearchResponse;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
import java.io.*;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
import java.net.URL;
import java.util.HashMap;
=======
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java

/**
 * The sumo client implementation.
Solution content
import java.io.*;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;

/**
 * The sumo client implementation.
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
    }

    /**
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
     * Sets a custom Sumo Logic API url, i.e.,
     * different from https://api.sumologic.com
=======
     * Sets the flag indicating whether https should be
     * used for connecting to the web-service.
     * 

*

Note: This method resets the server * port to a default value (80/443).

>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java * * @param urlString The custom sumo logic api URL * @throws MalformedURLException On URL syntax error
Solution content
    }

    /**
     * Sets a custom Sumo Logic API url, i.e.,
     * different from https://api.sumologic.com
     *
     * @param urlString The custom sumo logic api URL
     * @throws MalformedURLException On URL syntax error
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Comment
Chunk
Conflicting content
     * @param urlString The custom sumo logic api URL
     * @throws MalformedURLException On URL syntax error
     */
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
    public void setURL(String urlString) throws MalformedURLException {
        URL url = new URL(urlString);
        this.hostname = url.getHost();
        this.port = (url.getPort() == -1) ?
                (url.getDefaultPort() == -1 ? 80 : url.getDefaultPort()) : url.getPort();
        this.protocol = url.getProtocol();
=======
    public void setUseHTTPs(boolean useHTTPs) {
        this.useHTTPs = useHTTPs;
        if (this.useHTTPs) port = 443;
        else port = 80;
    }

    /**
     * Sets the HTTP(s) port of sumo's log web service.
     *
     * @param port The HTTP(s) port.
     */
    public void setPort(int port) {
        this.port = port;
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java
    }

    /**
Solution content
     * @param urlString The custom sumo logic api URL
     * @throws MalformedURLException On URL syntax error
     */
    public void setURL(String urlString) throws MalformedURLException {
        URL url = new URL(urlString);
        this.hostname = url.getHost();
        this.port = (url.getPort() == -1) ?
                (url.getDefaultPort() == -1 ? 80 : url.getDefaultPort()) : url.getPort();
        this.protocol = url.getProtocol();
    }

    /**
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Attribute
Comment
Method declaration
Method invocation
Method signature
Variable
Chunk
Conflicting content
        // Try to issue query
        HttpGet searchGetMethod = null;
        InputStream httpStream = null;
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
        JsonParser jp = null;
        SearchResponse searchResponse = null;
        try {
            // Issue http get request
            searchGetMethod = new HttpGet(
                    URIUtils.createURI(
                            protocol,
                            hostname + ":" + port,
                            -1,
                            "/" + UrlParameters.API_SERVICE +
                                    "/" + UrlParameters.VERSION_PREFIX + "1" +
                                    "/" + UrlParameters.LOGS_SERVICE +
                                    "/" + UrlParameters.SEARCH,
                            request.toString(),
                            null
                    )
=======
        try {
            // Issue http get request
            searchGetMethod = new HttpGet(
                URIUtils.createURI(
                    useHTTPs ? "https" : "http",
                    hostname + (((port != 443 && useHTTPs) || (port != 80 && !useHTTPs)) ? ":" + port : ""),
                    -1,
                    "/" + Headers.API_SERVICE +
                            "/" + Headers.VERSION_PREFIX + "1" +
                            "/" + Headers.LOGS_SERVICE +
                            "/" + Headers.SEARCH,
                    query.toString(),
                    null
                )
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java
            );
            HttpResponse response = httpClient.execute(searchGetMethod);
            HttpEntity entity = response.getEntity();
Solution content
        // Try to issue query
        HttpGet searchGetMethod = null;
        InputStream httpStream = null;
        JsonParser jp = null;
        SearchResponse searchResponse = null;
        try {
            // Issue http get request
            searchGetMethod = new HttpGet(
                    URIUtils.createURI(
                            protocol,
                            hostname + ":" + port,
                            -1,
                            "/" + UrlParameters.API_SERVICE +
                                    "/" + UrlParameters.VERSION_PREFIX + "1" +
                                    "/" + UrlParameters.LOGS_SERVICE +
                                    "/" + UrlParameters.SEARCH,
                            request.toString(),
                            null
                    )

            );
            HttpResponse response = httpClient.execute(searchGetMethod);
            HttpEntity entity = response.getEntity();
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Comment
Method invocation
Try statement
Variable
Chunk
Conflicting content
            if (response.getStatusLine().getStatusCode() == 200) {

                // Parse all JSON records
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
                searchResponse = new SearchResponse(request);
                jp = jsonFactory.createJsonParser(httpStream);
                if (jp.nextToken() != JsonToken.START_ARRAY) {
                    return searchResponse;
                }
                while (jp.nextToken() == JsonToken.START_OBJECT) {
                    HashMap map = new HashMap();
=======
                SearchResult searchResult = new SearchResult(query);
                JsonParser jp = jsonFactory.createJsonParser(httpStream);
                if  (jp.nextToken() != JsonToken.START_ARRAY) {
                    return searchResult;
                }
                while (jp.nextToken() == JsonToken.START_OBJECT) {
                    LogMessage msg = new LogMessage();
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java
                    while (jp.nextToken() != JsonToken.END_OBJECT) {
                        String key = jp.getCurrentName();
                        jp.nextToken();
Solution content
            if (response.getStatusLine().getStatusCode() == 200) {

                // Parse all JSON records
                searchResponse = new SearchResponse(request);
                jp = jsonFactory.createJsonParser(httpStream);
                if (jp.nextToken() != JsonToken.START_ARRAY) {
                    return searchResponse;
                }
                while (jp.nextToken() == JsonToken.START_OBJECT) {
                    HashMap map = new HashMap();
                    while (jp.nextToken() != JsonToken.END_OBJECT) {
                        String key = jp.getCurrentName();
                        jp.nextToken();
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
If statement
Method invocation
Variable
While statement
Chunk
Conflicting content
                        String key = jp.getCurrentName();
                        jp.nextToken();
                        String value = jp.getText();
<<<<<<< HEAD:src/main/java/com/sumologic/client/SumoLogicClient.java
                        map.put(key, value);
                    }
                    searchResponse.getMessages().add( new LogMessage(map) );
=======
                        msg.getInternalMap().put(key, value);
                    }
                    searchResult.getMessages().add(msg);
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/SumoClient.java
                }
            }
Solution content
                        String key = jp.getCurrentName();
                        jp.nextToken();
                        String value = jp.getText();
                        map.put(key, value);
                    }
                    searchResponse.getMessages().add(new LogMessage(map));
                }
            }
File
SumoLogicClient.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Chunk
Conflicting content
package com.sumologic.client.model;

<<<<<<< HEAD:src/main/java/com/sumologic/client/model/LogMessage.java
import com.sumologic.client.UrlParameters;
=======
import com.sumologic.client.Headers;
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/model/LogMessage.java

import java.util.Date;
import java.util.HashMap;
Solution content
package com.sumologic.client.model;

import com.sumologic.client.UrlParameters;
import java.util.Date;
import java.util.HashMap;
File
LogMessage.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
     *
     * @param map The fields of the log message.
     */
<<<<<<< HEAD:src/main/java/com/sumologic/client/model/LogMessage.java
    public LogMessage(HashMap map) {
=======
    public LogMessage( HashMap map ) {
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/model/LogMessage.java
        this.map = map;
    }
Solution content
     *
     * @param map The fields of the log message.
     */
    public LogMessage( HashMap map ) {
        this.map = map;
    }
File
LogMessage.java
Developer's decision
Version 1
Kind of conflict
Method signature
Chunk
Conflicting content
        }
        return URLEncodedUtils.format(params, "UTF-8");
    }
<<<<<<< HEAD:src/main/java/com/sumologic/client/model/SearchRequest.java
=======

    private String query = "*";
    private Date fromTime = null;
    private Date toTime = null;
    private long limit = 0;
    private long offset = 0;
    private SearchOrder order = SearchOrder.DEFAULT;
    private String timeZone = "";
>>>>>>> bf0a475a2a7ffa34cf7e3eed9e6fedddb0fb5460:src/main/java/com/sumologic/client/model/SearchQuery.java
}
Solution content
        }
        return URLEncodedUtils.format(params, "UTF-8");
    }
}
File
SearchRequest.java
Developer's decision
Version 1
Kind of conflict
Attribute