Example usage for java.net URISyntaxException getMessage

List of usage examples for java.net URISyntaxException getMessage

Introduction

In this page you can find the example usage for java.net URISyntaxException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns a string describing the parse error.

Usage

From source file:org.yaoha.ApiConnector.java

public HttpResponse closeChangeset(String changesetId) throws ClientProtocolException, IOException,
        OAuthMessageSignerException, OAuthExpectationFailedException, OAuthCommunicationException {
    URI uri = null;// w  w w . jav a 2 s. c o  m
    try {
        uri = new URI("http", apiUrl, "/api/0.6/changeset/" + changesetId + "/close", null, null);
    } catch (URISyntaxException e) {
        Log.e(ApiConnector.class.getSimpleName(), "Closing changeset " + changesetId + " failed:");
        Log.e(ApiConnector.class.getSimpleName(), e.getMessage());
    }
    HttpPut request = new HttpPut(uri);
    request.setHeader(userAgentHeader);
    consumer.sign(request);
    return client.execute(request);
}

From source file:org.adslabs.adsfulltext.Worker.java

public boolean connect() {

    ConnectionFactory rabbitMQInstance;//from   w  w  w. java2s.c o m

    // This creates a connection object, that allows connections to be open to the same
    // RabbitMQ instance running
    //
    // There seems to be a lot of catches, but each one should list the reason for it's raise
    //
    // It is not necessary to disconnect the connection, it should be dropped when the program exits
    // See the API guide for more info: https://www.rabbitmq.com/api-guide.html

    try {

        rabbitMQInstance = new ConnectionFactory();
        logger.info("Connecting to RabbitMQ instance: {}", this.config.data.RABBITMQ_URI);
        rabbitMQInstance.setUri(this.config.data.RABBITMQ_URI);
        this.connection = rabbitMQInstance.newConnection();
        this.channel = this.connection.createChannel();

        // This tells RabbitMQ not to give more than one message to a worker at a time.
        // Or, in other words, don't dispatch a new message to a worker until it has processed
        // and acknowledged the previous one.
        this.channel.basicQos(this.prefetchCount);

        return true;

    } catch (java.net.URISyntaxException error) {

        logger.error("URI error: {}", error.getMessage());
        return false;

    } catch (java.io.IOException error) {

        logger.error("IO Error, is RabbitMQ running???: {}", error.getMessage());
        return false;

    } catch (java.security.NoSuchAlgorithmException error) {

        logger.error("Most likely an SSL related error: ", error.getMessage());
        return false;

    } catch (java.security.KeyManagementException error) {

        logger.error("Most likely an SSL related error: ", error.getMessage());
        return false;

    }
}

From source file:hydrograph.ui.perspective.ApplicationWorkbenchWindowAdvisor.java

private void serviceInitiator(Properties properties) throws IOException {
    if (OSValidator.isWindows()) {
        //Updated the java classpath to include the dependent jars
        String path = "";
        try {/*from  w ww  .java2 s  .c  o  m*/
            path = Paths.get(Platform.getInstallLocation().getURL().toURI()).toString() + "\\";
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            logger.error(e.getMessage());
        }

        logger.debug(Platform.getInstallLocation().getURL().getPath());
        String command = "java -cp \"" + getInstallationConfigPath().trim() + ";" + path
                + properties.getProperty(SERVICE_DEPENDENCIES) + ";" + path
                + properties.getProperty(SERVICE_JAR) + "\" " + properties.getProperty(DRIVER_CLASS);
        logger.debug("Starting server with command - " + command);
        ProcessBuilder builder = new ProcessBuilder(new String[] { "cmd", "/c", command });
        builder.start();
    } else if (OSValidator.isMac()) {
        logger.debug("On Mac Operating System....");
        //Updated the java classpath to include the dependent jars
        String command = "java -cp " + getInstallationConfigPath().trim() + ":"
                + Platform.getInstallLocation().getURL().getPath() + properties.getProperty(SERVICE_JAR) + ":"
                + Platform.getInstallLocation().getURL().getPath()
                + properties.getProperty(SERVICE_DEPENDENCIES) + " " + properties.getProperty(DRIVER_CLASS);
        logger.debug("command{}", command);
        ProcessBuilder builder = new ProcessBuilder(new String[] { "bash", "-c", command });
        builder.start();

    } else if (OSValidator.isUnix()) {
        new ProcessBuilder(new String[] { "java", "-jar", properties.getProperty(SERVICE_JAR) }).start();
    } else if (OSValidator.isSolaris()) {
    }
}

From source file:name.richardson.james.maven.plugins.uploader.UploadMojo.java

