Search in sources :

Example 16 with JoinString

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;
}
Also used : JoinString(org.commonjava.maven.atlas.ident.util.JoinString) MalformedURLException(java.net.MalformedURLException) JoinString(org.commonjava.maven.atlas.ident.util.JoinString)

Aggregations

JoinString (org.commonjava.maven.atlas.ident.util.JoinString)16 URI (java.net.URI)5 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)5 ProjectVersionRef (org.commonjava.maven.atlas.ident.ref.ProjectVersionRef)5 Location (org.commonjava.maven.galley.model.Location)5 Transfer (org.commonjava.maven.galley.model.Transfer)5 ArrayList (java.util.ArrayList)4 StoreKey (org.commonjava.indy.model.core.StoreKey)4 PluginView (org.commonjava.maven.galley.maven.model.view.PluginView)4 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 IndyDataException (org.commonjava.indy.data.IndyDataException)3 EProjectDirectRelationships (org.commonjava.maven.atlas.graph.model.EProjectDirectRelationships)3 ProjectRelationship (org.commonjava.maven.atlas.graph.rel.ProjectRelationship)3 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)3 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponse (io.swagger.annotations.ApiResponse)2 ApiResponses (io.swagger.annotations.ApiResponses)2 MalformedURLException (java.net.MalformedURLException)2 List (java.util.List)2