idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
9,500
protected < T > T processInjectionPoint ( final Member injectionTarget , final Class < T > injectionType , final GrpcClient annotation ) { final List < ClientInterceptor > interceptors = interceptorsFromAnnotation ( annotation ) ; final String name = annotation . value ( ) ; final Channel channel ; try { channel = getC...
Processes the given injection point and computes the appropriate value for the injection .
9,501
protected < T > T valueForMember ( final String name , final Member injectionTarget , final Class < T > injectionType , final Channel channel ) throws BeansException { if ( Channel . class . equals ( injectionType ) ) { return injectionType . cast ( channel ) ; } else if ( AbstractStub . class . isAssignableFrom ( inje...
Creates the instance to be injected for the given member .
9,502
private AccessPredicateConfigAttribute find ( final Collection < ConfigAttribute > attributes ) { for ( final ConfigAttribute attribute : attributes ) { if ( attribute instanceof AccessPredicateConfigAttribute ) { return ( AccessPredicateConfigAttribute ) attribute ; } } return null ; }
Finds the first AccessPredicateConfigAttribute in the given collection .
9,503
@ EventListener ( HeartbeatEvent . class ) public void heartbeat ( final HeartbeatEvent event ) { if ( this . monitor . update ( event . getValue ( ) ) ) { for ( final DiscoveryClientNameResolver discoveryClientNameResolver : this . discoveryClientNameResolvers ) { discoveryClientNameResolver . refresh ( ) ; } } }
Triggers a refresh of the registered name resolvers .
9,504
public static Map < String , Object > mapPropertyValues ( final List < Property > list , final PropertyResolver resolver ) { final Map < String , Object > inputConfig = new HashMap < String , Object > ( ) ; for ( final Property property : list ) { final Object value = resolver . resolvePropertyValue ( property . getNam...
Return All property values for the input property set mapped by name to value .
9,505
public static StepExecutionItem createPluginNodeStepItem ( final String type , final Map configuration , final boolean keepgoingOnSuccess , final StepExecutionItem handler , final String label , final List < PluginConfiguration > filterConfigurations ) { return new PluginNodeStepExecutionItemImpl ( type , configuration...
Create a workflow execution item for a plugin node step .
9,506
public static int comp ( Integer v1 , String s1 , Integer v2 , String s2 ) { if ( v1 != null && v2 != null ) { return v1 . compareTo ( v2 ) ; } else if ( v1 != null ) { return 1 ; } else if ( v2 != null ) { return - 1 ; } else if ( null == s1 && null == s2 ) { return 0 ; } else if ( null == s1 ) { return - 1 ; } else i...
Compares two version strings and their parsed integer values if available . Returns - 1 0 or 1 if value 1 is less than equal to or greater than value 2 respectively . Compares integers if both are available otherwise compares non - integer as less than integer . if no integers are available comparse strings and treats ...
9,507
public static VersionCompare forString ( final String value ) { VersionCompare vers = new VersionCompare ( ) ; if ( null == value || "" . equals ( value ) ) { return vers ; } String [ ] parr1 = value . split ( "-" , 2 ) ; String [ ] v1arr = parr1 [ 0 ] . split ( "\\." , 3 ) ; if ( v1arr . length > 0 ) { vers . majStrin...
Return a VersionCompare for the string
9,508
public UserInfo getUserInfo ( String username ) throws Exception { DirContext dir = context ( ) ; ArrayList roleList = new ArrayList ( getUserRoles ( username ) ) ; String credentials = getUserCredentials ( username ) ; return new UserInfo ( username , Credential . getCredential ( credentials ) , roleList ) ; }
Get the UserInfo for a specified username
9,509
public void initialize ( Subject subject , CallbackHandler callbackHandler , Map sharedState , Map options ) { super . initialize ( subject , callbackHandler , sharedState , options ) ; Properties props = loadProperties ( ( String ) options . get ( "file" ) ) ; initWithProps ( props ) ; }
Read contents of the configured property file .
9,510
private Collection getUserRoles ( String userName ) throws NamingException { log . debug ( "Obtaining roles for userName: " + userName ) ; String filter = "(" + roleMemberRDN + "=" + userNameRDN + "=" + userName + "," + userBase + ")" ; NamingEnumeration roleResults = this . search ( roleBase , filter , new String [ ] ...
Get the collection of role names for the user
9,511
private Map getUsers ( ) throws NamingException { String filter = "(" + roleNameRDN + "=*)" ; HashMap users = new HashMap ( ) ; NamingEnumeration results = this . search ( roleBase , filter , new String [ ] { roleMemberRDN } ) ; while ( results != null && results . hasMore ( ) ) { SearchResult roleResult = ( SearchResu...
Return a Map of usernames to role sets .
9,512
private NamingEnumeration search ( String base , String filter , String [ ] returnAttrs ) throws NamingException { SearchControls constraints = new SearchControls ( ) ; constraints . setSearchScope ( SearchControls . SUBTREE_SCOPE ) ; constraints . setReturningAttributes ( returnAttrs ) ; DirContext dirContext = contex...
search using search base filter and declared return attributes
9,513
public int read ( final Reader reader ) throws IOException { final int c = reader . read ( cbuf ) ; if ( c > 0 ) { addData ( cbuf , 0 , c ) ; } return c ; }
Read some chars from a reader and return the number of characters read
9,514
public void addData ( final char [ ] data , final int off , final int size ) { if ( size < 1 ) { return ; } final String str = new String ( data , off , size ) ; if ( str . contains ( "\n" ) ) { final String [ ] lines = str . split ( "\\r?\\n" , - 1 ) ; for ( int i = 0 ; i < lines . length - 1 ; i ++ ) { appendString (...
Add character data to the buffer
9,515
public synchronized < T > T load ( final PluggableService < T > service , final String providerName ) throws ProviderLoaderException { if ( ! ( service instanceof ScriptPluginProviderLoadable ) ) { return null ; } ScriptPluginProviderLoadable < T > loader = ( ScriptPluginProviderLoadable < T > ) service ; final Provide...
Load a provider instance for the service by name
9,516
private PluginMeta getPluginMeta ( ) throws IOException { if ( null != metadata ) { return metadata ; } metadata = loadMeta ( file ) ; metadata . setId ( PluginUtils . generateShaIdFromName ( metadata . getName ( ) ) ) ; dateLoaded = new Date ( ) ; return metadata ; }
Get the plugin metadata loading from the file if necessary
9,517
private ScriptPluginProvider getPlugin ( final PluginMeta pluginMeta , final File file , final ProviderDef pluginDef , final ProviderIdent ident ) throws ProviderLoaderException , PluginException { if ( null == fileExpandedDir ) { final File dir ; try { dir = expandScriptPlugin ( file ) ; } catch ( IOException e ) { th...
Get the ScriptPluginProvider definition from the file for the given provider def and ident
9,518
private boolean matchesProvider ( final ProviderIdent ident , final ProviderDef pluginDef ) { return ident . getService ( ) . equals ( pluginDef . getService ( ) ) && ident . getProviderName ( ) . equals ( pluginDef . getName ( ) ) ; }
Return true if the ident matches the provider def metadata
9,519
public synchronized boolean isLoaderFor ( final ProviderIdent ident ) { final PluginMeta pluginMeta ; try { pluginMeta = getPluginMeta ( ) ; } catch ( IOException e ) { log . warn ( "Unable to load file meta: " + e . getMessage ( ) ) ; return false ; } if ( null == pluginMeta ) { return false ; } for ( final ProviderDe...
Return true if the plugin file can loade a provider for the ident
9,520
static PluginMeta loadMeta ( final File jar ) throws IOException { FileInputStream fileInputStream = new FileInputStream ( jar ) ; try { final ZipInputStream zipinput = new ZipInputStream ( fileInputStream ) ; final PluginMeta metadata = ScriptPluginProviderLoader . loadMeta ( jar , zipinput ) ; return metadata ; } fin...
Get plugin metadatat from a zip file
9,521
static PluginMeta loadMeta ( final File jar , final ZipInputStream zipinput ) throws IOException { final String basename = basename ( jar ) ; PluginMeta metadata = null ; boolean topfound = false ; boolean found = false ; boolean dirfound = false ; boolean resfound = false ; ZipEntry nextEntry = zipinput . getNextEntry...
Load plugin metadata for a file and zip inputstream
9,522
static PluginMeta loadMetadataYaml ( final InputStream stream ) { final Yaml yaml = new Yaml ( ) ; return yaml . loadAs ( stream , PluginMeta . class ) ; }
return loaded yaml plugin metadata from the stream
9,523
static PluginValidation validatePluginMeta ( final PluginMeta pluginList , final File file ) { PluginValidation . State state = PluginValidation . State . VALID ; if ( pluginList == null ) { return PluginValidation . builder ( ) . message ( "No metadata" ) . state ( PluginValidation . State . INVALID ) . build ( ) ; } ...
Return true if loaded metadata about the plugin file is valid .
9,524
private File expandScriptPlugin ( final File file ) throws IOException { if ( ! cachedir . exists ( ) ) { if ( ! cachedir . mkdirs ( ) ) { log . warn ( "Unable to create cache dir: " + cachedir . getAbsolutePath ( ) ) ; } } final File jardir = getFileCacheDir ( ) ; if ( ! jardir . exists ( ) ) { if ( ! jardir . mkdir (...
Expand zip file into plugin cache dir
9,525
private synchronized boolean removeScriptPluginCache ( ) { if ( null != fileExpandedDir && fileExpandedDir . exists ( ) ) { debug ( "removeScriptPluginCache: " + fileExpandedDir ) ; return FileUtils . deleteDir ( fileExpandedDir ) ; } return true ; }
Remove any cache dir for the file
9,526
private static String basename ( final File file ) { final String name = file . getName ( ) ; if ( name . contains ( "." ) ) { return name . substring ( 0 , name . lastIndexOf ( "." ) ) ; } return name ; }
Get basename of a file
9,527
private static void validateProviderDef ( final ProviderDef pluginDef ) throws PluginException { if ( null == pluginDef . getPluginType ( ) || "" . equals ( pluginDef . getPluginType ( ) ) ) { throw new PluginException ( "Script plugin missing plugin-type" ) ; } if ( "script" . equals ( pluginDef . getPluginType ( ) ) ...
Validate provider def
9,528
static String getVersionForFile ( final File file ) { try { final PluginMeta pluginMeta = loadMeta ( file ) ; return pluginMeta . getVersion ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return null ; }
Return the version string metadata value for the plugin file or null if it is not available or could not loaded
9,529
private String expandMessage ( final BuildEvent event , final String message ) { final HashMap < String , String > data = new HashMap < String , String > ( ) ; final String user = retrieveUserName ( event ) ; if ( null != user ) { data . put ( "user" , user ) ; } final String node = retrieveNodeName ( event ) ; if ( nu...
Process string specified by the framework . log . dispatch . console . format property replacing any well known tokens with values from the event .
9,530
public static String logLevelToString ( final int level ) { String logLevel ; switch ( level ) { case Project . MSG_DEBUG : logLevel = "DEBUG" ; break ; case Project . MSG_VERBOSE : logLevel = "VERBOSE" ; break ; case Project . MSG_INFO : logLevel = "INFO" ; break ; case Project . MSG_WARN : logLevel = "WARN" ; break ;...
Returns a string representing the specified log level
9,531
public static void buildFieldProperties ( final Class < ? > aClass , final DescriptionBuilder builder ) { for ( final Field field : collectClassFields ( aClass ) ) { final PluginProperty annotation = field . getAnnotation ( PluginProperty . class ) ; if ( null == annotation ) { continue ; } final Property pbuild = prop...
Add properties based on introspection of a class
9,532
public static Map < String , Object > configureProperties ( final PropertyResolver resolver , final Object object ) { return configureProperties ( resolver , buildDescription ( object , DescriptionBuilder . builder ( ) ) , object , PropertyScope . InstanceOnly ) ; }
Set field values on a plugin object by using annotated field values to create a Description and setting field values to resolved property values . Any resolved properties that are not mapped to a field will be included in the return result .
9,533
public static Map < String , Object > configureProperties ( final PropertyResolver resolver , final Description description , final Object object , PropertyScope defaultScope ) { Map < String , Object > inputConfig = mapDescribedProperties ( resolver , description , defaultScope ) ; if ( object instanceof Configurable ...
Set field values on a plugin object by using a Description and setting field values to resolved property values . Any resolved properties that are not mapped to a field will be included in the return result .
9,534
public static Map < String , Object > configureObjectFieldsWithProperties ( final Object object , final Map < String , Object > inputConfig ) { return configureObjectFieldsWithProperties ( object , buildFieldProperties ( object ) , inputConfig ) ; }
Set field values on an object using introspection and input values for those properties
9,535
public static Map < String , Object > configureObjectFieldsWithProperties ( final Object object , final List < Property > properties , final Map < String , Object > inputConfig ) { HashMap < String , Object > modified = new HashMap < > ( inputConfig ) ; for ( final Property property : properties ) { if ( null != modifi...
Set field values on an object given a list of properties and input values for those properties
9,536
public static Map < String , Object > mapDescribedProperties ( final PropertyResolver resolver , final Description description ) { return mapDescribedProperties ( resolver , description , null ) ; }
Retrieve the Description s Properties mapped to resolved values given the resolver using InsanceOnly default scope .
9,537
public static PropertyLookup create ( final File propfile , final Map defaults , final IPropertyLookup defaultsLookup ) { return new PropertyLookup ( propfile , defaults , defaultsLookup ) ; }
Calls base constructor feeding defaults from Map and IPropertyLookup params
9,538
public String getProperty ( final String key ) { if ( hasProperty ( key ) ) { return properties . getProperty ( key ) ; } else { throw new PropertyLookupException ( "property not found: " + key ) ; } }
Get the property per specified key
9,539
public static Properties fetchProperties ( final File propFile ) { final Properties properties = new Properties ( ) ; try { FileInputStream fis = new FileInputStream ( propFile ) ; try { properties . load ( fis ) ; } finally { if ( null != fis ) { fis . close ( ) ; } } } catch ( IOException e ) { throw new PropertyLook...
given a file reads in its properties
9,540
protected Properties difference ( final Map map ) { final Properties difference = new Properties ( ) ; for ( final Object o : map . entrySet ( ) ) { final Map . Entry entry = ( Map . Entry ) o ; final String key = ( String ) entry . getKey ( ) ; final String val = ( String ) entry . getValue ( ) ; if ( ! properties . c...
Reads map of input properties and returns a collection of those that are unique to that input set .
9,541
public static boolean hasProperty ( final String propKey , final File propFile ) { if ( null == propKey ) throw new IllegalArgumentException ( "propKey param was null" ) ; if ( null == propFile ) throw new IllegalArgumentException ( "propFile param was null" ) ; if ( propFile . exists ( ) ) { final Properties p = new P...
Reads propFile and then checks if specified key exists .
9,542
public static Properties expand ( final Map properties ) { final Properties expandedProperties = new Properties ( ) ; for ( final Object o : properties . entrySet ( ) ) { final Map . Entry entry = ( Map . Entry ) o ; final String key = ( String ) entry . getKey ( ) ; final String keyValue = ( String ) entry . getValue ...
expand a given Properties object and return a new one . This will process each key to a given Properties object get its value and expand it . Each value may contain references to other keys within this given Properties object and if so all keys and their expanded keyValues will be resolved into a new Properties object ...
9,543
public static String expand ( String keyString , Properties properties ) { return PropertyUtil . expand ( keyString , ( Map ) properties ) ; }
expand a keyString that may contain references to properties located in provided Properties object
9,544
public static String expand ( String keyString , Project project ) { return expand ( keyString , project . getProperties ( ) ) ; }
expand a keyString that may contain referecnes to other properties
9,545
@ SuppressWarnings ( "unchecked" ) public static NodeEntryImpl createFromMap ( final Map < String , Object > map ) throws IllegalArgumentException { final NodeEntryImpl nodeEntry = new NodeEntryImpl ( ) ; final HashMap < String , Object > newmap = new HashMap < String , Object > ( map ) ; for ( final String excludeProp...
Create NodeEntryImpl from map data . It will convert tags of type String as a comma separated list of tags or tags a collection of strings into a set . It will remove properties excluded from allowed import .
9,546
public Charset setCharset ( Charset charset ) { Charset prev = this . charset . get ( ) ; this . charset . set ( charset ) ; return prev ; }
Set the charset to use
9,547
public LogBufferManager < D , T > installManager ( ) { LogBufferManager < D , T > manager = factory . apply ( charset . get ( ) ) ; this . manager . set ( manager ) ; return manager ; }
Install a new inherited thread local buffer manager and return it
9,548
private LogBufferManager < D , T > getOrCreateManager ( ) { if ( null == manager . get ( ) ) { installManager ( ) ; } return manager . get ( ) ; }
If no manager is set install one otherwise return the existing one
9,549
private Holder < T > getOrReset ( ) { if ( buffer . get ( ) == null || buffer . get ( ) . getBuffer ( ) . isEmpty ( ) ) { resetEventBuffer ( ) ; } return buffer . get ( ) ; }
get the thread s event buffer reset it if it is empty
9,550
private void resetEventBuffer ( ) { if ( buffer . get ( ) == null ) { buffer . set ( new Holder < > ( getOrCreateManager ( ) . create ( charset . get ( ) ) ) ) ; } else { buffer . get ( ) . reset ( ) ; } }
reset existing or create a new buffer with the current context
9,551
private void flushEventBuffer ( ) { Holder < T > holder = buffer . get ( ) ; logger . accept ( holder . getBuffer ( ) . get ( ) ) ; holder . clear ( ) ; }
emit a log event for the current contents of the buffer
9,552
public StreamingLogWriter removeOverride ( ) { StreamingLogWriter previous = override . get ( ) . pop ( ) . orElse ( null ) ; return previous ; }
Remove the overriding writer if any
9,553
public static String parameterString ( StepContextId contextId ) { return null != contextId . getParams ( ) ? "@" + parameterString ( contextId . getParams ( ) ) : "" ; }
Generate string for a context id s parameter section if present
9,554
private static void setupNodeStates ( WorkflowState current , WorkflowStateImpl parent , StepIdentifier ident ) { HashMap < String , WorkflowNodeState > nodeStates = new HashMap < > ( ) ; if ( null != parent . getNodeStates ( ) ) { nodeStates . putAll ( parent . getNodeStates ( ) ) ; } ArrayList < String > allNodes = n...
Configure the nodeStates map for the workflow by visiting each step in the workflow and connecting the step + node state for nodeSteps to the nodeStates map
9,555
public String setAttribute ( final String name , final String value ) { if ( null != value ) { return getAttributes ( ) . put ( name , value ) ; } else { getAttributes ( ) . remove ( name ) ; return value ; } }
Set the value for a specific attribute
9,556
private File getTemplateFile ( String filename ) throws IOException { File templateFile = null ; final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename ; InputStream is = Setup . class . getClassLoader ( ) . getResourceAsStream ( resource ) ; if ( null == is ) { throw new RuntimeException ( "Unable to load re...
Look for template in the jar resources otherwise look for it on filepath
9,557
private void validateInstall ( ) throws SetupException { if ( null == parameters . getBaseDir ( ) || parameters . getBaseDir ( ) . equals ( "" ) ) { throw new SetupException ( "rdeck.base property not defined or is the empty string" ) ; } if ( ! checkIfDir ( "rdeck.base" , parameters . getBaseDir ( ) ) ) { throw new Se...
Checks the basic install assumptions
9,558
private boolean checkIfDir ( final String propName , final String path ) { if ( null == path || path . equals ( "" ) ) { throw new IllegalArgumentException ( propName + "property had null or empty value" ) ; } return new File ( path ) . exists ( ) ; }
check if path exists as a directory
9,559
private void generatePreferences ( final String args [ ] , Properties input ) throws SetupException { File frameworkPreferences = new File ( Constants . getFrameworkPreferences ( parameters . getBaseDir ( ) ) ) ; try { Preferences . generate ( args , frameworkPreferences . getAbsolutePath ( ) , input ) ; } catch ( Exce...
generate the preferences . properties file
9,560
public StateObj evaluateRules ( final StateObj state ) { MutableStateObj dataState = States . mutable ( ) ; getRuleSet ( ) . stream ( ) . filter ( i -> i . test ( state ) ) . map ( input -> Optional . ofNullable ( input . evaluate ( state ) ) ) . flatMap ( o -> o . map ( Stream :: of ) . orElseGet ( Stream :: empty ) )...
Evaluate each rule if it applies accrue the new state changes
9,561
protected boolean authenticate ( String name , char [ ] password ) throws LoginException { try { if ( ( name == null ) || ( password == null ) ) { debug ( "user or pass is null" ) ; return false ; } debug ( "PAM authentication trying (" + serviceName + ") for: " + name ) ; UnixUser authenticate = new PAM ( serviceName ...
Authenticates using PAM
9,562
protected List < Principal > createRolePrincipals ( UnixUser username ) { ArrayList < Principal > principals = new ArrayList < Principal > ( ) ; if ( null != supplementalRoles ) { for ( String supplementalRole : supplementalRoles ) { Principal rolePrincipal = createRolePrincipal ( supplementalRole ) ; if ( null != role...
Create Principals for any roles
9,563
private boolean authorizedPath ( AuthContext context , Path path , String action ) { Decision evaluate = context . evaluate ( resourceForPath ( path ) , action , environmentForPath ( path ) ) ; return evaluate . isAuthorized ( ) ; }
Evaluate access based on path
9,564
private Map < String , String > resourceForPath ( Path path ) { return AuthorizationUtil . resource ( STORAGE_PATH_AUTH_RES_TYPE , authResForPath ( path ) ) ; }
Return authorization resource map for a path
9,565
private Map < String , String > authResForPath ( Path path ) { HashMap < String , String > authResource = new HashMap < String , String > ( ) ; authResource . put ( PATH_RES_KEY , path . getPath ( ) ) ; authResource . put ( NAME_RES_KEY , path . getName ( ) ) ; return authResource ; }
Map containing path and name given a path
9,566
protected void go ( ) throws CLIToolOptionsException { if ( null == action ) { throw new CLIToolOptionsException ( "Command expected. Choose one of: " + Arrays . asList ( Actions . values ( ) ) ) ; } try { switch ( action ) { case list : listAction ( ) ; break ; case test : testAction ( ) ; break ; case create : create...
Call the action
9,567
private boolean applyArgValidate ( ) throws CLIToolOptionsException { if ( argValidate ) { Validation validation = validatePolicies ( ) ; if ( argVerbose && ! validation . isValid ( ) ) { reportValidation ( validation ) ; } if ( ! validation . isValid ( ) ) { log ( "The validation " + ( validation . isValid ( ) ? "pass...
If argValidate is specified validate the input exit 2 if invalid . Print validation report if argVerbose
9,568
public void parse ( ) throws NodeFileParserException { final ResourceXMLParser resourceXMLParser ; if ( null != file ) { resourceXMLParser = new ResourceXMLParser ( file ) ; } else { resourceXMLParser = new ResourceXMLParser ( input ) ; } resourceXMLParser . setReceiver ( this ) ; try { resourceXMLParser . parse ( ) ; ...
Parse the project . xml formatted file and fill in the nodes found
9,569
private void fillNode ( final ResourceXMLParser . Entity entity , final NodeEntryImpl node ) { node . setUsername ( entity . getProperty ( NODE_USERNAME ) ) ; node . setHostname ( entity . getProperty ( NODE_HOSTNAME ) ) ; node . setOsArch ( entity . getProperty ( NODE_OS_ARCH ) ) ; node . setOsFamily ( entity . getPro...
Fill the NodeEntryImpl based on the Entity s parsed attributes
9,570
public String [ ] getResourceNames ( ) { if ( null != resourcesList ) { return resourcesList . toArray ( new String [ resourcesList . size ( ) ] ) ; } if ( null != basedirListing ) { return basedirListing . toArray ( new String [ basedirListing . size ( ) ] ) ; } String [ ] list = listZipPath ( zipFile , resourcesBased...
Get the list of resources in the jar
9,571
public void extractResources ( ) throws IOException { if ( ! cacheDir . isDirectory ( ) ) { if ( ! cacheDir . mkdirs ( ) ) { } } if ( null != resourcesList ) { extractJarContents ( resourcesList , cacheDir ) ; for ( final String s : resourcesList ) { File libFile = new File ( cacheDir , s ) ; libFile . deleteOnExit ( )...
Extract resources return the extracted files
9,572
private void continueProcessing ( ) { try { while ( ! Thread . currentThread ( ) . isInterrupted ( ) ) { HashMap < String , String > changes = new HashMap < > ( ) ; getAvailableChanges ( changes ) ; if ( changes . isEmpty ( ) ) { if ( inProcess . isEmpty ( ) ) { workflowEngine . event ( WorkflowSystemEventType . EndOfC...
Continue processing from current state
9,573
private void getAvailableChanges ( final Map < String , String > changes ) { WorkflowSystem . OperationCompleted < DAT > task = stateChangeQueue . poll ( ) ; while ( task != null && task . getNewState ( ) != null ) { changes . putAll ( task . getNewState ( ) . getState ( ) ) ; DAT result = task . getResult ( ) ; if ( n...
Poll for changes from the queue and process all changes that are immediately available without waiting
9,574
private void processRunnableOperations ( final Consumer < WorkflowSystem . OperationResult < DAT , RES , OP > > resultConsumer , final List < OP > shouldrun , final List < OP > shouldskip , final DAT inputData ) { for ( final OP operation : shouldrun ) { if ( shouldskip . contains ( operation ) ) { continue ; } pending...
Process the runnable operations
9,575
private void waitForChanges ( final Map < String , String > changes ) throws InterruptedException { WorkflowSystem . OperationCompleted < DAT > take = stateChangeQueue . poll ( sleeper . time ( ) , sleeper . unit ( ) ) ; if ( null == take || take . getNewState ( ) . getState ( ) . isEmpty ( ) ) { sleeper . backoff ( ) ...
Sleep until changes are available on the queue if any are found then consume remaining and return false otherwise return true
9,576
private void processStateChanges ( final Map < String , String > changes ) { workflowEngine . event ( WorkflowSystemEventType . WillProcessStateChange , String . format ( "saw state changes: %s" , changes ) , changes ) ; workflowEngine . getState ( ) . updateState ( changes ) ; boolean update = Rules . update ( workflo...
Handle the state changes for the rule engine
9,577
private void processOperations ( final Consumer < WorkflowSystem . OperationResult < DAT , RES , OP > > resultConsumer ) { int origPendingCount = pending . size ( ) ; List < OP > shouldrun = pending . stream ( ) . filter ( input -> input . shouldRun ( workflowEngine . getState ( ) ) ) . collect ( Collectors . toList ( ...
Run and skip pending operations
9,578
private void processSkippedOperations ( final List < OP > shouldskip ) { for ( final OP operation : shouldskip ) { workflowEngine . event ( WorkflowSystemEventType . WillSkipOperation , String . format ( "Skip condition statisfied for operation: %s, skipping" , operation ) , operation ) ; StateObj newstate = operation ...
Process skipped operations
9,579
protected List getUserRoles ( final DirContext dirContext , final String username ) throws LoginException , NamingException { if ( _ignoreRoles ) { ArrayList < String > strings = new ArrayList < > ( ) ; addSupplementalRoles ( strings ) ; return strings ; } else { return super . getUserRoles ( dirContext , username ) ; ...
Override to perform behavior of ignoreRoles option
9,580
public boolean login ( ) throws LoginException { if ( ( getShared ( ) . isUseFirstPass ( ) || getShared ( ) . isTryFirstPass ( ) ) && getShared ( ) . isHasSharedAuth ( ) ) { debug ( String . format ( "JettyCombinedLdapLoginModule: login with shared auth, " + "try? %s, use? %s" , getShared ( ) . isTryFirstPass ( ) , get...
Override default login logic to use shared login credentials if available
9,581
public static void fileCopy ( final File src , final File dest , final boolean overwrite ) throws IOException { if ( ! dest . exists ( ) || ( dest . exists ( ) && overwrite ) ) { FileUtils . mkParentDirs ( dest ) ; if ( overwrite ) { Files . copy ( src . toPath ( ) , dest . toPath ( ) , StandardCopyOption . REPLACE_EXI...
Copies file src to dest using nio .
9,582
public static void deleteDirOnExit ( final File dir ) { if ( dir . isDirectory ( ) ) { final String [ ] children = dir . list ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { deleteDirOnExit ( new File ( dir , children [ i ] ) ) ; } } dir . deleteOnExit ( ) ; }
Delete a directory recursively . This method will delete all files and subdirectories .
9,583
public static void fileRename ( final File file , final String newPath , final Class clazz ) { File newDestFile = new File ( newPath ) ; File lockFile = new File ( newDestFile . getAbsolutePath ( ) + ".lock" ) ; try { synchronized ( clazz ) { FileChannel channel = new RandomAccessFile ( lockFile , "rw" ) . getChannel (...
Rename a file . Uses Java s nio library to use a lock .
9,584
public static void mkParentDirs ( final File file ) throws IOException { File parentFile = file . getParentFile ( ) ; if ( parentFile == null ) { parentFile = file . getAbsoluteFile ( ) . getParentFile ( ) ; } if ( parentFile != null && ! parentFile . exists ( ) ) { if ( ! parentFile . mkdirs ( ) ) { throw new IOExcept...
Create parent directory structure of a given file if it doesn t already exist .
9,585
public static File getBaseDir ( final List < File > files ) { String common = getCommonPrefix ( files . stream ( ) . map ( new Function < File , String > ( ) { public String apply ( final File file ) { return file . getAbsolutePath ( ) ; } } ) . collect ( Collectors . toList ( ) ) ) ; if ( null != common ) { return new...
Return common base directory of the given files
9,586
public static String relativePath ( File parent , File child ) { Path superPath = parent . toPath ( ) ; Path subPath = child . toPath ( ) ; if ( ! subPath . startsWith ( superPath ) ) { throw new IllegalArgumentException ( "Not a subpath: " + child ) ; } return superPath . relativize ( subPath ) . toString ( ) ; }
Return the relative path between a parent directory and some child path
9,587
private WorkflowStatusDataResult executeWFSectionNodeDispatch ( StepExecutionContext executionContext , int stepCount , List < StepExecutionResult > results , Map < String , Collection < StepExecutionResult > > failures , final Map < Integer , StepExecutionResult > stepFailures , IWorkflow flowsection , WFSharedContext...
Execute a workflow section that should be dispatched across nodes
9,588
private List < IWorkflow > splitWorkflowDispatchedSections ( IWorkflow workflow ) throws ExecutionServiceException { ArrayList < StepExecutionItem > dispatchItems = new ArrayList < > ( ) ; ArrayList < IWorkflow > sections = new ArrayList < > ( ) ; for ( final StepExecutionItem item : workflow . getCommands ( ) ) { Step...
Splits a workflow into a sequence of sub - workflows separated along boundaries of node - dispatch sets .
9,589
public static ExtSSHExec build ( final INodeEntry nodeentry , final String [ ] args , final Project project , final Map < String , Map < String , String > > dataContext , final SSHConnectionInfo sshConnectionInfo , final int loglevel , final PluginLogger logger ) throws BuilderException { final ExtSSHExec extSSHExec = ...
Build a Task that performs SSH command
9,590
private void remove ( final ProviderIdent ident ) { final cacheItem cacheItem = cache . get ( ident ) ; if ( null != cacheItem ) { filecache . remove ( cacheItem . getFirst ( ) ) ; } cache . remove ( ident ) ; }
Remove the association with ident and remove any filecache association as well .
9,591
public synchronized ProviderLoader getLoaderForIdent ( final ProviderIdent ident ) throws ProviderLoaderException { final cacheItem cacheItem = cache . get ( ident ) ; if ( null == cacheItem ) { return rescanForItem ( ident ) ; } final File file = cacheItem . getFirst ( ) ; if ( cacheItem . getSecond ( ) . isExpired ( ...
Get the loader for the provider
9,592
private ProviderLoader loadFileProvider ( final cacheItem cached ) { final File file = cached . getFirst ( ) ; final PluginScanner second = cached . getSecond ( ) ; return filecache . get ( file , second ) ; }
return the loader stored in filecache for the file and scanner
9,593
private synchronized ProviderLoader rescanForItem ( final ProviderIdent ident ) throws ProviderLoaderException { File candidate = null ; PluginScanner cscanner = null ; for ( final PluginScanner scanner : getScanners ( ) ) { final File file = scanner . scanForFile ( ident ) ; if ( null != file ) { if ( null != candidat...
Rescan for the ident and cache and return the loader
9,594
public void addEnv ( final Environment . Variable env ) { if ( null == envVars ) { envVars = new ArrayList < Environment . Variable > ( ) ; } envVars . add ( env ) ; }
Add an Env element
9,595
public void execute ( ) throws BuildException { if ( getHost ( ) == null ) { throw new BuildException ( "Host is required." ) ; } if ( getUserInfo ( ) . getName ( ) == null ) { throw new BuildException ( "Username is required." ) ; } if ( getUserInfo ( ) . getKeyfile ( ) == null && getUserInfo ( ) . getPassword ( ) == ...
Execute the command on the remote host .
9,596
private void writeToFile ( String from , boolean append , File to ) throws IOException { FileWriter out = null ; try { out = new FileWriter ( to . getAbsolutePath ( ) , append ) ; StringReader in = new StringReader ( from ) ; char [ ] buffer = new char [ BUFFER_SIZE ] ; int bytesRead ; while ( true ) { bytesRead = in ....
Writes a string to a file . If destination file exists it may be overwritten depending on the append value .
9,597
private Set < Resource < T > > listStackDirectory ( Path path ) { HashSet < Resource < T > > merge = new HashSet < Resource < T > > ( ) ; if ( treeHandlerList . size ( ) > 0 ) { for ( SelectiveTree < T > treeHandler : treeHandlerList ) { if ( PathUtil . hasRoot ( treeHandler . getSubPath ( ) , path ) && ! PathUtil . eq...
List all treeHandlers as directories which have the given path as a parent
9,598
public static long genSeed ( final String ident ) { try { MessageDigest instance = MessageDigest . getInstance ( "SHA-1" ) ; byte [ ] strbytes = ident . getBytes ( "UTF-8" ) ; byte [ ] digest = instance . digest ( strbytes ) ; return ByteBuffer . wrap ( digest , 0 , Long . BYTES ) . getLong ( ) ; } catch ( NoSuchAlgori...
generate random seed from unique ident string
9,599
public void openStream ( ) throws IOException { socket = new Socket ( host , port ) ; socketStream = socket . getOutputStream ( ) ; if ( null != context . get ( "name" ) && null != context . get ( "id" ) ) { Object group = context . get ( "group" ) ; String desc = ( null != group ? group + "/" : "" ) + context . get ( ...
Open a stream called before addEntry is called