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:eumetsat.pn.elasticsearch.ElasticsearchFeeder.java

public static void main(String[] args) throws IOException {
    try {/*from   w  w w.  j a  v a2 s.c om*/
        URI configuration = ISO2JSON.class.getResource("/feeder-log4j2.xml").toURI();
        Configurator.initialize("eumetsat.pn", null, configuration);
    } catch (URISyntaxException e) {
        log.error("Could not configure logging: {}", e.getMessage());
    }

    ISO2JSON transformer = new ElasticsearchFeeder();
    transformer.transformAndIndex();

    log.info("Finished.");
}

From source file:eumetsat.pn.solr.SolrFeeder.java

public static void main(String[] args) throws IOException {
    try {//from   www . j a va 2  s .  c  o m
        URI configuration = ISO2JSON.class.getResource("/feeder-log4j2.xml").toURI();
        Configurator.initialize("eumetsat.pn", null, configuration);
    } catch (URISyntaxException e) {
        log.error("Could not configure logging: {}", e.getMessage());
    }

    ISO2JSON transformer = new SolrFeeder();
    transformer.transformAndIndex();

    log.info("Finished.");
}

From source file:edu.usc.goffish.gofs.tools.GoFSFormat.java

public static void main(String[] args) throws IOException {
    if (args.length < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);//from   www .j a v a2s .  c o m
    }

    if (args.length == 1 && args[0].equals("-help")) {
        PrintUsageAndQuit(null);
    }

    Path executableDirectory;
    try {
        executableDirectory = Paths
                .get(GoFSFormat.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getParent();
    } catch (URISyntaxException e) {
        throw new RuntimeException("Unexpected error retrieving executable location", e);
    }
    Path configPath = executableDirectory.resolve(DEFAULT_CONFIG).normalize();

    boolean copyBinaries = false;

    // parse optional arguments
    int i = 0;
    OptArgLoop: for (i = 0; i < args.length - REQUIRED_ARGS; i++) {
        switch (args[i]) {
        case "-config":
            i++;

            try {
                configPath = Paths.get(args[i]);
            } catch (InvalidPathException e) {
                PrintUsageAndQuit("Config file - " + e.getMessage());
            }

            break;
        case "-copyBinaries":
            copyBinaries = true;
            break;
        default:
            break OptArgLoop;
        }
    }

    if (args.length - i < REQUIRED_ARGS) {
        PrintUsageAndQuit(null);
    }

    // finished parsing args
    if (i < args.length) {
        PrintUsageAndQuit("Unrecognized argument \"" + args[i] + "\"");
    }

    // parse config

    System.out.println("Parsing config...");

    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setDelimiterParsingDisabled(true);
    try {
        config.load(Files.newInputStream(configPath));
    } catch (ConfigurationException e) {
        throw new IOException(e);
    }

    // retrieve data nodes
    ArrayList<URI> dataNodes;
    {
        String[] dataNodesArray = config.getStringArray(GOFS_DATANODES_KEY);
        if (dataNodesArray.length == 0) {
            throw new ConversionException("Config must contain key " + GOFS_DATANODES_KEY);
        }

        dataNodes = new ArrayList<>(dataNodesArray.length);

        if (dataNodesArray.length == 0) {
            throw new ConversionException("Config key " + GOFS_DATANODES_KEY
                    + " has invalid format - must define at least one data node");
        }

        try {
            for (String node : dataNodesArray) {
                URI dataNodeURI = new URI(node);

                if (!"file".equalsIgnoreCase(dataNodeURI.getScheme())) {
                    throw new ConversionException("config key " + GOFS_DATANODES_KEY + " value \"" + dataNodeURI
                            + "\" has invalid format - data node urls must have 'file' scheme");
                } else if (dataNodeURI.getPath() == null || dataNodeURI.getPath().isEmpty()) {
                    throw new ConversionException("config key " + GOFS_DATANODES_KEY + " value \"" + dataNodeURI
                            + "\" has invalid format - data node urls must have an absolute path specified");
                }

                // ensure uri ends with a slash, so we know it is a directory
                if (!dataNodeURI.getPath().endsWith("/")) {
                    dataNodeURI = dataNodeURI.resolve(dataNodeURI.getPath() + "/");
                }

                dataNodes.add(dataNodeURI);
            }
        } catch (URISyntaxException e) {
            throw new ConversionException(
                    "Config key " + GOFS_DATANODES_KEY + " has invalid format - " + e.getMessage());
        }
    }

    // validate serializer type
    Class<? extends ISliceSerializer> serializerType;
    {
        String serializerTypeName = config.getString(GOFS_SERIALIZER_KEY);
        if (serializerTypeName == null) {
            throw new ConversionException("Config must contain key " + GOFS_SERIALIZER_KEY);
        }

        try {
            serializerType = SliceSerializerProvider.loadSliceSerializerType(serializerTypeName);
        } catch (ReflectiveOperationException e) {
            throw new ConversionException(
                    "Config key " + GOFS_SERIALIZER_KEY + " has invalid format - " + e.getMessage());
        }
    }

    // retrieve name node
    IInternalNameNode nameNode;
    try {
        nameNode = NameNodeProvider.loadNameNodeFromConfig(config, GOFS_NAMENODE_TYPE_KEY,
                GOFS_NAMENODE_LOCATION_KEY);
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException("Unable to load name node", e);
    }

    System.out.println("Contacting name node...");

    // validate name node
    if (!nameNode.isAvailable()) {
        throw new IOException("Name node at " + nameNode.getURI() + " is not available");
    }

    System.out.println("Contacting data nodes...");

    // validate data nodes
    for (URI dataNode : dataNodes) {
        // only attempt ssh if host exists
        if (dataNode.getHost() != null) {
            try {
                SSHHelper.SSH(dataNode, "true");
            } catch (IOException e) {
                throw new IOException("Data node at " + dataNode + " is not available", e);
            }
        }
    }

    // create temporary directory
    Path workingDir = Files.createTempDirectory("gofs_format");
    try {
        // create deploy directory
        Path deployDirectory = Files.createDirectory(workingDir.resolve(DATANODE_DIR_NAME));

        // create empty slice directory
        Files.createDirectory(deployDirectory.resolve(DataNode.DATANODE_SLICE_DIR));

        // copy binaries
        if (copyBinaries) {
            System.out.println("Copying binaries...");
            FileUtils.copyDirectory(executableDirectory.toFile(),
                    deployDirectory.resolve(executableDirectory.getFileName()).toFile());
        }

        // write config file
        Path dataNodeConfigFile = deployDirectory.resolve(DataNode.DATANODE_CONFIG);
        try {
            // create config for every data node and scp deploy folder into place
            for (URI dataNodeParent : dataNodes) {
                URI dataNode = dataNodeParent.resolve(DATANODE_DIR_NAME);

                PropertiesConfiguration datanode_config = new PropertiesConfiguration();
                datanode_config.setDelimiterParsingDisabled(true);
                datanode_config.setProperty(DataNode.DATANODE_INSTALLED_KEY, true);
                datanode_config.setProperty(DataNode.DATANODE_NAMENODE_TYPE_KEY,
                        config.getString(GOFS_NAMENODE_TYPE_KEY));
                datanode_config.setProperty(DataNode.DATANODE_NAMENODE_LOCATION_KEY,
                        config.getString(GOFS_NAMENODE_LOCATION_KEY));
                datanode_config.setProperty(DataNode.DATANODE_LOCALHOSTURI_KEY, dataNode.toString());

                try {
                    datanode_config.save(Files.newOutputStream(dataNodeConfigFile));
                } catch (ConfigurationException e) {
                    throw new IOException(e);
                }

                System.out.println("Formatting data node " + dataNode.toString() + "...");

                // scp everything into place on the data node
                SCPHelper.SCP(deployDirectory, dataNodeParent);

                // update name node
                nameNode.addDataNode(dataNode);
            }

            // update name node
            nameNode.setSerializer(serializerType);
        } catch (Exception e) {
            System.out.println(
                    "ERROR: data node formatting interrupted - name node and data nodes are in an inconsistent state and require clean up");
            throw e;
        }

        System.out.println("GoFS format complete");

    } finally {
        FileUtils.deleteQuietly(workingDir.toFile());
    }
}

