List of usage examples for java.net URI toString
public String toString()
From source file:com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfDeployer.java
private String extractParentPath(URI ovfUri) { return ovfUri.toString().substring(0, ovfUri.toString().lastIndexOf("/") + 1); }
From source file:ca.sfu.federation.action.ShowHelpWebSiteAction.java
/** * Handle action performed event./*w w w.j av a2s.c o m*/ * @param ae Event */ public void actionPerformed(ActionEvent ae) { try { URI uri = new URI(ApplicationContext.PROJECT_HELP_WEBSITE_URL); // open the default web browser for the HTML page logger.log(Level.INFO, "Opening desktop browser to {0}", uri.toString()); Desktop.getDesktop().browse(uri); } catch (Exception ex) { String stack = ExceptionUtils.getFullStackTrace(ex); logger.log(Level.WARNING, "Could not open browser for help web site {0}\n\n{1}", new Object[] { ApplicationContext.PROJECT_HELP_WEBSITE_URL, stack }); } }
From source file:org.nekorp.workflow.desktop.data.access.rest.ServicioDAOImp.java
@Override public void guardar(Servicio dato) { if (dato.getId() == null) { URI resource = factory.getTemplate().postForLocation(factory.getRootUlr() + "/servicios", dato); String[] uri = StringUtils.split(resource.toString(), '/'); String id = uri[uri.length - 1]; dato.setId(Long.valueOf(id)); } else {/* w w w . j a v a 2 s. c om*/ Map<String, Object> map = new HashMap<>(); map.put("id", dato.getId()); factory.getTemplate().postForLocation(factory.getRootUlr() + "/servicios/{id}", dato, map); } }
From source file:org.cruk.genologics.api.jaxb.URIAdapter.java
/** * Convert the given URI into its string format. * * @param v The URI to print./*from w w w. j a v a2s.co m*/ * * @return The URI as a string, or null if {@code v} is null. */ @Override public String marshal(URI v) { String s = null; if (v != null) { s = v.toString(); if (REMOVE_STATE) { s = removeStateParameter(s); } } return s; }
From source file:com.microsoft.tfs.client.eclipse.project.ProjectManagerWorkspaceJob.java
ProjectManagerWorkspaceJob(final ProjectManagerDataProvider dataProvider, final IProject project, final URI serverURI, final Credentials credentials) { super(MessageFormat.format(Messages.getString("ProjectManagerWorkspaceJob.JobNameFormat"), //$NON-NLS-1$ serverURI.toString())); setSystem(true);/*from w w w . ja v a 2 s . c om*/ this.project = project; this.serverURI = serverURI; this.credentials = credentials; }
From source file:main.java.miro.validator.fetcher.RsyncFetcher.java
public boolean alreadyDownloaded(URI uri) { String dlUriStr;//ww w. jav a 2s.com String uriStr = uri.toString(); for (URI dluri : downloadedURIs) { dlUriStr = dluri.toString(); if (uriStr.startsWith(dlUriStr)) return true; } return false; }
From source file:com.yourmediashelf.fedora.client.request.Upload.java
@Override public UploadResponse execute(FedoraClient fedora) throws FedoraClientException { ClientResponse response = null;//from w w w. j a va 2 s . c o m String path = String.format("upload"); WebResource wr = resource(fedora).path(path); MediaType mediaType = MediaType.valueOf(fedora.getMimeType(file)); FormDataMultiPart formDataMultiPart = new FormDataMultiPart(); try { MultiPart multiPart = formDataMultiPart.bodyPart(new FileDataBodyPart("file", file, mediaType)); // Check for a 302 (expected if baseUrl is http but Fedora is configured // to require SSL response = wr.head(); if (response.getStatus() == 302) { URI newLocation = response.getLocation(); logger.warn("302 status for upload request: " + newLocation); wr = resource(newLocation.toString()); } response = wr.queryParams(getQueryParams()).type(MediaType.MULTIPART_FORM_DATA_TYPE) .post(ClientResponse.class, multiPart); return new UploadResponse(response); } finally { IOUtils.closeQuietly(formDataMultiPart); } }
From source file:org.openlmis.fulfillment.service.referencedata.BaseReferenceDataServiceTest.java
@Test public void shouldFindById() throws Exception { // given//from w ww .ja va2s . c om BaseReferenceDataService<T> service = prepareService(); UUID id = UUID.randomUUID(); T instance = generateInstance(); ResponseEntity<T> response = mock(ResponseEntity.class); // when when(response.getBody()).thenReturn(instance); when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET), any(HttpEntity.class), eq(service.getResultClass()))).thenReturn(response); T found = service.findOne(id); // then verify(restTemplate).exchange(uriCaptor.capture(), eq(HttpMethod.GET), entityCaptor.capture(), eq(service.getResultClass())); URI uri = uriCaptor.getValue(); String url = service.getServiceUrl() + service.getUrl() + id; assertThat(uri.toString(), is(equalTo(url))); assertThat(found, is(instance)); assertAuthHeader(entityCaptor.getValue()); assertThat(entityCaptor.getValue().getBody(), is(nullValue())); }
From source file:gmusic.api.comm.ApacheConnector.java
private HttpRequestBase adjustAddress(URI address, HttpRequestBase request) throws MalformedURLException, URISyntaxException { if (address.toString().startsWith(HTTPS_PLAY_GOOGLE_COM_MUSIC_SERVICES)) { address = new URI(address.toURL() + String.format(COOKIE_FORMAT, getCookieValue("xt"))); }/*from w ww .java 2s . co m*/ request.setURI(address); if (authorizationToken != null) { request.addHeader(GOOGLE_LOGIN_AUTH_KEY, String.format(GOOGLE_LOGIN_AUTH_VALUE, authorizationToken)); } // if((address.toString().startsWith("https://android.clients.google.com/music/mplay")) && deviceId != null) // { // request.addHeader("X-Device-ID", deviceId); // } return request; }
From source file:org.hawkular.client.RestFactory.java
public T createAPI(URI uri, String userName, String password) { HttpClient httpclient = null;//w w w. ja v a2 s. c o m if (uri.toString().startsWith("https")) { httpclient = getHttpClient(); } else { httpclient = HttpClientBuilder.create().build(); } ResteasyClient client = null; if (userName != null) { HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort()); CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials(userName, password)); // Create AuthCache instance AuthCache authCache = new BasicAuthCache(); // Generate BASIC scheme object and add it to the local auth cache BasicScheme basicAuth = new BasicScheme(); authCache.put(targetHost, basicAuth); // Add AuthCache to the execution context HttpClientContext context = HttpClientContext.create(); context.setCredentialsProvider(credsProvider); context.setAuthCache(authCache); ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(httpclient, context); client = new ResteasyClientBuilder().httpEngine(engine).build(); } else { ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(getHttpClient()); client = new ResteasyClientBuilder().httpEngine(engine).build(); } client.register(JacksonJaxbJsonProvider.class); client.register(JacksonObjectMapperProvider.class); client.register(RestRequestFilter.class); client.register(RestResponseFilter.class); client.register(HCJacksonJson2Provider.class); ProxyBuilder<T> proxyBuilder = client.target(uri).proxyBuilder(apiClassType); if (classLoader != null) { proxyBuilder = proxyBuilder.classloader(classLoader); } return proxyBuilder.build(); }