public void execute() throws MojoExecutionException {
    this.getLog().info("Uploading project to BukkitDev");
    final String gameVersion = this.getGameVersion();
    final URIBuilder builder = new URIBuilder();
    final MultipartEntity entity = new MultipartEntity();
    HttpPost request;/*from w  w w  .ja v a  2s  . c o m*/

    // create the request
    builder.setScheme("http");
    builder.setHost("dev.bukkit.org");
    builder.setPath("/" + this.projectType + "/" + this.slug.toLowerCase() + "/upload-file.json");
    try {
        entity.addPart("file_type", new StringBody(this.getFileType()));
        entity.addPart("name", new StringBody(this.project.getArtifact().getVersion()));
        entity.addPart("game_versions", new StringBody(gameVersion));
        entity.addPart("change_log", new StringBody(this.changeLog));
        entity.addPart("known_caveats", new StringBody(this.knownCaveats));
        entity.addPart("change_markup_type", new StringBody(this.markupType));
        entity.addPart("caveats_markup_type", new StringBody(this.markupType));
        entity.addPart("file", new FileBody(this.getArtifactFile(this.project.getArtifact())));
    } catch (final UnsupportedEncodingException e) {
        throw new MojoExecutionException(e.getMessage());
    }

    // create the actual request
    try {
        request = new HttpPost(builder.build());
        request.setHeader("User-Agent", "MavenCurseForgeUploader/1.0");
        request.setHeader("X-API-Key", this.key);
        request.setEntity(entity);
    } catch (final URISyntaxException exception) {
        throw new MojoExecutionException(exception.getMessage());
    }

    this.getLog().debug(request.toString());

    // send the request and handle any replies
    try {
        final HttpClient client = new DefaultHttpClient();
        final HttpResponse response = client.execute(request);
        switch (response.getStatusLine().getStatusCode()) {
        case 201:
            this.getLog().info("File uploaded successfully.");
            break;
        case 403:
            this.getLog().error(
                    "You have not specifed your API key correctly or do not have permission to upload to that project.");
            break;
        case 404:
            this.getLog().error("Project was not found. Either it is specified wrong or been renamed.");
            break;
        case 422:
            this.getLog().error("There was an error in uploading the plugin");
            this.getLog().debug(request.toString());
            this.getLog().debug(EntityUtils.toString(response.getEntity()));
            break;
        default:
            this.getLog().warn("Unexpected response code: " + response.getStatusLine().getStatusCode());
            break;
        }
    } catch (final ClientProtocolException exception) {
        throw new MojoExecutionException(exception.getMessage());
    } catch (final IOException exception) {
        throw new MojoExecutionException(exception.getMessage());
    }

}

From source file:io.hops.hopsworks.api.zeppelin.util.ZeppelinResource.java

private FileObject[] getPidFiles(Project project) throws URISyntaxException, FileSystemException {
    ZeppelinConfig zepConf = zeppelinConfFactory.getProjectConf(project.getName());
    if (zepConf == null) {
        return new FileObject[0];
    }/*from w  w  w  .j  a v  a 2s  . c  om*/
    ZeppelinConfiguration conf = zepConf.getConf();
    URI filesystemRoot;
    FileSystemManager fsManager;
    String runPath = conf.getRelativeDir("run");
    try {
        filesystemRoot = new URI(runPath);
    } catch (URISyntaxException e1) {
        throw new URISyntaxException("Not a valid URI", e1.getMessage());
    }

    if (filesystemRoot.getScheme() == null) { // it is local path
        try {
            filesystemRoot = new URI(new File(runPath).getAbsolutePath());
        } catch (URISyntaxException e) {
            throw new URISyntaxException("Not a valid URI", e.getMessage());
        }
    }
    FileObject[] pidFiles = null;
    try {
        fsManager = VFS.getManager();
        //      pidFiles = fsManager.resolveFile(filesystemRoot.toString() + "/").
        pidFiles = fsManager.resolveFile(filesystemRoot.getPath()).getChildren();
    } catch (FileSystemException ex) {
        throw new FileSystemException("Directory not found: " + filesystemRoot.getPath(), ex.getMessage());
    }
    return pidFiles;
}

From source file:com.alibaba.shared.django.DjangoClient.java

protected URI buildURI(String baseUrl, Map<String, String> params, boolean hasAccessToken) {
    try {//from   ww w . j av a2s .c  om
        URIBuilder builder = new URIBuilder(baseUrl);
        if (hasAccessToken) {
            builder.addParameter(ACCESS_TOKEN_KEY, accessToken());
        }
        for (String paramName : params.keySet()) {
            builder.addParameter(paramName, params.get(paramName));
        }
        return builder.build();
    } catch (URISyntaxException e) {
        throw new DjangoRequestException(e.getMessage(), e);
    }
}

From source file:com.aurel.track.util.LdapUtil.java

/**
 * Gets the base URL from a complete URL (possibly with dn)
 * //from w w w. j  a  va2 s. com
 * @param ldapServerURL
 * @return
 */
public static String getBaseURL(String ldapServerURL) {
    String baseURL = null;
    URI uri = null;
    try {
        uri = new URI(ldapServerURL);
    } catch (URISyntaxException e) {
        LOGGER.warn("Creating an URI from " + ldapServerURL + " failed with " + e.getMessage());
    }
    if (uri != null) {
        // uri.get
        baseURL = uri.getScheme() + "://" + uri.getHost();
        int port = uri.getPort();
        if (port > 0) {
            baseURL += ":" + uri.getPort();
        }
        baseURL += "/";
        LOGGER.debug("Base url from " + ldapServerURL + " is " + baseURL);
    }
    return baseURL;
}

