List of usage examples for java.net URISyntaxException getMessage
public String getMessage()
From source file:ar.com.aleatoria.ue.rest.SimpleBufferingClientHttpRequest.java
public URI getURI() { try {//from w ww .j a v a 2 s.co m return this.connection.getURL().toURI(); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not get HttpURLConnection URI: " + ex.getMessage(), ex); } }
From source file:com.epam.ngb.cli.manager.command.handler.http.GeneAddingHandler.java
@Override public int runCommand() { try {// w w w.j av a 2s . co m String url = serverParameters.getServerUrl() + getRequestUrl(); URIBuilder builder = new URIBuilder(String.format(url, referenceId)); if (geneFileId != null) { builder.addParameter("geneFileId", String.valueOf(geneFileId)); } HttpPut put = new HttpPut(builder.build()); setDefaultHeader(put); if (isSecure()) { addAuthorizationToRequest(put); } String result = RequestManager.executeRequest(put); checkAndPrintRegistrationResult(result, printJson, printTable); } catch (URISyntaxException e) { throw new ApplicationException(e.getMessage(), e); } return 0; }
From source file:it.geosolutions.geobatch.unredd.script.test.utils.ResourceLoader.java
protected File loadFile(String name) { try {// www . j a va2 s .c om URL url = this.getClass().getClassLoader().getResource(name); if (url == null) throw new IllegalArgumentException("Cant get file '" + name + "'"); File file = new File(url.toURI()); return file; } catch (URISyntaxException e) { LOGGER.error("Can't load file " + name + ": " + e.getMessage(), e); return null; } }
From source file:com.synopsys.integration.blackduck.service.model.pdf.RiskReportWriter.java
public void createHtmlReportFiles(final Gson gson, final File outputDirectory, final ReportData reportData) throws RiskReportException { try {//w w w. jav a2 s . co m final RiskReportResourceCopier copier = new RiskReportResourceCopier( outputDirectory.getCanonicalPath()); File htmlFile = null; try { final List<File> writtenFiles = copier.copy(); for (final File file : writtenFiles) { if (file.getName().equals(RiskReportResourceCopier.RISK_REPORT_HTML_FILE_NAME)) { htmlFile = file; break; } } } catch (final URISyntaxException e) { throw new RiskReportException("Couldn't create the report: " + e.getMessage(), e); } if (htmlFile == null) { throw new RiskReportException( "Could not find the file : " + RiskReportResourceCopier.RISK_REPORT_HTML_FILE_NAME + ", the report files must not have been copied into the report directory."); } String htmlFileString = FileUtils.readFileToString(htmlFile, "UTF-8"); final String reportString = gson.toJson(reportData); htmlFileString = htmlFileString.replace(RiskReportResourceCopier.JSON_TOKEN_TO_REPLACE, reportString); FileUtils.writeStringToFile(htmlFile, htmlFileString, "UTF-8"); } catch (final IOException e) { throw new RiskReportException("Couldn't create the report: " + e.getMessage(), e); } }
From source file:com.epam.ngb.cli.manager.command.handler.http.AbstractAnnotationReferenceHandler.java
@Override public int runCommand() { String url = serverParameters.getServerUrl() + getRequestUrl(); for (Long annotationFileId : annotationFileIds) { try {//from w w w .j av a 2s . c o m URIBuilder builder = new URIBuilder(String.format(url, referenceId)); builder.addParameter("annotationFileId", String.valueOf(annotationFileId)); builder.addParameter("remove", String.valueOf(isRemoving())); HttpPut put = new HttpPut(builder.build()); setDefaultHeader(put); if (isSecure()) { addAuthorizationToRequest(put); } String result = RequestManager.executeRequest(put); checkAndPrintRegistrationResult(result, printJson, printTable); } catch (URISyntaxException e) { throw new ApplicationException(e.getMessage(), e); } } return 0; }
From source file:org.dataconservancy.ui.it.support.AuthorizedDepositorRequest.java
public HttpPost asHttpPost() { if (collectionId == null || collectionId.isEmpty() || userId == null || userId.isEmpty()) { throw new IllegalStateException( "Collection ID, or User ID not set: Call setAuthorizedUser or removeAuthorizedUser first"); }/*w w w. j ava 2 s . c om*/ HttpPost post = null; try { post = new HttpPost(urlConfig.getUserCollectionsUrl().toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e.getMessage(), e); } List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("selectedCollectionId", collectionId)); if (userAuthorized) { params.add(new BasicNameValuePair("userIdsToAdd", userId)); } else { params.add(new BasicNameValuePair("userIdsToRemove", userId)); } params.add(new BasicNameValuePair(STRIPES_EVENT, "Edit Depositors")); HttpEntity entity = null; try { entity = new UrlEncodedFormEntity(params, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e.getMessage(), e); } post.setEntity(entity); return post; }
From source file:org.exoplatform.utils.image.CookieAwarePicassoDownloader.java
/** * Syncs all cookies from ExoConnectionUtils cookieStore from Apache's * HttpClient to HttpURLConnection.//from ww w.j a va 2 s. c o m * * @param manager the CookieManager in which to store the retrieved cookies */ private void syncCookies(CookieManager manager) { CookieStore store = ExoConnectionUtils.cookiesStore; if (store == null) return; for (Cookie cookie : store.getCookies()) { HttpCookie c = new HttpCookie(cookie.getName(), cookie.getValue()); c.setDomain(cookie.getDomain()); c.setPath(cookie.getPath()); c.setVersion(cookie.getVersion()); String url = AccountSetting.getInstance().getDomainName() + "/" + cookie.getPath(); try { manager.getCookieStore().add(new URI(url), c); } catch (URISyntaxException e) { Log.e(TAG, e.getMessage(), e); } } }
From source file:io.kahu.hawaii.util.call.http.util.UriBuilder.java
public URI build() throws ServerException { assert baseUrl != null : "Base URL must be set."; StringBuilder urlBuilder = new StringBuilder(baseUrl); if (StringUtils.isNotBlank(path)) { String trimmedPath = StringUtils.trim(path); if (trimmedPath.startsWith("/") && baseUrl.endsWith("/")) { trimmedPath = trimmedPath.substring(1); }/*w w w . ja v a 2s . co m*/ urlBuilder.append(trimmedPath); } if (pathVariables != null && pathVariables.length > 0) { String url = urlBuilder.toString(); urlBuilder = new StringBuilder(); substitutePathVariables(urlBuilder, url); } if (queryParameters != null && !queryParameters.isEmpty()) { appendQueryParameters(urlBuilder, queryParameters); } try { return new URI(urlBuilder.toString()); } catch (URISyntaxException e) { throw new ServerException(ServerError.URI_INVALID, e.getMessage(), e); } }
From source file:com.jefftharris.passwdsafe.sync.owncloud.OwncloudEditDialog.java
@Override @SuppressLint("InflateParams") public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) { Bundle args = getArguments();/*from w ww . j ava 2s. c o m*/ String url = args.getString("url"); int syncFreq = args.getInt("syncFreq"); Activity act = getActivity(); LayoutInflater factory = LayoutInflater.from(act); View view = factory.inflate(R.layout.fragment_owncloud_edit_dialog, null); itsUrlEdit = (TextView) view.findViewById(R.id.url); itsSyncInterval = (Spinner) view.findViewById(R.id.owncloud_interval); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.owncloud).setView(view).setPositiveButton(android.R.string.ok, this) .setNegativeButton(android.R.string.cancel, this); AlertDialog dialog = builder.create(); itsValidator = new DialogValidator.AlertValidator(dialog, view) { @Override protected String doValidation() { try { new URI(itsUrlEdit.getText().toString()); } catch (URISyntaxException e) { return e.getMessage(); } return null; } }; // Must set text before registering view so validation isn't // triggered right away itsUrlEdit.setText(url); itsValidator.registerTextView(itsUrlEdit); ProviderSyncFreqPref freq = ProviderSyncFreqPref.freqValueOf(syncFreq); itsSyncInterval.setSelection(freq.getDisplayIdx()); return dialog; }
From source file:cn.hi321.browser.weave.client.WeaveBasicObject.java
public URI getUri() throws JSONException { if (m_uri == null) { try {/*from ww w . j av a 2 s . c o m*/ String baseUriStr = m_queryUri.toASCIIString(); String queryPart = m_queryUri.getRawQuery(); if (queryPart != null) baseUriStr = baseUriStr.substring(0, baseUriStr.indexOf(queryPart) - 1); if (!baseUriStr.endsWith("/")) baseUriStr += "/"; String nodeUriStr = baseUriStr + new URI(null, null, getId(), null).toASCIIString(); m_uri = new URI(nodeUriStr); } catch (URISyntaxException e) { throw new JSONException(e.getMessage()); } } return m_uri; }