Skip to content

Commit

Permalink
Merge pull request #28 from yma96/main
Browse files Browse the repository at this point in the history
Fix the Illegal character encoder issue for repo name
  • Loading branch information
yma96 authored Jul 5, 2024
2 parents 52a0888 + 444fb82 commit e93b35f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.commonjava.indy.client.core.util.UrlUtils.encode;
import static org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY;

public class IndyStoresClientModule
Expand Down Expand Up @@ -59,7 +60,7 @@ public boolean exists( final StoreType type, final String name )
public boolean exists( final StoreKey key )
throws IndyClientException
{
return http.exists( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), key.getName() ) );
return http.exists( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), encode( key.getName() ) ) );
}

@Deprecated
Expand All @@ -72,15 +73,15 @@ public void delete( final StoreType type, final String name, final String change
public void delete( final StoreKey key, final String changelog )
throws IndyClientException
{
http.deleteWithChangelog( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), key.getName() ), changelog );
http.deleteWithChangelog( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), encode( key.getName() ) ), changelog );
}

public void delete( final StoreKey key, final String changelog, final boolean deleteContent )
throws IndyClientException
{
http.deleteWithChangelog(
UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(),
key.getName(), deleteContent ? "?deleteContent=true" : "" ), changelog );
encode( key.getName() ), deleteContent ? "?deleteContent=true" : "" ), changelog );
}

public boolean update( final ArtifactStore store, final String changelog )
Expand All @@ -102,7 +103,7 @@ public <T extends ArtifactStore> T load( StoreType type, String name, final Clas
public <T extends ArtifactStore> T load( StoreKey key, final Class<T> cls )
throws IndyClientException
{
return http.get( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), key.getName() ), cls );
return http.get( UrlUtils.buildUrl( STORE_BASEPATH, key.getPackageType(), key.getType().singularEndpointName(), encode( key.getName() ) ), cls );
}

public StoreListingDTO<HostedRepository> listHostedRepositories()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
*/
package org.commonjava.indy.client.core.util;

import org.commonjava.indy.client.core.IndyClientException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -193,4 +196,8 @@ public static String normalizePath( final String... path )
return sb.toString();
}

public static String encode( String value )
{
return URLEncoder.encode( value, StandardCharsets.UTF_8 );
}
}

0 comments on commit e93b35f

Please sign in to comment.