List of usage examples for java.net URL toExternalForm
public String toExternalForm()
From source file:net.sf.ginp.setup.SetupManagerImpl.java
/** * @see net.sf.ginp.setup.SetupManager#deleteConfiguration(java.net.URL) *///from ww w . j a va 2s. co m public final void deleteConfiguration(final URL configUrl) { Preferences preferences = Preferences.userNodeForPackage(SetupManagerImpl.class); preferences.remove(configUrl.toExternalForm()); try { preferences.flush(); } catch (BackingStoreException e) { log.error("No big deal if we couldn't delete", e); } }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdateManager.java
private void openWebPage(Context context, URL url, final UpdateListener listener) { if (listener != null) { listener.onUpdateProgress(null); }//w ww . j av a 2 s .c o m try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toExternalForm()))); } catch (Exception e) { if (listener == null) { Log.e("open web page failed", e); } else { listener.onUpdateFailed(e); } } if (listener != null) { listener.onUpdateProgress(100); listener.onUpdateCompleted(); } }
From source file:com.mothsoft.alexis.domain.Tweet.java
public Tweet(Long remoteTweetId, Date createdAt, String screenName, String fullName, URL profileImageUrl, String text, List<TweetLink> links, List<TweetMention> mentions, List<TweetHashtag> hashtags, boolean retweet, String retweetUserName) { super(DocumentType.T, Tweet.urlOf(remoteTweetId, screenName), null, null); this.remoteTweetId = remoteTweetId; setCreationDate(createdAt);/*from w w w . j ava2s . c o m*/ this.screenName = screenName; this.fullName = fullName; this.profileImageUrl = profileImageUrl.toExternalForm(); final DocumentContent documentContent = new DocumentContent(this, text); setDocumentContent(documentContent); this.links = links; this.mentions = mentions; this.hashtags = hashtags; this.retweet = retweet; this.retweetUserName = retweetUserName; for (final TweetLink ith : links) { ith.setTweet(this); } for (final TweetMention ith : mentions) { ith.setTweet(this); } for (final TweetHashtag ith : hashtags) { ith.setTweet(this); } }
From source file:eu.annocultor.tagger.vocabularies.AbstractVocabulary.java
public final void loadTermsFromSparqlEndpoint(String query, File cacheDir, URL sparqlEndpoint) throws Exception { loadTerms(query, true, cacheDir, sparqlEndpoint.toExternalForm()); }
From source file:net.community.chest.gitcloud.facade.AbstractContextInitializer.java
protected void showArtifactsVersions() { scanArtifactsManifests(new Predicate<Pair<URL, Manifest>>() { @Override/*from ww w . j a v a 2 s . c o m*/ @SuppressWarnings("synthetic-access") public boolean evaluate(Pair<URL, Manifest> e) { URL url = e.getKey(); Manifest manifest = e.getValue(); Pair<Attributes.Name, String> versionInfo = ManifestUtils.findFirstManifestAttributeValue(manifest, ManifestUtils.STANDARD_VERSION_ATTRS_NAMES); if (versionInfo == null) { logger.info( "showArtifactsVersions(" + url.toExternalForm() + ") no version information extracted"); } else { logger.info("showArtifactsVersions(" + url.toExternalForm() + ")[" + versionInfo.getLeft() + "]: " + versionInfo.getRight()); } return false; // don't stop } }); }
From source file:org.sonatype.nexus.proxy.storage.remote.httpclient.HttpClientRemoteStorage.java
@Override public void deleteItem(final ProxyRepository repository, final ResourceStoreRequest request) throws ItemNotFoundException, UnsupportedStorageOperationException, RemoteStorageException { final URL remoteUrl = appendQueryString(getAbsoluteUrlFromBase(repository, request), repository); final HttpDelete method = new HttpDelete(remoteUrl.toExternalForm()); final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method); final int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_NO_CONTENT && statusCode != HttpStatus.SC_ACCEPTED) { throw new RemoteStorageException( "The response to HTTP " + method.getMethod() + " was unexpected HTTP Code " + statusCode + " : " + httpResponse.getStatusLine().getReasonPhrase() + " [repositoryId=\"" + repository.getId() + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]"); }/*w w w .j a v a 2 s . com*/ }
From source file:com.nokia.helium.diamonds.DiamondsSessionSocket.java
/** * Internal method to send data to diamonds. * If ignore result is true, then the method will return null, else the message return by the query * will be returned./*from w ww . j a va 2s . c om*/ * @param message * @param ignoreResult * @return * @throws DiamondsException is thrown in case of message retrieval error, connection error. */ protected synchronized String sendInternal(Message message, boolean ignoreResult) throws DiamondsException { URL destURL = url; if (buildId != null) { try { destURL = new URL(url.getProtocol(), url.getHost(), url.getPort(), buildId); } catch (MalformedURLException e) { throw new DiamondsException("Error generating the url to send the message: " + e.getMessage(), e); } } PostMethod post = new PostMethod(destURL.toExternalForm()); try { File tempFile = streamToTempFile(message.getInputStream()); tempFile.deleteOnExit(); messages.add(tempFile); post.setRequestEntity(new FileRequestEntity(tempFile, "text/xml")); } catch (MessageCreationException e) { throw new DiamondsException("Error retrieving the message: " + e.getMessage(), e); } catch (IOException e) { throw new DiamondsException("Error serializing the message into a temporary file: " + e.getMessage(), e); } try { int result = httpClient.executeMethod(post); if (result != HttpStatus.SC_OK && result != HttpStatus.SC_ACCEPTED) { throw new DiamondsException("Error sending the message: " + post.getStatusLine() + "(" + post.getResponseBodyAsString() + ")"); } if (!ignoreResult) { return post.getResponseBodyAsString(); } } catch (HttpException e) { throw new DiamondsException("Error sending the message: " + e.getMessage(), e); } catch (IOException e) { throw new DiamondsException("Error sending the message: " + e.getMessage(), e); } finally { post.releaseConnection(); } return null; }
From source file:net.sf.ginp.setup.SetupManagerImpl.java
/** * @param configUrl/* w w w . j av a2s . co m*/ * @param configuration * @return the saves prefs object */ private Preferences storeConfig(final URL configUrl, final String configuration) { Preferences preferences = Preferences.userNodeForPackage(SetupManagerImpl.class); preferences.put(configUrl.toExternalForm(), configuration); return preferences; }
From source file:com.bce.gis.io.zweidm.SmsParser.java
public IStatus parse(final URL url, final IProgressMonitor monitor) throws IOException { InputStream is = null;//from w w w. j av a 2 s .com try { final long contentLength = UrlUtilities.getContentLength(url); is = new ProgressInputStream(new BufferedInputStream(url.openStream()), contentLength, monitor); parse(is); is.close(); final String okMessage = String.format(Messages.getString("SmsParser_0"), url.toExternalForm()); //$NON-NLS-1$ final String problemMessage = String.format(Messages.getString("SmsParser_1"), url.toExternalForm()); //$NON-NLS-1$ return m_stati.asMultiStatusOrOK(problemMessage, okMessage); } finally { IOUtils.closeQuietly(is); } }