List of usage examples for java.net URI toString
public String toString()
From source file:com.ibm.amc.FileManager.java
/** * Resolves an input URI to a URL suitable for WAMT. If the URI represents a temporary file, * converts it to the real file location. * /* w w w . j a va2 s . c o m*/ * @param uri * the input URI * @return the output URL */ public static URL resolveUriToUrl(URI uri) { // if a null is passed in, send one back if (uri == null) return null; try { return resolveUri(uri).toURL(); } catch (MalformedURLException e) { if (logger.isDebugEnabled()) { logger.debug("resolveUriToUrl()", "MalformedURLException:", e); logger.stacktrace(e); } if (uri.getScheme().equals(SCHEME)) { throw new AmcIllegalArgumentException(e, "CWZBA2002E_TEMPORARY_FILE_FAILED", uri.toString()); } else { throw new AmcIllegalArgumentException("CWZBA2003E_INVALID_URI", uri.toString()); } } }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * ?.// w w w .ja v a 2 s. co m * * @param uri * the uri * @param paramNameList * the param name list * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return the string */ public static String removeParameterList(URI uri, List<String> paramNameList, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(paramNameList)) {// paramNameListnull return uriString; } String queryString = uri.getRawQuery();// URI? URI???? URI return removeParameterList(uriString, queryString, paramNameList, charsetType); }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * url???.//from w w w. j a v a2s . c o m * * @param uri * the uri * @param paramNameList * ?????list * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return the string * @see #toSafeArrayValueMap(String, String) */ public static String retentionParamList(URI uri, List<String> paramNameList, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(paramNameList)) { // paramNameList null return uriString; } String queryString = uri.getRawQuery(); // URI? URI???? URI return retentionParamList(uriString, queryString, paramNameList, charsetType); }
From source file:io.swagger.api.impl.ToolsApiServiceImpl.java
/** * Convert our Tool object to a standard Tool format * * @param container our data object// w w w .ja v a2 s. c o m * @return standardised data object */ private static Pair<io.swagger.model.Tool, Table<String, SourceFile.FileType, Object>> convertContainer2Tool( Entry container) { Table<String, SourceFile.FileType, Object> fileTable = HashBasedTable.create(); String globalId; // TODO: properly pass this information String newID; try { // construct escaped ID if (container instanceof Tool) { newID = ((Tool) container).getToolPath(); } else if (container instanceof Workflow) { newID = "#workflow/" + ((Workflow) container).getPath(); } else { LOG.error("Could not construct URL for our container with id: " + container.getId()); return null; } String escapedID = URLEncoder.encode(newID, StandardCharsets.UTF_8.displayName()); URI uri = new URI(config.getScheme(), null, config.getHostname(), Integer.parseInt(config.getPort()), "/api/ga4gh/v1/tools/", null, null); globalId = uri.toString() + escapedID; } catch (URISyntaxException | UnsupportedEncodingException e) { LOG.error("Could not construct URL for our container with id: " + container.getId()); return null; } // TODO: hook this up to a type field in our DB? ToolClass type = container instanceof Tool ? ToolClassesApiServiceImpl.getCommandLineToolClass() : ToolClassesApiServiceImpl.getWorkflowClass(); io.swagger.model.Tool tool = new io.swagger.model.Tool(); if (container.getAuthor() == null) { tool.setAuthor("Unknown author"); } else { tool.setAuthor(container.getAuthor()); } tool.setDescription(container.getDescription()); tool.setMetaVersion(container.getLastUpdated() != null ? container.getLastUpdated().toString() : null); tool.setToolclass(type); tool.setId(newID); tool.setUrl(globalId); tool.setVerified(false); tool.setVerifiedSource(""); // tool specific if (container instanceof Tool) { Tool inputTool = (Tool) container; tool.setToolname(inputTool.getToolname()); tool.setOrganization(inputTool.getNamespace()); tool.setToolname(inputTool.getName()); } // workflow specific if (container instanceof Workflow) { Workflow inputTool = (Workflow) container; tool.setToolname(inputTool.getPath()); tool.setOrganization(inputTool.getOrganization()); tool.setToolname(inputTool.getWorkflowName()); } // TODO: contains has no counterpart in our DB // setup versions as well Set inputVersions; if (container instanceof Tool) { inputVersions = ((Tool) container).getTags(); } else { inputVersions = ((Workflow) container).getWorkflowVersions(); } for (Version inputVersion : (Set<Version>) inputVersions) { // tags with no names make no sense here // also hide hidden tags if (inputVersion.getName() == null || inputVersion.isHidden()) { continue; } if (inputVersion instanceof Tag && ((Tag) inputVersion).getImageId() == null) { continue; } ToolVersion version = new ToolVersion(); // version id String globalVersionId; try { globalVersionId = globalId + "/versions/" + URLEncoder.encode(inputVersion.getName(), StandardCharsets.UTF_8.displayName()); } catch (UnsupportedEncodingException e) { LOG.error("Could not construct URL for our container with id: " + container.getId()); return null; } version.setUrl(globalVersionId); version.setId(tool.getId() + ":" + inputVersion.getName()); version.setName(inputVersion.getName()); version.setVerified(false); version.setVerifiedSource(""); version.setDockerfile(false); String urlBuilt; final String githubPrefix = "git@github.com:"; final String bitbucketPrefix = "git@bitbucket.org:"; if (container.getGitUrl().startsWith(githubPrefix)) { urlBuilt = extractHTTPPrefix(container.getGitUrl(), inputVersion.getReference(), githubPrefix, "https://raw.githubusercontent.com/"); } else if (container.getGitUrl().startsWith(bitbucketPrefix)) { urlBuilt = extractHTTPPrefix(container.getGitUrl(), inputVersion.getReference(), bitbucketPrefix, "https://bitbucket.org/"); } else { LOG.error("Found a git url neither from bitbucket or github " + container.getGitUrl()); urlBuilt = null; } final Set<SourceFile> sourceFiles = inputVersion.getSourceFiles(); for (SourceFile file : sourceFiles) { if (inputVersion instanceof Tag) { switch (file.getType()) { case DOCKERFILE: ToolDockerfile dockerfile = new ToolDockerfile(); dockerfile.setDockerfile(file.getContent()); dockerfile.setUrl(urlBuilt + ((Tag) inputVersion).getDockerfilePath()); version.setDockerfile(true); fileTable.put(inputVersion.getName(), DOCKERFILE, dockerfile); break; case DOCKSTORE_CWL: version.addDescriptorTypeItem(ToolVersion.DescriptorTypeEnum.CWL); fileTable.put(inputVersion.getName(), DOCKSTORE_CWL, buildSourceFile(urlBuilt + ((Tag) inputVersion).getCwlPath(), file)); break; case DOCKSTORE_WDL: version.addDescriptorTypeItem(ToolVersion.DescriptorTypeEnum.CWL); fileTable.put(inputVersion.getName(), DOCKSTORE_WDL, buildSourceFile(urlBuilt + ((Tag) inputVersion).getWdlPath(), file)); break; } } else if (inputVersion instanceof WorkflowVersion) { switch (file.getType()) { case DOCKSTORE_CWL: version.addDescriptorTypeItem(ToolVersion.DescriptorTypeEnum.CWL); fileTable.put(inputVersion.getName(), DOCKSTORE_CWL, buildSourceFile( urlBuilt + ((WorkflowVersion) inputVersion).getWorkflowPath(), file)); break; case DOCKSTORE_WDL: version.addDescriptorTypeItem(ToolVersion.DescriptorTypeEnum.CWL); fileTable.put(inputVersion.getName(), DOCKSTORE_WDL, buildSourceFile( urlBuilt + ((WorkflowVersion) inputVersion).getWorkflowPath(), file)); break; } } } if (container instanceof Tool) { version.setImage(((Tool) container).getPath() + ":" + inputVersion.getName()); } if (!version.getDescriptorType().isEmpty()) { // ensure that descriptor is non-null before adding to list tool.getVersions().add(version); version.setMetaVersion( inputVersion.getLastModified() != null ? String.valueOf(inputVersion.getLastModified()) : null); } } return new ImmutablePair<>(tool, fileTable); }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * ?./*from w ww . j a v a 2 s.c om*/ * * <p> * uri????,?,?a=1&a=2,a,[3,4], a=3&a=4. * </p> * * @param uri * ? ?,?,??,<br> * ??, ? * @param arrayValueMap * singleValueMap request.getParameterMap * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return ?,uri????,? */ public static String addParameterArrayValueMap(URI uri, Map<String, String[]> arrayValueMap, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } String uriString = uri.toString(); if (Validator.isNullOrEmpty(arrayValueMap)) { return uriString; } String queryString = uri.getRawQuery(); return addParameterArrayValueMap(uriString, queryString, arrayValueMap, charsetType); }
From source file:com.eucalyptus.www.X509Download.java
@SuppressWarnings("ConstantConditions") private static URI hostMap(final URI uri) { final Optional<Cidr> hostMatcher = InetAddresses.isInetAddress(uri.getHost()) ? Cidr.parse().apply(AuthenticationProperties.CREDENTIAL_DOWNLOAD_HOST_MATCH) : Optional.<Cidr>absent(); if (hostMatcher.isPresent()) { final Host host = Hosts.lookup(InetAddresses.forString(uri.getHost())); if (host != null) { final Optional<InetAddress> mappedHost = Iterables.tryFind(host.getHostAddresses(), hostMatcher.get());//w ww .j a va2 s . com if (mappedHost.isPresent()) { return URI .create(uri.toString().replaceFirst(uri.getHost(), mappedHost.get().getHostAddress())); } } } return uri; }
From source file:com.aliyun.oss.integrationtests.TestUtils.java
public static String composeLocation(OSSClient client, String endpoint, String bucketName, String key) { try {// www .j a va2 s . c o m URI baseUri = URI.create(endpoint); URI resultUri = null; if (client.getClientConfiguration().isSLDEnabled()) { resultUri = new URI(baseUri.getScheme(), null, baseUri.getHost(), baseUri.getPort(), String.format("/%s/%s", bucketName, HttpUtil.urlEncode(key, DEFAULT_CHARSET_NAME)), null, null); } else { resultUri = new URI(baseUri.getScheme(), null, bucketName + "." + baseUri.getHost(), baseUri.getPort(), String.format("/%s", HttpUtil.urlEncode(key, DEFAULT_CHARSET_NAME)), null, null); } return URLDecoder.decode(resultUri.toString(), DEFAULT_CHARSET_NAME); } catch (Exception e) { throw new IllegalArgumentException(e.getMessage(), e); } }
From source file:com.seajas.search.bridge.contender.metadata.URIWriteConverter.java
/** * {@inheritDoc} */ @Override public String convert(final URI source) { return source.toString(); }
From source file:com.sunchenbin.store.feilong.core.net.ParamUtil.java
/** * ?./* ww w .ja v a 2s.com*/ * * @param uri * the uri * @param paramName * the param name * @param charsetType * ??, {@link CharsetType}<br> * <span style="color:green">null empty,?,?</span><br> * ??,??,ie?chrome? url ,? * @return the string * @see #removeParameterList(URI, List, String) */ public static String removeParameter(URI uri, String paramName, String charsetType) { if (null == uri) { return StringUtils.EMPTY; } if (Validator.isNullOrEmpty(paramName)) {// paramNameList null return uri.toString(); } List<String> paramNameList = new ArrayList<String>(); paramNameList.add(paramName); return removeParameterList(uri, paramNameList, charsetType); }
From source file:com.ryan.ryanreader.fragments.CommentListingFragment.java
public static CommentListingFragment newInstance(final String parentPostIdAndType, final URI url, final UUID session, final CacheRequest.DownloadType downloadType) { final CommentListingFragment f = new CommentListingFragment(); final Bundle bundle = new Bundle(4); bundle.putString("parentPostIdAndType", parentPostIdAndType); bundle.putString("url", url.toString()); if (session != null) bundle.putString("session", session.toString()); bundle.putString("downloadType", downloadType.name()); f.setArguments(bundle);/*from w w w . ja va 2 s . com*/ return f; }