1717
1818import com .redhat .red .build .koji .model .xmlrpc .KojiArchiveInfo ;
1919import org .apache .commons .lang .StringUtils ;
20- import org .commonjava .indy .koji .conf .IndyKojiConfig ;
21- import org .commonjava .indy .koji .util .KojiUtils ;
2220import org .commonjava .atlas .maven .ident .ref .ArtifactRef ;
2321import org .commonjava .atlas .maven .ident .ref .SimpleProjectRef ;
22+ import org .commonjava .indy .koji .util .KojiUtils ;
23+ import org .commonjava .indy .model .core .StoreKey ;
2424import org .commonjava .maven .galley .TransferException ;
2525import org .slf4j .Logger ;
2626import org .slf4j .LoggerFactory ;
3030import java .util .HashSet ;
3131import java .util .List ;
3232import java .util .Set ;
33- import java .util .regex .Pattern ;
3433
3534import static org .commonjava .indy .pkg .maven .content .group .MavenMetadataMerger .METADATA_NAME ;
3635import static org .commonjava .maven .galley .maven .util .ArtifactPathUtils .formatMetadataPath ;
@@ -44,25 +43,42 @@ public class KojiPathPatternFormatter
4443
4544 private final Logger logger = LoggerFactory .getLogger ( getClass () );
4645
47- public Set <String > getPatterns ( ArtifactRef artifactRef , List <KojiArchiveInfo > archives )
46+ public Set <String > getPatterns ( final StoreKey inStore , ArtifactRef artifactRef , List <KojiArchiveInfo > archives )
4847 {
49- return getPatterns ( artifactRef , archives , false );
48+ return getPatterns ( inStore , artifactRef , archives , false );
5049 }
5150
52- public Set <String > getPatterns ( ArtifactRef artifactRef , List <KojiArchiveInfo > archives , boolean skipVersionTest )
51+ public Set <String > getPatterns ( final StoreKey inStore , ArtifactRef artifactRef , List <KojiArchiveInfo > archives , boolean skipVersionTest )
5352 {
5453 Set <String > patterns = new HashSet <>();
5554 for ( KojiArchiveInfo a : archives )
5655 {
56+ if ( !inStore .getPackageType ().equals ( a .getBuildType () ) )
57+ {
58+ logger .info ( "Discarding non-{} archive from path patterns: {}" , inStore .getPackageType (), a );
59+ continue ;
60+ }
61+
5762 ArtifactRef ar = a .asArtifact ();
63+
5864 if ( !skipVersionTest && !kojiUtils .isVersionSignatureAllowedWithVersion ( a .getVersion () ) )
5965 {
6066 logger .warn (
6167 "Cannot use Koji archive for path_mask_patterns: {}. Version '{}' is not allowed from Koji." , a ,
6268 a .getVersion () );
6369 continue ;
6470 }
71+
6572 String pattern = getPatternString ( ar , a );
73+
74+ if ( !skipVersionTest && !kojiUtils .isVersionSignatureAllowedWithVersion ( a .getVersion () ) )
75+ {
76+ logger .warn (
77+ "Cannot use Koji archive for path_mask_patterns: {}. Version '{}' is not allowed from Koji." , a ,
78+ a .getVersion () );
79+ continue ;
80+ }
81+
6682 if ( pattern != null )
6783 {
6884 patterns .add ( pattern );
0 commit comments