signature:
public class JaxRsUtils { /** * Create a { @ code Map < TKey , TValue > } instance from a
 * { @ code Map < TKey , TValue [ ] } instance .
 * @ param data
 * Input data .
 * @ return
 * A new instance which contains all the entries
 * in the input data . If the input data is { @ code null }
 * or empty , an empty { @ code MultivaluedMap } instance
 * is returned . */
public static < TKey , TValue > MultivaluedMap < TKey , TValue > createMultivaluedMap ( Map < TKey , TValue [ ] > data ) { } }

implementation: MultivaluedMap < TKey , TValue > target = new MultivaluedHashMap < TKey , TValue > ( ) ; return putAll ( target , data ) ;


signature:
public class JaxRsUtils { /** * Put all entries in a { @ code Map < TKey , TValue [ ] > } instance
 * into an existing { @ code MultivaluedMap < TKey , TValue > } .
 * @ param target
 * Target { @ code MultivaluedMap } instance .
 * @ param data
 * Input data .
 * @ return
 * The object given as { @ code target } . */
public static < TKey , TValue > MultivaluedMap < TKey , TValue > putAll ( MultivaluedMap < TKey , TValue > target , Map < TKey , TValue [ ] > data ) { } }

implementation: if ( target == null || data == null ) { return target ; } for ( Map . Entry < TKey , TValue [ ] > entry : data . entrySet ( ) ) { target . addAll ( entry . getKey ( ) , entry . getValue ( ) ) ; } return target ;


signature:
public class BaseBackchannelAuthenticationEndpoint { /** * Handle a backchannel authentication request in CIBA ( Client Initiated
 * Backchannel Authentication ) flow .
 * This method internally creates a { @ link BackchannelAuthenticationRequestHandler }
 * instance and calls its { @ link BackchannelAuthenticationRequestHandler # handle ( MultivaluedMap , String ) }
 * method . Then , this method uses the value returned from the { @ code handle ( ) }
 * method as a response from this method .
 * When { @ code BackchannelAuthenticationRequestHandler . handle ( ) } method raises a { @ link
 * WebApplicationException } , this method calls { @ link # onError ( WebApplicationException )
 * onError ( ) } method with the exception . The default implementation of { @ code onError ( ) }
 * does nothing . You can override the method as necessary . After calling
 * { @ code onError ( ) } method , this method calls { @ code getResponse ( ) } method of
 * the exception and uses the returned value as a response from this method .
 * @ param api
 * An implementation of { @ link AuthleteApi } .
 * @ param spi
 * An implementation of { @ link BackchannelAuthenticationRequestHandlerSpi } .
 * @ param parameters
 * Request parameters of the backchannel authentication request .
 * @ param authorization
 * The value of { @ code Authorization } header of the backchannel authentication
 * request .
 * @ param clientCertificatePath
 * The certificate path used in mutual TLS authentication , in PEM format . The
 * client ' s own certificate is the first in this array . Can be { @ code null } .
 * @ return
 * A response that should be returned to the client application .
 * @ since 2.13 */
public Response handle ( AuthleteApi api , BackchannelAuthenticationRequestHandlerSpi spi , MultivaluedMap < String , String > parameters , String authorization , String [ ] clientCertificatePath ) { } }

implementation:
try { // Create a handler .
BackchannelAuthenticationRequestHandler handler = new BackchannelAuthenticationRequestHandler ( api , spi ) ; // Delegate the task to the handler .
return handler . handle ( parameters , authorization , clientCertificatePath ) ; } catch ( WebApplicationException e ) { // An error occurred in the handler .
onError ( e ) ; // Convert the error to a Response .
return e . getResponse ( ) ; }


signature:
public class MessagesHelper { /** * Interpolate arguments into the message format string for the given message .
 * If a non - null locale is provided , an attempt is made to load a properties
 * file for the Message class of which this message is an instance , and the
 * property named by this message ' s name is used as the format string . If that
 * fails , or if the locale is null , the message object ' s default format string
 * is used .
 * The format string contains embedded place holders indicating where arguments
 * are to be substituted . Each place holder takes the form < code > % n < / code > or
 * < code > % { n } < / code > , where < code > n < / code > is an integer from 1 to the number of
 * arguments . The second form allows interpolation at a site immediately
 * followed by other digits .
 * To prevent a percent sign from triggering interpolation , double it :
 * < code > % % < / code > . For example , < code > " % % 1 % % { 2 } " < / code > will always produce
 * < code > " % 1 % { 2 } " < / code > .
 * The result is obtained by replacing each placeholder with the corresponding
 * argument ' s { @ link # toString ( ) } value ( except that null arguments are rendered
 * as empty strings ) .
 * @ param message Messages
 * @ param args Args
 * @ param locale Locale
 * @ return message with interpolated arguments */
public static String format ( Locale locale , Messages message , Object ... args ) { } }

implementation: String formatString = message . getFormatString ( locale ) ; Object [ ] sortArgs = sortArgs ( formatString , args ) ; String printfString = Stream . of ( formatString . split ( "%%" ) ) . map ( part -> placeholderPattern . matcher ( part ) . replaceAll ( "%s" ) ) . collect ( Collectors . joining ( "%%" ) ) ; return String . format ( printfString , sortArgs ) ;


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # downloadAll ( java . util . List , java . lang . String ) */
@ Override public List < Transfer > retrieveAll ( final List < ? extends ArtifactStore > stores , final String path ) throws IndyWorkflowException { } }

implementation: return retrieveAll ( stores , path , new EventMetadata ( ) ) ;


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # downloadAll ( java . util . List , java . lang . String ) */
@ Override @ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public List < Transfer > retrieveAll ( final List < ? extends ArtifactStore > stores , final String path , final EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: try { List < Transfer > txfrs = transfers . retrieveAll ( locationExpander . expand ( new VirtualResource ( LocationUtils . toLocations ( stores ) , path ) ) , eventMetadata ) ; return txfrs ; } catch ( final TransferException e ) { logger . error ( e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to retrieve ALL paths: {} from: {}. Reason: {}" , e , path , stores , e . getMessage ( ) ) ; }


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # download ( org . commonjava . indy . core . model . ArtifactStore ,
 * java . lang . String ) */
@ Override public Transfer retrieve ( final ArtifactStore store , final String path ) throws IndyWorkflowException { } }

implementation: return retrieve ( store , path , new EventMetadata ( ) ) ;


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # download ( org . commonjava . indy . core . model . ArtifactStore ,
 * java . lang . String ) */
@ Override @ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public Transfer retrieve ( final ArtifactStore store , final String path , final EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: return retrieve ( store , path , false , eventMetadata ) ;


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # upload ( org . commonjava . indy . core . model . DeployPoint ,
 * java . lang . String , java . io . InputStream ) */
