List of usage examples for java.net URI getPath
public String getPath()
From source file:de.thingweb.thing.Thing.java
public String resolveActionUri(String name, int index) { URI uri = getUri(index); Action a = getAction(name);//from w ww . j av a 2 s .c o m if (a != null) { try { String path = uri.getPath(); if (path.endsWith("/")) { path = path + a.getHrefs().get(index); } else { path = path + "/" + a.getHrefs().get(index); } uri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), path, uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { throw new RuntimeException("TD with malformed hrefs"); } } else { throw new RuntimeException("No such Property"); } return uri.toString(); }
From source file:edu.wisc.ws.client.support.DestinationOverridingWebServiceTemplate.java
@Override public String getDefaultUri() { final DestinationProvider destinationProvider = this.getDestinationProvider(); if (destinationProvider != null) { final URI uri = destinationProvider.getDestination(); if (uri == null) { return null; }// w w w.j a v a 2s . c om if (portOverride == null) { return uri.toString(); } final URI overridenUri; try { overridenUri = new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), portOverride, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { this.logger.error("Could not override port on URI " + uri + " to " + portOverride, e); return uri.toString(); } return overridenUri.toString(); } return null; }
From source file:com.snowplowanalytics.refererparser.Parser.java
public Referer parse(URI refererUri, String pageHost, List<String> internalDomains) { if (refererUri == null) { return null; }//from w ww . j ava 2s .c o m return parse(refererUri.getScheme(), refererUri.getHost(), refererUri.getPath(), refererUri.getRawQuery(), pageHost, internalDomains); }
From source file:main.java.miro.validator.fetcher.RsyncFetcher.java
public boolean addPrefetchURI(URI pfUri) { if (pointsToFile(pfUri)) return false; List<URI> toBeRemoved = new ArrayList<URI>(); boolean alreadyContained = false; for (URI uri : prefetchURIs) { if (uri.getHost().equals(pfUri.getHost())) { if (pfUri.getPath().startsWith(uri.getPath())) alreadyContained = true; if (uri.getPath().startsWith(pfUri.getPath())) toBeRemoved.add(uri);/*from www . ja v a 2 s . c o m*/ } } if (!alreadyContained) { prefetchURIs.add(pfUri); prefetchURIs.removeAll(toBeRemoved); } return !alreadyContained; }
From source file:org.apache.servicemix.jms.JmsComponent.java
protected Endpoint getResolvedEPR(ServiceEndpoint ep) throws Exception { // We receive an exchange for an EPR that has not been used yet. // Register a provider endpoint and restart processing. JmsEndpoint jmsEp = new JmsEndpoint(true); jmsEp.setServiceUnit(new DefaultServiceUnit(component)); jmsEp.setService(ep.getServiceName()); jmsEp.setEndpoint(ep.getEndpointName()); jmsEp.setRole(MessageExchange.Role.PROVIDER); URI uri = new URI(ep.getEndpointName()); Map map = URISupport.parseQuery(uri.getQuery()); if (IntrospectionSupport.setProperties(jmsEp, map, "jms.")) { uri = URISupport.createRemainingURI(uri, map); }// w w w . j a v a2s .c o m if (uri.getPath() != null) { String path = uri.getSchemeSpecificPart(); while (path.startsWith("/")) { path = path.substring(1); } if (path.startsWith(AbstractJmsProcessor.STYLE_QUEUE + "/")) { jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_QUEUE); jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_QUEUE.length() + 1)); } else if (path.startsWith(AbstractJmsProcessor.STYLE_TOPIC + "/")) { jmsEp.setDestinationStyle(AbstractJmsProcessor.STYLE_TOPIC); jmsEp.setJmsProviderDestinationName(path.substring(AbstractJmsProcessor.STYLE_TOPIC.length() + 1)); } } return jmsEp; }
From source file:de.shadowhunt.subversion.RepositoryFactory.java
/** * Create a new {@link Repository} for given {@link URI} and use the given {@link HttpClient} with the {@link * HttpClient} to connect to the server. * * @param repository {@link URI} to the root of the repository (e.g: http://repository.example.net/svn/test_repo) * @param client {@link HttpClient} that will handle all requests for this repository * @param context {@link HttpContext} that will be used by all requests to this repository * * @return a new {@link Repository} for given {@link URI} * * @throws NullPointerException if any parameter is {@code null} * @throws SubversionException if no {@link Repository} can be created * @throws de.shadowhunt.subversion.TransmissionException if an error occurs in the underlining communication with * the server//from ww w.j a va 2 s. c om */ public final Repository createRepository(final URI repository, final HttpClient client, final HttpContext context) { Validate.notNull(repository, "repository must not be null"); Validate.notNull(client, "client must not be null"); Validate.notNull(context, "context must not be null"); final URI saneUri = sanitise(repository, Resource.create(repository.getPath())); return createRepository0(saneUri, client, context); }
From source file:ch.cyberduck.core.dav.DAVPath.java
@Override public AttributedList<Path> list(final AttributedList<Path> children) { try {//from w ww . j ava 2s. co m this.getSession().check(); this.getSession().message(MessageFormat .format(Locale.localizedString("Listing directory {0}", "Status"), this.getName())); final List<DavResource> resources = this.getSession().getClient().list(this.toURL()); for (final DavResource resource : resources) { // Try to parse as RFC 2396 final URI uri = resource.getHref(); DAVPath p = new DAVPath(this.getSession(), uri.getPath(), resource.isDirectory() ? DIRECTORY_TYPE : FILE_TYPE); p.setParent(this); p.readAttributes(resource); children.add(p); } } catch (IOException e) { log.warn("Listing directory failed:" + e.getMessage()); children.attributes().setReadable(false); } return children; }
From source file:com.abiquo.abiserver.pojo.service.RemoteService.java
private boolean modifiedUri() { try {//from www.j a va2s .c om URI u = new URI(uri); return !fixProtocol(u.getScheme()).equals(fixProtocol(protocol)) || !u.getHost().equals(domainName) || u.getPort() != port || !StringUtils.isEmpty(u.getPath()) && !u.getPath().replaceFirst("/", "").equals(serviceMapping); } catch (URISyntaxException e) { return true; } catch (NullPointerException e) { return true; } }
From source file:com.buaa.cfs.fs.Path.java
/** Resolve a child path against a parent path. */ public Path(Path parent, Path child) { // Add a slash to parent's path so resolution is compatible with URI's URI parentUri = parent.uri; String parentPath = parentUri.getPath(); if (!(parentPath.equals("/") || parentPath.isEmpty())) { try {/* www . j a va2s. c om*/ parentUri = new URI(parentUri.getScheme(), parentUri.getAuthority(), parentUri.getPath() + "/", null, parentUri.getFragment()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } } URI resolved = parentUri.resolve(child.uri); initialize(resolved.getScheme(), resolved.getAuthority(), resolved.getPath(), resolved.getFragment()); }
From source file:com.sra.biotech.submittool.persistence.service.SubmissionServiceImpl.java
public URI assignStudy(URI submissionUri, Study study) { ObjectMapper objectMapper = restTemplateService.getObjectMapperWithHalModule(); ObjectNode jsonNodeStudy = (ObjectNode) objectMapper.valueToTree(study); jsonNodeStudy.put("submission", submissionUri.getPath()); URI studyUri = restTemplate.postForLocation(studiesUri(), jsonNodeStudy); ResponseEntity<Resource<Study>> studyResponseEntity = restTemplate.exchange(studyUri, HttpMethod.GET, null, new ParameterizedTypeReference<Resource<Study>>() { });//from w ww . j a v a 2 s . c om Resource<Study> studyResource = studyResponseEntity.getBody(); Link submissionLinkThroughStudy = studyResource.getLink("submission"); System.out.println("Submission Link through Study = " + submissionLinkThroughStudy); return studyUri; }