From source file:com.xx_dev.apn.proxy.utils.HostNamePortUtil.java

public static String getHostName(HttpRequest httpRequest) {
    String originalHostHeader = httpRequest.headers().get(HttpHeaders.Names.HOST);

    if (StringUtils.isBlank(originalHostHeader) && httpRequest.getMethod().equals(HttpMethod.CONNECT)) {
        originalHostHeader = httpRequest.getUri();
    }/*from ww  w  . j  a va2s  . co  m*/

    if (StringUtils.isNotBlank(originalHostHeader)) {
        String originalHost = StringUtils.split(originalHostHeader, ": ")[0];
        return originalHost;
    } else {
        String uriStr = httpRequest.getUri();
        try {
            URI uri = new URI(uriStr);

            String schema = uri.getScheme();

            String originalHost = uri.getHost();

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

From source file:com.blackducksoftware.integration.jira.common.HubUrlParser.java

public static String getRelativeUrl(final String url) throws HubIntegrationException {
    if (url == null) {
        return null;
    }/*ww  w .  j  ava 2 s .  c  o m*/
    try {
        final String baseUrl = getBaseUrl(url);
        final URI baseUri = new URI(baseUrl);
        final URI origUri = new URI(url);
        final URI relativeUri = baseUri.relativize(origUri);
        return relativeUri.toString();
    } catch (URISyntaxException e) {
        throw new HubIntegrationException("Invalid URI syntax exception on " + url + ": " + e.getMessage());
    }
}

From source file:org.edgexfoundry.EdgeXConfigWatcherApplication.java

public static void registerWatcher(List<CatalogService> services, String notificationPath) {
    try (CloseableHttpAsyncClient httpClient = HttpAsyncClients.createDefault();) {
        httpClient.start();/*from   ww w. java  2  s  . com*/
        for (CatalogService service : services) {
            LOGGER.info("Attempting registration of {} to: {}", service.getServiceName(), notificationPath);
            URL serviceNotificationURL = new URL(notificationProtocol, service.getAddress(),
                    service.getServicePort(), notificationPath);
            HttpGet request = new HttpGet(serviceNotificationURL.toURI());
            Future<HttpResponse> future = httpClient.execute(request, null);
            future.get();
            LOGGER.info("Registered {} @ {}", service.getServiceName(), notificationPath);
        }
    } catch (URISyntaxException e) {
        LOGGER.error("URI Syntax issue: " + e.getMessage());
    } catch (InterruptedException e) {
        LOGGER.error("Interrupted process: " + e.getMessage());
        Thread.currentThread().interrupt();
    } catch (ExecutionException e) {
        LOGGER.error("Execution problem: " + e.getMessage());
    } catch (IOException e) {
        LOGGER.error("IO problem: " + e.getMessage());
    }
}

From source file:cool.pandora.modeller.ui.handlers.iiif.PatchSequenceHandler.java

private static URI getDestinationURI(final Map<String, BagInfoField> map) {
    final URIResolver uriResolver;
    try {/*from  ww  w  .  j ava2s  .c  om*/
        uriResolver = URIResolver.resolve().map(map).containerKey(ProfileOptions.SEQUENCE_CONTAINER_KEY)
                .resource("normal").pathType(5).build();
        return uriResolver.render();
    } catch (URISyntaxException e) {
        log.debug(e.getMessage());
    }
    return null;
}

From source file:cool.pandora.modeller.ui.handlers.text.CreateWordsHandler.java

private static URI getWordObjectURI(final Map<String, BagInfoField> map, final String resourceID) {
    final URIResolver uriResolver;
    try {//from  w ww . ja v  a  2s .  c  o  m
        uriResolver = URIResolver.resolve().map(map).containerKey(ProfileOptions.TEXT_WORD_CONTAINER_KEY)
                .resource(resourceID).pathType(5).build();
        return uriResolver.render();
    } catch (final URISyntaxException e) {
        log.debug(e.getMessage());
    }
    return null;
}

From source file:cool.pandora.modeller.ui.handlers.text.CreateWordsHandler.java

/**
 * getWordContainerURI./* ww w .j  a  v a  2  s  . co  m*/
 *
 * @param map Map
 * @return String
 */
public static URI getWordContainerURI(final Map<String, BagInfoField> map) {
    final URIResolver uriResolver;
    try {
        uriResolver = URIResolver.resolve().map(map).containerKey(ProfileOptions.TEXT_WORD_CONTAINER_KEY)
                .pathType(4).build();
        return uriResolver.render();
    } catch (final URISyntaxException e) {
        log.debug(e.getMessage());
    }
    return null;
}

From source file:com.splicemachine.derby.impl.load.ImportUtils.java

public static DistributedFileSystem getFileSystem(String path) throws StandardException {
    try {// ww  w  .  j  a va 2s.  c  o m
        return SIDriver.driver().getSIEnvironment().fileSystem(path);
    } catch (URISyntaxException e) {
        throw StandardException.newException(SQLState.FILESYSTEM_URI_EXCEPTION, e.getMessage());
    } catch (Exception ioe) { // Runtime is added to handle Amazon S3 Issues
        throw StandardException.newException(SQLState.FILESYSTEM_IO_EXCEPTION, ioe.getMessage());
    }
}