@ Override @ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public Transfer store ( final ArtifactStore store , final String path , final InputStream stream , final TransferOperation op , final EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation:
if ( store . getKey ( ) . getType ( ) == StoreType . group ) { // FIXME : Why is this null ? Investigate .
return null ; } if ( store . getKey ( ) . getType ( ) != hosted ) { throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot deploy to non-deploy point artifact store: {}." , store . getKey ( ) ) ; } if ( ! isIgnoreReadonly ( eventMetadata ) && storeManager . isReadonly ( store ) ) { throw new IndyWorkflowException ( ApplicationStatus . METHOD_NOT_ALLOWED . code ( ) , "The store {} is readonly. If you want to store any content to this store, please modify it to non-readonly" , store . getKey ( ) ) ; } if ( store instanceof HostedRepository ) { final HostedRepository deploy = ( HostedRepository ) store ; // final ArtifactPathInfo pathInfo = ArtifactPathInfo . parse ( path ) ;
final ContentQuality quality = getQuality ( path ) ; if ( quality != null && quality == ContentQuality . SNAPSHOT ) { if ( ! deploy . isAllowSnapshots ( ) ) { logger . error ( "Cannot store snapshot in non-snapshot deploy point: {}" , deploy . getName ( ) ) ; throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot store snapshot in non-snapshot deploy point: {}" , deploy . getName ( ) ) ; } } else if ( ! deploy . isAllowReleases ( ) ) { logger . error ( "Cannot store release in snapshot-only deploy point: {}" , deploy . getName ( ) ) ; throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot store release in snapshot-only deploy point: {}" , deploy . getName ( ) ) ; } } // final Transfer target = getStorageReference ( deploy , path ) ;
// TODO : Need some protection for released files !
// if ( target . exists ( ) )
// throw new WebApplicationException (
// Response . status ( Status . BAD _ REQUEST ) . entity ( " Deployment path already exists . " ) . build ( ) ) ;
try { KeyedLocation loc = LocationUtils . toLocation ( store ) ; if ( isIgnoreReadonly ( eventMetadata ) && loc instanceof CacheOnlyLocation ) { ( ( CacheOnlyLocation ) loc ) . setReadonly ( false ) ; } final ConcreteResource resource = new ConcreteResource ( loc , path ) ; Transfer txfr = transfers . store ( resource , stream , eventMetadata ) ; nfc . clearMissing ( resource ) ; return txfr ; } catch ( final BadGatewayException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Bad gateway: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( final TransferTimeoutException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Timeout: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( final TransferLocationException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Location Error: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( TransferException e ) { logger . error ( String . format ( "Failed to store: %s in: %s. Reason: %s" , path , store . getKey ( ) , e . getMessage ( ) ) , e ) ; throw new IndyWorkflowException ( "Failed to store: %s in: %s. Reason: %s" , e , path , store . getKey ( ) , e . getMessage ( ) ) ; }


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # upload ( java . util . List , java . lang . String ,
 * java . io . InputStream ) */
@ Override public Transfer store ( final List < ? extends ArtifactStore > stores , final String path , final InputStream stream , final TransferOperation op ) throws IndyWorkflowException { } }

implementation: return store ( stores , path , stream , op , new EventMetadata ( ) ) ;


signature:
public class DefaultDownloadManager { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . util . FileManager # upload ( java . util . List , java . lang . String ,
 * java . io . InputStream ) */
@ Override public Transfer store ( final List < ? extends ArtifactStore > stores , final String path , final InputStream stream , final TransferOperation op , final EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: final ContentQuality quality = getQuality ( path ) ; HostedRepository selected = null ; for ( final ArtifactStore store : stores ) { if ( ! isIgnoreReadonly ( eventMetadata ) && storeManager . isReadonly ( store ) ) { logger . debug ( "The store {} is readonly, store operation not allowed" ) ; continue ; } if ( storeIsSuitableFor ( store , quality , op ) ) { selected = ( HostedRepository ) store ; break ; } } if ( selected == null ) { logger . warn ( "Cannot deploy. No valid deploy points in group." ) ; throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "No deployment locations available." ) ; } logger . info ( "Storing: {} in selected: {} with event metadata: {}" , path , selected , eventMetadata ) ; store ( selected , path , stream , op , eventMetadata ) ; return getStorageReference ( selected . getKey ( ) , path ) ;


signature:
public class DefaultDownloadManager { /** * clean just the cache ( storage of groups and remote repos ) */
private boolean deleteCache ( ArtifactStore store , String path , EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: if ( store . getKey ( ) . getType ( ) == hosted ) { return false ; } final Transfer item = getStorageReference ( store , path == null ? ROOT_PATH : path ) ; logger . trace ( "Delete cache, item: {}" , item ) ; return doDelete ( item , eventMetadata ) ;


signature: public class NFCContentListener { @ CacheEntryRemoved public void removeIndex ( final CacheEntryRemovedEvent < IndexedStorePath , IndexedStorePath > e ) { } }

implementation:
if ( e . isPre ( ) ) { IndexedStorePath isp = e . getValue ( ) ; final StoreKey key = new StoreKey ( isp . getPackageType ( ) , isp . getStoreType ( ) , isp . getStoreName ( ) ) ; // Only care about group level , as remote repo nfc is handled by remote timeout handler ( see galley DownloadHandler ) ,
// and hosted is handled by DownloadManager
if ( key . getType ( ) == StoreType . group ) { try { final ArtifactStore store = storeDataManager . getArtifactStore ( key ) ; final ConcreteResource r = new ConcreteResource ( LocationUtils . toLocation ( store ) , isp . getPath ( ) ) ; logger . debug ( "Add NFC of resource {} in store {}" , r , store ) ; if ( StoreType . hosted != key . getType ( ) ) { nfc . addMissing ( r ) ; } } catch ( IndyDataException ex ) { logger . error ( String . format ( "When add nfc missing for indexed artifact of path %s in store %s, failed to lookup store. Reason: %s" , isp . getPath ( ) , key , ex . getMessage ( ) ) , ex ) ; } } }


signature:
public class TimeoutEventListener { /** * private Executor executor ; */
public void onExpirationEvent ( @ Observes final SchedulerEvent event ) { } }

implementation: if ( ! ( event instanceof SchedulerTriggerEvent ) || ! event . getJobType ( ) . equals ( ScheduleManager . CONTENT_JOB_TYPE ) ) { return ; } ContentExpiration expiration ; try { expiration = objectMapper . readValue ( event . getPayload ( ) , ContentExpiration . class ) ; } catch ( final IOException e ) { logger . error ( "Failed to read ContentExpiration from event payload." , e ) ; return ; } final StoreKey key = expiration . getKey ( ) ; final String path = expiration . getPath ( ) ; try { ArtifactStore store = storeManager . getArtifactStore ( key ) ; if ( store == null ) { logger . warn ( "Store: {} is no longer available. Nothing to do for path: {}" , key , path ) ; } boolean deleted = store == null || contentManager . delete ( store , path ) ; if ( ! deleted ) { logger . error ( "Failed to delete Transfer for: {} in: {} (for content timeout)." , path , key ) ; } else { deleteExpiration ( key , path ) ; } } catch ( IndyWorkflowException e ) { logger . error ( String . format ( "Failed to retrieve Transfer for: %s in: %s (for content timeout). Reason: %s" , path , key , e ) , e ) ; } catch ( IndyDataException e ) { scheduleManager . deleteJob ( scheduleManager . groupName ( key , ScheduleManager . CONTENT_JOB_TYPE ) , path ) ; logger . error ( String . format ( "Failed to retrieve ArtifactStore for: %s (for content timeout). Reason: %s" , key , e ) , e ) ; }


signature:
public class ImpliedRepoMaintainer { /** * We cannot currently remove formerly implied repos because we can ' t distinguish between the above states . */
public void updateImpliedStores ( @ Observes final ArtifactStorePreUpdateEvent event ) { } }

implementation:
if ( ! storeManager . isStarted ( ) ) { return ; } if ( ! config . isEnabled ( ) ) { logger . debug ( "Implied-repository processing is not enabled." ) ; return ; } try { // TODO : Update for changes map .
final Map < StoreKey , ArtifactStore > currentStores = mapStores ( event ) ; for ( final ArtifactStore store : event ) { logger . debug ( "Processing store: {} for implied repo metadata" , store ) ; processStore ( store , currentStores ) ; } } catch ( Throwable error ) { Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; logger . error ( String . format ( "Implied-repository maintenance failed: %s" , error . getMessage ( ) ) , error ) ; }


signature:
public class CertUtils { /** * Create a self - signed X . 509 cert
 * @ param dn the X . 509 Distinguished Name , eg " CN = Test , L = London , C = GB "
 * @ param days how many days from now the cert is valid for
 * @ param algorithm the signing algorithm , eg " SHA256withRSA " */
public static X509Certificate generateX509Certificate ( KeyPair pair , String dn , int days , String algorithm ) throws GeneralSecurityException , IOException { } }

implementation:
PrivateKey privateKey = pair . getPrivate ( ) ; X509CertInfo info = new X509CertInfo ( ) ; Date from = new Date ( ) ; Date to = new Date ( from . getTime ( ) + TimeUnit . DAYS . toMillis ( days ) ) ; CertificateValidity interval = new CertificateValidity ( from , to ) ; BigInteger sn = new BigInteger ( 64 , new SecureRandom ( ) ) ; X500Name owner = new X500Name ( dn ) ; info . set ( X509CertInfo . VALIDITY , interval ) ; info . set ( X509CertInfo . SERIAL_NUMBER , new CertificateSerialNumber ( sn ) ) ; info . set ( X509CertInfo . SUBJECT , owner ) ; info . set ( X509CertInfo . ISSUER , owner ) ; info . set ( X509CertInfo . KEY , new CertificateX509Key ( pair . getPublic ( ) ) ) ; info . set ( X509CertInfo . VERSION , new CertificateVersion ( CertificateVersion . V3 ) ) ; AlgorithmId algo = new AlgorithmId ( AlgorithmId . sha256WithRSAEncryption_oid ) ; info . set ( X509CertInfo . ALGORITHM_ID , new CertificateAlgorithmId ( algo ) ) ; // Sign the cert to identify the algorithm that ' s used .
X509CertImpl cert = new X509CertImpl ( info ) ; cert . sign ( privateKey , algorithm ) ; // Update the algorithm , and resign .
algo = ( AlgorithmId ) cert . get ( X509CertImpl . SIG_ALG ) ; info . set ( CertificateAlgorithmId . NAME + "." + CertificateAlgorithmId . ALGORITHM , algo ) ; cert = new X509CertImpl ( info ) ; cert . sign ( privateKey , algorithm ) ; return cert ;


signature:
public class AbstractStoreDataManager { /** * TODO : currently we only check hosted readonly to prevent unexpected removing of both files and repo itself .
 * We may expand to remote or group in the future to support functions like remote repo " deploy - through " . */
@ Override public boolean isReadonly ( final ArtifactStore store ) { } }

implementation: if ( store != null ) { if ( store . getKey ( ) . getType ( ) == hosted && ( ( HostedRepository ) store ) . isReadonly ( ) ) { return true ; } } return false ;


signature:
public class IndyMetricsConstants { /** * Get default metric name . Use abbreviated package name , e . g . , foo . bar . ClassA . methodB - > f . b . ClassA . methodB */
public static String getDefaultName ( Class < ? > declaringClass , String method ) { } }

implementation:
// minimum len 1 shortens the package name and keeps class name
String cls = ClassUtils . getAbbreviatedName ( declaringClass . getName ( ) , 1 ) ; return name ( cls , method ) ;


signature:
public class IndyMetricsConstants { /** * Get the metric fullname .
 * @ param name user specified name
 * @ param defaultName ' class name + method name ' , not null . */
public static String getName ( String nodePrefix , String name , String defaultName , String ... suffix ) { } }

implementation: if ( isBlank ( name ) || name . equals ( DEFAULT ) ) { name = defaultName ; } return name ( name ( nodePrefix , name ) , suffix ) ;


signature:
public class RelateGenerationManager { /** * Generate relationship file for pom transfer .
 * @ param transfer
 * @ param op
 * @ return transfer pointing to the generated rel file . */
public Transfer generateRelationshipFile ( Transfer transfer , TransferOperation op ) { } }

implementation:
final Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; if ( ! config . isEnabled ( ) ) { logger . debug ( "Relate Add-on is not enabled." ) ; return null ; } logger . debug ( "Relate generation for {}" , transfer ) ; if ( transfer == null ) { logger . debug ( "No transfer. No .rel generation performed." ) ; return null ; } String txfrPath = transfer . getPath ( ) ; if ( ! txfrPath . endsWith ( ".pom" ) ) { logger . debug ( "This is not a pom transfer." ) ; return null ; } ArtifactPathInfo artPathInfo = ArtifactPathInfo . parse ( txfrPath ) ; if ( artPathInfo == null ) { logger . debug ( "Not an artifact download ({}). No .rel generation performed." , txfrPath ) ; return null ; } ConcreteResource pomResource = transfer . getResource ( ) ; StoreKey storeKey = StoreKey . fromString ( transfer . getLocation ( ) . getName ( ) ) ; ArtifactStore store ; try { store = storeManager . getArtifactStore ( storeKey ) ; } catch ( final IndyDataException ex ) { logger . error ( "Error retrieving artifactStore with key " + storeKey , ex ) ; return null ; } logger . debug ( "Generate .rel corresponding to associated POM download: {}/{}" , storeKey , pomResource . getPath ( ) ) ; try { URI source = new URI ( pomResource . getLocation ( ) . getUri ( ) + REL_SUFFIX ) ; ProjectVersionRef ref = artPathInfo . getProjectId ( ) ; // get all groups that this store is a member of
Set < ArtifactStore > stores = new HashSet < > ( ) ; stores . add ( store ) ; stores . addAll ( storeManager . query ( ) . getGroupsContaining ( store . getKey ( ) ) ) ; List < ? extends Location > supplementalLocations = LocationUtils . toLocations ( stores . toArray ( new ArtifactStore [ 0 ] ) ) ; MavenPomView pomView = mavenPomReader . read ( ref , transfer , supplementalLocations , ALL_PROFILES ) ; EProjectDirectRelationships rel = mavenModelProcessor . readRelationships ( pomView , source , new ModelProcessorConfig ( ) ) ; Transfer transferRel = transfer . getSiblingMeta ( REL_SUFFIX ) ; writeRelationships ( rel , transferRel , op ) ; return transferRel ; } catch ( Exception e ) { logger . error ( "Error generating .rel file for " + txfrPath + " from store " + store , e ) ; return null ; }


signature:
public class KojiBuildAuthority { /** * Checks if the given archive GAV contains unreplaced placeholders , e . g . " $ { parent . version } " in the version field . */
private boolean containsPlaceholders ( final KojiArchiveInfo archive ) { } }

implementation: return contains ( trimToEmpty ( archive . getArtifactId ( ) ) , "${" ) || contains ( trimToEmpty ( archive . getGroupId ( ) ) , "${" ) || contains ( trimToEmpty ( archive . getVersion ( ) ) , "${" ) ;


signature:
public class TemplatingEngine { /** * TODO Cache these . . . though this will hurt hot - reloading . Perhaps a debug mode configuration ? */
private Template getTemplate ( final String acceptHeader , final String templateKey ) throws IndyGroovyException { } }

implementation: final String accept = ( acceptHeader == null ? "" : acceptHeader . replace ( '/' , '_' ) + "/" ) ; try { final String filename = accept + templateKey + ".groovy" ; final DataFile templateFile = manager . getDataFile ( TEMPLATES , filename ) ; logger . info ( "Looking for template: {} for ACCEPT header: {} in: {}" , templateKey , acceptHeader , templateFile ) ; Template template ; if ( templateFile . exists ( ) && ! templateFile . isDirectory ( ) ) { template = engine . createTemplate ( templateFile . readString ( ) ) ; } else { final String urlpath = TEMPLATES + "/" + accept + templateKey + ".groovy" ; logger . info ( "Looking for template: {} for ACCEPT header: {} in: {}" , templateKey , acceptHeader , urlpath ) ; final URL u = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( urlpath ) ; template = u == null ? null : engine . createTemplate ( u ) ; } if ( template == null ) { throw new IndyGroovyException ( "Failed to locate template: %s (with ACCEPT header: %s)" , templateKey , acceptHeader ) ; } return template ; } catch ( final CompilationFailedException e ) { throw new IndyGroovyException ( "Failed to compile template: %s. Reason: %s" , e , templateKey , e . getMessage ( ) ) ; } catch ( final ClassNotFoundException e ) { throw new IndyGroovyException ( "Failed to compile template: %s. Reason: %s" , e , templateKey , e . getMessage ( ) ) ; } catch ( final IOException e ) { throw new IndyGroovyException ( "Failed to read template: %s. Reason: %s" , e , templateKey , e . getMessage ( ) ) ; }


signature:
public class ContentUtils { /** * Attempt to remove duplicates , even " fuzzy " ones where a directory is
 * listed with trailing ' / ' in some cases but not others . */
public static List < StoreResource > dedupeListing ( final List < StoreResource > listing ) { } }

implementation: final List < StoreResource > result = new ArrayList < StoreResource > ( ) ; final Map < String , StoreResource > mapping = new LinkedHashMap < String , StoreResource > ( ) ; for ( final StoreResource res : listing ) { final String path = res . getPath ( ) ; if ( mapping . containsKey ( path ) ) { continue ; } if ( mapping . containsKey ( path + "/" ) ) { continue ; } mapping . put ( path , res ) ; result . add ( res ) ; } return result ;


signature:
public class StoreContentListener { /** * Handles store disable / enablement . */
@ Measure public void onStoreEnablement ( @ Observes final ArtifactStoreEnablementEvent event ) { } }

implementation:
Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; logger . trace ( "Got store-enablement event: {}" , event ) ; if ( event . isPreprocessing ( ) ) { if ( event . isDisabling ( ) ) { /* For disablement , we remove the merged metadata files by paths via listing mergable files in the target repo ' s local cache .
 * We do not cache pom / jar files in affected groups so don ' t worry about them . */
processAllPaths ( event , mergablePathStrings ( ) , false ) ; } else { /* When enabling a repo , we have to clean all ( mergable ) content from containing groups ' cache because
 * we don ' t have complete listing of the enabled repo and listing it is very slow . The only option how to keep
 * the cache consistent is to drop everything from it . */
processAllPathsExt ( event , mergablePathStrings ( ) ) ; } }


signature:
public class StoreContentListener { /** * TODO : If we find points where a new HostedRepository is added , we should be using its comprehensive index to minimize the index damage to the group . */
private void removeAllSupercededMemberContent ( final ArtifactStore store , final Map < ArtifactStore , ArtifactStore > changeMap ) { } }

implementation:
StoreKey key = store . getKey ( ) ; // we ' re only interested in groups , since only adjustments to group memberships can invalidate indexed content .
if ( group == key . getType ( ) ) { List < StoreKey > newMembers = ( ( Group ) store ) . getConstituents ( ) ; logger . debug ( "New members of: {} are: {}" , store , newMembers ) ; Group group = ( Group ) changeMap . get ( store ) ; List < StoreKey > oldMembers = group . getConstituents ( ) ; logger . debug ( "Old members of: {} are: {}" , group , oldMembers ) ; int commonSize = Math . min ( newMembers . size ( ) , oldMembers . size ( ) ) ; int divergencePoint ; // look in the members that overlap in new / old groups and see if there are changes that would
// indicate member reordering . If so , it might lead previously suppressed results to be prioritized ,
// which would invalidate part of the content index for the group .
boolean foundDivergence = false ; for ( divergencePoint = 0 ; divergencePoint < commonSize ; divergencePoint ++ ) { logger . debug ( "Checking for common member at index: {}" , divergencePoint ) ; if ( ! oldMembers . get ( divergencePoint ) . equals ( newMembers . get ( divergencePoint ) ) ) { foundDivergence = true ; break ; } } // [ NOS - 128]
// 1 . If membership has shrunk , we can remove origin - indexed paths , which will remove merged group content
// based on the removed member ' s content .
// 2 . If membership has grown , we should iterate new members ' indexed content looking for mergable paths .
// For each of these , we need to removeIndexedStorePaths using the group and the mergable path .
// [ addendum ]
// 3 . If membership is the same size but has been reordered , we need to iterate from the divergence point
// and invalidate the non - mergable files . This is because the reordering may change what artifacts
// should obscure which other physical artifacts .
// NOTE : In any case , once we isolate the changes , we need to handle matches in two ways :
// 1 . deleteTransfers ( )
// 2 . add the indexedStorePath to the removed Set so we can propagage their removal through any groups
// that include the one we ' re affecting directly here . . . using clearIndexedPathFrom ( ) to do this .
if ( ! foundDivergence ) { if ( newMembers . size ( ) < oldMembers . size ( ) ) { divergencePoint = commonSize ; } else { divergencePoint = newMembers . size ( ) ; } } logger . debug ( "group membership divergence point: {}" , divergencePoint ) ; Set < StoreKey > affectedMembers = new HashSet < > ( ) ; boolean removeMergableOnly = divergencePoint >= oldMembers . size ( ) ; // if we can iterate some old members that have been removed or reordered , invalidate the
// group content index entries for those .
if ( divergencePoint < oldMembers . size ( ) ) { for ( int i = divergencePoint ; i < oldMembers . size ( ) ; i ++ ) { affectedMembers . add ( oldMembers . get ( i ) ) ; } } else { // for new added members , need to clear the indexed path with this group store for repo metadata merging
// See [ NOS - 128]
for ( int i = divergencePoint - 1 ; i >= commonSize ; i -- ) { affectedMembers . add ( newMembers . get ( i ) ) ; } } logger . debug ( "Got members affected by membership divergence: {}" , affectedMembers ) ; if ( ! affectedMembers . isEmpty ( ) ) { Set < Group > groups = new HashSet < > ( ) ; groups . add ( group ) ; try { groups . addAll ( storeDataManager . query ( ) . packageType ( group . getPackageType ( ) ) . getGroupsAffectedBy ( group . getKey ( ) ) ) ; } catch ( IndyDataException e ) { logger . error ( String . format ( "Cannot retrieve groups affected by: %s. Reason: %s" , group . getKey ( ) , e . getMessage ( ) ) , e ) ; } logger . debug ( "Got affected groups: {}" , groups ) ; DrainingExecutorCompletionService < Integer > clearService = new DrainingExecutorCompletionService < > ( cleanupExecutor ) ; final Predicate < ? super String > mergableFilter = removeMergableOnly ? mergablePathStrings ( ) : ( p ) -> true ; // NOTE : We ' re NOT checking load for this executor , since this is an async process that is critical to
// data integrity .
affectedMembers . forEach ( ( memberKey ) -> { logger . debug ( "Listing all {}paths in: {}" , ( removeMergableOnly ? "mergeable " : "" ) , memberKey ) ; listPathsAnd ( memberKey , mergableFilter , p -> clearService . submit ( clearPathProcessor ( p , memberKey , groups ) ) ) ; } ) ; drainAndCount ( clearService , "store: " + store . getKey ( ) ) ; }


signature:
public class GitManager { /** * private boolean verifyChangesExist ( final Collection < String > paths )
 * throws GitSubsystemException
 * return lockAnd ( me - > {
 * try
 * final DiffFormatter formatter = new DiffFormatter ( System . out ) ;
 * formatter . setRepository ( repo ) ;
 * resolve the HEAD object
 * final ObjectId oid = repo . resolve ( Constants . HEAD ) ;
 * if ( oid = = null )
 * if there ' s no head , then these must be real changes . . .
 * return true ;
 * reset a new tree object to the HEAD
 * final RevWalk walk = new RevWalk ( repo ) ;
 * final RevCommit commit = walk . parseCommit ( oid ) ;
 * final RevTree treeWalk = walk . parseTree ( commit ) ;
 * construct filters for the paths we ' re trying to add / commit
 * final List < TreeFilter > filters = new ArrayList < > ( ) ;
 * for ( final String path : paths )
 * filters . add ( PathFilter . create ( path ) ) ;
 * we ' re interested in trees with an actual diff . This should improve walk performance .
 * filters . add ( TreeFilter . ANY _ DIFF ) ;
 * set the path filters from above
 * walk . setTreeFilter ( AndTreeFilter . create ( filters ) ) ;
 * setup the tree for doing the comparison vs . uncommitted files
 * final CanonicalTreeParser tree = new CanonicalTreeParser ( ) ;
 * final ObjectReader oldReader = repo . newObjectReader ( ) ;
 * try
 * tree . reset ( oldReader , treeWalk . getId ( ) ) ;
 * finally
 * oldReader . release ( ) ;
 * walk . dispose ( ) ;
 * this iterator will actually scan the uncommitted files for diff ' ing
 * final FileTreeIterator files = new FileTreeIterator ( repo ) ;
 * do the scan .
 * final List < DiffEntry > entries = formatter . scan ( tree , files ) ;
 * we ' re not interested in WHAT the differences are , only that there are differences .
 * return entries ! = null & & ! entries . isEmpty ( ) ;
 * catch ( final IOException e )
 * throw new GitSubsystemException ( " Failed to scan for actual changes among : % s . Reason : % s " , e , paths ,
 * e . getMessage ( ) ) ; */
private String buildMessage ( final ChangeSummary summary , final Collection < String > paths ) { } }

implementation: final StringBuilder message = new StringBuilder ( ) . append ( summary . getSummary ( ) ) ; if ( config . isCommitFileManifestsEnabled ( ) ) { message . append ( "\n\nFiles changed:\n" ) . append ( join ( paths , "\n" ) ) ; } return message . toString ( ) ;


signature:
public class GitManager { /** * Commit the changelog entries
 * @ return size of changelog entries being committed */
public int commit ( ) throws GitSubsystemException { } }

implementation: int committed = lockAnd ( me -> { final int size = changelogEntries . size ( ) ; if ( ! changelogEntries . isEmpty ( ) ) { try { CommitCommand commit = git . commit ( ) ; StringBuilder sb = new StringBuilder ( ) . append ( COMMIT_CHANGELOG_ENTRIES + "\n\n" ) ; for ( ChangelogEntry et : changelogEntries ) { sb . append ( et . getUsername ( ) + " " + et . getTimestamp ( ) + " " + et . getMessage ( ) ) ; sb . append ( "\n\n" ) ; } String message = sb . toString ( ) ; logger . info ( message ) ; commit . setMessage ( message ) . setAuthor ( SYSTEM_USER , email ) . call ( ) ; changelogEntries . clear ( ) ; } catch ( final JGitInternalException | GitAPIException e ) { throw new GitSubsystemException ( "Cannot commit to git: " + e . getMessage ( ) , e ) ; } } return size ; } ) ; return committed ;


signature: public class GitManager { private ChangeSummary toChangeSummary ( final RevCommit commit ) { } }

implementation: final PersonIdent who = commit . getAuthorIdent ( ) ; final Date when = new Date ( TimeUnit . MILLISECONDS . convert ( commit . getCommitTime ( ) , TimeUnit . SECONDS ) ) ; return new ChangeSummary ( who . getName ( ) , commit . getFullMessage ( ) , when , commit . getId ( ) . name ( ) ) ;


signature:
public class ISPNRemoteConfiguration { /** * utils */
public boolean isRemoteCache ( String cacheName ) { } }

implementation: if ( remotePatterns == null ) { return false ; } String [ ] patterns = remotePatterns . split ( "," ) ; for ( String pattern : patterns ) { if ( isNotBlank ( pattern ) ) { if ( cacheName . matches ( pattern ) || cacheName . equals ( pattern ) ) { return true ; } } } return false ;


signature:
public class IndyZabbixReporter { /** * for histograms .
 * @ param key
 * @ param snapshot
 * @ param dataObjectList */
private void addSnapshotDataObject ( String key , Snapshot snapshot , long clock , List < DataObject > dataObjectList ) { } }

implementation: dataObjectList . add ( toDataObject ( key , ".min" , snapshot . getMin ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".max" , snapshot . getMax ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".mean" , snapshot . getMean ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".stddev" , snapshot . getStdDev ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".median" , snapshot . getMedian ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".75th" , snapshot . get75thPercentile ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".95th" , snapshot . get95thPercentile ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".98th" , snapshot . get98thPercentile ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".99th" , snapshot . get99thPercentile ( ) , clock ) ) ; dataObjectList . add ( toDataObject ( key , ".99.9th" , snapshot . get999thPercentile ( ) , clock ) ) ;


signature:
public class StoreEnablementManager { /** * FIXME : Convert to using ArtifactStoreEnablementEvent . */
@ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public void onStoreEnablementChange ( @ Observes ArtifactStoreEnablementEvent event ) { } }

implementation: if ( event . isPreprocessing ( ) ) { return ; } for ( ArtifactStore store : event ) { if ( ! event . isDisabling ( ) ) { try { cancelReEnablementTimeout ( store . getKey ( ) ) ; } catch ( IndySchedulerException e ) { Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; logger . error ( String . format ( "Failed to delete re-enablement job for %s." , store . getKey ( ) ) , e ) ; } } }


signature: public class StoreEnablementManager { @ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public void onStoreError ( @ Observes IndyStoreErrorEvent evt ) { } }

implementation:
Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; StoreKey key = evt . getStoreKey ( ) ; Throwable error = evt . getError ( ) ; try { ArtifactStore store = storeDataManager . getArtifactStore ( key ) ; if ( store == null ) { logger . warn ( "Attempt to disable missing repo! Skipping." ) ; return ; } store = store . copyOf ( ) ; int disableTimeout = store . getDisableTimeout ( ) ; if ( disableTimeout <= TIMEOUT_NEVER_DISABLE ) { logger . debug ( "Disable-timeout set to {}, will never disable the repo" , disableTimeout ) ; store . setDisabled ( false ) ; } else { store . setDisabled ( true ) ; final ChangeSummary changeSummary = new ChangeSummary ( ChangeSummary . SYSTEM_USER , String . format ( "Disabling %s due to error: %s\n\nStack Trace:\n  %s" , key , error , StringUtils . join ( error . getStackTrace ( ) , "\n  " ) ) ) ; storeDataManager . storeArtifactStore ( store , changeSummary , false , true , new EventMetadata ( ) ) ; logger . warn ( "{} has been disabled due to store-level error: {}\n Will re-enable in {} seconds." , key , error , disableTimeout == TIMEOUT_USE_DEFAULT ? config . getStoreDisableTimeoutSeconds ( ) : disableTimeout ) ; // TODO : How is it this doesn ' t duplicate the event handler method onStoreUpdate ( ) . . . we ' re updating the store just above here .
setReEnablementTimeout ( key ) ; } } catch ( IndyDataException e ) { logger . error ( String . format ( "Failed to disable %s on error: %s" , key , error ) , e ) ; } catch ( IndySchedulerException e ) { logger . error ( String . format ( "Failed to schedule re-enablement of %s for retry." , key ) , e ) ; }


signature:
public class AutoProxDataManagerDecorator { /** * Validates the remote connection , produced from rule - set for given key ,
 * for a remote repo or group containing a remote . If :
 * < ul >
 * < li > rule . isValidationEnabled ( ) = = false , return true < / li >
 * < li > rule . getValidationRemote ( ) = = null , return true < / li >
 * < li >
 * rule . getRemoteValidationPath ( ) ! = null , validate remote . getUrl ( ) + validationPath
 * < ul >
 * < li > if response code is 200 OK , then return true < / li >
 * < li > otherwise , return false < / li >
 * < / ul >
 * < / li >
 * < / ul >
 * @ throws IndyDataException if the selected rule encounters an error while creating the new group / repository instance ( s ) . */
private boolean checkValidity ( final StoreKey key ) throws IndyDataException { } }

implementation: if ( catalog . isValidationEnabled ( key ) ) { try { final RemoteRepository validationRepo = catalog . createValidationRemote ( key ) ; if ( validationRepo == null ) { logger . info ( "No validation repository was created: assuming {} is valid." , key ) ; return true ; } String path = catalog . getRemoteValidationPath ( key ) ; if ( path == null ) { path = PathUtils . ROOT ; } logger . debug ( "\n\n\n\n\n[AutoProx] Checking path: {} under remote URL: {}" , path , validationRepo . getUrl ( ) ) ; boolean result = false ; try { result = transferManager . exists ( new ConcreteResource ( LocationUtils . toLocation ( validationRepo ) , path ) ) ; } catch ( final TransferException e ) { logger . warn ( "[AutoProx] Cannot connect to target repository: '{}'. Reason: {}" , validationRepo , e . getMessage ( ) ) ; logger . debug ( "[AutoProx] exception from validation attempt for: " + validationRepo , e ) ; } logger . debug ( "Validation result for: {} is: {}" , validationRepo , result ) ; return result ; } catch ( final AutoProxRuleException e ) { throw new IndyDataException ( "[AUTOPROX] Failed to create new group from factory matching: '%s'. Reason: %s" , e , key , e . getMessage ( ) ) ; } } return true ;


signature:
public class ProxyResponseHelper { /** * Create repositories ( group , remote , hosted ) when trackingId is present . Otherwise create normal remote
 * repository with specified name .
 * @ param trackingId
 * @ param url
 * @ param name distinct remote repository name . null if trackingId is given */
private ProxyCreationResult createRepo ( String trackingId , URL url , String name ) throws IndyDataException { } }

implementation: UrlInfo info = new UrlInfo ( url . toExternalForm ( ) ) ; UserPass up = UserPass . parse ( ApplicationHeader . authorization , httpRequest , url . getAuthority ( ) ) ; String baseUrl = getBaseUrl ( url , false ) ; logger . debug ( ">>>> Create repo: trackingId=" + trackingId + ", name=" + name ) ; ProxyCreationResult result = repoCreator . create ( trackingId , name , baseUrl , info , up , LoggerFactory . getLogger ( repoCreator . getClass ( ) ) ) ; ChangeSummary changeSummary = new ChangeSummary ( ChangeSummary . SYSTEM_USER , "Creating HTTProx proxy for: " + info . getUrl ( ) ) ; RemoteRepository remote = result . getRemote ( ) ; if ( remote != null ) { storeManager . storeArtifactStore ( remote , changeSummary , false , true , new EventMetadata ( ) ) ; } HostedRepository hosted = result . getHosted ( ) ; if ( hosted != null ) { storeManager . storeArtifactStore ( hosted , changeSummary , false , true , new EventMetadata ( ) ) ; } Group group = result . getGroup ( ) ; if ( group != null ) { storeManager . storeArtifactStore ( group , changeSummary , false , true , new EventMetadata ( ) ) ; } return result ;


signature:
public class ProxyResponseHelper { /** * if repo with this name already exists , we need to use a different name */
private String getRemoteRepositoryName ( URL url ) throws IndyDataException { } }

implementation: final String name = repoCreator . formatId ( url . getHost ( ) , getPort ( url ) , 0 , null , StoreType . remote ) ; logger . debug ( "Looking for remote repo starts with name: {}" , name ) ; AbstractProxyRepositoryCreator abstractProxyRepositoryCreator = null ; if ( repoCreator instanceof AbstractProxyRepositoryCreator ) { abstractProxyRepositoryCreator = ( AbstractProxyRepositoryCreator ) repoCreator ; } if ( abstractProxyRepositoryCreator == null ) { return name ; } Predicate < ArtifactStore > filter = abstractProxyRepositoryCreator . getNameFilter ( name ) ; List < String > l = storeManager . query ( ) . packageType ( GENERIC_PKG_KEY ) . storeType ( RemoteRepository . class ) . stream ( filter ) . map ( repository -> repository . getName ( ) ) . collect ( Collectors . toList ( ) ) ; if ( l . isEmpty ( ) ) { return name ; } return abstractProxyRepositoryCreator . getNextName ( l ) ;


signature:
public class AbstractProxyRepositoryCreator { /** * Get the remote repo names with name starts with base name ( PROXY _ REPO _ PREFIX + host + " _ " + port ) */
public Predicate < ArtifactStore > getNameFilter ( String name ) { } }

implementation: return store -> store . getName ( ) . startsWith ( name ) ;


signature:
public class AbstractProxyRepositoryCreator { /** * Get the next distinct name based on the query result by filter of getNameFilter
 * @ param names
 * @ return */
public String getNextName ( List < String > names ) { } }

implementation: if ( names . isEmpty ( ) ) { return null ; } String name0 = names . get ( 0 ) ; if ( names . size ( ) == 1 ) { return name0 + "_1" ; } Collections . sort ( names ) ; String last = names . get ( names . size ( ) - 1 ) ; String index = last . substring ( last . lastIndexOf ( "_" ) + 1 ) ; return name0 + "_" + ( Integer . parseInt ( index ) + 1 ) ;


signature:
public class IndyFileEventManager { /** * private Executor executor ; */
@ Override public void fire ( final FileNotFoundEvent evt ) { } }

implementation: if ( shouldFireEvent ( evt . getEventMetadata ( ) ) ) { fireEvent ( notFoundEvent , evt ) ; }


signature:
public class IndyKafkaProducer { /** * Non - blocking send . The message will not be really available to consumers until flush ( )
 * or close ( ) is called , or until another blocking send is called . */
public void send ( String topic , String message ) throws IOException { } }

implementation: send ( topic , message , null ) ;


signature:
public class IndyKafkaProducer { /** * Non - blocking send with a logback formatter to format the message . */
public void send ( String topic , String message , LogbackFormatter formatter ) throws IOException { } }

implementation: doKafkaSend ( topic , message , formatter ) ;


signature:
public class IndyKafkaProducer { /** * Blocking send . The message will be available to consumers immediately . Wait for at most the given time
 * for the operation to complete . */
public void send ( String topic , String message , long timeoutMillis ) throws IOException , InterruptedException , ExecutionException , TimeoutException { } }

implementation: send ( topic , message , null , timeoutMillis ) ;


signature:
public class IndyKafkaProducer { /** * Blocking send with a logback formatter to format the message . */
public void send ( String topic , String message , LogbackFormatter formatter , long timeoutMillis ) throws IOException , InterruptedException , ExecutionException , TimeoutException { } }

implementation: Future future = doKafkaSend ( topic , message , formatter ) ; if ( future != null ) { future . get ( timeoutMillis , TimeUnit . MILLISECONDS ) ; }


signature: public class ImpliedRepoConfig { public boolean isBlacklisted ( final String url ) throws MalformedURLException { } }

implementation: final URL u = new URL ( url ) ; return isBlacklisted ( u ) ;


signature:
public class ProxyRequestReader { /** * TODO : NONE of the request headers ( except authorization ) are passed through ! */
@ Override public void handleEvent ( final ConduitStreamSourceChannel sourceChannel ) { } }

implementation: boolean sendResponse = false ; try { final int read = doRead ( sourceChannel ) ; if ( read <= 0 ) { logger . debug ( "Reads: {} " , read ) ; return ; } byte [ ] bytes = bReq . toByteArray ( ) ; if ( sslTunnel != null ) { logger . debug ( "Send to ssl tunnel, {}, bytes:\n\n {}\n" , new String ( bytes ) , Hex . encodeHexString ( bytes ) ) ; directTo ( sslTunnel ) ; return ; } logger . debug ( "Request in progress is:\n\n{}" , new String ( bytes ) ) ; if ( headDone ) { logger . debug ( "Request done. parsing." ) ; MessageConstraints mc = MessageConstraints . DEFAULT ; SessionInputBufferImpl inbuf = new SessionInputBufferImpl ( new HttpTransportMetricsImpl ( ) , 1024 ) ; HttpRequestFactory requestFactory = new DefaultHttpRequestFactory ( ) ; LineParser lp = new BasicLineParser ( ) ; DefaultHttpRequestParser requestParser = new DefaultHttpRequestParser ( inbuf , lp , requestFactory , mc ) ; inbuf . bind ( new ByteArrayInputStream ( bytes ) ) ; try { logger . debug ( "Passing parsed http request off to response writer." ) ; HttpRequest request = requestParser . parse ( ) ; logger . debug ( "Request contains {} header: '{}'" , ApplicationHeader . authorization . key ( ) , request . getHeaders ( ApplicationHeader . authorization . key ( ) ) ) ; writer . setHttpRequest ( request ) ; sendResponse = true ; } catch ( ConnectionClosedException e ) { logger . warn ( "Client closed connection. Aborting proxy request." ) ; sendResponse = false ; sourceChannel . shutdownReads ( ) ; } catch ( HttpException e ) { logger . error ( "Failed to parse http request: " + e . getMessage ( ) , e ) ; writer . setError ( e ) ; } } else { logger . debug ( "Request not finished. Pausing until more reads are available." ) ; sourceChannel . resumeReads ( ) ; } } catch ( final IOException e ) { writer . setError ( e ) ; sendResponse = true ; } if ( sendResponse ) { sinkChannel . resumeWrites ( ) ; }


signature:
public class ReplicationController { /** * FIXME : Find a better solution to the passed - in generic deserialization problem . . . erasure is a mother . . . */
private List < ? extends ArtifactStore > getRemoteStores ( final ReplicationDTO dto ) throws IndyWorkflowException { } }

implementation:
final String apiUrl = dto . getApiUrl ( ) ; String remotesUrl = null ; String groupsUrl = null ; String hostedUrl = null ; try { remotesUrl = buildUrl ( apiUrl , "/admin/remotes" ) ; groupsUrl = buildUrl ( apiUrl , "/admin/groups" ) ; hostedUrl = buildUrl ( apiUrl , "/admin/hosted" ) ; } catch ( final MalformedURLException e ) { throw new IndyWorkflowException ( "Failed to construct store definition-retrieval URL from api-base: {}. Reason: {}" , e , apiUrl , e . getMessage ( ) ) ; } // logger . info ( " \ n \ n \ n \ n \ n [ AutoProx ] Checking URL : { } from : " , new Throwable ( ) , url ) ;
final List < ArtifactStore > result = new ArrayList < ArtifactStore > ( ) ; addStoresFrom ( result , remotesUrl , dto , RemoteRepository . class ) ; addStoresFrom ( result , groupsUrl , dto , Group . class ) ; addStoresFrom ( result , hostedUrl , dto , HostedRepository . class ) ; return result ;


signature:
public class IndyKojiContentProvider { /** * This is to register ISPN caches produced by this provider so that the Metrics knows them . */
public Set < String > getCacheNames ( ) { } }

implementation: Set < String > ret = new HashSet < > ( ) ; if ( kojiConfig . isEnabled ( ) && kojiConfig . isQueryCacheEnabled ( ) ) { ret . add ( KOJI_TAGS ) ; ret . add ( KOJI_BUILD_INFO ) ; ret . add ( KOJI_BUILD_INFO_CONTAINING_ARTIFACT ) ; ret . add ( KOJI_ARCHIVES_FOR_BUILD ) ; ret . add ( KOJI_ARCHIVES_MATCHING_GA ) ; } return ret ;


signature:
public class IndyKojiContentProvider { /** * The caller actually passes SimpleArtifactRef which has right hashcode / equals so we can use it as cache key . */
public List < KojiBuildInfo > listBuildsContaining ( ArtifactRef artifactRef , KojiSessionInfo session ) throws KojiClientException { } }

implementation: return computeIfAbsent ( KOJI_BUILD_INFO_CONTAINING_ARTIFACT , ArtifactRef . class , List . class , artifactRef , ( ) -> kojiClient . listBuildsContaining ( artifactRef , session ) , kojiConfig . getQueryCacheTimeoutHours ( ) ) ;


signature:
public class IndyKojiContentProvider { /** * NOTE : This also enriches the archive results ! */
public List < KojiArchiveInfo > listArchivesMatching ( ProjectRef ga , KojiSessionInfo session ) throws KojiClientException { } }

implementation: KojiArchiveQuery query = new KojiArchiveQuery ( ga ) ; return computeIfAbsent ( KOJI_ARCHIVES_MATCHING_GA , ProjectRef . class , List . class , ga , ( ) -> { List < KojiArchiveInfo > archives = kojiClient . listArchives ( query , session ) ; kojiClient . enrichArchiveTypeInfo ( archives , session ) ; return archives ; } , kojiConfig . getQueryCacheTimeoutHours ( ) ) ;


signature:
public class IndyKojiContentProvider { /** * NOTE : This also enriches the archive results ! */
public List < KojiArchiveInfo > listArchivesForBuild ( Integer buildId , KojiSessionInfo session ) throws KojiClientException { } }

implementation: KojiArchiveQuery query = new KojiArchiveQuery ( ) . withBuildId ( buildId ) ; return computeIfAbsent ( KOJI_ARCHIVES_FOR_BUILD , Integer . class , List . class , buildId , ( ) -> { List < KojiArchiveInfo > archives = kojiClient . listArchives ( query , session ) ; kojiClient . enrichArchiveTypeInfo ( archives , session ) ; return archives ; } ) ;


signature:
public class FoloUtils { /** * Write sealed records to a zip file . */
public static void zipTrackedContent ( File out , Set < TrackedContent > sealed ) throws IOException { } }

implementation: logger . info ( "Writing sealed zip to: '{}'" , out . getAbsolutePath ( ) ) ; try ( ZipOutputStream zip = new ZipOutputStream ( new FileOutputStream ( out ) ) ) { for ( TrackedContent f : sealed ) { String name = SEALED . getValue ( ) + "/" + f . getKey ( ) . getId ( ) ; logger . trace ( "Adding {} to zip" , name ) ; zip . putNextEntry ( new ZipEntry ( name ) ) ; copy ( toInputStream ( f ) , zip ) ; } }


signature:
public class FoloUtils { /** * Read records from input stream and execute consumer function .
 * @ param inputStream
 * @ param consumer
 * @ return count of records read from the stream */
public static int readZipInputStreamAnd ( InputStream inputStream , Consumer < TrackedContent > consumer ) throws IOException , ClassNotFoundException { } }

implementation: int count = 0 ; try ( ZipInputStream stream = new ZipInputStream ( inputStream ) ) { ZipEntry entry ; while ( ( entry = stream . getNextEntry ( ) ) != null ) { logger . trace ( "Read entry: %s, len: %d" , entry . getName ( ) , entry . getSize ( ) ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; int len ; byte [ ] buffer = new byte [ 1024 ] ; while ( ( len = stream . read ( buffer ) ) > 0 ) { bos . write ( buffer , 0 , len ) ; } bos . close ( ) ; ObjectInputStream ois = new ObjectInputStream ( new ByteArrayInputStream ( bos . toByteArray ( ) ) ) ; TrackedContent record = ( TrackedContent ) ois . readObject ( ) ; consumer . accept ( record ) ; count ++ ; } } return count ;


signature:
public class StoreResource { /** * Convert a series of { @ link StoreResource } s into a DTO for use in generating browser or other directory listings . */
public static List < DirectoryListingEntryDTO > convertToEntries ( final List < StoreResource > items ) { } }

implementation: final List < DirectoryListingEntryDTO > entries = new ArrayList < DirectoryListingEntryDTO > ( ) ; for ( final StoreResource resource : items ) { entries . add ( new DirectoryListingEntryDTO ( resource . getStoreKey ( ) , resource . getPath ( ) ) ) ; } return entries ;


signature:
public class PromotionManager { /** * Provides target group store key for a given group name . This is meant to provide the same instance of the key
 * for a name to be able to synchronize promotion requests based on this instance .
 * @ param targetName the target group name
 * @ return the group store key */
private StoreKey getTargetKey ( final String targetName ) { } }

implementation: return targetGroupKeyMap . computeIfAbsent ( targetName , k -> new StoreKey ( MavenPackageTypeDescriptor . MAVEN_PKG_KEY , StoreType . group , targetName ) ) ;


signature:
public class PromotionManager { /** * Promote artifacts from the source to the target given in the { @ link PathsPromoteRequest } . If a set of paths are given , only try to promotePaths those .
 * Otherwise , build a recursive list of available artifacts in the source store , and try to promotePaths them all .
 * @ param request The request containing source and target store keys , and an optional list of paths to promotePaths
 * @ return The result , including the source and target store keys used , the paths completed ( promoted successfully ) , the pending paths ( those that
 * weren ' t processed due to some error . . . or null ) , and a nullable error explaining what ( if anything ) went wrong with the promotion .
 * @ throws PromotionException
 * @ throws IndyWorkflowException */
@ Measure public PathsPromoteResult promotePaths ( final PathsPromoteRequest request , final String baseUrl ) throws PromotionException , IndyWorkflowException { } }

implementation: MDC . put ( PROMOTION_TYPE , PATH_PROMOTION ) ; MDC . put ( PROMOTION_SOURCE , request . getSource ( ) . toString ( ) ) ; MDC . put ( PROMOTION_TARGET , request . getTargetKey ( ) . toString ( ) ) ; Future < PathsPromoteResult > future = submitPathsPromoteRequest ( request , baseUrl ) ; if ( request . isAsync ( ) ) { return new PathsPromoteResult ( request ) . accepted ( ) ; } else { try { return future . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { logger . error ( "Path prromotion failed: " + request . getSource ( ) + " -> " + request . getTargetKey ( ) , e ) ; throw new PromotionException ( "Execution of path promotion failed." , e ) ; } }


signature:
public class PromotionManager { /** * Attempt to resumePathsPromote from a previously failing { @ link PathsPromoteResult } . This is meant to handle cases where a transient ( or correctable ) error
 * occurs on the server side , and promotion can proceed afterward . It works much like the { @ link # promotePaths ( PathsPromoteRequest , String ) } call , using the pending
 * paths list from the input result as the list of paths to process . The output { @ link PathsPromoteResult } contains all previous completed paths PLUS
 * any additional completed transfers when it is returned , thus providing a cumulative result to the user .
 * @ param result The result to resumePathsPromote
 * @ return The same result , with any successful path promotions moved from the pending to completed paths list , and the error cleared ( or set to a
 * new error )
 * @ throws PromotionException
 * @ throws IndyWorkflowException */
public PathsPromoteResult resumePathsPromote ( final PathsPromoteResult result , final String baseUrl ) throws PromotionException , IndyWorkflowException { } }

implementation: final PathsPromoteRequest request = result . getRequest ( ) ; Future < PathsPromoteResult > future = submitResumePathsPromote ( result , baseUrl ) ; if ( request . isAsync ( ) ) { return new PathsPromoteResult ( request ) . accepted ( ) ; } else { try { return future . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { logger . error ( "Path promotion resume failed: " + request . getSource ( ) + " -> " + request . getTargetKey ( ) , e ) ; throw new PromotionException ( "Execution of path promotion resume failed." , e ) ; } }


signature:
public class PromotionManager { /** * Attempt to rollbackPathsPromote a previously failing { @ link PathsPromoteResult } . This is meant to handle cases where an unrecoverable error
 * occurs on the server side , and promotion can NOT proceed afterward . All paths in the completed paths set are deleted from the target , if
 * possible . The output { @ link PathsPromoteResult } contains the previous content , with any successfully removed target paths moved back from the
 * completed - paths list to the pending - paths list . If an error occurs during rollbackPathsPromote , the error field will be set . . . otherwise , it will be null .
 * @ param result The result to rollbackPathsPromote
 * @ return The same result , with any successful deletions moved from the completed to pending paths list , and the error cleared ( or set to a
 * new error )
 * @ throws PromotionException
 * @ throws IndyWorkflowException */
public PathsPromoteResult rollbackPathsPromote ( final PathsPromoteResult result ) throws PromotionException , IndyWorkflowException { } }

implementation: final PathsPromoteRequest request = result . getRequest ( ) ; Future < PathsPromoteResult > future = submitRollbackPathsPromote ( result ) ; if ( request . isAsync ( ) ) { return new PathsPromoteResult ( request ) . accepted ( ) ; } else { try { return future . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { logger . error ( "Path promotion rollback failed: " + request . getSource ( ) + " -> " + request . getTargetKey ( ) , e ) ; throw new PromotionException ( "Execution of path promotion rollback failed." , e ) ; } }


signature:
public class PromotionManager { /** * NOTE : Adding sourcePaths parameter here to cut down on number of paths for clearing from NFC .
 * @ param sourcePaths The set of paths that need to be cleared from the NFC .
 * @ param store The store whose affected groups should have their NFC entries cleared
 * @ throws IndyDataException */
private void clearStoreNFC ( final Set < String > sourcePaths , ArtifactStore store ) throws IndyDataException { } }

implementation: Set < String > paths = sourcePaths . stream ( ) . map ( sp -> sp . startsWith ( "/" ) && sp . length ( ) > 1 ? sp . substring ( 1 ) : sp ) . collect ( Collectors . toSet ( ) ) ; paths . forEach ( path -> { ConcreteResource resource = new ConcreteResource ( LocationUtils . toLocation ( store ) , path ) ; logger . debug ( "Clearing NFC path: {} from: {}\n\tResource: {}" , path , store . getKey ( ) , resource ) ; nfc . clearMissing ( resource ) ; } ) ; Set < Group > groups = storeManager . query ( ) . getGroupsAffectedBy ( store . getKey ( ) ) ; if ( groups != null ) { groups . forEach ( group -> paths . forEach ( path -> { ConcreteResource resource = new ConcreteResource ( LocationUtils . toLocation ( group ) , path ) ; logger . debug ( "Clearing NFC path: {} from: {}\n\tResource: {}" , path , group . getKey ( ) , resource ) ; nfc . clearMissing ( resource ) ; } ) ) ; }


signature:
public class PathMaskChecker { /** * path mask checking */
public static boolean checkListingMask ( final ArtifactStore store , final String path ) { } }

implementation:
Set < String > maskPatterns = store . getPathMaskPatterns ( ) ; logger . trace ( "Checking mask in: {}" , store . getKey ( ) ) ; logger . trace ( "Mask patterns in {}: {}" , store . getName ( ) , maskPatterns ) ; if ( maskPatterns == null || maskPatterns . isEmpty ( ) ) { logger . trace ( "Checking mask in: {}, - NO PATTERNS" , store . getName ( ) ) ; return true ; } for ( String pattern : maskPatterns ) { if ( isRegexPattern ( pattern ) ) { // if there is a regexp pattern we cannot check presence of directory listing , because we would have to
// check only the beginning of the regexp and that ' s impossible , so we have to assume that the path is
// present
return true ; } } for ( String pattern : maskPatterns ) { if ( path . startsWith ( pattern ) || pattern . startsWith ( path ) ) { logger . trace ( "Checking mask in: {}, pattern: {} - MATCH" , store . getName ( ) , pattern ) ; return true ; } } logger . debug ( "Listing for path {} not enabled by path mask {} of repo {}" , path , maskPatterns , store . getKey ( ) ) ; return false ;


signature:
public class IndyLocationExpander { /** * For group references , expand into a list of concrete repository locations ( hosted or remote ) . For remote repository references that are
 * specified as cache - only locations ( see : { @ link CacheOnlyLocation } ) , lookup the corresponding { @ link RemoteRepository } and use it to create a
 * { @ link RepositoryLocation } that contains any relevant SSL , authentication , proxy , etc . attbributes . */
@ Override public < T extends Location > List < Location > expand ( final Collection < T > locations ) throws TransferException { } }

implementation: final List < Location > result = new ArrayList < Location > ( ) ; for ( final Location location : locations ) { if ( location instanceof GroupLocation ) { final GroupLocation gl = ( GroupLocation ) location ; try { logger . debug ( "Expanding group: {}" , gl . getKey ( ) ) ; final List < ArtifactStore > members = data . query ( ) . packageType ( gl . getKey ( ) . getPackageType ( ) ) . getOrderedConcreteStoresInGroup ( gl . getKey ( ) . getName ( ) ) ; if ( members != null ) { for ( final ArtifactStore member : members ) { if ( ! result . contains ( member ) ) { logger . debug ( "expansion += {}" , member . getKey ( ) ) ; result . add ( LocationUtils . toLocation ( member ) ) ; } } logger . debug ( "Expanded group: {} to:\n  {}" , gl . getKey ( ) , new JoinString ( "\n  " , result ) ) ; } } catch ( final IndyDataException e ) { throw new TransferException ( "Failed to lookup ordered concrete artifact stores contained in group: {}. Reason: {}" , e , gl , e . getMessage ( ) ) ; } } else if ( location instanceof CacheOnlyLocation && ! ( ( CacheOnlyLocation ) location ) . isHostedRepository ( ) ) { final StoreKey key = ( ( KeyedLocation ) location ) . getKey ( ) ; try { final ArtifactStore store = data . getArtifactStore ( key ) ; if ( store == null ) { throw new TransferException ( "Cannot find ArtifactStore to match key: %s." , key ) ; } logger . debug ( "Adding single store: {} for location: {}" , store , location ) ; result . add ( LocationUtils . toLocation ( store ) ) ; } catch ( final IndyDataException e ) { throw new TransferException ( "Failed to lookup store for key: {}. Reason: {}" , e , key , e . getMessage ( ) ) ; } } else { logger . debug ( "No expansion available for location: {}" , location ) ; result . add ( location ) ; } } return result ;


signature:
public class IndyLocationExpander { /** * Using the same basic logic as { @ link IndyLocationExpander # expand ( Collection ) } , convert the specified { @ link Resource } into a
 * { @ link VirtualResource } that contains references to the expanded { @ link Location } list .
 * @ see IndyLocationExpander # expand ( Collection ) */
@ Override public VirtualResource expand ( final Resource resource ) throws TransferException { } }

implementation: List < Location > locations ; if ( resource instanceof VirtualResource ) { final List < ConcreteResource > concrete = ( ( VirtualResource ) resource ) . toConcreteResources ( ) ; final List < ConcreteResource > result = new ArrayList < ConcreteResource > ( ) ; for ( final ConcreteResource cr : concrete ) { final List < Location > expanded = expand ( cr . getLocation ( ) ) ; for ( final Location location : expanded ) { result . add ( new ConcreteResource ( location , cr . getPath ( ) ) ) ; } } return new VirtualResource ( result ) ; } else { final ConcreteResource cr = ( ConcreteResource ) resource ; locations = expand ( cr . getLocation ( ) ) ; return new VirtualResource ( locations , cr . getPath ( ) ) ; }


signature:
public class MavenMetadataGenerator { /** * Will generate group related files ( e . g maven - metadata . xml ) from cache level , which means all the generation of the
 * files will be cached . In terms of cache clearing , see # { @ link MetadataMergeListener }
 * @ param group
 * @ param members concrete store in group
 * @ param path
 * @ return
 * @ throws IndyWorkflowException */
private Metadata generateGroupMetadata ( final Group group , final List < ArtifactStore > members , final List < StoreKey > contributingMembers , final String path ) throws IndyWorkflowException { } }

implementation: if ( ! canProcess ( path ) ) { logger . error ( "The path is not a metadata file: {} " , path ) ; return null ; } String toMergePath = path ; if ( ! path . endsWith ( MavenMetadataMerger . METADATA_NAME ) ) { toMergePath = normalize ( normalize ( parentPath ( toMergePath ) ) , MavenMetadataMerger . METADATA_NAME ) ; } Metadata meta = getMetaFromCache ( group . getKey ( ) , toMergePath ) ; if ( meta != null ) { return meta ; } Metadata master = new Metadata ( ) ; master . setVersioning ( new Versioning ( ) ) ; MetadataIncrementalResult incrementalResult = new MetadataIncrementalResult ( new HashSet < > ( members ) , Collections . emptySet ( ) , master ) ; incrementalResult = mergeMissing ( group , incrementalResult , toMergePath , "cached" , this :: retrieveCached ) ; contributingMembers . addAll ( incrementalResult . merged ) ; incrementalResult = mergeMissing ( group , incrementalResult , toMergePath , "downloaded" , this :: downloadMissing ) ; contributingMembers . addAll ( incrementalResult . merged ) ; incrementalResult = mergeMissing ( group , incrementalResult , toMergePath , "generated" , this :: generateMissing ) ; contributingMembers . addAll ( incrementalResult . merged ) ; if ( metadataProviders != null ) { master = mergeProviderMetadata ( group , incrementalResult . result , toMergePath ) ; } else { master = incrementalResult . result ; } if ( ! incrementalResult . missing . isEmpty ( ) ) { logger . warn ( "After download and generation attempts, metadata is still missing from the following stores: {}" , incrementalResult . missing ) ; } List < String > versions = master . getVersioning ( ) . getVersions ( ) ; if ( versions != null && ! versions . isEmpty ( ) ) { merger . sortVersions ( master ) ; return master ; } List < Plugin > plugins = master . getPlugins ( ) ; if ( plugins != null && ! plugins . isEmpty ( ) ) { return master ; } logger . error ( "The group metadata generation is not successful for path: {} in group: {}" , path , group ) ; return null ;


signature:
public class MavenMetadataGenerator { /** * Clear obsolete files after a meta is generated . This may be http download metadata , etc .
 * @ param item */
private void clearObsoleteFiles ( Transfer item ) { } }

implementation: Transfer httpMeta = item . getSiblingMeta ( HTTP_METADATA_EXT ) ; try { httpMeta . delete ( ) ; } catch ( IOException e ) { logger . warn ( "Failed to delete {}" , httpMeta . getResource ( ) ) ; }


signature:
public class ScriptEngine { /** * Provide a standard set of places to store common types of scripts used throughout Indy , such as
 * { @ link org . commonjava . indy . model . core . ArtifactStore } creators . This is better from a config maintenance
 * perspective than having these spread out across the whole data / subdirectory structure , particularly since it ' s
 * likely if one script needs to be revised , they all will .
 * If the script doesn ' t exist in the data / scripts directory structure , this method will search the classpath
 * for the same path ( scripts / [ type ] / [ name ] ) . */
public < T > T parseStandardScriptInstance ( final StandardScriptType scriptType , final String name , final Class < T > type ) throws IndyGroovyException { } }

implementation: return parseStandardScriptInstance ( scriptType , name , type , false ) ;


signature:
public class ScriptEngine { /** * Provide a standard set of places to store common types of scripts used throughout Indy , such as
 * { @ link org . commonjava . indy . model . core . ArtifactStore } creators . This is better from a config maintenance
 * perspective than having these spread out across the whole data / subdirectory structure , particularly since it ' s
 * likely if one script needs to be revised , they all will .
 * If the script doesn ' t exist in the data / scripts directory structure , this method will search the classpath
 * for the same path ( scripts / [ type ] / [ name ] ) . */
public < T > T parseStandardScriptInstance ( final StandardScriptType scriptType , final String name , final Class < T > type , boolean processCdiInjections ) throws IndyGroovyException { } }

implementation: DataFile dataFile = dataFileManager . getDataFile ( SCRIPTS_SUBDIR , scriptType . subdir ( ) , name ) ; String script = null ; if ( dataFile == null || ! dataFile . exists ( ) || dataFile . isDirectory ( ) ) { URL resource = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( Paths . get ( SCRIPTS_SUBDIR , scriptType . subdir ( ) , name ) . toString ( ) ) ; if ( resource == null ) { throw new IndyGroovyException ( "Cannot read standard script from: %s/%s/%s" , SCRIPTS_SUBDIR , scriptType . subdir ( ) , name ) ; } else { Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; logger . debug ( "Loading script: {}/{}/{} for class: {} from classpath resource: {}" , SCRIPTS_SUBDIR , scriptType , name , type . getName ( ) , resource ) ; try ( InputStream in = resource . openStream ( ) ) { script = IOUtils . toString ( in ) ; } catch ( IOException e ) { throw new IndyGroovyException ( "Cannot read standard script from classpath: %s/%s/%s. Reason: %s" , e , SCRIPTS_SUBDIR , scriptType . subdir ( ) , name , e . getMessage ( ) ) ; } } } else { try { script = dataFile . readString ( ) ; } catch ( IOException e ) { throw new IndyGroovyException ( "Failed to read standard script from: %s/%s. Reason: %s" , e , scriptType . subdir ( ) , name , e . getMessage ( ) ) ; } } Object instance = null ; try { final Class < ? > clazz = groovyClassloader . parseClass ( script ) ; instance = clazz . newInstance ( ) ; T result = type . cast ( instance ) ; return processCdiInjections ? inject ( result ) : result ; } catch ( final CompilationFailedException e ) { throw new IndyGroovyException ( "Failed to compile groovy script: '%s'. Reason: %s" , e , script , e . getMessage ( ) ) ; } catch ( final InstantiationException | IllegalAccessException e ) { throw new IndyGroovyException ( "Cannot instantiate class parsed from script: '%s'. Reason: %s" , e , script , e . getMessage ( ) ) ; } catch ( final ClassCastException e ) { throw new IndyGroovyException ( "Script: '%s' instance: %s cannot be cast as: %s" , e , script , instance , type . getName ( ) ) ; }


signature:
public class CacheHandle { /** * TODO : Why is this separate from { @ link BasicCacheHandle # execute ( Function ) } ? */
protected < R > R doExecuteCache ( String metricName , Function < Cache < K , V > , R > operation ) { } }

implementation: Supplier < R > execution = executionFor ( operation ) ; if ( metricsManager != null ) { return metricsManager . wrapWithStandardMetrics ( execution , ( ) -> getMetricName ( metricName ) ) ; } return execution . get ( ) ;


signature:
public class ProxyMITMSSLServer { /** * Generate the keystore on - the - fly and initiate SSL socket factory . */
private SSLServerSocketFactory getSSLServerSocketFactory ( String host ) throws Exception { } }

implementation: AtomicReference < Exception > err = new AtomicReference < > ( ) ; KeyStore ks = keystoreMap . computeIfAbsent ( host , ( k ) -> { try { return getKeyStore ( k ) ;


signature:
public class DefaultKojiRepoNameParser { /** * Retrieve what is behind koji - or koji - binary -
 * @ param repoName
 * @ return koji build nvr */
public String parse ( String repoName ) { } }

implementation: String prefix = null ; if ( repoName . startsWith ( KOJI_BINARY_ ) ) { prefix = KOJI_BINARY_ ; } else if ( repoName . startsWith ( KOJI_ ) ) { prefix = KOJI_ ; } if ( prefix != null ) { return repoName . substring ( prefix . length ( ) ) ; } return null ;


signature: public class DefaultContentManager { @ Override public Transfer store ( final List < ? extends ArtifactStore > stores , final StoreKey topKey , final String path , final InputStream stream , final TransferOperation op , final EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: logger . debug ( "Storing: {} in: {} with event metadata: {}" , path , stores , eventMetadata ) ; final Transfer txfr = downloadManager . store ( stores , path , stream , op , eventMetadata ) ; if ( txfr != null ) { final KeyedLocation kl = ( KeyedLocation ) txfr . getLocation ( ) ; ArtifactStore transferStore ; try { transferStore = storeManager . getArtifactStore ( kl . getKey ( ) ) ; } catch ( final IndyDataException e ) { throw new IndyWorkflowException ( "Failed to lookup store: %s. Reason: %s" , e , kl . getKey ( ) , e . getMessage ( ) ) ; } for ( final ContentGenerator generator : contentGenerators ) { logger . debug ( "{} Handling content storage of: {} in: {}" , generator , path , transferStore . getKey ( ) ) ; generator . handleContentStorage ( transferStore , path , txfr , eventMetadata ) ; } clearNFCEntries ( kl , path ) ; } return txfr ;


signature:
public class DefaultContentManager { /** * clean just the cache ( storage of groups and remote repos ) */
private boolean deleteCache ( ArtifactStore store , String path , EventMetadata eventMetadata ) throws IndyWorkflowException { } }

implementation: logger . trace ( "Delete cache, store:{}, path:{}" , store . getName ( ) , path ) ; if ( hosted == store . getKey ( ) . getType ( ) ) { return false ; } else { return downloadManager . delete ( store , path , eventMetadata ) ; }


signature:
public class StoreAdminHandler { /** * private HttpServletRequest request ; */
@ ApiOperation ( "Check if a given store exists" ) @ ApiResponses ( { } }

implementation: @ ApiResponse ( code = 200 , message = "The store exists" ) , @ ApiResponse ( code = 404 , message = "The store doesn't exist" ) } ) @ Path ( "/{name}" ) @ HEAD public Response exists ( final @ PathParam ( "packageType" ) String packageType , final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type , @ ApiParam ( required = true ) @ PathParam ( "name" ) final String name ) { Response response ; final StoreType st = StoreType . get ( type ) ; logger . info ( "Checking for existence of: {}:{}:{}" , packageType , st , name ) ; if ( adminController . exists ( new StoreKey ( packageType , st , name ) ) ) { logger . info ( "returning OK" ) ; response = Response . ok ( ) . build ( ) ; } else { logger . info ( "Returning NOT FOUND" ) ; response = Response . status ( Status . NOT_FOUND ) . build ( ) ; } return response ;


signature:
public class StoreAdminHandler { /** * ( non - Javadoc )
 * @ see org . commonjava . indy . core . rest . admin . DeployPointAdminResource # store ( java . lang . String ) */
@ ApiOperation ( "Update an existing store" ) @ ApiResponses ( { } }

implementation: @ ApiResponse ( code = 200 , message = "The store was updated" ) , @ ApiResponse ( code = 400 , message = "The store specified in the body JSON didn't match the URL parameters" ) , } ) @ ApiImplicitParams ( { @ ApiImplicitParam ( allowMultiple = false , paramType = "body" , name = "body" , required = true , dataType = "org.commonjava.indy.model.core.ArtifactStore" , value = "The artifact store definition JSON" ) } ) @ Path ( "/{name}" ) @ PUT @ Consumes ( ApplicationContent . application_json ) public Response store ( final @ PathParam ( "packageType" ) String packageType , final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type , final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name , final @ Context HttpServletRequest request , final @ Context SecurityContext securityContext ) { final StoreType st = StoreType . get ( type ) ; Response response = null ; String json = null ; try { json = IOUtils . toString ( request . getInputStream ( ) ) ; json = objectMapper . patchLegacyStoreJson ( json ) ; } catch ( final IOException e ) { final String message = "Failed to read " + st . getStoreClass ( ) . getSimpleName ( ) + " from request body." ; logger . error ( message , e ) ; response = formatResponse ( e , message ) ; } if ( response != null ) { return response ; } ArtifactStore store = null ; try { store = objectMapper . readValue ( json , st . getStoreClass ( ) ) ; } catch ( final IOException e ) { final String message = "Failed to parse " + st . getStoreClass ( ) . getSimpleName ( ) + " from request body." ; logger . error ( message , e ) ; response = formatResponse ( e , message ) ; } if ( response != null ) { return response ; } if ( ! packageType . equals ( store . getPackageType ( ) ) || st != store . getType ( ) || ! name . equals ( store . getName ( ) ) ) { response = Response . status ( Status . BAD_REQUEST ) . entity ( String . format ( "Store in URL path is: '%s' but in JSON it is: '%s'" , new StoreKey ( packageType , st , name ) , store . getKey ( ) ) ) . build ( ) ; } try { String user = securityManager . getUser ( securityContext , request ) ; logger . info ( "Storing: {}" , store ) ; if ( adminController . store ( store , user , false ) ) { response = ok ( ) . build ( ) ; } else { logger . warn ( "{} NOT modified!" , store ) ; response = notModified ( ) . build ( ) ; } } catch ( final IndyWorkflowException e ) { logger . error ( e . getMessage ( ) , e ) ; response = formatResponse ( e ) ; } return response ;


signature:
public class DataFileStoreUtils { /** * Load all store definitions from disk and apply consumer function . */
public static void loadFromDiskAnd ( DataFileManager manager , IndyObjectMapper serializer , final ChangeSummary summary , Consumer < ArtifactStore > consumer ) { } }

implementation: loadFromDiskAnd ( manager , serializer , null , summary , consumer ) ;


signature:
public class DataFileStoreUtils { /** * Load store definitions from disk and apply consumer function .
 * @ param manager
 * @ param serializer
 * @ param key if null , load all .
 * @ param summary
 * @ param consumer */
public static void loadFromDiskAnd ( DataFileManager manager , IndyObjectMapper serializer , StoreKey key , final ChangeSummary summary , Consumer < ArtifactStore > consumer ) { } }

implementation:
if ( key != null ) // Load a single file
{ DataFile f = manager . getDataFile ( INDY_STORE , key . getPackageType ( ) , key . getType ( ) . singularEndpointName ( ) , key . getName ( ) + ".json" ) ; if ( f . exists ( ) ) { ArtifactStore store ; try { String json = f . readString ( ) ; store = serializer . readValue ( json , key . getType ( ) . getStoreClass ( ) ) ; } catch ( IOException e ) { logger . error ( "Failed to read file" , e ) ; return ; } consumer . accept ( store ) ; } return ; } // Load all
DataFile [ ] packageDirs = manager . getDataFile ( INDY_STORE ) . listFiles ( ( f ) -> true ) ; for ( DataFile pkgDir : packageDirs ) { for ( StoreType type : StoreType . values ( ) ) { DataFile [ ] files = pkgDir . getChild ( type . singularEndpointName ( ) ) . listFiles ( f -> true ) ; if ( files != null ) { for ( final DataFile f : files ) { try { final String json = f . readString ( ) ; final ArtifactStore store = serializer . readValue ( json , type . getStoreClass ( ) ) ; if ( store == null ) { f . delete ( summary ) ; } else { consumer . accept ( store ) ; } } catch ( final IOException e ) { logger . error ( String . format ( "Failed to load %s store: %s. Reason: %s" , type , f , e . getMessage ( ) ) , e ) ; try { f . delete ( summary ) ; } catch ( IOException e1 ) { logger . error ( "Failed to delete invalid store definition file: " + f , e ) ; } } } } } }


signature:
public class HostedByArchiveManager { /** * private ExecutorService executors ; */
public HostedRepository createStoreByArc ( final InputStream fileInput , final String repoName , final String user , final String ignoredPrefix ) throws IndyWorkflowException { } }

implementation: final HostedRepository repo = createHostedByName ( repoName , user , "Create hosted by zip." ) ; storeZipContentInHosted ( fileInput , ignoredPrefix , repo ) ; return repo ;


signature:
public class ImpliedRepoMetadataManager { /** * TODO : Need to deal with pre - existing implications . */
public void addImpliedMetadata ( final ArtifactStore origin , final List < ArtifactStore > implied ) throws ImpliedReposException { } }

implementation: try { final List < StoreKey > impliedKeys = new ArrayList < > ( implied . size ( ) ) ; for ( final ArtifactStore store : implied ) { impliedKeys . add ( store . getKey ( ) ) ; updateImpliedBy ( store , origin ) ; } origin . setMetadata ( IMPLIED_STORES , mapper . writeValueAsString ( new ImpliedRemotesWrapper ( impliedKeys ) ) ) ; } catch ( final JsonProcessingException e ) { throw new ImpliedReposException ( "Failed to serialize implied stores: %s to JSON: %s. Error: %s" , e , implied , origin . getKey ( ) , e . getMessage ( ) ) ; }


signature:
public class IndyHttpProvider { /** * Create http request context and apply site config .
 * @ param siteId ID to represent the site . It is generally the hostname of target site .
 * @ return
 * @ throws IndyHttpException */
public HttpClientContext createContext ( final String siteId ) throws IndyHttpException { } }

implementation: try { return httpFactory . createContext ( siteConfigLookup . lookup ( siteId ) ) ; } catch ( JHttpCException e ) { throw new IndyHttpException ( "Failed to create http client context: %s" , e , e . getMessage ( ) ) ; }


signature:
public class IndyHttpProvider { /** * Create http client and apply site config .
 * @ param siteId ID to represent the site . It is generally the hostname of target site .
 * @ return
 * @ throws IndyHttpException */
public CloseableHttpClient createClient ( final String siteId ) throws IndyHttpException { } }

implementation: try { return httpFactory . createClient ( siteConfigLookup . lookup ( siteId ) ) ; } catch ( JHttpCException e ) { throw new IndyHttpException ( "Failed to create http client: %s" , e , e . getMessage ( ) ) ; }


signature:
public class PromotionValidator { /** * NOTE : As of Indy 1.2.6 , ValidationRequest passed back to enable further post - processing , especially of promotion
 * paths , after promotion takes place . This enables us to avoid re - executing recursive path discovery , for instance .
 * @ param request
 * @ param result
 * @ param baseUrl
 * @ return
 * @ throws PromotionValidationException
 * @ throws IndyWorkflowException */
@ Measure public ValidationRequest validate ( PromoteRequest request , ValidationResult result , String baseUrl ) throws PromotionValidationException , IndyWorkflowException { } }

implementation: ValidationRuleSet set = validationsManager . getRuleSetMatching ( request . getTargetKey ( ) ) ; ArtifactStore source ; try { source = storeDataMgr . getArtifactStore ( request . getSource ( ) ) ; } catch ( IndyDataException e ) { throw new PromotionValidationException ( String . format ( "Failed to retrieve source ArtifactStore: %s for validation" , request . getSource ( ) ) , e ) ; } if ( set != null ) { logger . debug ( "Running validation rule-set for promotion: {}" , set . getName ( ) ) ; result . setRuleSet ( set . getName ( ) ) ; MDC . put ( PROMOTION_VALIDATION_RULE_SET , set . getName ( ) ) ; List < String > ruleNames = set . getRuleNames ( ) ; if ( ruleNames != null && ! ruleNames . isEmpty ( ) ) { final ArtifactStore store = getRequestStore ( request , baseUrl ) ; final ValidationRequest req = new ValidationRequest ( request , set , validationTools , store ) ; try { DrainingExecutorCompletionService < Exception > svc = new DrainingExecutorCompletionService < > ( validateService ) ; detectOverloadVoid ( ( ) -> { for ( String ruleRef : ruleNames ) { svc . submit ( ( ) -> { MDC . put ( PROMOTION_VALIDATION_RULE , ruleRef ) ; Exception err = null ; try { executeValidationRule ( ruleRef , req , result , request ) ; } catch ( Exception e ) { err = e ; } finally { MDC . remove ( PROMOTION_VALIDATION_RULE ) ; } return err ; } ) ; } } ) ; List < String > errors = new ArrayList < > ( ) ; svc . drain ( err -> { if ( err != null ) { logger . error ( "Promotion validation failure" , err ) ; errors . add ( err . getMessage ( ) ) ; } } ) ; if ( ! errors . isEmpty ( ) ) { throw new PromotionValidationException ( format ( "Failed to do promotion validation: \n\n%s" , join ( errors , "\n" ) ) ) ; } } catch ( InterruptedException e ) { throw new PromotionValidationException ( "Failed to do promotion validation: validation execution has been interrupted " , e ) ; } catch ( ExecutionException e ) { throw new PromotionValidationException ( "Failed to execute promotion validations" , e ) ; } finally { if ( needTempRepo ( request ) ) { try { final String changeSum = format ( "Removes the temp remote repo [%s] after promote operation." , store ) ; storeDataMgr . deleteArtifactStore ( store . getKey ( ) , new ChangeSummary ( ChangeSummary . SYSTEM_USER , changeSum ) , new EventMetadata ( ) . set ( ContentManager . SUPPRESS_EVENTS , true ) ) ; Transfer root = downloadManager . getStoreRootDirectory ( store ) ; if ( root . exists ( ) ) { root . delete ( false ) ; } logger . debug ( "Promotion temporary repo {} has been deleted for {}" , store . getKey ( ) , request . getSource ( ) ) ; } catch ( IndyDataException | IOException e ) { logger . warn ( "Temporary promotion validation repository was NOT removed correctly." , e ) ; } } } return req ; } else { logger . info ( "No validation rules are defined for: {}" , request . getTargetKey ( ) ) ; return new ValidationRequest ( request , set , validationTools , source ) ; } } else { logger . info ( "No validation rule-sets are defined for: {}" , request . getTargetKey ( ) ) ; return new ValidationRequest ( request , set , validationTools , source ) ; }


signature:
public class KojiRepairManager { /** * Repair one remote repository .
 * @ param packageType
 * @ param repository repository to be repaired . If null , the repository name will be retrieved according to
 * the buildInfo and the naming format in koji . conf .
 * @ param buildInfo koji build which this repository proxies
 * @ param user the user does the repair
 * @ param isDryRun
 * @ return
 * @ throws KojiRepairException */
private KojiRepairResult . RepairResult doRepair ( String packageType , RemoteRepository repository , KojiBuildInfo buildInfo , String user , boolean isDryRun ) throws KojiRepairException { } }

implementation:
StoreKey storeKey ; if ( repository != null ) { storeKey = repository . getKey ( ) ; } else { String name = kojiUtils . getRepositoryName ( buildInfo ) ; storeKey = new StoreKey ( packageType , StoreType . remote , name ) ; try { repository = ( RemoteRepository ) storeManager . getArtifactStore ( storeKey ) ; } catch ( IndyDataException e ) { throw new KojiRepairException ( "Cannot get store: %s. Reason: %s" , e , storeKey , e . getMessage ( ) ) ; } } KojiRepairResult . RepairResult repairResult = new KojiRepairResult . RepairResult ( storeKey ) ; String url = repository . getUrl ( ) ; String newUrl ; try { newUrl = kojiUtils . formatStorageUrl ( config . getStorageRootUrl ( ) , buildInfo ) ; // volume is involved
} catch ( MalformedURLException e ) { throw new KojiRepairException ( "Failed to format storage Url: %s. Reason: %s" , e , storeKey , e . getMessage ( ) ) ; } boolean changed = ! url . equals ( newUrl ) ; if ( changed ) { repairResult . withPropertyChange ( "url" , url , newUrl ) ; if ( ! isDryRun ) { ChangeSummary changeSummary = new ChangeSummary ( user , "Repair " + storeKey + " url with volume: " + buildInfo . getVolumeName ( ) ) ; repository . setUrl ( newUrl ) ; repository . setMetadata ( METADATA_KOJI_BUILD_ID , Integer . toString ( buildInfo . getId ( ) ) ) ; boolean fireEvents = false ; boolean skipIfExists = false ; try { storeManager . storeArtifactStore ( repository , changeSummary , skipIfExists , fireEvents , new EventMetadata ( ) ) ; } catch ( IndyDataException e ) { throw new KojiRepairException ( "Failed to repair store: %s. Reason: %s" , e , storeKey , e . getMessage ( ) ) ; } } } return repairResult ;


signature: public class KeycloakProxyAuthenticator { protected void sendChallengeResponse ( HttpWrapper http , String error , String description ) throws IOException { } }

implementation: StringBuilder header = new StringBuilder ( String . format ( PROXY_AUTHENTICATE_FORMAT , httproxConfig . getProxyRealm ( ) ) ) ; if ( error != null ) { header . append ( ", error=\"" ) . append ( error ) . append ( "\"" ) ; } if ( description != null ) { header . append ( ", error_description=\"" ) . append ( description ) . append ( "\"" ) ; } final String challenge = header . toString ( ) ; ApplicationStatus stat = ApplicationStatus . PROXY_AUTHENTICATION_REQUIRED ; http . writeStatus ( stat . code ( ) , stat . message ( ) ) ; http . writeHeader ( ApplicationHeader . proxy_authenticate , challenge ) ;


signature:
public class ResourceManagementFilter { /** * Put to MDC / threadContext request IDs . */
private void putRequestIDs ( HttpServletRequest hsr , ThreadContext threadContext , MDCManager mdcManager ) { } }

implementation:
/* We would always generate internalID and provide that in the MDC .
 * If the calling service supplies an externalID , we ' d map that under its own key .
 * PreferredID should try to use externalID if it ' s available , and default over to using internalID if it ' s not .
 * What this gives us is a single key we can use to reference an ID for the request ,
 * and whenever possible it ' ll reflect the externally supplied ID . */
String internalID = UUID . randomUUID ( ) . toString ( ) ; String externalID = hsr . getHeader ( EXTERNAL_ID ) ; String preferredID = externalID != null ? externalID : internalID ; mdcManager . putRequestIDs ( internalID , externalID , preferredID ) ; /* * We should also put the same values in the ThreadContext map , so we can reference them from code without
 * having to go through the logging framework */
threadContext . put ( INTERNAL_ID , internalID ) ; if ( externalID != null ) { threadContext . put ( EXTERNAL_ID , externalID ) ; } threadContext . put ( PREFERRED_ID , preferredID ) ;


signature:
public class MetadataStoreListener { /** * Listen to an # { @ link ArtifactStorePreUpdateEvent } and clear the metadata cache due to changed memeber in that event
 * @ param event */
public void onStoreUpdate ( @ Observes final ArtifactStorePreUpdateEvent event ) { } }

implementation: logger . trace ( "Got store-update event: {}" , event ) ; if ( ArtifactStoreUpdateType . UPDATE == event . getType ( ) ) { for ( ArtifactStore store : event ) { removeMetadataCacheContent ( store , event . getChangeMap ( ) ) ; } }


signature:
public class MetadataStoreListener { /** * Indy normally does not handle FileDeletionEvent when the cached metadata files were deleted due to store
 * enable / disable / delete , etc . Lately we add a force - deletion for group / remote - repo cache files . This requires to
 * delete affected group metadata files and clear ISPN cache too . We use this method for just this case , i . e . ,
 * only if CHECK _ CACHE _ ONLY is true . */
public void onMetadataFileForceDelete ( @ Observes final FileDeletionEvent event ) { } }

implementation: EventMetadata eventMetadata = event . getEventMetadata ( ) ; if ( ! Boolean . TRUE . equals ( eventMetadata . get ( CHECK_CACHE_ONLY ) ) ) { return ; } logger . trace ( "Got file-delete event: {}" , event ) ; Transfer transfer = event . getTransfer ( ) ; String path = transfer . getPath ( ) ; if ( ! path . endsWith ( METADATA_NAME ) ) { logger . trace ( "Not {} , path: {}" , METADATA_NAME , path ) ; return ; } Location loc = transfer . getLocation ( ) ; if ( ! ( loc instanceof KeyedLocation ) ) { logger . trace ( "Ignore FileDeletionEvent, not a KeyedLocation, location: {}" , loc ) ; return ; } KeyedLocation keyedLocation = ( KeyedLocation ) loc ; StoreKey storeKey = keyedLocation . getKey ( ) ; try { ArtifactStore store = storeManager . getArtifactStore ( storeKey ) ; metadataGenerator . clearAllMerged ( store , path ) ; } catch ( IndyDataException e ) { logger . error ( "Handle FileDeletionEvent failed" , e ) ; }


signature:
public class MetadataStoreListener { /** * if a store is disabled / enabled , we should clear its metadata cache and all of its affected groups cache too . */
private void handleStoreDisableOrEnable ( final ArtifactStore store , final Map < ArtifactStore , ArtifactStore > changeMap ) { } }

implementation: logger . trace ( "Processing en/disable event for: {}" , store . getKey ( ) ) ; final ArtifactStore oldStore = changeMap . get ( store ) ; if ( store . isDisabled ( ) != oldStore . isDisabled ( ) ) { logger . trace ( "En/disable state changed for: {}" , store . getKey ( ) ) ; removeMetadataCache ( store ) ; } else { logger . trace ( "En/disable state has not changed for: {}" , store . getKey ( ) ) ; }


signature:
public class MetadataStoreListener { /** * If group members changed , should clear the cascading groups metadata cache */
private void handleGroupMembersChanged ( final ArtifactStore store , final Map < ArtifactStore , ArtifactStore > changeMap ) { } }

implementation: final StoreKey key = store . getKey ( ) ; if ( StoreType . group == key . getType ( ) ) { final List < StoreKey > newMembers = ( ( Group ) store ) . getConstituents ( ) ; logger . trace ( "New members of: {} are: {}" , store . getKey ( ) , newMembers ) ; final Group group = ( Group ) changeMap . get ( store ) ; final List < StoreKey > oldMembers = group . getConstituents ( ) ; logger . trace ( "Old members of: {} are: {}" , group . getName ( ) , oldMembers ) ; boolean membersChanged = false ; if ( newMembers . size ( ) != oldMembers . size ( ) ) { membersChanged = true ; } else { for ( StoreKey storeKey : newMembers ) { if ( ! oldMembers . contains ( storeKey ) ) { membersChanged = true ; } } } if ( membersChanged ) { logger . trace ( "Membership change confirmed. Clearing caches for group: {} and groups affected by it." , group . getKey ( ) ) ; clearGroupMetaCache ( group , group ) ; try { storeManager . query ( ) . getGroupsAffectedBy ( group . getKey ( ) ) . forEach ( g -> clearGroupMetaCache ( g , group ) ) ; } catch ( IndyDataException e ) { logger . error ( String . format ( "Can not get affected groups of %s" , group . getKey ( ) ) , e ) ; } } else { logger . trace ( "No members changed, no need to expunge merged metadata" ) ; } }


signature:
public class MetadataMergeListener { /** * Will clear the both merge path and merge info file of member and group contains that member ( cascaded )
 * if that path of file changed in the member of # originatingStore */
@ Override public void clearMergedPath ( ArtifactStore originatingStore , Set < Group > affectedGroups , String path ) { } }

implementation: final Map < String , MetadataInfo > metadataMap = versionMetadataCache . get ( originatingStore . getKey ( ) ) ; if ( metadataMap != null && ! metadataMap . isEmpty ( ) ) { if ( metadataMap . get ( path ) != null ) { metadataMap . remove ( path ) ; affectedGroups . forEach ( group -> { final Map < String , MetadataInfo > grpMetaMap = versionMetadataCache . get ( group . getKey ( ) ) ; if ( grpMetaMap != null && ! grpMetaMap . isEmpty ( ) ) { grpMetaMap . remove ( path ) ; } } ) ; } }


signature:
public class SettingsURIMatcher { /** * / * ( non - Javadoc )
 * @ see org . commonjava . indy . dotmaven . util . URIMatcher # getStoreType ( ) */
@ Override public StoreType getStoreType ( ) { } }

implementation: if ( ! matches ( ) ) { return null ; } final String typePart = matcher . group ( TYPE_GRP ) ; if ( typePart == null ) { return null ; } final StoreType type = StoreType . get ( typePart ) ; return type ;