use of org.commonjava.maven.atlas.ident.util.JoinString in project indy by Commonjava.
the class JaxRsUriFormatter method formatAbsolutePathTo.
@Override
public String formatAbsolutePathTo(final String base, final String... parts) {
logger.debug("Formatting URL from base: '{}' and parts: {}", base, new JoinString(", ", parts));
String url = null;
try {
url = UrlUtils.buildUrl(base, parts);
} catch (final MalformedURLException e) {
logger.warn("Failed to use UrlUtils to build URL from base: {} and parts: {}", base, join(parts, ", "));
url = PathUtils.normalize(base, PathUtils.normalize(parts));
}
if (url.length() > 0 && !url.matches("[a-zA-Z0-9]+\\:\\/\\/.+") && url.charAt(0) != '/') {
url = "/" + url;
}
logger.debug("Resulting URL: '{}'", url);
return url;
// URL baseUrl = null;
// String path = base;
// try
// {
// baseUrl = new URL( base );
// path = baseUrl.getPath();
// }
// catch ( MalformedURLException e )
// {
// // not a URL.
// }
//
// path = PathUtils.normalize( base, PathUtils.normalize( parts ) );
// if ( !path.startsWith( "/" ) )
// {
// path = "/" + path;
// }
//
// if ( baseUrl != null )
// {
// // reconstruct...
// }
//
// return path;
}
Aggregations