List of usage examples for java.net URI getSchemeSpecificPart
public String getSchemeSpecificPart()
From source file:org.n52.sos.web.JdbcUrl.java
protected final void parse(String string) throws URISyntaxException { URI uri = new URI(string); scheme = uri.getScheme();/*from w w w.j av a 2s . co m*/ uri = new URI(uri.getSchemeSpecificPart()); type = uri.getScheme(); host = uri.getHost(); port = uri.getPort(); String[] path = uri.getPath().split(SLASH_STRING); if (path.length == 1 && !path[0].isEmpty()) { database = path[0]; } else if (path.length == 2 && path[0].isEmpty() && !path[1].isEmpty()) { database = path[1]; } for (NameValuePair nvp : URLEncodedUtils.parse(uri, "UTF-8")) { if (nvp.getName().equals(QUERY_PARAMETER_USER)) { user = nvp.getValue(); } else if (nvp.getName().equals(QUERY_PARAMETER_PASSWORD)) { password = nvp.getValue(); } } }
From source file:nl.mpi.lamus.workspace.factory.implementation.LamusWorkspaceNodeFactory.java
/** * @see WorkspaceNodeFactory#getNewExternalNode(int, java.net.URI) *//*from w ww .j a v a 2 s. c om*/ @Override public WorkspaceNode getNewExternalNode(int workpaceID, URI originURI) { WorkspaceNode node = new LamusWorkspaceNode(); node.setWorkspaceID(workpaceID); String uriSchemeSpecificPart = originURI.getSchemeSpecificPart(); String nameToUse; if (!uriSchemeSpecificPart.endsWith(File.separator)) { nameToUse = FilenameUtils.getName(uriSchemeSpecificPart); } else { nameToUse = FilenameUtils .getName(uriSchemeSpecificPart.substring(0, uriSchemeSpecificPart.length() - 1)); } node.setName(nameToUse); node.setTitle(nameToUse); node.setOriginURI(originURI); node.setType(WorkspaceNodeType.UNKNOWN); node.setStatus(WorkspaceNodeStatus.EXTERNAL); node.setProtected(false); return node; }
From source file:org.eel.kitchen.jsonschema.ref.JsonRef.java
/** * Main constructor, {@code protected} by design * * @param uri the URI to build that reference *//* w w w.j av a 2 s .c om*/ protected JsonRef(final URI uri) { final String scheme = uri.getScheme(); final String ssp = uri.getSchemeSpecificPart(); final String uriFragment = uri.getFragment(); final String realFragment = uriFragment == null ? "" : uriFragment; try { this.uri = new URI(scheme, ssp, realFragment); locator = new URI(scheme, ssp, ""); fragment = JsonFragment.fromFragment(realFragment); asString = this.uri.toString(); hashCode = asString.hashCode(); } catch (URISyntaxException e) { throw new RuntimeException("WTF??", e); } }
From source file:com.nesscomputing.service.discovery.client.ServiceURI.java
public ServiceURI(final URI uri) throws URISyntaxException { if (!"srvc".equals(uri.getScheme())) { throw new URISyntaxException(uri.toString(), "ServiceURI only supports srvc:// URIs"); }/*from ww w. j a v a2s .com*/ if (!StringUtils.startsWith(uri.getSchemeSpecificPart(), "//")) { throw new URISyntaxException(uri.toString(), "ServiceURI only supports srvc:// URIs"); } final String schemeSpecificPart = uri.getSchemeSpecificPart().substring(2); final int slashIndex = schemeSpecificPart.indexOf('/'); if (slashIndex == -1) { throw new URISyntaxException(uri.toString(), "ServiceURI requires a slash at the end of the service!"); } final int colonIndex = schemeSpecificPart.indexOf(':'); if (colonIndex == -1 || colonIndex > slashIndex) { serviceName = schemeSpecificPart.substring(0, slashIndex); serviceType = null; } else { serviceName = schemeSpecificPart.substring(0, colonIndex); serviceType = schemeSpecificPart.substring(colonIndex + 1, slashIndex); } path = uri.getRawPath(); query = uri.getRawQuery(); fragment = uri.getRawFragment(); }
From source file:org.gatherdata.alert.notify.mail.internal.EmailNotifier.java
public boolean canSendTo(URI notificationAddress) { log.debug("canSendTo(" + notificationAddress + ")"); log.debug("\t scheme:" + notificationAddress.getScheme()); log.debug("\t scheme specific:" + notificationAddress.getSchemeSpecificPart()); log.debug("\t fragment:" + notificationAddress.getFragment()); log.debug("\t host:" + notificationAddress.getHost()); log.debug("\t path:" + notificationAddress.getPath()); try {//from ww w. jav a 2s.co m log.debug("\t as URL:" + notificationAddress.toURL()); } catch (MalformedURLException e) { e.printStackTrace(); } return SCHEME_TYPES.contains(notificationAddress.getScheme()); }
From source file:gov.nih.nci.caarray.dataStorage.database.DatabaseMultipartBlobDataStorage.java
/** * {@inheritDoc}/* www . j a v a 2 s. co m*/ */ @Override public void remove(Collection<URI> handles) throws DataStoreException { final List<Long> blobIds = new ArrayList<Long>(); for (final URI handle : handles) { checkScheme(handle); blobIds.add(Long.valueOf(handle.getSchemeSpecificPart())); } this.blobDao.deleteByIds(blobIds); }
From source file:gov.nih.nci.caarray.dataStorage.fileSystem.FilesystemDataStorage.java
/** * {@inheritDoc}/*from ww w .j a v a2 s. c o m*/ */ @Override public File openFile(URI handle, boolean compressed) throws DataStoreException { checkScheme(handle); final File file = file(handle.getSchemeSpecificPart(), compressed); if (!file.exists()) { throw new DataStoreException("No data available for handle " + handle); } return file; }
From source file:gov.nih.nci.caarray.dataStorage.database.DatabaseMultipartBlobDataStorage.java
/** * {@inheritDoc}//w w w . j a v a 2s.c o m */ @Override public void releaseFile(URI handle, boolean compressed) { checkScheme(handle); final String tempFileName = fileName(handle.getSchemeSpecificPart(), compressed); this.tempFileCacheSource.get().delete(tempFileName); }
From source file:org.apache.felix.karaf.jaas.config.impl.ResourceKeystoreInstance.java
/** * @param keystorePath the keystorePath to set *//*from w w w . jav a 2 s . c o m*/ public void setPath(URL keystorePath) throws IOException { this.path = keystorePath; if (keystorePath.getProtocol().equals("file")) { URI uri = URI.create(keystorePath.toString().replace(" ", "%20")); this.keystoreFile = new File(uri.getSchemeSpecificPart()); } }
From source file:org.chiba.xml.xforms.connector.file.FileSubmissionHandler.java
/** * Serializes and submits the specified instance data over the * <code>file</code> protocol. * * @param submission the submission issuing the request. * @param instance the instance data to be serialized and submitted. * @return <code>null</code>. * @throws XFormsException if any error occurred during submission. *///from w w w . jav a2s . co m public Map submit(Submission submission, Node instance) throws XFormsException { if (submission.getMethod().equalsIgnoreCase("get")) { try { // create uri URI uri = new URI(getURI()); // use scheme specific part in order to handle UNC names String fileName = uri.getSchemeSpecificPart(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("getting file '" + fileName + "'"); } // create file File file = new File(fileName); InputStream inputStream; // check for directory if (file.isDirectory()) { // create input stream from directory listing Document document = FileURIResolver.buildDirectoryListing(file); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DOMUtil.prettyPrintDOM(document, outputStream); inputStream = new ByteArrayInputStream(outputStream.toByteArray()); } else { // create file input stream inputStream = new FileInputStream(new File(fileName)); } Map response = new HashMap(); response.put(ChibaAdapter.SUBMISSION_RESPONSE_STREAM, inputStream); return response; } catch (Exception e) { throw new XFormsException(e); } } if (submission.getMethod().equalsIgnoreCase("put")) { if (!submission.getReplace().equals("none")) { throw new XFormsException("submission mode '" + submission.getReplace() + "' not supported"); } try { // create uri URI uri = new URI(getURI()); // use scheme specific part in order to handle UNC names String fileName = uri.getSchemeSpecificPart(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("putting file '" + fileName + "'"); } // create output steam and serialize instance data FileOutputStream stream = new FileOutputStream(new File(fileName)); serialize(submission, instance, stream); stream.close(); } catch (Exception e) { throw new XFormsException(e); } return new HashMap(); } throw new XFormsException("submission method '" + submission.getMethod() + "' not supported"); }