@Override public void connect() throws IOException { Preconditions.checkState(is == null, "Already connected"); try { LOG.debug("Connecting to {}", url); FileSystem fs = FileSystem.get(url.toURI(), conf); is = fs.open(new Path(url.toURI())); } catch (URISyntaxException e) { throw new IOException(e.toString()); } }
public String currentLocalPath() { try { File jarLocation = new File(CommonProxyUtilities.class.getProtectionDomain().getCodeSource() .getLocation().toURI().getPath()); return jarLocation.getParent(); } catch (URISyntaxException e) { LOG.error(e.toString(), e); } return null; }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); try { parseURI(string, false); } catch (URISyntaxException e) { throw new IOException(e.toString()); } }
/** * Allows a processor to accept relative resource paths. * For example, to produce the output value {@code net/nowhere/lib/icon.png} * given an element in the package {@code net.nowhere.app}, the following inputs are permitted: * <ul> * <li>{@code ../lib/icon.png} * <li>{@code /net/nowhere/lib/icon.png} * </ul> * @param originatingElement the annotated element, used for its package * @param resource a possibly relative resource path * @return an absolute resource path (with no leading slash) * @throws LayerGenerationException in case the resource path is malformed * @since 7.51 */ public static String absolutizeResource(Element originatingElement, String resource) throws LayerGenerationException { if (resource.startsWith("/")) { return resource.substring(1); } else { try { return new URI(null, findPackage(originatingElement).replace('.', '/') + "/", null).resolve(new URI(null, resource, null)).getPath(); } catch (URISyntaxException x) { throw new LayerGenerationException(x.toString(), originatingElement); } } } private static String findPackage(Element e) {
@Override protected List<PathData> expandArgument(String arg) throws IOException { List<PathData> items = new LinkedList<PathData>(); if (arg.equals("-")) { readStdin = true; } else { try { items.add(new PathData(new URI(arg), getConf())); } catch (URISyntaxException e) { if (Path.WINDOWS) { // Unlike URI, PathData knows how to parse Windows drive-letter paths. items.add(new PathData(arg, getConf())); } else { throw new IOException("Unexpected URISyntaxException: " + e.toString()); } } } return items; }
compilationUnit.getErrorCollector().addWarning( WarningMessage.POSSIBLE_ERRORS, "Failed to parse URL as URI because of exception " + e.toString(), null, null);
private String normalize(String theValue) { if (theValue == null) { return null; } URI retVal; try { retVal = new URI(theValue).normalize(); String urlString = retVal.toString(); if (urlString.endsWith("/") && urlString.length() > 1) { retVal = new URI(urlString.substring(0, urlString.length() - 1)); } } catch (URISyntaxException e) { ourLog.debug("Failed to normalize URL '{}', message was: {}", theValue, e.toString()); return theValue; } return retVal.toASCIIString(); }
public XMLLexicon() { try { URL defaultLexicon = this.getClass().getClassLoader().getResource("default-lexicon.xml"); if(null != defaultLexicon) { createLexicon(defaultLexicon.toURI()); } else { createLexicon(this.getClass().getResource( "/simplenlg/lexicon/default-lexicon.xml").toURI()); } } catch (URISyntaxException ex) { System.out.println(ex.toString()); } }
public KVMStoragePool getStoragePoolByURI(String uri) { URI storageUri = null; try { storageUri = new URI(uri); } catch (URISyntaxException e) { throw new CloudRuntimeException(e.toString()); } String sourcePath = null; String uuid = null; String sourceHost = ""; StoragePoolType protocol = null; if (storageUri.getScheme().equalsIgnoreCase("nfs") || storageUri.getScheme().equalsIgnoreCase("NetworkFilesystem")) { sourcePath = storageUri.getPath(); sourcePath = sourcePath.replace("//", "/"); sourceHost = storageUri.getHost(); uuid = UUID.nameUUIDFromBytes(new String(sourceHost + sourcePath).getBytes()).toString(); protocol = StoragePoolType.NetworkFilesystem; } // secondary storage registers itself through here return createStoragePool(uuid, sourceHost, 0, sourcePath, "", protocol, false); }
Log.e(TAG, e.toString()); e.printStackTrace();
/** @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String) */ public void startPrefixMapping(String prefix, String targ) throws SAXException { logger.finest("Target == '" + targ + "'"); try { URI tns = new URI(targ); Schema s = SchemaFactory.getInstance(tns); if (s == null) { prefixURIs.put(prefix, tns); return; } if ((prefix == null) || "".equalsIgnoreCase(prefix)) { defaultNS = s.getTargetNamespace(); } targSchemas.put(s.getTargetNamespace(), s); prefixURIs.put(prefix, tns); } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e); } }
tns = new URI(targ); } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e);
this.targetNamespace = new URI(targetNamespace1); } catch (URISyntaxException e) { logger.warning(e.toString()); throw new SAXException(e);
: instanceDocument.resolve(uri); } catch (URISyntaxException e1) { logger.warning(e1.toString());
return new PrepareForMigrationAnswer(command, e.toString()); } catch (final URISyntaxException e) { return new PrepareForMigrationAnswer(command, e.toString()); } finally { if (!skipDisconnect) {
@Override public Answer attachIso(final AttachCommand cmd) { final DiskTO disk = cmd.getDisk(); final TemplateObjectTO isoTO = (TemplateObjectTO)disk.getData(); final DataStoreTO store = isoTO.getDataStore(); try { String dataStoreUrl = getDataStoreUrlFromStore(store); final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); attachOrDetachISO(conn, cmd.getVmName(), dataStoreUrl + File.separator + isoTO.getPath(), true); } catch (final LibvirtException e) { return new Answer(cmd, false, e.toString()); } catch (final URISyntaxException e) { return new Answer(cmd, false, e.toString()); } catch (final InternalErrorException e) { return new Answer(cmd, false, e.toString()); } catch (final InvalidParameterValueException e) { return new Answer(cmd, false, e.toString()); } return new Answer(cmd); }
@Override public Answer dettachIso(final DettachCommand cmd) { final DiskTO disk = cmd.getDisk(); final TemplateObjectTO isoTO = (TemplateObjectTO)disk.getData(); final DataStoreTO store = isoTO.getDataStore(); try { String dataStoreUrl = getDataStoreUrlFromStore(store); final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); attachOrDetachISO(conn, cmd.getVmName(), dataStoreUrl + File.separator + isoTO.getPath(), false); } catch (final LibvirtException e) { return new Answer(cmd, false, e.toString()); } catch (final URISyntaxException e) { return new Answer(cmd, false, e.toString()); } catch (final InternalErrorException e) { return new Answer(cmd, false, e.toString()); } catch (final InvalidParameterValueException e) { return new Answer(cmd, false, e.toString()); } return new Answer(cmd); }