From source file:org.apache.sling.etcd.client.impl.EtcdClientImpl.java

@Nonnull
private URI buildUri(@Nonnull URI endpoint, @Nonnull String path, @Nonnull Map<String, String> parameters) {
    try {//w  w w.  ja  va 2s  .co  m
        URIBuilder builder = new URIBuilder();
        for (Map.Entry<String, String> p : parameters.entrySet()) {
            builder.setParameter(p.getKey(), p.getValue());
        }
        return builder.setScheme(endpoint.getScheme()).setHost(endpoint.getHost()).setPort(endpoint.getPort())
                .setPath(path).build();
    } catch (URISyntaxException e) {
        throw new EtcdException(e.getMessage(), e);
    }
}

From source file:org.yql4j.YqlQuery.java

/**
 * Returns a newly constructed URI for this query.
 * //from  w  w  w .j  av  a  2  s . c om
 * @return the URI
 */
private URI compileUri() {
    try {
        boolean oAuth = (consumerKey != null) && (consumerSecret != null);
        boolean aliasQuery = queryString == null;

        String baseUri = oAuth ? QUERY_URL_OAUTH : QUERY_URL_PUBLIC;
        if (aliasQuery) {
            baseUri += "/" + aliasPrefix + "/" + aliasName;
        }
        URIBuilder builder = new URIBuilder(baseUri);

        // Set parameters
        builder.addParameter("diagnostics", Boolean.toString(diagnostics));
        for (String env : environmentFiles) {
            builder.addParameter("env", env);
        }
        if (format != null) {
            builder.addParameter("format", format.name().toLowerCase());
        }
        if (!aliasQuery) {
            String useTablesPrefix = "";
            for (Entry<String, String> entry : tableFiles.entrySet()) {
                useTablesPrefix += "USE '" + entry.getKey() + "' AS " + entry.getValue() + "; ";
            }
            builder.addParameter("q", useTablesPrefix + queryString);
        }
        for (Entry<String, String> varDef : variables.entrySet()) {
            builder.addParameter(varDef.getKey(), varDef.getValue());
        }

        return builder.build();
    } catch (URISyntaxException e) {
        logger.error(e.getMessage(), e);
        return null;
    }
}

From source file:de.vandermeer.skb.datatool.commons.DataSet.java

/**
 * Loads a data set from file system, does many consistency checks as well.
 * @param fsl list of files to load data from
 * @param fileExt the file extension used (translated to "." + fileExt + ".json"), empty if none used
 * @return 0 on success, larger than zero on JSON parsing error (number of found errors)
 *//*from  w  w w .j a  va 2  s  . co  m*/
@SuppressWarnings("unchecked")
public int load(List<FileSource> fsl, String fileExt) {
    int ret = 0;
    String commonPath = this.calcCommonPath(fsl);

    for (FileSource fs : fsl) {
        String keyStart = this.calcKeyStart(fs, commonPath);
        ObjectMapper om = new ObjectMapper();
        om.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        try {
            List<Map<String, Object>> jsonList = om.readValue(fs.asFile(),
                    new TypeReference<ArrayList<HashMap<String, Object>>>() {
                    });
            for (Map<String, Object> entryMap : jsonList) {
                E entry = this.factory.newInstanceLoaded(keyStart, entryMap);
                if (entry.getKey().contains("#dummy")) {
                    continue;
                }

                String dup = entry.testDuplicate((Collection<DataEntry>) this.entries.values());
                if (this.entries.containsKey(entry.getKey())) {
                    Skb_Console.conError("{}: duplicate key <{}> found in file <{}>",
                            new Object[] { this.cs.getAppName(), entry.getKey(), fs.getAbsoluteName() });
                } else if (dup != null) {
                    Skb_Console.conError("{}: entry already in map: k1 <{}> <> k2 <{}> found in file <{}>",
                            new Object[] { this.cs.getAppName(), dup, entry.getKey(), fs.getAbsoluteName() });
                } else {
                    if (this.excluded == null
                            || (!ArrayUtils.contains(this.excluded, entry.getCompareString()))) {
                        this.entries.put(entry.getKey(), (E) entry);
                    }
                }
            }
            this.files++;
        } catch (IllegalArgumentException iaex) {
            Skb_Console.conError("{}: problem creating entry: <{}> in file <{}>",
                    new Object[] { this.cs.getAppName(), iaex.getMessage(), fs.getAbsoluteName() });
            ret++;
        } catch (URISyntaxException ue) {
            Skb_Console.conError("{}: problem creating a URI for a link: <{}> in file <{}>",
                    new Object[] { this.cs.getAppName(), ue.getMessage(), fs.getAbsoluteName() });
            ret++;
        } catch (NullPointerException npe) {
            npe.printStackTrace();
            ret++;
        } catch (Exception ex) {
            Skb_Console.conError(
                    "reading acronym from JSON failed with exception <{}>, cause <{}> and message <{}> in file <{}>",
                    new Object[] { ex.getClass().getSimpleName(), ex.getCause(), ex.getMessage(),
                            fs.getAbsoluteName() });
            ret++;
        }
    }

    return ret;
}