repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
roboconf/roboconf-platform
core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/resources/impl/DebugResource.java
DebugResource.createDiagnostic
Diagnostic createDiagnostic( Instance instance ) { Diagnostic result = new Diagnostic( InstanceHelpers.computeInstancePath( instance )); for( Map.Entry<String,Boolean> entry : ComponentHelpers.findComponentDependenciesFor( instance.getComponent()).entrySet()) { String facetOrComponentName = entry.getKey(); Collection<Import> imports = instance.getImports().get( facetOrComponentName ); boolean resolved = imports != null && ! imports.isEmpty(); boolean optional = entry.getValue(); result.getDependenciesInformation().add( new DependencyInformation( facetOrComponentName, optional, resolved )); } return result; }
java
Diagnostic createDiagnostic( Instance instance ) { Diagnostic result = new Diagnostic( InstanceHelpers.computeInstancePath( instance )); for( Map.Entry<String,Boolean> entry : ComponentHelpers.findComponentDependenciesFor( instance.getComponent()).entrySet()) { String facetOrComponentName = entry.getKey(); Collection<Import> imports = instance.getImports().get( facetOrComponentName ); boolean resolved = imports != null && ! imports.isEmpty(); boolean optional = entry.getValue(); result.getDependenciesInformation().add( new DependencyInformation( facetOrComponentName, optional, resolved )); } return result; }
[ "Diagnostic", "createDiagnostic", "(", "Instance", "instance", ")", "{", "Diagnostic", "result", "=", "new", "Diagnostic", "(", "InstanceHelpers", ".", "computeInstancePath", "(", "instance", ")", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", ...
Creates a diagnostic for an instance. @param instance a non-null instance @return a non-null diagnostic
[ "Creates", "a", "diagnostic", "for", "an", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/resources/impl/DebugResource.java#L184-L198
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java
VariableHelpers.parseExportedVariables
public static Map<String,ExportedVariable> parseExportedVariables( String line ) { Pattern randomPattern = Pattern.compile( ParsingConstants.PROPERTY_GRAPH_RANDOM_PATTERN, Pattern.CASE_INSENSITIVE ); Pattern varPattern = Pattern.compile( "([^,=]+)(\\s*=\\s*(\"([^\",]+)\"|([^,]+)))?" ); Map<String,ExportedVariable> result = new LinkedHashMap<> (); Matcher varMatcher = varPattern.matcher( line ); while( varMatcher.find()) { String key = varMatcher.group( 1 ).trim(); if( Utils.isEmptyOrWhitespaces( key )) continue; String value = null; if( varMatcher.group( 3 ) != null ) { // We do not always trim! // Surrounding white spaces are kept when defined between quotes. if( varMatcher.group( 5 ) != null ) value = varMatcher.group( 5 ).trim(); else value = varMatcher.group( 4 ); } ExportedVariable var = new ExportedVariable(); Matcher m = randomPattern.matcher( key ); if( m.matches()) { var.setRandom( true ); var.setRawKind( m.group( 1 )); key = m.group( 2 ).trim(); } var.setName( key.trim()); if( value != null ) var.setValue( value ); result.put( var.getName(), var ); } return result; }
java
public static Map<String,ExportedVariable> parseExportedVariables( String line ) { Pattern randomPattern = Pattern.compile( ParsingConstants.PROPERTY_GRAPH_RANDOM_PATTERN, Pattern.CASE_INSENSITIVE ); Pattern varPattern = Pattern.compile( "([^,=]+)(\\s*=\\s*(\"([^\",]+)\"|([^,]+)))?" ); Map<String,ExportedVariable> result = new LinkedHashMap<> (); Matcher varMatcher = varPattern.matcher( line ); while( varMatcher.find()) { String key = varMatcher.group( 1 ).trim(); if( Utils.isEmptyOrWhitespaces( key )) continue; String value = null; if( varMatcher.group( 3 ) != null ) { // We do not always trim! // Surrounding white spaces are kept when defined between quotes. if( varMatcher.group( 5 ) != null ) value = varMatcher.group( 5 ).trim(); else value = varMatcher.group( 4 ); } ExportedVariable var = new ExportedVariable(); Matcher m = randomPattern.matcher( key ); if( m.matches()) { var.setRandom( true ); var.setRawKind( m.group( 1 )); key = m.group( 2 ).trim(); } var.setName( key.trim()); if( value != null ) var.setValue( value ); result.put( var.getName(), var ); } return result; }
[ "public", "static", "Map", "<", "String", ",", "ExportedVariable", ">", "parseExportedVariables", "(", "String", "line", ")", "{", "Pattern", "randomPattern", "=", "Pattern", ".", "compile", "(", "ParsingConstants", ".", "PROPERTY_GRAPH_RANDOM_PATTERN", ",", "Patter...
Parse a list of exported variables. @param line a non-null line @return a non-null map of exported variables
[ "Parse", "a", "list", "of", "exported", "variables", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java#L114-L154
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java
VariableHelpers.findPrefixesForExportedVariables
public static Set<String> findPrefixesForExportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( String exportedVariableName : InstanceHelpers.findAllExportedVariables( instance ).keySet()) result.add( VariableHelpers.parseVariableName( exportedVariableName ).getKey()); return result; }
java
public static Set<String> findPrefixesForExportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( String exportedVariableName : InstanceHelpers.findAllExportedVariables( instance ).keySet()) result.add( VariableHelpers.parseVariableName( exportedVariableName ).getKey()); return result; }
[ "public", "static", "Set", "<", "String", ">", "findPrefixesForExportedVariables", "(", "Instance", "instance", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "String", "exportedVariableName", ":", "Ins...
Finds the component and facet names that prefix the variables an instance exports. @param instance an instance @return a non-null set with all the component and facet names this instance exports
[ "Finds", "the", "component", "and", "facet", "names", "that", "prefix", "the", "variables", "an", "instance", "exports", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java#L162-L169
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java
VariableHelpers.findPrefixesForImportedVariables
public static Set<String> findPrefixesForImportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( instance.getComponent()).values()) result.add( VariableHelpers.parseVariableName( var.getName()).getKey()); return result; }
java
public static Set<String> findPrefixesForImportedVariables( Instance instance ) { Set<String> result = new HashSet<> (); for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( instance.getComponent()).values()) result.add( VariableHelpers.parseVariableName( var.getName()).getKey()); return result; }
[ "public", "static", "Set", "<", "String", ">", "findPrefixesForImportedVariables", "(", "Instance", "instance", ")", "{", "Set", "<", "String", ">", "result", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "ImportedVariable", "var", ":", "ComponentH...
Finds the component and facet names that prefix the variables an instance imports. @param instance an instance @return a non-null set with all the component and facet names this instance imports
[ "Finds", "the", "component", "and", "facet", "names", "that", "prefix", "the", "variables", "an", "instance", "imports", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/model/helpers/VariableHelpers.java#L177-L184
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.setDescription
public void setDescription( String applicationName, String newDesc ) throws ApplicationWsException { this.logger.finer( "Updating the description of application " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "description" ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.TEXT_PLAIN ) .post( ClientResponse.class, newDesc ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
java
public void setDescription( String applicationName, String newDesc ) throws ApplicationWsException { this.logger.finer( "Updating the description of application " + applicationName + "." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "description" ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.TEXT_PLAIN ) .post( ClientResponse.class, newDesc ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
[ "public", "void", "setDescription", "(", "String", "applicationName", ",", "String", "newDesc", ")", "throws", "ApplicationWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Updating the description of application \"", "+", "applicationName", "+", "\".\"", ...
Changes the description of an application. @param applicationName the application name @param newDesc the new description to set @throws ApplicationWsException if something went wrong
[ "Changes", "the", "description", "of", "an", "application", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L108-L120
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.undeployAll
public void undeployAll( String applicationName, String instancePath ) throws ApplicationWsException { this.logger.finer( "Undeploying instances in " + applicationName + " from instance = " + instancePath ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "undeploy-all" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
java
public void undeployAll( String applicationName, String instancePath ) throws ApplicationWsException { this.logger.finer( "Undeploying instances in " + applicationName + " from instance = " + instancePath ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "undeploy-all" ); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
[ "public", "void", "undeployAll", "(", "String", "applicationName", ",", "String", "instancePath", ")", "throws", "ApplicationWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Undeploying instances in \"", "+", "applicationName", "+", "\" from instance = \"...
Undeploys several instances at once. @param applicationName the application name @param instancePath the path of the instance to undeploy (null for all the application instances) @throws ApplicationWsException if something went wrong
[ "Undeploys", "several", "instances", "at", "once", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L177-L192
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.listChildrenInstances
public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; }
java
public List<Instance> listChildrenInstances( String applicationName, String instancePath, boolean all ) { this.logger.finer( "Listing children instances for " + instancePath + " in " + applicationName + "." ); WebResource path = this.resource .path( UrlConstants.APP ).path( applicationName ).path( "instances" ) .queryParam( "all-children", String.valueOf( all )); if( instancePath != null ) path = path.queryParam( "instance-path", instancePath ); List<Instance> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .type( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Instance>> () {}); if( result != null ) { this.logger.finer( result.size() + " children instances were found for " + instancePath + " in " + applicationName + "." ); } else { this.logger.finer( "No child instance was found for " + instancePath + " in " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; }
[ "public", "List", "<", "Instance", ">", "listChildrenInstances", "(", "String", "applicationName", ",", "String", "instancePath", ",", "boolean", "all", ")", "{", "this", ".", "logger", ".", "finer", "(", "\"Listing children instances for \"", "+", "instancePath", ...
Lists all the children of an instance. @param applicationName the application name @param instancePath the instance path (null to get root instances) @param all true to list indirect children too, false to only list direct children @return a non-null list of instance paths
[ "Lists", "all", "the", "children", "of", "an", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L202-L226
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.addInstance
public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
java
public void addInstance( String applicationName, String parentInstancePath, Instance instance ) throws ApplicationWsException { this.logger.finer( "Adding an instance to the application " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ).path( applicationName ).path( "instances" ); if( parentInstancePath != null ) path = path.queryParam( "instance-path", parentInstancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON ) .post( ClientResponse.class, instance ); handleResponse( response ); this.logger.finer( String.valueOf( response.getStatusInfo())); }
[ "public", "void", "addInstance", "(", "String", "applicationName", ",", "String", "parentInstancePath", ",", "Instance", "instance", ")", "throws", "ApplicationWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Adding an instance to the application \"", "+"...
Adds an instance into an application. @param applicationName the application name @param parentInstancePath the path of the parent instance (null to create a root instance) @param instance the instance to add @throws ApplicationWsException if a problem occurred with the instance management
[ "Adds", "an", "instance", "into", "an", "application", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L236-L249
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.removeInstance
public void removeInstance( String applicationName, String instancePath ) { this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...", instancePath, applicationName ) ); WebResource path = this.resource .path( UrlConstants.APP ) .path( applicationName ) .path( "instances" ) .queryParam( "instance-path", instancePath ); this.wsClient.createBuilder( path ).delete(); this.logger.finer( String.format( "Instance \"%s\" has been removed from application \"%s\"", instancePath, applicationName ) ); }
java
public void removeInstance( String applicationName, String instancePath ) { this.logger.finer( String.format( "Removing instance \"%s\" from application \"%s\"...", instancePath, applicationName ) ); WebResource path = this.resource .path( UrlConstants.APP ) .path( applicationName ) .path( "instances" ) .queryParam( "instance-path", instancePath ); this.wsClient.createBuilder( path ).delete(); this.logger.finer( String.format( "Instance \"%s\" has been removed from application \"%s\"", instancePath, applicationName ) ); }
[ "public", "void", "removeInstance", "(", "String", "applicationName", ",", "String", "instancePath", ")", "{", "this", ".", "logger", ".", "finer", "(", "String", ".", "format", "(", "\"Removing instance \\\"%s\\\" from application \\\"%s\\\"...\"", ",", "instancePath",...
Removes an instance. @param applicationName the application name @param instancePath the path of the instance to remove
[ "Removes", "an", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L258-L271
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.bindApplication
public void bindApplication( String applicationName, String boundTplName, String boundApp ) throws ApplicationWsException { this.logger.finer( "Creating a binding for external exports in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "bind" ) .queryParam( "bound-tpl", boundTplName ) .queryParam( "bound-app", boundApp ); ClientResponse response = this.wsClient.createBuilder( path ).post( ClientResponse.class ); handleResponse( response ); }
java
public void bindApplication( String applicationName, String boundTplName, String boundApp ) throws ApplicationWsException { this.logger.finer( "Creating a binding for external exports in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "bind" ) .queryParam( "bound-tpl", boundTplName ) .queryParam( "bound-app", boundApp ); ClientResponse response = this.wsClient.createBuilder( path ).post( ClientResponse.class ); handleResponse( response ); }
[ "public", "void", "bindApplication", "(", "String", "applicationName", ",", "String", "boundTplName", ",", "String", "boundApp", ")", "throws", "ApplicationWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Creating a binding for external exports in \"", "+...
Binds an application for external exports. @param applicationName the application name @param boundTplName the template name (no qualifier as it does not make sense for external exports) @param boundApp the name of the application (instance of <code>tplName</code>) @throws ApplicationWsException if something went wrong
[ "Binds", "an", "application", "for", "external", "exports", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L380-L392
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java
ApplicationWsDelegate.listAllCommands
public List<String> listAllCommands( String applicationName ) { this.logger.finer( "Listing commands in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "commands" ); List<String> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<String>> () {}); if( result != null ) { this.logger.finer( result.size() + " command(s) were found for " + applicationName + "." ); } else { this.logger.finer( "No command was found for " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; }
java
public List<String> listAllCommands( String applicationName ) { this.logger.finer( "Listing commands in " + applicationName + "..." ); WebResource path = this.resource.path( UrlConstants.APP ) .path( applicationName ).path( "commands" ); List<String> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<String>> () {}); if( result != null ) { this.logger.finer( result.size() + " command(s) were found for " + applicationName + "." ); } else { this.logger.finer( "No command was found for " + applicationName + "." ); result = new ArrayList<>( 0 ); } return result; }
[ "public", "List", "<", "String", ">", "listAllCommands", "(", "String", "applicationName", ")", "{", "this", ".", "logger", ".", "finer", "(", "\"Listing commands in \"", "+", "applicationName", "+", "\"...\"", ")", ";", "WebResource", "path", "=", "this", "."...
Lists application commands. @param applicationName an application name @return a non-null list of command names
[ "Lists", "application", "commands", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/ApplicationWsDelegate.java#L400-L419
train
roboconf/roboconf-platform
core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java
Agent.findPlugin
public PluginInterface findPlugin( Instance instance ) { // Find a plug-in PluginInterface result = null; if( this.simulatePlugins ) { this.logger.finer( "Simulating plugins..." ); result = new PluginMock(); } else { String installerName = null; if( instance.getComponent() != null ) installerName = ComponentHelpers.findComponentInstaller( instance.getComponent()); // Run through available plug-ins for( PluginInterface pi : this.plugins ) { if( pi.getPluginName().equalsIgnoreCase( installerName )) { result = pi; break; } } if( result == null ) this.logger.severe( "No plugin was found for instance '" + instance.getName() + "' with installer '" + installerName + "'." ); } // Initialize the result, if any if( result != null ) result.setNames( this.applicationName, this.scopedInstancePath ); return result == null ? null : new PluginProxy( result ); }
java
public PluginInterface findPlugin( Instance instance ) { // Find a plug-in PluginInterface result = null; if( this.simulatePlugins ) { this.logger.finer( "Simulating plugins..." ); result = new PluginMock(); } else { String installerName = null; if( instance.getComponent() != null ) installerName = ComponentHelpers.findComponentInstaller( instance.getComponent()); // Run through available plug-ins for( PluginInterface pi : this.plugins ) { if( pi.getPluginName().equalsIgnoreCase( installerName )) { result = pi; break; } } if( result == null ) this.logger.severe( "No plugin was found for instance '" + instance.getName() + "' with installer '" + installerName + "'." ); } // Initialize the result, if any if( result != null ) result.setNames( this.applicationName, this.scopedInstancePath ); return result == null ? null : new PluginProxy( result ); }
[ "public", "PluginInterface", "findPlugin", "(", "Instance", "instance", ")", "{", "// Find a plug-in", "PluginInterface", "result", "=", "null", ";", "if", "(", "this", ".", "simulatePlugins", ")", "{", "this", ".", "logger", ".", "finer", "(", "\"Simulating plu...
Finds the right plug-in for an instance. @param instance a non-null instance @return the plug-in associated with the instance's installer name
[ "Finds", "the", "right", "plug", "-", "in", "for", "an", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java#L213-L243
train
roboconf/roboconf-platform
core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java
Agent.listPlugins
public void listPlugins() { if( this.plugins.isEmpty()) { this.logger.info( "No plug-in was found for Roboconf's agent." ); } else { StringBuilder sb = new StringBuilder( "Available plug-ins in Roboconf's agent: " ); for( Iterator<PluginInterface> it = this.plugins.iterator(); it.hasNext(); ) { sb.append( it.next().getPluginName()); if( it.hasNext()) sb.append( ", " ); } sb.append( "." ); this.logger.info( sb.toString()); } }
java
public void listPlugins() { if( this.plugins.isEmpty()) { this.logger.info( "No plug-in was found for Roboconf's agent." ); } else { StringBuilder sb = new StringBuilder( "Available plug-ins in Roboconf's agent: " ); for( Iterator<PluginInterface> it = this.plugins.iterator(); it.hasNext(); ) { sb.append( it.next().getPluginName()); if( it.hasNext()) sb.append( ", " ); } sb.append( "." ); this.logger.info( sb.toString()); } }
[ "public", "void", "listPlugins", "(", ")", "{", "if", "(", "this", ".", "plugins", ".", "isEmpty", "(", ")", ")", "{", "this", ".", "logger", ".", "info", "(", "\"No plug-in was found for Roboconf's agent.\"", ")", ";", "}", "else", "{", "StringBuilder", "...
This method lists the available plug-ins and logs it.
[ "This", "method", "lists", "the", "available", "plug", "-", "ins", "and", "logs", "it", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java#L249-L265
train
roboconf/roboconf-platform
core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java
Agent.pluginAppears
public void pluginAppears( PluginInterface pi ) { if( pi != null ) { this.logger.info( "Plugin '" + pi.getPluginName() + "' is now available in Roboconf's agent." ); this.plugins.add( pi ); listPlugins(); } }
java
public void pluginAppears( PluginInterface pi ) { if( pi != null ) { this.logger.info( "Plugin '" + pi.getPluginName() + "' is now available in Roboconf's agent." ); this.plugins.add( pi ); listPlugins(); } }
[ "public", "void", "pluginAppears", "(", "PluginInterface", "pi", ")", "{", "if", "(", "pi", "!=", "null", ")", "{", "this", ".", "logger", ".", "info", "(", "\"Plugin '\"", "+", "pi", ".", "getPluginName", "(", ")", "+", "\"' is now available in Roboconf's a...
This method is invoked by iPojo every time a new plug-in appears. @param pi the appearing plugin.
[ "This", "method", "is", "invoked", "by", "iPojo", "every", "time", "a", "new", "plug", "-", "in", "appears", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java#L272-L278
train
roboconf/roboconf-platform
core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java
Agent.pluginDisappears
public void pluginDisappears( PluginInterface pi ) { // May happen if a plug-in could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( pi == null ) { this.logger.info( "An invalid plugin is removed." ); } else { this.plugins.remove( pi ); this.logger.info( "Plugin '" + pi.getPluginName() + "' is not available anymore in Roboconf's agent." ); } listPlugins(); }
java
public void pluginDisappears( PluginInterface pi ) { // May happen if a plug-in could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( pi == null ) { this.logger.info( "An invalid plugin is removed." ); } else { this.plugins.remove( pi ); this.logger.info( "Plugin '" + pi.getPluginName() + "' is not available anymore in Roboconf's agent." ); } listPlugins(); }
[ "public", "void", "pluginDisappears", "(", "PluginInterface", "pi", ")", "{", "// May happen if a plug-in could not be instantiated", "// (iPojo uses proxies). In this case, it results in a NPE here.", "if", "(", "pi", "==", "null", ")", "{", "this", ".", "logger", ".", "in...
This method is invoked by iPojo every time a plug-in disappears. @param pi the disappearing plugin.
[ "This", "method", "is", "invoked", "by", "iPojo", "every", "time", "a", "plug", "-", "in", "disappears", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java#L285-L297
train
roboconf/roboconf-platform
core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java
Agent.reloadUserData
void reloadUserData() { if( Utils.isEmptyOrWhitespaces( this.parameters )) { this.logger.warning( "No parameters were specified in the agent configuration. No user data will be retrieved." ); } else if( ! this.overrideProperties ) { this.logger.fine( "User data are NOT supposed to be used." ); } else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )) { if( getMessagingClient() != null && getMessagingClient().getMessageProcessor() != null ) ((AgentMessageProcessor) getMessagingClient().getMessageProcessor()).resetRequest(); } else { // Retrieve the agent's configuration AgentProperties props = null; this.logger.fine( "User data are supposed to be used. Retrieving in progress..." ); if( AgentConstants.PLATFORM_EC2.equalsIgnoreCase( this.parameters ) || AgentConstants.PLATFORM_OPENSTACK.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForAmazonOrOpenStack( this.logger ); else if( AgentConstants.PLATFORM_AZURE.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForAzure( this.logger ); else if( AgentConstants.PLATFORM_VMWARE.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForVmware( this.logger ); else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )) props = new AgentProperties(); else props = this.userDataHelper.findParametersFromUrl( this.parameters, this.logger ); // If there was a configuration... if( props != null ) { // Error messages do not matter when we reset an agent String errorMessage = null; if( ! Constants.AGENT_RESET.equalsIgnoreCase( this.parameters ) && (errorMessage = props.validate()) != null ) { this.logger.severe( "An error was found in user data. " + errorMessage ); } this.applicationName = props.getApplicationName(); this.domain = props.getDomain(); this.scopedInstancePath = props.getScopedInstancePath(); if( ! Utils.isEmptyOrWhitespaces( props.getIpAddress())) { this.ipAddress = props.getIpAddress(); this.logger.info( "The agent's address was overwritten from user data and set to " + this.ipAddress ); } try { this.logger.info( "Reconfiguring the agent with user data." ); this.userDataHelper.reconfigureMessaging( this.karafEtc, props.getMessagingConfiguration()); } catch( Exception e ) { this.logger.severe("Error in messaging reconfiguration from user data: " + e); } } } }
java
void reloadUserData() { if( Utils.isEmptyOrWhitespaces( this.parameters )) { this.logger.warning( "No parameters were specified in the agent configuration. No user data will be retrieved." ); } else if( ! this.overrideProperties ) { this.logger.fine( "User data are NOT supposed to be used." ); } else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )) { if( getMessagingClient() != null && getMessagingClient().getMessageProcessor() != null ) ((AgentMessageProcessor) getMessagingClient().getMessageProcessor()).resetRequest(); } else { // Retrieve the agent's configuration AgentProperties props = null; this.logger.fine( "User data are supposed to be used. Retrieving in progress..." ); if( AgentConstants.PLATFORM_EC2.equalsIgnoreCase( this.parameters ) || AgentConstants.PLATFORM_OPENSTACK.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForAmazonOrOpenStack( this.logger ); else if( AgentConstants.PLATFORM_AZURE.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForAzure( this.logger ); else if( AgentConstants.PLATFORM_VMWARE.equalsIgnoreCase( this.parameters )) props = this.userDataHelper.findParametersForVmware( this.logger ); else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )) props = new AgentProperties(); else props = this.userDataHelper.findParametersFromUrl( this.parameters, this.logger ); // If there was a configuration... if( props != null ) { // Error messages do not matter when we reset an agent String errorMessage = null; if( ! Constants.AGENT_RESET.equalsIgnoreCase( this.parameters ) && (errorMessage = props.validate()) != null ) { this.logger.severe( "An error was found in user data. " + errorMessage ); } this.applicationName = props.getApplicationName(); this.domain = props.getDomain(); this.scopedInstancePath = props.getScopedInstancePath(); if( ! Utils.isEmptyOrWhitespaces( props.getIpAddress())) { this.ipAddress = props.getIpAddress(); this.logger.info( "The agent's address was overwritten from user data and set to " + this.ipAddress ); } try { this.logger.info( "Reconfiguring the agent with user data." ); this.userDataHelper.reconfigureMessaging( this.karafEtc, props.getMessagingConfiguration()); } catch( Exception e ) { this.logger.severe("Error in messaging reconfiguration from user data: " + e); } } } }
[ "void", "reloadUserData", "(", ")", "{", "if", "(", "Utils", ".", "isEmptyOrWhitespaces", "(", "this", ".", "parameters", ")", ")", "{", "this", ".", "logger", ".", "warning", "(", "\"No parameters were specified in the agent configuration. No user data will be retrieve...
Reloads user data.
[ "Reloads", "user", "data", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/Agent.java#L367-L430
train
stephanrauh/AngularFaces
AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGDefaultSecurityFilter.java
NGDefaultSecurityFilter.checkParameter
@Override public boolean checkParameter(String key, String value) { if (null == value) { return true; } value = value.toLowerCase(); if (value.contains("'")) { return false; } if (value.contains("--")) { return false; } if (value.contains("drop ")) { return false; } if (value.contains("insert ")) { return false; } if (value.contains("select ")) { return false; } if (value.contains("delete ")) { return false; } if (value.contains("<")) { return false; } if (value.contains(">")) { return false; } return true; }
java
@Override public boolean checkParameter(String key, String value) { if (null == value) { return true; } value = value.toLowerCase(); if (value.contains("'")) { return false; } if (value.contains("--")) { return false; } if (value.contains("drop ")) { return false; } if (value.contains("insert ")) { return false; } if (value.contains("select ")) { return false; } if (value.contains("delete ")) { return false; } if (value.contains("<")) { return false; } if (value.contains(">")) { return false; } return true; }
[ "@", "Override", "public", "boolean", "checkParameter", "(", "String", "key", ",", "String", "value", ")", "{", "if", "(", "null", "==", "value", ")", "{", "return", "true", ";", "}", "value", "=", "value", ".", "toLowerCase", "(", ")", ";", "if", "(...
returns true if the parameter seems to be ok.
[ "returns", "true", "if", "the", "parameter", "seems", "to", "be", "ok", "." ]
43d915f004645b1bbbf2625214294dab0858ba01
https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGDefaultSecurityFilter.java#L35-L68
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java
SchedulerWsDelegate.createOrUpdateJob
public String createOrUpdateJob( String jobId, String jobName, String appName, String cmdName, String cron ) throws SchedulerWsException { if( jobId == null ) this.logger.finer( "Creating a new scheduled job." ); else this.logger.finer( "Updating the following scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ); if( jobId != null ) path = path.queryParam( "job-id", jobId ); path = path.queryParam( "job-name", jobName ); path = path.queryParam( "app-name", appName ); path = path.queryParam( "cmd-name", cmdName ); path = path.queryParam( "cron", cron ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); StringWrapper wrapper = response.getEntity( StringWrapper.class ); return wrapper.toString(); }
java
public String createOrUpdateJob( String jobId, String jobName, String appName, String cmdName, String cron ) throws SchedulerWsException { if( jobId == null ) this.logger.finer( "Creating a new scheduled job." ); else this.logger.finer( "Updating the following scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ); if( jobId != null ) path = path.queryParam( "job-id", jobId ); path = path.queryParam( "job-name", jobName ); path = path.queryParam( "app-name", appName ); path = path.queryParam( "cmd-name", cmdName ); path = path.queryParam( "cron", cron ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .post( ClientResponse.class ); handleResponse( response ); StringWrapper wrapper = response.getEntity( StringWrapper.class ); return wrapper.toString(); }
[ "public", "String", "createOrUpdateJob", "(", "String", "jobId", ",", "String", "jobName", ",", "String", "appName", ",", "String", "cmdName", ",", "String", "cron", ")", "throws", "SchedulerWsException", "{", "if", "(", "jobId", "==", "null", ")", "this", "...
Creates or updates a scheduled job. @param jobId the job's ID (null to create a new job) @param jobName the job's name @param appName the application's name @param cmdName the name of the commands file to execute @param cron the CRON expression to trigger the job @return the created (or updated) job @throws SchedulerWsException if the creation or the update failed
[ "Creates", "or", "updates", "a", "scheduled", "job", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java#L131-L155
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java
SchedulerWsDelegate.deleteJob
public void deleteJob( String jobId ) throws SchedulerWsException { this.logger.finer( "Deleting scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .delete( ClientResponse.class ); handleResponse( response ); }
java
public void deleteJob( String jobId ) throws SchedulerWsException { this.logger.finer( "Deleting scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .delete( ClientResponse.class ); handleResponse( response ); }
[ "public", "void", "deleteJob", "(", "String", "jobId", ")", "throws", "SchedulerWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Deleting scheduled job: \"", "+", "jobId", ")", ";", "WebResource", "path", "=", "this", ".", "resource", ".", "path...
Deletes a scheduled job. @param jobId the job's ID @throws SchedulerWsException if the deletion failed
[ "Deletes", "a", "scheduled", "job", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java#L163-L173
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java
SchedulerWsDelegate.getJobProperties
public ScheduledJob getJobProperties( String jobId ) throws SchedulerWsException { this.logger.finer( "Getting the properties of a scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( ClientResponse.class ); handleResponse( response ); return response.getEntity( ScheduledJob.class ); }
java
public ScheduledJob getJobProperties( String jobId ) throws SchedulerWsException { this.logger.finer( "Getting the properties of a scheduled job: " + jobId ); WebResource path = this.resource.path( UrlConstants.SCHEDULER ).path( jobId ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( ClientResponse.class ); handleResponse( response ); return response.getEntity( ScheduledJob.class ); }
[ "public", "ScheduledJob", "getJobProperties", "(", "String", "jobId", ")", "throws", "SchedulerWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Getting the properties of a scheduled job: \"", "+", "jobId", ")", ";", "WebResource", "path", "=", "this", ...
Gets the properties of a scheduled job. @param jobId the job's ID @throws SchedulerWsException if the retrieving failed
[ "Gets", "the", "properties", "of", "a", "scheduled", "job", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/SchedulerWsDelegate.java#L181-L192
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ProcessStore.java
ProcessStore.getProcess
public static synchronized Process getProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.get(toAgentId(applicationName, scopedInstancePath)); }
java
public static synchronized Process getProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.get(toAgentId(applicationName, scopedInstancePath)); }
[ "public", "static", "synchronized", "Process", "getProcess", "(", "String", "applicationName", ",", "String", "scopedInstancePath", ")", "{", "return", "PROCESS_MAP", ".", "get", "(", "toAgentId", "(", "applicationName", ",", "scopedInstancePath", ")", ")", ";", "...
Retrieves a stored process, when found. @return The process
[ "Retrieves", "a", "stored", "process", "when", "found", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ProcessStore.java#L54-L56
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ProcessStore.java
ProcessStore.clearProcess
public static synchronized Process clearProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.remove(toAgentId(applicationName, scopedInstancePath)); }
java
public static synchronized Process clearProcess(String applicationName, String scopedInstancePath) { return PROCESS_MAP.remove(toAgentId(applicationName, scopedInstancePath)); }
[ "public", "static", "synchronized", "Process", "clearProcess", "(", "String", "applicationName", ",", "String", "scopedInstancePath", ")", "{", "return", "PROCESS_MAP", ".", "remove", "(", "toAgentId", "(", "applicationName", ",", "scopedInstancePath", ")", ")", ";"...
Removes a stored process, if found.
[ "Removes", "a", "stored", "process", "if", "found", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ProcessStore.java#L62-L64
train
stephanrauh/AngularFaces
AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/AttributeUtilities.java
AttributeUtilities.getAttribute
public static Object getAttribute(UIComponent component, String attributeName) { Object value = component.getPassThroughAttributes().get(attributeName); if (null == value) { value = component.getAttributes().get(attributeName); } if (null == value) { if (!attributeName.equals(attributeName.toLowerCase())) { return getAttribute(component, attributeName.toLowerCase()); } } if (value instanceof ValueExpression) { value = ((ValueExpression) value).getValue(FacesContext.getCurrentInstance().getELContext()); } return value; }
java
public static Object getAttribute(UIComponent component, String attributeName) { Object value = component.getPassThroughAttributes().get(attributeName); if (null == value) { value = component.getAttributes().get(attributeName); } if (null == value) { if (!attributeName.equals(attributeName.toLowerCase())) { return getAttribute(component, attributeName.toLowerCase()); } } if (value instanceof ValueExpression) { value = ((ValueExpression) value).getValue(FacesContext.getCurrentInstance().getELContext()); } return value; }
[ "public", "static", "Object", "getAttribute", "(", "UIComponent", "component", ",", "String", "attributeName", ")", "{", "Object", "value", "=", "component", ".", "getPassThroughAttributes", "(", ")", ".", "get", "(", "attributeName", ")", ";", "if", "(", "nul...
Apache MyFaces make HMTL attributes of HTML elements pass-through-attributes. This method finds the attribute, no matter whether it is stored as an ordinary or as an pass-through-attribute.
[ "Apache", "MyFaces", "make", "HMTL", "attributes", "of", "HTML", "elements", "pass", "-", "through", "-", "attributes", ".", "This", "method", "finds", "the", "attribute", "no", "matter", "whether", "it", "is", "stored", "as", "an", "ordinary", "or", "as", ...
43d915f004645b1bbbf2625214294dab0858ba01
https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/AttributeUtilities.java#L37-L51
train
stephanrauh/AngularFaces
AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/AttributeUtilities.java
AttributeUtilities.getAttributeAsString
public static String getAttributeAsString(UIComponent component, String attributeName) { try { Object attribute = getAttribute(component, attributeName); if (null != attribute) { if (attribute instanceof ValueExpression) { return (String) ((ValueExpression) attribute) .getValue(FacesContext.getCurrentInstance().getELContext()); } else if (attribute instanceof String) { return (String) attribute; } else { LOGGER.severe("unexpected data type of label: " + attributeName + " type:" + attribute.getClass().getName()); return "unexpected data type of label: " + attributeName + " type:" + attribute.getClass().getName(); } } if (null == attribute) { ValueExpression vex = component.getValueExpression(attributeName); if (null != vex) { return (String) vex.getValue(FacesContext.getCurrentInstance().getELContext()); } } } catch (ClassCastException error) { LOGGER.fine("Attribute is not a String: " + attributeName); } return null; }
java
public static String getAttributeAsString(UIComponent component, String attributeName) { try { Object attribute = getAttribute(component, attributeName); if (null != attribute) { if (attribute instanceof ValueExpression) { return (String) ((ValueExpression) attribute) .getValue(FacesContext.getCurrentInstance().getELContext()); } else if (attribute instanceof String) { return (String) attribute; } else { LOGGER.severe("unexpected data type of label: " + attributeName + " type:" + attribute.getClass().getName()); return "unexpected data type of label: " + attributeName + " type:" + attribute.getClass().getName(); } } if (null == attribute) { ValueExpression vex = component.getValueExpression(attributeName); if (null != vex) { return (String) vex.getValue(FacesContext.getCurrentInstance().getELContext()); } } } catch (ClassCastException error) { LOGGER.fine("Attribute is not a String: " + attributeName); } return null; }
[ "public", "static", "String", "getAttributeAsString", "(", "UIComponent", "component", ",", "String", "attributeName", ")", "{", "try", "{", "Object", "attribute", "=", "getAttribute", "(", "component", ",", "attributeName", ")", ";", "if", "(", "null", "!=", ...
Apache MyFaces sometimes returns a ValueExpression when you read an attribute. Mojarra does not, but requires a second call. The method treats both frameworks in a uniform way and evaluates the expression, if needed, returning a String value.
[ "Apache", "MyFaces", "sometimes", "returns", "a", "ValueExpression", "when", "you", "read", "an", "attribute", ".", "Mojarra", "does", "not", "but", "requires", "a", "second", "call", ".", "The", "method", "treats", "both", "frameworks", "in", "a", "uniform", ...
43d915f004645b1bbbf2625214294dab0858ba01
https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/AngularFaces-core/src/main/java/de/beyondjava/angularFaces/core/transformation/AttributeUtilities.java#L60-L86
train
roboconf/roboconf-platform
core/roboconf-plugin-script/src/main/java/net/roboconf/plugin/script/internal/PluginScript.java
PluginScript.generateTemplate
protected File generateTemplate(File template, Instance instance) throws IOException { String scriptName = instance.getName().replace( "\\s+", "_" ); File generated = File.createTempFile( scriptName, ".script"); InstanceTemplateHelper.injectInstanceImports(instance, template, generated); return generated; }
java
protected File generateTemplate(File template, Instance instance) throws IOException { String scriptName = instance.getName().replace( "\\s+", "_" ); File generated = File.createTempFile( scriptName, ".script"); InstanceTemplateHelper.injectInstanceImports(instance, template, generated); return generated; }
[ "protected", "File", "generateTemplate", "(", "File", "template", ",", "Instance", "instance", ")", "throws", "IOException", "{", "String", "scriptName", "=", "instance", ".", "getName", "(", ")", ".", "replace", "(", "\"\\\\s+\"", ",", "\"_\"", ")", ";", "F...
Generates a file from the template and the instance. @param template @param instance @return the generated file @throws IOException
[ "Generates", "a", "file", "from", "the", "template", "and", "the", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-script/src/main/java/net/roboconf/plugin/script/internal/PluginScript.java#L215-L222
train
roboconf/roboconf-platform
miscellaneous/roboconf-maven-plugin/src/main/java/net/roboconf/maven/MavenPluginUtils.java
MavenPluginUtils.formatErrors
public static StringBuilder formatErrors( Collection<? extends RoboconfError> errors, Log log ) { StringBuilder result = new StringBuilder(); for( Map.Entry<RoboconfError,String> entry : RoboconfErrorHelpers.formatErrors( errors, null, true ).entrySet()) { if( entry.getKey().getErrorCode().getLevel() == ErrorLevel.WARNING ) log.warn( entry.getValue()); else log.error( entry.getValue()); result.append( entry.getValue()); result.append( "\n" ); } return result; }
java
public static StringBuilder formatErrors( Collection<? extends RoboconfError> errors, Log log ) { StringBuilder result = new StringBuilder(); for( Map.Entry<RoboconfError,String> entry : RoboconfErrorHelpers.formatErrors( errors, null, true ).entrySet()) { if( entry.getKey().getErrorCode().getLevel() == ErrorLevel.WARNING ) log.warn( entry.getValue()); else log.error( entry.getValue()); result.append( entry.getValue()); result.append( "\n" ); } return result; }
[ "public", "static", "StringBuilder", "formatErrors", "(", "Collection", "<", "?", "extends", "RoboconfError", ">", "errors", ",", "Log", "log", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", ...
Formats a Roboconf errors and outputs it in the logs. @param error an error @param log the Maven logger @return a string builder with the output
[ "Formats", "a", "Roboconf", "errors", "and", "outputs", "it", "in", "the", "logs", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-maven-plugin/src/main/java/net/roboconf/maven/MavenPluginUtils.java#L56-L70
train
stephanrauh/AngularFaces
AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGSecureRenderer.java
NGSecureRenderer.encodeBegin
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { long timer = System.nanoTime(); long random = (long) (Math.random() * Integer.MAX_VALUE); long token = timer ^ random; NGSecureUtilities.setSecurityToken(String.valueOf(token), component.getClientId()); super.encodeBegin(context, component); NGSecurityFilter filter = findAndVerifySecurityFilter(context, component); showLegalDisclaimer(context, filter); }
java
@Override public void encodeBegin(FacesContext context, UIComponent component) throws IOException { long timer = System.nanoTime(); long random = (long) (Math.random() * Integer.MAX_VALUE); long token = timer ^ random; NGSecureUtilities.setSecurityToken(String.valueOf(token), component.getClientId()); super.encodeBegin(context, component); NGSecurityFilter filter = findAndVerifySecurityFilter(context, component); showLegalDisclaimer(context, filter); }
[ "@", "Override", "public", "void", "encodeBegin", "(", "FacesContext", "context", ",", "UIComponent", "component", ")", "throws", "IOException", "{", "long", "timer", "=", "System", ".", "nanoTime", "(", ")", ";", "long", "random", "=", "(", "long", ")", "...
Stores a unique token in the session to prevent repeated submission of the same form.
[ "Stores", "a", "unique", "token", "in", "the", "session", "to", "prevent", "repeated", "submission", "of", "the", "same", "form", "." ]
43d915f004645b1bbbf2625214294dab0858ba01
https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGSecureRenderer.java#L54-L64
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.createDockerClient
public static DockerClient createDockerClient( Map<String,String> targetProperties ) throws TargetException { // Validate what needs to be validated. Logger logger = Logger.getLogger( DockerHandler.class.getName()); logger.fine( "Setting the target properties." ); String edpt = targetProperties.get( DockerHandler.ENDPOINT ); if( Utils.isEmptyOrWhitespaces( edpt )) edpt = DockerHandler.DEFAULT_ENDPOINT; // The configuration is straight-forward. Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost( edpt ) .withRegistryUsername( targetProperties.get( DockerHandler.USER )) .withRegistryPassword( targetProperties.get( DockerHandler.PASSWORD )) .withRegistryEmail( targetProperties.get( DockerHandler.EMAIL )) .withApiVersion( targetProperties.get( DockerHandler.VERSION )); // Build the client. DockerClientBuilder clientBuilder = DockerClientBuilder.getInstance( config.build()); return clientBuilder.build(); }
java
public static DockerClient createDockerClient( Map<String,String> targetProperties ) throws TargetException { // Validate what needs to be validated. Logger logger = Logger.getLogger( DockerHandler.class.getName()); logger.fine( "Setting the target properties." ); String edpt = targetProperties.get( DockerHandler.ENDPOINT ); if( Utils.isEmptyOrWhitespaces( edpt )) edpt = DockerHandler.DEFAULT_ENDPOINT; // The configuration is straight-forward. Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost( edpt ) .withRegistryUsername( targetProperties.get( DockerHandler.USER )) .withRegistryPassword( targetProperties.get( DockerHandler.PASSWORD )) .withRegistryEmail( targetProperties.get( DockerHandler.EMAIL )) .withApiVersion( targetProperties.get( DockerHandler.VERSION )); // Build the client. DockerClientBuilder clientBuilder = DockerClientBuilder.getInstance( config.build()); return clientBuilder.build(); }
[ "public", "static", "DockerClient", "createDockerClient", "(", "Map", "<", "String", ",", "String", ">", "targetProperties", ")", "throws", "TargetException", "{", "// Validate what needs to be validated.", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "Do...
Creates a Docker client from target properties. @param targetProperties a non-null map @return a Docker client @throws TargetException if something went wrong
[ "Creates", "a", "Docker", "client", "from", "target", "properties", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L71-L94
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.deleteImageIfItExists
public static void deleteImageIfItExists( String imageId, DockerClient dockerClient ) { if( imageId != null ) { List<Image> images = dockerClient.listImagesCmd().exec(); if( findImageById( imageId, images ) != null ) dockerClient.removeImageCmd( imageId ).withForce( true ).exec(); } }
java
public static void deleteImageIfItExists( String imageId, DockerClient dockerClient ) { if( imageId != null ) { List<Image> images = dockerClient.listImagesCmd().exec(); if( findImageById( imageId, images ) != null ) dockerClient.removeImageCmd( imageId ).withForce( true ).exec(); } }
[ "public", "static", "void", "deleteImageIfItExists", "(", "String", "imageId", ",", "DockerClient", "dockerClient", ")", "{", "if", "(", "imageId", "!=", "null", ")", "{", "List", "<", "Image", ">", "images", "=", "dockerClient", ".", "listImagesCmd", "(", "...
Deletes a Docker image if it exists. @param imageId the image ID (not null) @param dockerClient a Docker client
[ "Deletes", "a", "Docker", "image", "if", "it", "exists", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L102-L109
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.findImageByIdOrByTag
public static Image findImageByIdOrByTag( String name, DockerClient dockerClient ) { Image image = null; if( ! Utils.isEmptyOrWhitespaces( name )) { Logger logger = Logger.getLogger( DockerUtils.class.getName()); List<Image> images = dockerClient.listImagesCmd().exec(); if(( image = DockerUtils.findImageById( name, images )) != null ) logger.fine( "Found a Docker image with ID " + name ); else if(( image = DockerUtils.findImageByTag( name, images )) != null ) logger.fine( "Found a Docker image with tag " + name ); } return image; }
java
public static Image findImageByIdOrByTag( String name, DockerClient dockerClient ) { Image image = null; if( ! Utils.isEmptyOrWhitespaces( name )) { Logger logger = Logger.getLogger( DockerUtils.class.getName()); List<Image> images = dockerClient.listImagesCmd().exec(); if(( image = DockerUtils.findImageById( name, images )) != null ) logger.fine( "Found a Docker image with ID " + name ); else if(( image = DockerUtils.findImageByTag( name, images )) != null ) logger.fine( "Found a Docker image with tag " + name ); } return image; }
[ "public", "static", "Image", "findImageByIdOrByTag", "(", "String", "name", ",", "DockerClient", "dockerClient", ")", "{", "Image", "image", "=", "null", ";", "if", "(", "!", "Utils", ".", "isEmptyOrWhitespaces", "(", "name", ")", ")", "{", "Logger", "logger...
Finds an image by ID or by tag. @param name an image ID or a tag name (can be null) @param dockerClient a Docker client (not null) @return an image, or null if none matched
[ "Finds", "an", "image", "by", "ID", "or", "by", "tag", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L118-L132
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.findImageById
public static Image findImageById( String imageId, List<Image> images ) { Image result = null; for( Image img : images ) { if( img.getId().equals(imageId)) { result = img; break; } } return result; }
java
public static Image findImageById( String imageId, List<Image> images ) { Image result = null; for( Image img : images ) { if( img.getId().equals(imageId)) { result = img; break; } } return result; }
[ "public", "static", "Image", "findImageById", "(", "String", "imageId", ",", "List", "<", "Image", ">", "images", ")", "{", "Image", "result", "=", "null", ";", "for", "(", "Image", "img", ":", "images", ")", "{", "if", "(", "img", ".", "getId", "(",...
Finds an image by ID. @param imageId the image ID (not null) @param images a non-null list of images @return an image, or null if none was found
[ "Finds", "an", "image", "by", "ID", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L141-L152
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.findImageByTag
public static Image findImageByTag( String imageTag, List<Image> images ) { Image result = null; for( Image img : images ) { String[] tags = img.getRepoTags(); if( tags == null ) continue; for( String s : tags ) { if( s.contains( imageTag )) { result = img; break; } } } return result; }
java
public static Image findImageByTag( String imageTag, List<Image> images ) { Image result = null; for( Image img : images ) { String[] tags = img.getRepoTags(); if( tags == null ) continue; for( String s : tags ) { if( s.contains( imageTag )) { result = img; break; } } } return result; }
[ "public", "static", "Image", "findImageByTag", "(", "String", "imageTag", ",", "List", "<", "Image", ">", "images", ")", "{", "Image", "result", "=", "null", ";", "for", "(", "Image", "img", ":", "images", ")", "{", "String", "[", "]", "tags", "=", "...
Finds an image by tag. @param imageTag the image tag (not null) @param images a non-null list of images @return an image, or null if none was found
[ "Finds", "an", "image", "by", "tag", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L161-L178
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.findContainerByIdOrByName
public static Container findContainerByIdOrByName( String name, DockerClient dockerClient ) { Container result = null; List<Container> containers = dockerClient.listContainersCmd().withShowAll( true ).exec(); for( Container container : containers ) { List<String> names = Arrays.asList( container.getNames()); // Docker containers are prefixed with '/'. // At least, those we created, since their parent is the Docker daemon. if( container.getId().equals( name ) || names.contains( "/" + name )) { result = container; break; } } return result; }
java
public static Container findContainerByIdOrByName( String name, DockerClient dockerClient ) { Container result = null; List<Container> containers = dockerClient.listContainersCmd().withShowAll( true ).exec(); for( Container container : containers ) { List<String> names = Arrays.asList( container.getNames()); // Docker containers are prefixed with '/'. // At least, those we created, since their parent is the Docker daemon. if( container.getId().equals( name ) || names.contains( "/" + name )) { result = container; break; } } return result; }
[ "public", "static", "Container", "findContainerByIdOrByName", "(", "String", "name", ",", "DockerClient", "dockerClient", ")", "{", "Container", "result", "=", "null", ";", "List", "<", "Container", ">", "containers", "=", "dockerClient", ".", "listContainersCmd", ...
Finds a container by ID or by name. @param name the container ID or name (not null) @param dockerClient a Docker client @return a container, or null if none was found
[ "Finds", "a", "container", "by", "ID", "or", "by", "name", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L187-L204
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.getContainerState
public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) { ContainerState result = null; try { InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec(); if( resp != null ) result = resp.getState(); } catch( Exception e ) { // nothing } return result; }
java
public static ContainerState getContainerState( String containerId, DockerClient dockerClient ) { ContainerState result = null; try { InspectContainerResponse resp = dockerClient.inspectContainerCmd( containerId ).exec(); if( resp != null ) result = resp.getState(); } catch( Exception e ) { // nothing } return result; }
[ "public", "static", "ContainerState", "getContainerState", "(", "String", "containerId", ",", "DockerClient", "dockerClient", ")", "{", "ContainerState", "result", "=", "null", ";", "try", "{", "InspectContainerResponse", "resp", "=", "dockerClient", ".", "inspectCont...
Gets the state of a container. @param containerId the container ID @param dockerClient the Docker client @return a container state, or null if the container was not found
[ "Gets", "the", "state", "of", "a", "container", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L213-L226
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.configureOptions
public static void configureOptions( Map<String,String> options, CreateContainerCmd cmd ) throws TargetException { Logger logger = Logger.getLogger( DockerUtils.class.getName()); // Basically, we had two choices: // 1. Map our properties to the Java REST API. // 2. By-pass it and send our custom JSon object. // // The second option is much more complicated. // So, we use Java reflection and some hacks to match Docker properties // with the setter methods available in the API. The API remains in charge // of generating the right JSon objects. Map<String,List<String>> hackedSetterNames = new HashMap<> (); // List known types List<Class<?>> types = new ArrayList<> (); types.add( String.class ); types.add( String[].class ); types.add( long.class ); types.add( Long.class ); types.add( int.class ); types.add( Integer.class ); types.add( boolean.class ); types.add( Boolean.class ); types.add( Capability[].class ); // Deal with the options for( Map.Entry<String,String> entry : options.entrySet()) { String optionValue = entry.getValue(); // Now, guess what option to set String methodName = entry.getKey().replace( "-", " " ).trim(); methodName = WordUtils.capitalize( methodName ); methodName = methodName.replace( " ", "" ); methodName = "with" + methodName; Method _m = null; for( Method m : cmd.getClass().getMethods()) { boolean sameMethod = methodName.equalsIgnoreCase( m.getName()); boolean methodWithAlias = hackedSetterNames.containsKey( methodName ) && hackedSetterNames.get( methodName ).contains( m.getName()); if( sameMethod || methodWithAlias ) { // Only one parameter? if( m.getParameterTypes().length != 1 ) { logger.warning( "A method was found for " + entry.getKey() + " but it does not have the right number of parameters." ); continue; } // The right type? if( ! types.contains( m.getParameterTypes()[ 0 ])) { // Since Docker-java 3.x, there are two methods to set cap-add and cap-drop. // One takes an array as parameter, the other takes a list. logger.warning( "A method was found for " + entry.getKey() + " but it does not have the right parameter type. " + "Skipping it. You may want to add a feature request." ); continue; } // That's probably the right one. _m = m; break; } } // Handle errors if( _m == null ) throw new TargetException( "Nothing matched the " + entry.getKey() + " option in the REST API. Please, report it." ); // Try to set the option in the REST client try { Object o = prepareParameter( optionValue, _m.getParameterTypes()[ 0 ]); _m.invoke( cmd, o ); } catch( ReflectiveOperationException | IllegalArgumentException e ) { throw new TargetException( "Option " + entry.getKey() + " could not be set." ); } } }
java
public static void configureOptions( Map<String,String> options, CreateContainerCmd cmd ) throws TargetException { Logger logger = Logger.getLogger( DockerUtils.class.getName()); // Basically, we had two choices: // 1. Map our properties to the Java REST API. // 2. By-pass it and send our custom JSon object. // // The second option is much more complicated. // So, we use Java reflection and some hacks to match Docker properties // with the setter methods available in the API. The API remains in charge // of generating the right JSon objects. Map<String,List<String>> hackedSetterNames = new HashMap<> (); // List known types List<Class<?>> types = new ArrayList<> (); types.add( String.class ); types.add( String[].class ); types.add( long.class ); types.add( Long.class ); types.add( int.class ); types.add( Integer.class ); types.add( boolean.class ); types.add( Boolean.class ); types.add( Capability[].class ); // Deal with the options for( Map.Entry<String,String> entry : options.entrySet()) { String optionValue = entry.getValue(); // Now, guess what option to set String methodName = entry.getKey().replace( "-", " " ).trim(); methodName = WordUtils.capitalize( methodName ); methodName = methodName.replace( " ", "" ); methodName = "with" + methodName; Method _m = null; for( Method m : cmd.getClass().getMethods()) { boolean sameMethod = methodName.equalsIgnoreCase( m.getName()); boolean methodWithAlias = hackedSetterNames.containsKey( methodName ) && hackedSetterNames.get( methodName ).contains( m.getName()); if( sameMethod || methodWithAlias ) { // Only one parameter? if( m.getParameterTypes().length != 1 ) { logger.warning( "A method was found for " + entry.getKey() + " but it does not have the right number of parameters." ); continue; } // The right type? if( ! types.contains( m.getParameterTypes()[ 0 ])) { // Since Docker-java 3.x, there are two methods to set cap-add and cap-drop. // One takes an array as parameter, the other takes a list. logger.warning( "A method was found for " + entry.getKey() + " but it does not have the right parameter type. " + "Skipping it. You may want to add a feature request." ); continue; } // That's probably the right one. _m = m; break; } } // Handle errors if( _m == null ) throw new TargetException( "Nothing matched the " + entry.getKey() + " option in the REST API. Please, report it." ); // Try to set the option in the REST client try { Object o = prepareParameter( optionValue, _m.getParameterTypes()[ 0 ]); _m.invoke( cmd, o ); } catch( ReflectiveOperationException | IllegalArgumentException e ) { throw new TargetException( "Option " + entry.getKey() + " could not be set." ); } } }
[ "public", "static", "void", "configureOptions", "(", "Map", "<", "String", ",", "String", ">", "options", ",", "CreateContainerCmd", "cmd", ")", "throws", "TargetException", "{", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "DockerUtils", ".", "cl...
Finds the options and tries to configure them on the creation command. @param options the options (key = name, value = option value) @param cmd a non-null command to create a container @throws TargetException
[ "Finds", "the", "options", "and", "tries", "to", "configure", "them", "on", "the", "creation", "command", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L235-L318
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.prepareParameter
public static Object prepareParameter( String rawValue, Class<?> clazz ) throws TargetException { // Simple types Object result; if( clazz == int.class || clazz == Integer.class ) result = Integer.parseInt( rawValue ); else if( clazz == long.class || clazz == Long.class ) result = Long.parseLong( rawValue ); else if( clazz == boolean.class || clazz == Boolean.class ) result = Boolean.parseBoolean( rawValue ); // Arrays of string else if( clazz == String[].class ) { List<String> parts = Utils.splitNicely( rawValue, "," ); result = parts.toArray( new String[ parts.size()]); } // Capabilities else if( clazz == Capability[].class ) { List<Capability> caps = new ArrayList<> (); for( String s : Utils.splitNicely( rawValue, "," )) { try { caps.add( Capability.valueOf( s )); } catch( Exception e ) { throw new TargetException( "Unknown capability: " + s ); } } result = caps.toArray( new Capability[ caps.size()]); } // Default: keep the string else result = rawValue; return result; }
java
public static Object prepareParameter( String rawValue, Class<?> clazz ) throws TargetException { // Simple types Object result; if( clazz == int.class || clazz == Integer.class ) result = Integer.parseInt( rawValue ); else if( clazz == long.class || clazz == Long.class ) result = Long.parseLong( rawValue ); else if( clazz == boolean.class || clazz == Boolean.class ) result = Boolean.parseBoolean( rawValue ); // Arrays of string else if( clazz == String[].class ) { List<String> parts = Utils.splitNicely( rawValue, "," ); result = parts.toArray( new String[ parts.size()]); } // Capabilities else if( clazz == Capability[].class ) { List<Capability> caps = new ArrayList<> (); for( String s : Utils.splitNicely( rawValue, "," )) { try { caps.add( Capability.valueOf( s )); } catch( Exception e ) { throw new TargetException( "Unknown capability: " + s ); } } result = caps.toArray( new Capability[ caps.size()]); } // Default: keep the string else result = rawValue; return result; }
[ "public", "static", "Object", "prepareParameter", "(", "String", "rawValue", ",", "Class", "<", "?", ">", "clazz", ")", "throws", "TargetException", "{", "// Simple types", "Object", "result", ";", "if", "(", "clazz", "==", "int", ".", "class", "||", "clazz"...
Prepares the parameter to pass it to the REST API. @param rawValue the raw value, as a string @param clazz the class associated with the input parameter @return the object, converted to the right class @throws TargetException
[ "Prepares", "the", "parameter", "to", "pass", "it", "to", "the", "REST", "API", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L328-L364
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.findDefaultImageVersion
public static String findDefaultImageVersion( String rawVersion ) { String rbcfVersion = rawVersion; if( rbcfVersion == null || rbcfVersion.toLowerCase().endsWith( "snapshot" )) rbcfVersion = LATEST; return rbcfVersion; }
java
public static String findDefaultImageVersion( String rawVersion ) { String rbcfVersion = rawVersion; if( rbcfVersion == null || rbcfVersion.toLowerCase().endsWith( "snapshot" )) rbcfVersion = LATEST; return rbcfVersion; }
[ "public", "static", "String", "findDefaultImageVersion", "(", "String", "rawVersion", ")", "{", "String", "rbcfVersion", "=", "rawVersion", ";", "if", "(", "rbcfVersion", "==", "null", "||", "rbcfVersion", ".", "toLowerCase", "(", ")", ".", "endsWith", "(", "\...
Finds the version of the default Docker image. @param rawVersion the raw version (e.g. ManifestUtils.findBundleVersion()) @return {@value #LATEST} if the raw version is null or a snapshot, a specific version otherwise
[ "Finds", "the", "version", "of", "the", "default", "Docker", "image", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L393-L401
train
roboconf/roboconf-platform
core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java
DockerUtils.buildContainerNameFrom
public static String buildContainerNameFrom( String scopedInstancePath, String applicationName ) { String containerName = scopedInstancePath + "_from_" + applicationName; containerName = containerName.replaceFirst( "^/", "" ).replace( "/", "-" ).replaceAll( "\\s+", "_" ); // Prevent container names from being too long (see #480) if( containerName.length() > 61 ) containerName = containerName.substring( 0, 61 ); return containerName; }
java
public static String buildContainerNameFrom( String scopedInstancePath, String applicationName ) { String containerName = scopedInstancePath + "_from_" + applicationName; containerName = containerName.replaceFirst( "^/", "" ).replace( "/", "-" ).replaceAll( "\\s+", "_" ); // Prevent container names from being too long (see #480) if( containerName.length() > 61 ) containerName = containerName.substring( 0, 61 ); return containerName; }
[ "public", "static", "String", "buildContainerNameFrom", "(", "String", "scopedInstancePath", ",", "String", "applicationName", ")", "{", "String", "containerName", "=", "scopedInstancePath", "+", "\"_from_\"", "+", "applicationName", ";", "containerName", "=", "containe...
Builds a container name. @param scopedInstancePath a scoped instance path @param applicationName an application name @return a non-null string
[ "Builds", "a", "container", "name", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-target-docker/src/main/java/net/roboconf/target/docker/internal/DockerUtils.java#L410-L420
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/dsl/converters/FromInstances.java
FromInstances.buildFileDefinition
public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }
java
public FileDefinition buildFileDefinition( Collection<Instance> rootInstances, File targetFile, boolean addComment, boolean saveRuntimeInformation ) { FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.INSTANCE ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } for( Instance rootInstance : rootInstances ) result.getBlocks().addAll( buildInstanceOf( result, rootInstance, addComment, saveRuntimeInformation )); return result; }
[ "public", "FileDefinition", "buildFileDefinition", "(", "Collection", "<", "Instance", ">", "rootInstances", ",", "File", "targetFile", ",", "boolean", "addComment", ",", "boolean", "saveRuntimeInformation", ")", "{", "FileDefinition", "result", "=", "new", "FileDefin...
Builds a file definition from a collection of instances. @param rootInstances the root instances (not null) @param targetFile the target file (will not be written) @param addComment true to insert generated comments @param saveRuntimeInformation true to save runtime information (such as IP...), false otherwise @return a non-null file definition
[ "Builds", "a", "file", "definition", "from", "a", "collection", "of", "instances", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/dsl/converters/FromInstances.java#L60-L75
train
roboconf/roboconf-platform
core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java
PluginFile.readProperties
Properties readProperties( Instance instance ) throws PluginException { Properties result = null; File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File file = new File( instanceDirectory, FILE_NAME ); try { if( file.exists()) { result = Utils.readPropertiesFile( file ); } else { this.logger.warning( file + " does not exist or is invalid. There is no instruction for the plugin." ); result = new Properties(); } } catch( IOException e ) { throw new PluginException( e ); } return result; }
java
Properties readProperties( Instance instance ) throws PluginException { Properties result = null; File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File file = new File( instanceDirectory, FILE_NAME ); try { if( file.exists()) { result = Utils.readPropertiesFile( file ); } else { this.logger.warning( file + " does not exist or is invalid. There is no instruction for the plugin." ); result = new Properties(); } } catch( IOException e ) { throw new PluginException( e ); } return result; }
[ "Properties", "readProperties", "(", "Instance", "instance", ")", "throws", "PluginException", "{", "Properties", "result", "=", "null", ";", "File", "instanceDirectory", "=", "InstanceHelpers", ".", "findInstanceDirectoryOnAgent", "(", "instance", ")", ";", "File", ...
Reads the "instructions.properties" file. @param instance the instance @return a non-null properties object (potentially empty) @throws PluginException
[ "Reads", "the", "instructions", ".", "properties", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java#L139-L159
train
roboconf/roboconf-platform
core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java
PluginFile.findActions
SortedSet<Action> findActions( String actionName, Properties properties ) { Pattern pattern = Pattern.compile( actionName + "\\.(\\d)+\\.(.*)", Pattern.CASE_INSENSITIVE ); SortedSet<Action> result = new TreeSet<Action>( new ActionComparator()); for( Map.Entry<Object,Object> entry : properties.entrySet()) { String key = String.valueOf( entry.getKey()).toLowerCase(); Matcher m = pattern.matcher( key ); if( ! m.matches()) continue; int position = Integer.parseInt( m.group( 1 )); ActionType actionType = ActionType.which( m.group( 2 )); String parameter = String.valueOf( entry.getValue()); result.add( new Action( position, actionType, parameter )); } return result; }
java
SortedSet<Action> findActions( String actionName, Properties properties ) { Pattern pattern = Pattern.compile( actionName + "\\.(\\d)+\\.(.*)", Pattern.CASE_INSENSITIVE ); SortedSet<Action> result = new TreeSet<Action>( new ActionComparator()); for( Map.Entry<Object,Object> entry : properties.entrySet()) { String key = String.valueOf( entry.getKey()).toLowerCase(); Matcher m = pattern.matcher( key ); if( ! m.matches()) continue; int position = Integer.parseInt( m.group( 1 )); ActionType actionType = ActionType.which( m.group( 2 )); String parameter = String.valueOf( entry.getValue()); result.add( new Action( position, actionType, parameter )); } return result; }
[ "SortedSet", "<", "Action", ">", "findActions", "(", "String", "actionName", ",", "Properties", "properties", ")", "{", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "actionName", "+", "\"\\\\.(\\\\d)+\\\\.(.*)\"", ",", "Pattern", ".", "CASE_INSENSITI...
Finds the actions to execute for a given step. @return a non-null list of actions (sorted in the right execution order)
[ "Finds", "the", "actions", "to", "execute", "for", "a", "given", "step", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java#L166-L183
train
roboconf/roboconf-platform
core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java
PluginFile.executeAction
void executeAction( Action action ) throws PluginException { try { switch( action.actionType ) { case DELETE: this.logger.fine( "Deleting " + action.parameter + "..." ); File f = new File( action.parameter ); Utils.deleteFilesRecursively( f ); break; case DOWNLOAD: this.logger.fine( "Downloading " + action.parameter + "..." ); URI uri = UriUtils.urlToUri( action.parameter ); File targetFile = new File( System.getProperty( "java.io.tmpdir" ), TMP_FILE ); InputStream in = null; try { in = uri.toURL().openStream(); Utils.copyStream( in, targetFile ); } finally { Utils.closeQuietly( in ); } break; case MOVE: List<String> parts = Utils.splitNicely( action.parameter, "->" ); if( parts.size() != 2 ) { this.logger.warning( "Invalid syntax for 'move' action. " + action.parameter ); } else { File source = new File( parts.get( 0 )); File target = new File( parts.get( 1 )); this.logger.fine( "Moving " + source + " to " + target + "..." ); if( ! source.renameTo( target )) throw new IOException( source + " could not be moved to " + target ); } break; case COPY: parts = Utils.splitNicely( action.parameter, "->" ); if( parts.size() != 2 ) { this.logger.warning( "Invalid syntax for 'copy' action. " + action.parameter ); } else { File source = new File( parts.get( 0 )); File target = new File( parts.get( 1 )); this.logger.fine( "Copying " + source + " to " + target + "..." ); Utils.copyStream( source, target ); } break; default: this.logger.fine( "Ignoring the action..." ); break; } } catch( Exception e ) { throw new PluginException( e ); } }
java
void executeAction( Action action ) throws PluginException { try { switch( action.actionType ) { case DELETE: this.logger.fine( "Deleting " + action.parameter + "..." ); File f = new File( action.parameter ); Utils.deleteFilesRecursively( f ); break; case DOWNLOAD: this.logger.fine( "Downloading " + action.parameter + "..." ); URI uri = UriUtils.urlToUri( action.parameter ); File targetFile = new File( System.getProperty( "java.io.tmpdir" ), TMP_FILE ); InputStream in = null; try { in = uri.toURL().openStream(); Utils.copyStream( in, targetFile ); } finally { Utils.closeQuietly( in ); } break; case MOVE: List<String> parts = Utils.splitNicely( action.parameter, "->" ); if( parts.size() != 2 ) { this.logger.warning( "Invalid syntax for 'move' action. " + action.parameter ); } else { File source = new File( parts.get( 0 )); File target = new File( parts.get( 1 )); this.logger.fine( "Moving " + source + " to " + target + "..." ); if( ! source.renameTo( target )) throw new IOException( source + " could not be moved to " + target ); } break; case COPY: parts = Utils.splitNicely( action.parameter, "->" ); if( parts.size() != 2 ) { this.logger.warning( "Invalid syntax for 'copy' action. " + action.parameter ); } else { File source = new File( parts.get( 0 )); File target = new File( parts.get( 1 )); this.logger.fine( "Copying " + source + " to " + target + "..." ); Utils.copyStream( source, target ); } break; default: this.logger.fine( "Ignoring the action..." ); break; } } catch( Exception e ) { throw new PluginException( e ); } }
[ "void", "executeAction", "(", "Action", "action", ")", "throws", "PluginException", "{", "try", "{", "switch", "(", "action", ".", "actionType", ")", "{", "case", "DELETE", ":", "this", ".", "logger", ".", "fine", "(", "\"Deleting \"", "+", "action", ".", ...
Executes an action. @param action the action to execute @throws PluginException
[ "Executes", "an", "action", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-file/src/main/java/net/roboconf/plugin/file/internal/PluginFile.java#L191-L251
train
roboconf/roboconf-platform
core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/websocket/WebSocketHandler.java
WebSocketHandler.send
private void send( String message ) { if( ! this.enabled.get()) { this.logger.finest( "Notifications were disabled by the DM." ); } else if( message == null ) { this.logger.finest( "No message to send to web socket clients." ); } else synchronized( SESSIONS ) { for( Session session : SESSIONS ) { try { this.logger.finest( "Sending a message to a web socket client..." ); session.getRemote().sendString( message ); } catch( IOException e ) { StringBuilder sb = new StringBuilder( "A notification could not be propagated for session " ); sb.append( session.getRemoteAddress()); sb.append( "." ); if( ! Utils.isEmptyOrWhitespaces( e.getMessage())) sb.append( " " + e.getMessage()); this.logger.severe( sb.toString()); Utils.logException( this.logger, e ); } } } }
java
private void send( String message ) { if( ! this.enabled.get()) { this.logger.finest( "Notifications were disabled by the DM." ); } else if( message == null ) { this.logger.finest( "No message to send to web socket clients." ); } else synchronized( SESSIONS ) { for( Session session : SESSIONS ) { try { this.logger.finest( "Sending a message to a web socket client..." ); session.getRemote().sendString( message ); } catch( IOException e ) { StringBuilder sb = new StringBuilder( "A notification could not be propagated for session " ); sb.append( session.getRemoteAddress()); sb.append( "." ); if( ! Utils.isEmptyOrWhitespaces( e.getMessage())) sb.append( " " + e.getMessage()); this.logger.severe( sb.toString()); Utils.logException( this.logger, e ); } } } }
[ "private", "void", "send", "(", "String", "message", ")", "{", "if", "(", "!", "this", ".", "enabled", ".", "get", "(", ")", ")", "{", "this", ".", "logger", ".", "finest", "(", "\"Notifications were disabled by the DM.\"", ")", ";", "}", "else", "if", ...
Sends a message to all the connected sessions. @param message the message to send
[ "Sends", "a", "message", "to", "all", "the", "connected", "sessions", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-rest-services/src/main/java/net/roboconf/dm/rest/services/internal/websocket/WebSocketHandler.java#L175-L201
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/AuthenticationWsDelegate.java
AuthenticationWsDelegate.login
public String login( String username, String password ) throws DebugWsException { this.logger.finer( "Logging in as " + username ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "e" ); ClientResponse response = path .header( "u", username ) .header( "p", password ) .post( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } // Get the session ID from the cookie that should have been returned String sessionId = null; List<NewCookie> cookies = response.getCookies(); if( cookies != null ) { for( NewCookie cookie : cookies ) { if( UrlConstants.SESSION_ID.equals( cookie.getName())) { sessionId = cookie.getValue(); break; } } } // Set the session ID this.wsClient.setSessionId( sessionId ); this.logger.finer( "Session ID: " + sessionId ); return sessionId; }
java
public String login( String username, String password ) throws DebugWsException { this.logger.finer( "Logging in as " + username ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "e" ); ClientResponse response = path .header( "u", username ) .header( "p", password ) .post( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } // Get the session ID from the cookie that should have been returned String sessionId = null; List<NewCookie> cookies = response.getCookies(); if( cookies != null ) { for( NewCookie cookie : cookies ) { if( UrlConstants.SESSION_ID.equals( cookie.getName())) { sessionId = cookie.getValue(); break; } } } // Set the session ID this.wsClient.setSessionId( sessionId ); this.logger.finer( "Session ID: " + sessionId ); return sessionId; }
[ "public", "String", "login", "(", "String", "username", ",", "String", "password", ")", "throws", "DebugWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Logging in as \"", "+", "username", ")", ";", "WebResource", "path", "=", "this", ".", "re...
Logs in with a user name and a password. @param username a user name @param password a password @return a session ID, or null if login failed @throws DebugWsException
[ "Logs", "in", "with", "a", "user", "name", "and", "a", "password", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/AuthenticationWsDelegate.java#L70-L102
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/AuthenticationWsDelegate.java
AuthenticationWsDelegate.logout
public void logout( String sessionId ) throws DebugWsException { this.logger.finer( "Logging out... Session ID = " + sessionId ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "s" ); ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class ); this.logger.finer( String.valueOf( response.getStatusInfo())); this.wsClient.setSessionId( null ); }
java
public void logout( String sessionId ) throws DebugWsException { this.logger.finer( "Logging out... Session ID = " + sessionId ); WebResource path = this.resource.path( UrlConstants.AUTHENTICATION ).path( "s" ); ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class ); this.logger.finer( String.valueOf( response.getStatusInfo())); this.wsClient.setSessionId( null ); }
[ "public", "void", "logout", "(", "String", "sessionId", ")", "throws", "DebugWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Logging out... Session ID = \"", "+", "sessionId", ")", ";", "WebResource", "path", "=", "this", ".", "resource", ".", ...
Terminates a session. @param sessionId a session ID @throws DebugWsException
[ "Terminates", "a", "session", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/AuthenticationWsDelegate.java#L110-L117
train
roboconf/roboconf-platform
karaf/roboconf-karaf-commands-agent/src/main/java/net/roboconf/karaf/commands/agent/plugins/CancelRecipeCommand.java
CancelRecipeCommand.cancelRecipe
private void cancelRecipe(String applicationName, String scopedInstancePath) { if(Utils.isEmptyOrWhitespaces(applicationName)) applicationName = ""; if(Utils.isEmptyOrWhitespaces(scopedInstancePath)) scopedInstancePath = ""; this.out.println("looking up [" + applicationName + "] [" + scopedInstancePath + "]"); Process p = ProcessStore.getProcess(applicationName, scopedInstancePath); if(p != null) { p.destroy(); ProcessStore.clearProcess(applicationName, scopedInstancePath); this.out.println("Recipe cancelled !"); } else { this.out.println("No running recipe to cancel."); } }
java
private void cancelRecipe(String applicationName, String scopedInstancePath) { if(Utils.isEmptyOrWhitespaces(applicationName)) applicationName = ""; if(Utils.isEmptyOrWhitespaces(scopedInstancePath)) scopedInstancePath = ""; this.out.println("looking up [" + applicationName + "] [" + scopedInstancePath + "]"); Process p = ProcessStore.getProcess(applicationName, scopedInstancePath); if(p != null) { p.destroy(); ProcessStore.clearProcess(applicationName, scopedInstancePath); this.out.println("Recipe cancelled !"); } else { this.out.println("No running recipe to cancel."); } }
[ "private", "void", "cancelRecipe", "(", "String", "applicationName", ",", "String", "scopedInstancePath", ")", "{", "if", "(", "Utils", ".", "isEmptyOrWhitespaces", "(", "applicationName", ")", ")", "applicationName", "=", "\"\"", ";", "if", "(", "Utils", ".", ...
Cancels running recipe, if any.
[ "Cancels", "running", "recipe", "if", "any", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/karaf/roboconf-karaf-commands-agent/src/main/java/net/roboconf/karaf/commands/agent/plugins/CancelRecipeCommand.java#L108-L121
train
roboconf/roboconf-platform
core/roboconf-agent-monitoring/src/main/java/net/roboconf/agent/monitoring/internal/rest/RestHandler.java
RestHandler.httpsQuery
private String httpsQuery() { String response = null; try { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new LocalX509TrustManager()}; // Install the all-trusting trust manager final SSLContext sc = SSLContext.getInstance("SSL"); sc.init( null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory()); // Create all-trusting host name verifier HostnameVerifier allHostsValid = new LocalHostnameVerifier(); HttpsURLConnection.setDefaultHostnameVerifier( allHostsValid ); URL restUrl = new URL( this.url ); HttpsURLConnection conn = (HttpsURLConnection) restUrl.openConnection(); response = query( conn ); } catch( Exception e ) { this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." ); Utils.logException(this.logger, e); } return response; }
java
private String httpsQuery() { String response = null; try { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new LocalX509TrustManager()}; // Install the all-trusting trust manager final SSLContext sc = SSLContext.getInstance("SSL"); sc.init( null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory()); // Create all-trusting host name verifier HostnameVerifier allHostsValid = new LocalHostnameVerifier(); HttpsURLConnection.setDefaultHostnameVerifier( allHostsValid ); URL restUrl = new URL( this.url ); HttpsURLConnection conn = (HttpsURLConnection) restUrl.openConnection(); response = query( conn ); } catch( Exception e ) { this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." ); Utils.logException(this.logger, e); } return response; }
[ "private", "String", "httpsQuery", "(", ")", "{", "String", "response", "=", "null", ";", "try", "{", "// Create a trust manager that does not validate certificate chains", "TrustManager", "[", "]", "trustAllCerts", "=", "new", "TrustManager", "[", "]", "{", "new", ...
Query a https URL, ignoring certificates. @return The query response
[ "Query", "a", "https", "URL", "ignoring", "certificates", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent-monitoring/src/main/java/net/roboconf/agent/monitoring/internal/rest/RestHandler.java#L179-L205
train
roboconf/roboconf-platform
core/roboconf-agent-monitoring/src/main/java/net/roboconf/agent/monitoring/internal/rest/RestHandler.java
RestHandler.httpQuery
private String httpQuery() { String response = null; try { URL restUrl = new URL( this.url ); HttpURLConnection conn = (HttpURLConnection) restUrl.openConnection(); response = query( conn ); } catch( Exception e ) { this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." ); Utils.logException(this.logger, e); } return response; }
java
private String httpQuery() { String response = null; try { URL restUrl = new URL( this.url ); HttpURLConnection conn = (HttpURLConnection) restUrl.openConnection(); response = query( conn ); } catch( Exception e ) { this.logger.severe( "Cannot issue GET on URL " + this.url + ". Monitoring notification is discarded." ); Utils.logException(this.logger, e); } return response; }
[ "private", "String", "httpQuery", "(", ")", "{", "String", "response", "=", "null", ";", "try", "{", "URL", "restUrl", "=", "new", "URL", "(", "this", ".", "url", ")", ";", "HttpURLConnection", "conn", "=", "(", "HttpURLConnection", ")", "restUrl", ".", ...
Query a http URL. @return The query response
[ "Query", "a", "http", "URL", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-agent-monitoring/src/main/java/net/roboconf/agent/monitoring/internal/rest/RestHandler.java#L211-L225
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.findGraphFilesToImport
public static Set<String> findGraphFilesToImport( File appDirectory, File editedFile, String fileContent ) { File graphDir = new File( appDirectory, Constants.PROJECT_DIR_GRAPH ); return findFilesToImport( graphDir, Constants.FILE_EXT_GRAPH, editedFile, fileContent ); }
java
public static Set<String> findGraphFilesToImport( File appDirectory, File editedFile, String fileContent ) { File graphDir = new File( appDirectory, Constants.PROJECT_DIR_GRAPH ); return findFilesToImport( graphDir, Constants.FILE_EXT_GRAPH, editedFile, fileContent ); }
[ "public", "static", "Set", "<", "String", ">", "findGraphFilesToImport", "(", "File", "appDirectory", ",", "File", "editedFile", ",", "String", "fileContent", ")", "{", "File", "graphDir", "=", "new", "File", "(", "appDirectory", ",", "Constants", ".", "PROJEC...
Finds all the graph files that can be imported. @param appDirectory the application's directory @param editedFile the graph file that is being edited @param fileContent the file content (not null) @return a non-null set of (relative) file paths
[ "Finds", "all", "the", "graph", "files", "that", "can", "be", "imported", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L76-L80
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.findInstancesFilesToImport
public static Set<String> findInstancesFilesToImport( File appDirectory, File editedFile, String fileContent ) { File instancesDir = new File( appDirectory, Constants.PROJECT_DIR_INSTANCES ); return findFilesToImport( instancesDir, Constants.FILE_EXT_INSTANCES, editedFile, fileContent ); }
java
public static Set<String> findInstancesFilesToImport( File appDirectory, File editedFile, String fileContent ) { File instancesDir = new File( appDirectory, Constants.PROJECT_DIR_INSTANCES ); return findFilesToImport( instancesDir, Constants.FILE_EXT_INSTANCES, editedFile, fileContent ); }
[ "public", "static", "Set", "<", "String", ">", "findInstancesFilesToImport", "(", "File", "appDirectory", ",", "File", "editedFile", ",", "String", "fileContent", ")", "{", "File", "instancesDir", "=", "new", "File", "(", "appDirectory", ",", "Constants", ".", ...
Finds all the instances files that can be imported. @param appDirectory the application's directory @param editedFile the graph file that is being edited @param fileContent the file content (not null) @return a non-null set of (relative) file paths
[ "Finds", "all", "the", "instances", "files", "that", "can", "be", "imported", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L90-L94
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.findFilesToImport
static Set<String> findFilesToImport( File searchDirectory, String fileExtension, File editedFile, String fileContent ) { // Find all the files Set<String> result = new TreeSet<> (); if( searchDirectory.exists()) { for( File f : Utils.listAllFiles( searchDirectory, fileExtension )) { if( f.equals( editedFile )) continue; String path = Utils.computeFileRelativeLocation( searchDirectory, f ); result.add( path ); } } // Remove those that are already imported Pattern importPattern = Pattern.compile( "\\b" + ParsingConstants.KEYWORD_IMPORT + "\\s+(.*)", Pattern.CASE_INSENSITIVE ); Matcher m = importPattern.matcher( fileContent ); while( m.find()) { String imp = m.group( 1 ).trim(); if( imp.endsWith( ";" )) imp = imp.substring( 0, imp.length() - 1 ); result.remove( imp.trim()); } return result; }
java
static Set<String> findFilesToImport( File searchDirectory, String fileExtension, File editedFile, String fileContent ) { // Find all the files Set<String> result = new TreeSet<> (); if( searchDirectory.exists()) { for( File f : Utils.listAllFiles( searchDirectory, fileExtension )) { if( f.equals( editedFile )) continue; String path = Utils.computeFileRelativeLocation( searchDirectory, f ); result.add( path ); } } // Remove those that are already imported Pattern importPattern = Pattern.compile( "\\b" + ParsingConstants.KEYWORD_IMPORT + "\\s+(.*)", Pattern.CASE_INSENSITIVE ); Matcher m = importPattern.matcher( fileContent ); while( m.find()) { String imp = m.group( 1 ).trim(); if( imp.endsWith( ";" )) imp = imp.substring( 0, imp.length() - 1 ); result.remove( imp.trim()); } return result; }
[ "static", "Set", "<", "String", ">", "findFilesToImport", "(", "File", "searchDirectory", ",", "String", "fileExtension", ",", "File", "editedFile", ",", "String", "fileContent", ")", "{", "// Find all the files", "Set", "<", "String", ">", "result", "=", "new",...
Finds all the files that can be imported. @param searchDirectory the search's directory @param fileExtension the file extension to search for @param editedFile the graph file that is being edited @param fileContent the file content (not null) @return a non-null set of (relative) file paths
[ "Finds", "all", "the", "files", "that", "can", "be", "imported", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L105-L136
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.basicProposal
public static RoboconfCompletionProposal basicProposal( String s, String lastWord, boolean trim ) { return new RoboconfCompletionProposal( s, trim ? s.trim() : s, null, lastWord.length()); }
java
public static RoboconfCompletionProposal basicProposal( String s, String lastWord, boolean trim ) { return new RoboconfCompletionProposal( s, trim ? s.trim() : s, null, lastWord.length()); }
[ "public", "static", "RoboconfCompletionProposal", "basicProposal", "(", "String", "s", ",", "String", "lastWord", ",", "boolean", "trim", ")", "{", "return", "new", "RoboconfCompletionProposal", "(", "s", ",", "trim", "?", "s", ".", "trim", "(", ")", ":", "s...
A convenience method to shorten the creation of a basic proposal. @param s @param lastWord @param trim @return a non-null proposal
[ "A", "convenience", "method", "to", "shorten", "the", "creation", "of", "a", "basic", "proposal", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L146-L148
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.findAllTypes
public static Map<String,RoboconfTypeBean> findAllTypes( File appDirectory ) { List<File> graphFiles = new ArrayList<> (); File graphDirectory = appDirectory; if( graphDirectory != null && graphDirectory.exists()) graphFiles = Utils.listAllFiles( graphDirectory, Constants.FILE_EXT_GRAPH ); Map<String,RoboconfTypeBean> result = new HashMap<> (); for( File f : graphFiles ) { try { FromGraphDefinition converter = new FromGraphDefinition( appDirectory, true ); Graphs g = converter.buildGraphs( f ); Collection<AbstractType> types = new ArrayList<> (); types.addAll( ComponentHelpers.findAllComponents( g )); types.addAll( g.getFacetNameToFacet().values()); for( AbstractType type : types ) { RoboconfTypeBean bean = new RoboconfTypeBean( type.getName(), converter.getTypeAnnotations().get( type.getName()), type instanceof Facet ); result.put( type.getName(), bean ); for( Map.Entry<String,String> entry : ComponentHelpers.findAllExportedVariables( type ).entrySet()) { bean.exportedVariables.put( entry.getKey(), entry.getValue()); } } } catch( Exception e ) { Logger logger = Logger.getLogger( CompletionUtils.class.getName()); Utils.logException( logger, e ); } } return result; }
java
public static Map<String,RoboconfTypeBean> findAllTypes( File appDirectory ) { List<File> graphFiles = new ArrayList<> (); File graphDirectory = appDirectory; if( graphDirectory != null && graphDirectory.exists()) graphFiles = Utils.listAllFiles( graphDirectory, Constants.FILE_EXT_GRAPH ); Map<String,RoboconfTypeBean> result = new HashMap<> (); for( File f : graphFiles ) { try { FromGraphDefinition converter = new FromGraphDefinition( appDirectory, true ); Graphs g = converter.buildGraphs( f ); Collection<AbstractType> types = new ArrayList<> (); types.addAll( ComponentHelpers.findAllComponents( g )); types.addAll( g.getFacetNameToFacet().values()); for( AbstractType type : types ) { RoboconfTypeBean bean = new RoboconfTypeBean( type.getName(), converter.getTypeAnnotations().get( type.getName()), type instanceof Facet ); result.put( type.getName(), bean ); for( Map.Entry<String,String> entry : ComponentHelpers.findAllExportedVariables( type ).entrySet()) { bean.exportedVariables.put( entry.getKey(), entry.getValue()); } } } catch( Exception e ) { Logger logger = Logger.getLogger( CompletionUtils.class.getName()); Utils.logException( logger, e ); } } return result; }
[ "public", "static", "Map", "<", "String", ",", "RoboconfTypeBean", ">", "findAllTypes", "(", "File", "appDirectory", ")", "{", "List", "<", "File", ">", "graphFiles", "=", "new", "ArrayList", "<>", "(", ")", ";", "File", "graphDirectory", "=", "appDirectory"...
Finds all the Roboconf types. @param appDirectory the application's directory (can be null) @return a non-null map of types (key = type name, value = type)
[ "Finds", "all", "the", "Roboconf", "types", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L181-L218
train
roboconf/roboconf-platform
miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java
CompletionUtils.resolveStringDescription
public static String resolveStringDescription( String variableName, String defaultValue ) { String result = null; if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( variableName ) || variableName.toLowerCase().endsWith( "." + Constants.SPECIFIC_VARIABLE_IP )) result = SET_BY_ROBOCONF; else if( ! Utils.isEmptyOrWhitespaces( defaultValue )) result = DEFAULT_VALUE + defaultValue; return result; }
java
public static String resolveStringDescription( String variableName, String defaultValue ) { String result = null; if( Constants.SPECIFIC_VARIABLE_IP.equalsIgnoreCase( variableName ) || variableName.toLowerCase().endsWith( "." + Constants.SPECIFIC_VARIABLE_IP )) result = SET_BY_ROBOCONF; else if( ! Utils.isEmptyOrWhitespaces( defaultValue )) result = DEFAULT_VALUE + defaultValue; return result; }
[ "public", "static", "String", "resolveStringDescription", "(", "String", "variableName", ",", "String", "defaultValue", ")", "{", "String", "result", "=", "null", ";", "if", "(", "Constants", ".", "SPECIFIC_VARIABLE_IP", ".", "equalsIgnoreCase", "(", "variableName",...
Resolves the description to show for an exported variable. @param variableName a non-null variable name @param defaultValue the default value (can be null) @return a description (can be null)
[ "Resolves", "the", "description", "to", "show", "for", "an", "exported", "variable", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-tooling-core/src/main/java/net/roboconf/tooling/core/autocompletion/CompletionUtils.java#L263-L273
train
stephanrauh/AngularFaces
AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGSecure.java
NGSecure.getValue
@Override public Object getValue() { final List<String> tokens = NGSecureUtilities.getSecurityToken(); return tokens.get(tokens.size() - 1); }
java
@Override public Object getValue() { final List<String> tokens = NGSecureUtilities.getSecurityToken(); return tokens.get(tokens.size() - 1); }
[ "@", "Override", "public", "Object", "getValue", "(", ")", "{", "final", "List", "<", "String", ">", "tokens", "=", "NGSecureUtilities", ".", "getSecurityToken", "(", ")", ";", "return", "tokens", ".", "get", "(", "tokens", ".", "size", "(", ")", "-", ...
This components value is the security token.
[ "This", "components", "value", "is", "the", "security", "token", "." ]
43d915f004645b1bbbf2625214294dab0858ba01
https://github.com/stephanrauh/AngularFaces/blob/43d915f004645b1bbbf2625214294dab0858ba01/AngularFaces_2.0/incubator/AngularFaces-widgets/src/main/java/de/beyondjava/angularFaces/secure/NGSecure.java#L65-L69
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java
DebugWsDelegate.checkMessagingConnectionForTheDm
public String checkMessagingConnectionForTheDm( String message ) throws DebugWsException { this.logger.finer( "Checking messaging connection with the DM: message=" + message ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "check-dm" ); if( message != null ) path = path.queryParam( "message", message ); ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } this.logger.finer( String.valueOf( response.getStatusInfo())); return response.getEntity( String.class ); }
java
public String checkMessagingConnectionForTheDm( String message ) throws DebugWsException { this.logger.finer( "Checking messaging connection with the DM: message=" + message ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "check-dm" ); if( message != null ) path = path.queryParam( "message", message ); ClientResponse response = this.wsClient.createBuilder( path ).get( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } this.logger.finer( String.valueOf( response.getStatusInfo())); return response.getEntity( String.class ); }
[ "public", "String", "checkMessagingConnectionForTheDm", "(", "String", "message", ")", "throws", "DebugWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Checking messaging connection with the DM: message=\"", "+", "message", ")", ";", "WebResource", "path", ...
Checks the DM is correctly connected with the messaging server. @param message a customized message content @return the content of the response
[ "Checks", "the", "DM", "is", "correctly", "connected", "with", "the", "messaging", "server", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java#L70-L88
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java
DebugWsDelegate.diagnoseInstance
public Diagnostic diagnoseInstance( String applicationName, String instancePath ) throws DebugWsException { this.logger.finer( "Diagnosing instance " + instancePath + " in application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-instance" ); path = path.queryParam( "application-name", applicationName ); path = path.queryParam( "instance-path", instancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } this.logger.finer( String.valueOf( response.getStatusInfo())); return response.getEntity( Diagnostic.class ); }
java
public Diagnostic diagnoseInstance( String applicationName, String instancePath ) throws DebugWsException { this.logger.finer( "Diagnosing instance " + instancePath + " in application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-instance" ); path = path.queryParam( "application-name", applicationName ); path = path.queryParam( "instance-path", instancePath ); ClientResponse response = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( ClientResponse.class ); if( Family.SUCCESSFUL != response.getStatusInfo().getFamily()) { String value = response.getEntity( String.class ); this.logger.finer( response.getStatusInfo() + ": " + value ); throw new DebugWsException( response.getStatusInfo().getStatusCode(), value ); } this.logger.finer( String.valueOf( response.getStatusInfo())); return response.getEntity( Diagnostic.class ); }
[ "public", "Diagnostic", "diagnoseInstance", "(", "String", "applicationName", ",", "String", "instancePath", ")", "throws", "DebugWsException", "{", "this", ".", "logger", ".", "finer", "(", "\"Diagnosing instance \"", "+", "instancePath", "+", "\" in application \"", ...
Runs a diagnostic for a given instance. @return the instance @throws DebugWsException
[ "Runs", "a", "diagnostic", "for", "a", "given", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java#L128-L149
train
roboconf/roboconf-platform
miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java
DebugWsDelegate.diagnoseApplication
public List<Diagnostic> diagnoseApplication( String applicationName ) { this.logger.finer( "Diagnosing application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-application" ); path = path.queryParam( "application-name", applicationName ); List<Diagnostic> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Diagnostic>> () {}); if( result == null ) this.logger.finer( "No diagnostic was returned for application " + applicationName ); return result; }
java
public List<Diagnostic> diagnoseApplication( String applicationName ) { this.logger.finer( "Diagnosing application " + applicationName ); WebResource path = this.resource.path( UrlConstants.DEBUG ).path( "diagnose-application" ); path = path.queryParam( "application-name", applicationName ); List<Diagnostic> result = this.wsClient.createBuilder( path ) .accept( MediaType.APPLICATION_JSON ) .get( new GenericType<List<Diagnostic>> () {}); if( result == null ) this.logger.finer( "No diagnostic was returned for application " + applicationName ); return result; }
[ "public", "List", "<", "Diagnostic", ">", "diagnoseApplication", "(", "String", "applicationName", ")", "{", "this", ".", "logger", ".", "finer", "(", "\"Diagnosing application \"", "+", "applicationName", ")", ";", "WebResource", "path", "=", "this", ".", "reso...
Runs a diagnostic for a given application. @return the diagnostic
[ "Runs", "a", "diagnostic", "for", "a", "given", "application", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/miscellaneous/roboconf-dm-rest-client/src/main/java/net/roboconf/dm/rest/client/delegates/DebugWsDelegate.java#L156-L170
train
roboconf/roboconf-platform
core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java
TargetHandlerResolverImpl.addTargetHandler
public void addTargetHandler( TargetHandler targetItf ) { if( targetItf != null ) { this.logger.info( "Target handler '" + targetItf.getTargetId() + "' is now available in Roboconf's DM." ); synchronized( this.targetHandlers ) { this.targetHandlers.add( targetItf ); } listTargets( this.targetHandlers, this.logger ); } }
java
public void addTargetHandler( TargetHandler targetItf ) { if( targetItf != null ) { this.logger.info( "Target handler '" + targetItf.getTargetId() + "' is now available in Roboconf's DM." ); synchronized( this.targetHandlers ) { this.targetHandlers.add( targetItf ); } listTargets( this.targetHandlers, this.logger ); } }
[ "public", "void", "addTargetHandler", "(", "TargetHandler", "targetItf", ")", "{", "if", "(", "targetItf", "!=", "null", ")", "{", "this", ".", "logger", ".", "info", "(", "\"Target handler '\"", "+", "targetItf", ".", "getTargetId", "(", ")", "+", "\"' is n...
Adds a new target handler. @param targetItf a target handler
[ "Adds", "a", "new", "target", "handler", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java#L52-L63
train
roboconf/roboconf-platform
core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java
TargetHandlerResolverImpl.removeTargetHandler
public void removeTargetHandler( TargetHandler targetItf ) { // May happen if a target could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( targetItf == null ) { this.logger.info( "An invalid target handler is removed." ); } else { synchronized( this.targetHandlers ) { this.targetHandlers.remove( targetItf ); } this.logger.info( "Target handler '" + targetItf.getTargetId() + "' is not available anymore in Roboconf's DM." ); } listTargets( this.targetHandlers, this.logger ); }
java
public void removeTargetHandler( TargetHandler targetItf ) { // May happen if a target could not be instantiated // (iPojo uses proxies). In this case, it results in a NPE here. if( targetItf == null ) { this.logger.info( "An invalid target handler is removed." ); } else { synchronized( this.targetHandlers ) { this.targetHandlers.remove( targetItf ); } this.logger.info( "Target handler '" + targetItf.getTargetId() + "' is not available anymore in Roboconf's DM." ); } listTargets( this.targetHandlers, this.logger ); }
[ "public", "void", "removeTargetHandler", "(", "TargetHandler", "targetItf", ")", "{", "// May happen if a target could not be instantiated", "// (iPojo uses proxies). In this case, it results in a NPE here.", "if", "(", "targetItf", "==", "null", ")", "{", "this", ".", "logger"...
Removes a target handler. @param targetItf a target handler
[ "Removes", "a", "target", "handler", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java#L70-L86
train
roboconf/roboconf-platform
core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java
TargetHandlerResolverImpl.listTargets
public static void listTargets( List<TargetHandler> targetHandlers, Logger logger ) { if( targetHandlers.isEmpty()) { logger.info( "No target was found for Roboconf's DM." ); } else { StringBuilder sb = new StringBuilder( "Available target in Roboconf's DM: " ); for( Iterator<TargetHandler> it = targetHandlers.iterator(); it.hasNext(); ) { sb.append( it.next().getTargetId()); if( it.hasNext()) sb.append( ", " ); } sb.append( "." ); logger.info( sb.toString()); } }
java
public static void listTargets( List<TargetHandler> targetHandlers, Logger logger ) { if( targetHandlers.isEmpty()) { logger.info( "No target was found for Roboconf's DM." ); } else { StringBuilder sb = new StringBuilder( "Available target in Roboconf's DM: " ); for( Iterator<TargetHandler> it = targetHandlers.iterator(); it.hasNext(); ) { sb.append( it.next().getTargetId()); if( it.hasNext()) sb.append( ", " ); } sb.append( "." ); logger.info( sb.toString()); } }
[ "public", "static", "void", "listTargets", "(", "List", "<", "TargetHandler", ">", "targetHandlers", ",", "Logger", "logger", ")", "{", "if", "(", "targetHandlers", ".", "isEmpty", "(", ")", ")", "{", "logger", ".", "info", "(", "\"No target was found for Robo...
This method lists the available target and logs them.
[ "This", "method", "lists", "the", "available", "target", "and", "logs", "them", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm/src/main/java/net/roboconf/dm/internal/api/impl/TargetHandlerResolverImpl.java#L128-L144
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.capitalize
public static String capitalize( String s ) { String result = s; if( ! Utils.isEmptyOrWhitespaces( s )) result = Character.toUpperCase( s.charAt( 0 )) + s.substring( 1 ).toLowerCase(); return result; }
java
public static String capitalize( String s ) { String result = s; if( ! Utils.isEmptyOrWhitespaces( s )) result = Character.toUpperCase( s.charAt( 0 )) + s.substring( 1 ).toLowerCase(); return result; }
[ "public", "static", "String", "capitalize", "(", "String", "s", ")", "{", "String", "result", "=", "s", ";", "if", "(", "!", "Utils", ".", "isEmptyOrWhitespaces", "(", "s", ")", ")", "result", "=", "Character", ".", "toUpperCase", "(", "s", ".", "charA...
Capitalizes a string. @param s a string @return the capitalized string
[ "Capitalizes", "a", "string", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L100-L107
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.removeFileExtension
public static String removeFileExtension( String filename ) { String result = filename; int index = filename.lastIndexOf( '.' ); if( index != -1 ) result= filename.substring( 0, index ); return result; }
java
public static String removeFileExtension( String filename ) { String result = filename; int index = filename.lastIndexOf( '.' ); if( index != -1 ) result= filename.substring( 0, index ); return result; }
[ "public", "static", "String", "removeFileExtension", "(", "String", "filename", ")", "{", "String", "result", "=", "filename", ";", "int", "index", "=", "filename", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "!=", "-", "1", ")", "...
Removes the extension from a file name. @param filename a non-null file name @return a non-null string
[ "Removes", "the", "extension", "from", "a", "file", "name", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L115-L123
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.filterEmptyValues
public static List<String> filterEmptyValues( List<String> values ) { List<String> result = new ArrayList<> (); for( String s : values ) { if( ! Utils.isEmptyOrWhitespaces( s )) result.add( s ); } return result; }
java
public static List<String> filterEmptyValues( List<String> values ) { List<String> result = new ArrayList<> (); for( String s : values ) { if( ! Utils.isEmptyOrWhitespaces( s )) result.add( s ); } return result; }
[ "public", "static", "List", "<", "String", ">", "filterEmptyValues", "(", "List", "<", "String", ">", "values", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "s", ":", "values", ")...
Creates a new list and only keeps values that are not null or made up of white characters. @param values a non-null list of items (can contain null and "empty" values) @return a list of items (never null), with no null or "empty" values
[ "Creates", "a", "new", "list", "and", "only", "keeps", "values", "that", "are", "not", "null", "or", "made", "up", "of", "white", "characters", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L167-L176
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.format
public static String format( Collection<String> items, String separator ) { StringBuilder sb = new StringBuilder(); for( Iterator<String> it = items.iterator(); it.hasNext(); ) { sb.append( it.next()); if( it.hasNext()) sb.append( separator ); } return sb.toString(); }
java
public static String format( Collection<String> items, String separator ) { StringBuilder sb = new StringBuilder(); for( Iterator<String> it = items.iterator(); it.hasNext(); ) { sb.append( it.next()); if( it.hasNext()) sb.append( separator ); } return sb.toString(); }
[ "public", "static", "String", "format", "(", "Collection", "<", "String", ">", "items", ",", "String", "separator", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Iterator", "<", "String", ">", "it", "=", "items...
Formats a collection of elements as a string. @param items a non-null list of items @param separator a string to separate items @return a non-null string
[ "Formats", "a", "collection", "of", "elements", "as", "a", "string", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L185-L195
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.copyStream
public static void copyStream( File inputFile, File outputFile ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStream( is, outputFile ); } finally { is.close(); } }
java
public static void copyStream( File inputFile, File outputFile ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStream( is, outputFile ); } finally { is.close(); } }
[ "public", "static", "void", "copyStream", "(", "File", "inputFile", ",", "File", "outputFile", ")", "throws", "IOException", "{", "InputStream", "is", "=", "new", "FileInputStream", "(", "inputFile", ")", ";", "try", "{", "copyStream", "(", "is", ",", "outpu...
Copies the content from inputFile into outputFile. @param inputFile an input file (must be a file and exist) @param outputFile will be created if it does not exist @throws IOException if something went wrong
[ "Copies", "the", "content", "from", "inputFile", "into", "outputFile", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L371-L378
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.copyStream
public static void copyStream( File inputFile, OutputStream os ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStreamUnsafelyUseWithCaution( is, os ); } finally { is.close(); } }
java
public static void copyStream( File inputFile, OutputStream os ) throws IOException { InputStream is = new FileInputStream( inputFile ); try { copyStreamUnsafelyUseWithCaution( is, os ); } finally { is.close(); } }
[ "public", "static", "void", "copyStream", "(", "File", "inputFile", ",", "OutputStream", "os", ")", "throws", "IOException", "{", "InputStream", "is", "=", "new", "FileInputStream", "(", "inputFile", ")", ";", "try", "{", "copyStreamUnsafelyUseWithCaution", "(", ...
Copies the content from inputFile into an output stream. @param inputFile an input file (must be a file and exist) @param os the output stream @throws IOException if something went wrong
[ "Copies", "the", "content", "from", "inputFile", "into", "an", "output", "stream", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L388-L395
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.appendStringInto
public static void appendStringInto( String s, File outputFile ) throws IOException { OutputStreamWriter fw = null; try { fw = new OutputStreamWriter( new FileOutputStream( outputFile, true ), StandardCharsets.UTF_8 ); fw.append( s ); } finally { Utils.closeQuietly( fw ); } }
java
public static void appendStringInto( String s, File outputFile ) throws IOException { OutputStreamWriter fw = null; try { fw = new OutputStreamWriter( new FileOutputStream( outputFile, true ), StandardCharsets.UTF_8 ); fw.append( s ); } finally { Utils.closeQuietly( fw ); } }
[ "public", "static", "void", "appendStringInto", "(", "String", "s", ",", "File", "outputFile", ")", "throws", "IOException", "{", "OutputStreamWriter", "fw", "=", "null", ";", "try", "{", "fw", "=", "new", "OutputStreamWriter", "(", "new", "FileOutputStream", ...
Appends a string into a file. @param s the string to write (not null) @param outputFile the file to write into @throws IOException if something went wrong
[ "Appends", "a", "string", "into", "a", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L418-L428
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.readPropertiesFile
public static Properties readPropertiesFile( File file ) throws IOException { Properties result = new Properties(); InputStream in = null; try { in = new FileInputStream( file ); result.load( in ); } finally { closeQuietly( in ); } return result; }
java
public static Properties readPropertiesFile( File file ) throws IOException { Properties result = new Properties(); InputStream in = null; try { in = new FileInputStream( file ); result.load( in ); } finally { closeQuietly( in ); } return result; }
[ "public", "static", "Properties", "readPropertiesFile", "(", "File", "file", ")", "throws", "IOException", "{", "Properties", "result", "=", "new", "Properties", "(", ")", ";", "InputStream", "in", "=", "null", ";", "try", "{", "in", "=", "new", "FileInputSt...
Reads properties from a file. @param file a properties file @return a {@link Properties} instance @throws IOException if reading failed
[ "Reads", "properties", "from", "a", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L533-L546
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.readPropertiesFileQuietly
public static Properties readPropertiesFileQuietly( File file, Logger logger ) { Properties result = new Properties(); try { if( file != null && file.exists()) result = readPropertiesFile( file ); } catch( Exception e ) { logger.severe( "Properties file " + file + " could not be read." ); logException( logger, e ); } return result; }
java
public static Properties readPropertiesFileQuietly( File file, Logger logger ) { Properties result = new Properties(); try { if( file != null && file.exists()) result = readPropertiesFile( file ); } catch( Exception e ) { logger.severe( "Properties file " + file + " could not be read." ); logException( logger, e ); } return result; }
[ "public", "static", "Properties", "readPropertiesFileQuietly", "(", "File", "file", ",", "Logger", "logger", ")", "{", "Properties", "result", "=", "new", "Properties", "(", ")", ";", "try", "{", "if", "(", "file", "!=", "null", "&&", "file", ".", "exists"...
Reads properties from a file but does not throw any error in case of problem. @param file a properties file (can be null) @param logger a logger (not null) @return a {@link Properties} instance (never null)
[ "Reads", "properties", "from", "a", "file", "but", "does", "not", "throw", "any", "error", "in", "case", "of", "problem", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L555-L568
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.readPropertiesQuietly
public static Properties readPropertiesQuietly( String fileContent, Logger logger ) { Properties result = new Properties(); try { if( fileContent != null ) { InputStream in = new ByteArrayInputStream( fileContent.getBytes( StandardCharsets.UTF_8 )); result.load( in ); } } catch( Exception e ) { logger.severe( "Properties could not be read from a string." ); logException( logger, e ); } return result; }
java
public static Properties readPropertiesQuietly( String fileContent, Logger logger ) { Properties result = new Properties(); try { if( fileContent != null ) { InputStream in = new ByteArrayInputStream( fileContent.getBytes( StandardCharsets.UTF_8 )); result.load( in ); } } catch( Exception e ) { logger.severe( "Properties could not be read from a string." ); logException( logger, e ); } return result; }
[ "public", "static", "Properties", "readPropertiesQuietly", "(", "String", "fileContent", ",", "Logger", "logger", ")", "{", "Properties", "result", "=", "new", "Properties", "(", ")", ";", "try", "{", "if", "(", "fileContent", "!=", "null", ")", "{", "InputS...
Reads properties from a string. @param file a properties file @param logger a logger (not null) @return a {@link Properties} instance
[ "Reads", "properties", "from", "a", "string", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L577-L592
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.writePropertiesFile
public static void writePropertiesFile( Properties properties, File file ) throws IOException { OutputStream out = null; try { out = new FileOutputStream( file ); properties.store( out, "" ); } finally { closeQuietly( out ); } }
java
public static void writePropertiesFile( Properties properties, File file ) throws IOException { OutputStream out = null; try { out = new FileOutputStream( file ); properties.store( out, "" ); } finally { closeQuietly( out ); } }
[ "public", "static", "void", "writePropertiesFile", "(", "Properties", "properties", ",", "File", "file", ")", "throws", "IOException", "{", "OutputStream", "out", "=", "null", ";", "try", "{", "out", "=", "new", "FileOutputStream", "(", "file", ")", ";", "pr...
Writes Java properties into a file. @param properties non-null properties @param file a properties file @throws IOException if writing failed
[ "Writes", "Java", "properties", "into", "a", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L601-L611
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.cleanNameWithAccents
public static String cleanNameWithAccents( String name ) { String temp = Normalizer.normalize( name, Normalizer.Form.NFD ); Pattern pattern = Pattern.compile( "\\p{InCombiningDiacriticalMarks}+" ); return pattern.matcher( temp ).replaceAll( "" ).trim(); }
java
public static String cleanNameWithAccents( String name ) { String temp = Normalizer.normalize( name, Normalizer.Form.NFD ); Pattern pattern = Pattern.compile( "\\p{InCombiningDiacriticalMarks}+" ); return pattern.matcher( temp ).replaceAll( "" ).trim(); }
[ "public", "static", "String", "cleanNameWithAccents", "(", "String", "name", ")", "{", "String", "temp", "=", "Normalizer", ".", "normalize", "(", "name", ",", "Normalizer", ".", "Form", ".", "NFD", ")", ";", "Pattern", "pattern", "=", "Pattern", ".", "com...
Replaces all the accents in a string. @param name a non-null string @return a non-null string, with their accents replaced by their neutral equivalent
[ "Replaces", "all", "the", "accents", "in", "a", "string", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L619-L624
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.updateProperties
public static String updateProperties( String propertiesContent, Map<String,String> keyToNewValue ) { for( Map.Entry<String,String> entry : keyToNewValue.entrySet()) { propertiesContent = propertiesContent.replaceFirst( "(?mi)^\\s*" + entry.getKey() + "\\s*[:=][^\n]*$", entry.getKey() + " = " + entry.getValue()); } return propertiesContent; }
java
public static String updateProperties( String propertiesContent, Map<String,String> keyToNewValue ) { for( Map.Entry<String,String> entry : keyToNewValue.entrySet()) { propertiesContent = propertiesContent.replaceFirst( "(?mi)^\\s*" + entry.getKey() + "\\s*[:=][^\n]*$", entry.getKey() + " = " + entry.getValue()); } return propertiesContent; }
[ "public", "static", "String", "updateProperties", "(", "String", "propertiesContent", ",", "Map", "<", "String", ",", "String", ">", "keyToNewValue", ")", "{", "for", "(", "Map", ".", "Entry", "<", "String", ",", "String", ">", "entry", ":", "keyToNewValue",...
Updates string properties. @param propertiesContent the properties file as a string @param keyToNewValue the keys to update with their new values @return a non-null string
[ "Updates", "string", "properties", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L656-L665
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.listDirectories
public static List<File> listDirectories( File root ) { List<File> result = new ArrayList<> (); File[] files = root.listFiles( new DirectoryFileFilter()); if( files != null ) result.addAll( Arrays.asList( files )); Collections.sort( result, new FileNameComparator()); return result; }
java
public static List<File> listDirectories( File root ) { List<File> result = new ArrayList<> (); File[] files = root.listFiles( new DirectoryFileFilter()); if( files != null ) result.addAll( Arrays.asList( files )); Collections.sort( result, new FileNameComparator()); return result; }
[ "public", "static", "List", "<", "File", ">", "listDirectories", "(", "File", "root", ")", "{", "List", "<", "File", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "File", "[", "]", "files", "=", "root", ".", "listFiles", "(", "new", ...
Lists directories located under a given file. @param root a file @return a non-null list of directories, sorted alphabetically by file names
[ "Lists", "directories", "located", "under", "a", "given", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L794-L803
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.computeFileRelativeLocation
public static String computeFileRelativeLocation( File rootDirectory, File subFile ) { String rootPath = rootDirectory.getAbsolutePath(); String subPath = subFile.getAbsolutePath(); if( ! subPath.startsWith( rootPath )) throw new IllegalArgumentException( "The sub-file must be contained in the directory." ); if( rootDirectory.equals( subFile )) throw new IllegalArgumentException( "The sub-file must be different than the directory." ); return subPath.substring( rootPath.length() + 1 ).replace( '\\', '/' ); }
java
public static String computeFileRelativeLocation( File rootDirectory, File subFile ) { String rootPath = rootDirectory.getAbsolutePath(); String subPath = subFile.getAbsolutePath(); if( ! subPath.startsWith( rootPath )) throw new IllegalArgumentException( "The sub-file must be contained in the directory." ); if( rootDirectory.equals( subFile )) throw new IllegalArgumentException( "The sub-file must be different than the directory." ); return subPath.substring( rootPath.length() + 1 ).replace( '\\', '/' ); }
[ "public", "static", "String", "computeFileRelativeLocation", "(", "File", "rootDirectory", ",", "File", "subFile", ")", "{", "String", "rootPath", "=", "rootDirectory", ".", "getAbsolutePath", "(", ")", ";", "String", "subPath", "=", "subFile", ".", "getAbsolutePa...
Computes the relative location of a file with respect to a root directory. @param rootDirectory a directory @param subFile a file contained (directly or indirectly) in the directory @return a non-null string
[ "Computes", "the", "relative", "location", "of", "a", "file", "with", "respect", "to", "a", "root", "directory", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L899-L910
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.extractZipArchive
public static void extractZipArchive( File zipFile, File targetDirectory ) throws IOException { extractZipArchive( zipFile, targetDirectory, null, null ); }
java
public static void extractZipArchive( File zipFile, File targetDirectory ) throws IOException { extractZipArchive( zipFile, targetDirectory, null, null ); }
[ "public", "static", "void", "extractZipArchive", "(", "File", "zipFile", ",", "File", "targetDirectory", ")", "throws", "IOException", "{", "extractZipArchive", "(", "zipFile", ",", "targetDirectory", ",", "null", ",", "null", ")", ";", "}" ]
Extracts a ZIP archive in a directory. @param zipFile a ZIP file (not null, must exist) @param targetDirectory the target directory (may not exist but must be a directory) @throws IOException if something went wrong
[ "Extracts", "a", "ZIP", "archive", "in", "a", "directory", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L919-L923
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.isAncestor
public static boolean isAncestor( File ancestorCandidate, File file ) { String path = ancestorCandidate.getAbsolutePath(); if( ! path.endsWith( "/" )) path += "/"; return file.getAbsolutePath().startsWith( path ); }
java
public static boolean isAncestor( File ancestorCandidate, File file ) { String path = ancestorCandidate.getAbsolutePath(); if( ! path.endsWith( "/" )) path += "/"; return file.getAbsolutePath().startsWith( path ); }
[ "public", "static", "boolean", "isAncestor", "(", "File", "ancestorCandidate", ",", "File", "file", ")", "{", "String", "path", "=", "ancestorCandidate", ".", "getAbsolutePath", "(", ")", ";", "if", "(", "!", "path", ".", "endsWith", "(", "\"/\"", ")", ")"...
Determines whether a directory contains a given file. @param ancestorCandidate the directory @param file the file @return true if the directory directly or indirectly contains the file
[ "Determines", "whether", "a", "directory", "contains", "a", "given", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1009-L1016
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.deleteFilesRecursively
public static void deleteFilesRecursively( File... files ) throws IOException { if( files == null ) return; List<File> filesToDelete = new ArrayList<> (); filesToDelete.addAll( Arrays.asList( files )); while( ! filesToDelete.isEmpty()) { File currentFile = filesToDelete.remove( 0 ); if( currentFile == null || ! currentFile.exists()) continue; // Non-empty directory: add sub-files and reinsert the current directory after File[] subFiles = currentFile.listFiles(); if( subFiles != null && subFiles.length > 0 ) { filesToDelete.add( 0, currentFile ); filesToDelete.addAll( 0, Arrays.asList( subFiles )); } // Existing file or empty directory => delete it else if( ! currentFile.delete()) throw new IOException( currentFile.getAbsolutePath() + " could not be deleted." ); } }
java
public static void deleteFilesRecursively( File... files ) throws IOException { if( files == null ) return; List<File> filesToDelete = new ArrayList<> (); filesToDelete.addAll( Arrays.asList( files )); while( ! filesToDelete.isEmpty()) { File currentFile = filesToDelete.remove( 0 ); if( currentFile == null || ! currentFile.exists()) continue; // Non-empty directory: add sub-files and reinsert the current directory after File[] subFiles = currentFile.listFiles(); if( subFiles != null && subFiles.length > 0 ) { filesToDelete.add( 0, currentFile ); filesToDelete.addAll( 0, Arrays.asList( subFiles )); } // Existing file or empty directory => delete it else if( ! currentFile.delete()) throw new IOException( currentFile.getAbsolutePath() + " could not be deleted." ); } }
[ "public", "static", "void", "deleteFilesRecursively", "(", "File", "...", "files", ")", "throws", "IOException", "{", "if", "(", "files", "==", "null", ")", "return", ";", "List", "<", "File", ">", "filesToDelete", "=", "new", "ArrayList", "<>", "(", ")", ...
Deletes files recursively. @param files the files to delete @throws IOException if a file could not be deleted
[ "Deletes", "files", "recursively", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1024-L1048
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.deleteFilesRecursivelyAndQuietly
public static void deleteFilesRecursivelyAndQuietly( File... files ) { try { deleteFilesRecursively( files ); } catch( IOException e ) { Logger logger = Logger.getLogger( Utils.class.getName()); logException( logger, e ); } }
java
public static void deleteFilesRecursivelyAndQuietly( File... files ) { try { deleteFilesRecursively( files ); } catch( IOException e ) { Logger logger = Logger.getLogger( Utils.class.getName()); logException( logger, e ); } }
[ "public", "static", "void", "deleteFilesRecursivelyAndQuietly", "(", "File", "...", "files", ")", "{", "try", "{", "deleteFilesRecursively", "(", "files", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Logger", "logger", "=", "Logger", ".", "get...
Deletes files recursively and remains quiet even if an exception is thrown. @param files the files to delete
[ "Deletes", "files", "recursively", "and", "remains", "quiet", "even", "if", "an", "exception", "is", "thrown", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1055-L1064
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.logException
public static void logException( Logger logger, Throwable t ) { logException( logger, Level.FINEST, t ); }
java
public static void logException( Logger logger, Throwable t ) { logException( logger, Level.FINEST, t ); }
[ "public", "static", "void", "logException", "(", "Logger", "logger", ",", "Throwable", "t", ")", "{", "logException", "(", "logger", ",", "Level", ".", "FINEST", ",", "t", ")", ";", "}" ]
Logs an exception with the given logger and the FINEST level. @param logger the logger @param t an exception or a throwable
[ "Logs", "an", "exception", "with", "the", "given", "logger", "and", "the", "FINEST", "level", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1136-L1138
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.closeStatement
public static void closeStatement( PreparedStatement ps, Logger logger ) { try { if( ps != null ) ps.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeStatement( PreparedStatement ps, Logger logger ) { try { if( ps != null ) ps.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
[ "public", "static", "void", "closeStatement", "(", "PreparedStatement", "ps", ",", "Logger", "logger", ")", "{", "try", "{", "if", "(", "ps", "!=", "null", ")", "ps", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "// ...
Closes a prepared statement. @param ps @param logger
[ "Closes", "a", "prepared", "statement", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1146-L1156
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.closeStatement
public static void closeStatement( Statement st, Logger logger ) { try { if( st != null ) st.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeStatement( Statement st, Logger logger ) { try { if( st != null ) st.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
[ "public", "static", "void", "closeStatement", "(", "Statement", "st", ",", "Logger", "logger", ")", "{", "try", "{", "if", "(", "st", "!=", "null", ")", "st", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "// Not impo...
Closes a statement. @param st @param logger
[ "Closes", "a", "statement", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1164-L1174
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.closeResultSet
public static void closeResultSet( ResultSet resultSet, Logger logger ) { try { if( resultSet != null ) resultSet.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeResultSet( ResultSet resultSet, Logger logger ) { try { if( resultSet != null ) resultSet.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
[ "public", "static", "void", "closeResultSet", "(", "ResultSet", "resultSet", ",", "Logger", "logger", ")", "{", "try", "{", "if", "(", "resultSet", "!=", "null", ")", "resultSet", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", ...
Closes a result set. @param st @param logger
[ "Closes", "a", "result", "set", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1182-L1192
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.closeConnection
public static void closeConnection( Connection conn, Logger logger ) { try { if( conn != null ) conn.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
java
public static void closeConnection( Connection conn, Logger logger ) { try { if( conn != null ) conn.close(); } catch( SQLException e ) { // Not important. Utils.logException( logger, e ); } }
[ "public", "static", "void", "closeConnection", "(", "Connection", "conn", ",", "Logger", "logger", ")", "{", "try", "{", "if", "(", "conn", "!=", "null", ")", "conn", ".", "close", "(", ")", ";", "}", "catch", "(", "SQLException", "e", ")", "{", "// ...
Closes a connection to a database. @param conn @param logger
[ "Closes", "a", "connection", "to", "a", "database", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1200-L1210
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.findUrlAndPort
public static Map.Entry<String,Integer> findUrlAndPort( String url ) { Matcher m = Pattern.compile( ".*(:\\d+).*" ).matcher( url ); String portAsString = m.find() ? m.group( 1 ).substring( 1 ) : null; Integer port = portAsString == null ? - 1 : Integer.parseInt( portAsString ); String address = portAsString == null ? url : url.replace( m.group( 1 ), "" ); return new AbstractMap.SimpleEntry<>( address, port ); }
java
public static Map.Entry<String,Integer> findUrlAndPort( String url ) { Matcher m = Pattern.compile( ".*(:\\d+).*" ).matcher( url ); String portAsString = m.find() ? m.group( 1 ).substring( 1 ) : null; Integer port = portAsString == null ? - 1 : Integer.parseInt( portAsString ); String address = portAsString == null ? url : url.replace( m.group( 1 ), "" ); return new AbstractMap.SimpleEntry<>( address, port ); }
[ "public", "static", "Map", ".", "Entry", "<", "String", ",", "Integer", ">", "findUrlAndPort", "(", "String", "url", ")", "{", "Matcher", "m", "=", "Pattern", ".", "compile", "(", "\".*(:\\\\d+).*\"", ")", ".", "matcher", "(", "url", ")", ";", "String", ...
Parses a raw URL and extracts the host and port. @param url a raw URL (not null) @return a non-null map entry (key = host URL without the port, value = the port, -1 if not specified)
[ "Parses", "a", "raw", "URL", "and", "extracts", "the", "host", "and", "port", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1268-L1276
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java
Utils.getValue
public static String getValue(Map<String,String> map, String key, String defaultValue) { return map.containsKey( key ) ? map.get( key ) : defaultValue; }
java
public static String getValue(Map<String,String> map, String key, String defaultValue) { return map.containsKey( key ) ? map.get( key ) : defaultValue; }
[ "public", "static", "String", "getValue", "(", "Map", "<", "String", ",", "String", ">", "map", ",", "String", "key", ",", "String", "defaultValue", ")", "{", "return", "map", ".", "containsKey", "(", "key", ")", "?", "map", ".", "get", "(", "key", "...
Returns the value contained in a map of string if it exists using the key. @param map a map of string @param key a string @param defaultValue the default value
[ "Returns", "the", "value", "contained", "in", "a", "map", "of", "string", "if", "it", "exists", "using", "the", "key", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/Utils.java#L1285-L1287
train
roboconf/roboconf-platform
core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java
TemplateUtils.findApplicationName
public static String findApplicationName( final File templateDir, final File templateFile ) { final File parentDir = templateFile.getParentFile(); final String appName; // No intermediate directory, the template is global! if( templateDir.equals( parentDir )) appName = null; // One intermediate directory: the template is specific to one application. // The name of the application is the name of the intermediate directory. else if( templateDir.equals( parentDir.getParentFile())) appName = parentDir.getName(); // Too many levels! else throw new IllegalArgumentException( "Not a template file: " + templateFile ); return appName; }
java
public static String findApplicationName( final File templateDir, final File templateFile ) { final File parentDir = templateFile.getParentFile(); final String appName; // No intermediate directory, the template is global! if( templateDir.equals( parentDir )) appName = null; // One intermediate directory: the template is specific to one application. // The name of the application is the name of the intermediate directory. else if( templateDir.equals( parentDir.getParentFile())) appName = parentDir.getName(); // Too many levels! else throw new IllegalArgumentException( "Not a template file: " + templateFile ); return appName; }
[ "public", "static", "String", "findApplicationName", "(", "final", "File", "templateDir", ",", "final", "File", "templateFile", ")", "{", "final", "File", "parentDir", "=", "templateFile", ".", "getParentFile", "(", ")", ";", "final", "String", "appName", ";", ...
Finds an application name from a template file. @param templateDir the templates root directory, the one being watched by the TemplateWatcher @param templateFile the template file @return name of the application targeted by the given template file, or {@code null} for a template global to all applications @throws IllegalStateException if the provided {@code templateFile} does not match
[ "Finds", "an", "application", "name", "from", "a", "template", "file", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java#L66-L85
train
roboconf/roboconf-platform
core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java
TemplateUtils.deleteGeneratedFiles
public static void deleteGeneratedFiles( Application app, File outputDirectory ) { File target = new File( outputDirectory, app.getName()); Utils.deleteFilesRecursivelyAndQuietly( target ); }
java
public static void deleteGeneratedFiles( Application app, File outputDirectory ) { File target = new File( outputDirectory, app.getName()); Utils.deleteFilesRecursivelyAndQuietly( target ); }
[ "public", "static", "void", "deleteGeneratedFiles", "(", "Application", "app", ",", "File", "outputDirectory", ")", "{", "File", "target", "=", "new", "File", "(", "outputDirectory", ",", "app", ".", "getName", "(", ")", ")", ";", "Utils", ".", "deleteFilesR...
Deletes the generated files for a given application. @param app an application (not null) @param outputDirectory the output directory (not null)
[ "Deletes", "the", "generated", "files", "for", "a", "given", "application", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java#L150-L154
train
roboconf/roboconf-platform
core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java
TemplateUtils.findTemplatesForApplication
public static Collection<TemplateEntry> findTemplatesForApplication( String appName, Collection<TemplateEntry> templates ) { final Collection<TemplateEntry> result = new ArrayList<> (); for( TemplateEntry te : templates ) { // TE.appName == null => OK. It applies to this application. // TE.appName == appName => OK. It also applies. if( te.getAppName() == null || te.getAppName().equals( appName )) result.add( te ); } return result; }
java
public static Collection<TemplateEntry> findTemplatesForApplication( String appName, Collection<TemplateEntry> templates ) { final Collection<TemplateEntry> result = new ArrayList<> (); for( TemplateEntry te : templates ) { // TE.appName == null => OK. It applies to this application. // TE.appName == appName => OK. It also applies. if( te.getAppName() == null || te.getAppName().equals( appName )) result.add( te ); } return result; }
[ "public", "static", "Collection", "<", "TemplateEntry", ">", "findTemplatesForApplication", "(", "String", "appName", ",", "Collection", "<", "TemplateEntry", ">", "templates", ")", "{", "final", "Collection", "<", "TemplateEntry", ">", "result", "=", "new", "Arra...
Finds the templates that can apply to a given application. @param appName an application name (can be null to match all) @param templates a non-null collection of templates @return a non-null collection of templates
[ "Finds", "the", "templates", "that", "can", "apply", "to", "a", "given", "application", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm-templating/src/main/java/net/roboconf/dm/templating/internal/templates/TemplateUtils.java#L163-L174
train
roboconf/roboconf-platform
core/roboconf-plugin-puppet/src/main/java/net/roboconf/plugin/puppet/internal/PluginPuppet.java
PluginPuppet.installPuppetModules
void installPuppetModules( Instance instance ) throws IOException, InterruptedException { // Load the modules names File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File modulesFile = new File( instanceDirectory, "modules.properties" ); if( ! modulesFile.exists()) return; Properties props = Utils.readPropertiesFile( modulesFile ); for( Map.Entry<Object,Object> entry : props.entrySet()) { List<String> commands = new ArrayList<> (); commands.add( "puppet" ); commands.add( "module" ); commands.add( "install" ); String value = entry.getValue().toString(); if( ! Utils.isEmptyOrWhitespaces( value )) { commands.add( "--version" ); commands.add( value ); } commands.add((String) entry.getKey()); commands.add( "--target-dir" ); commands.add( instanceDirectory.getAbsolutePath()); String[] params = commands.toArray( new String[ 0 ]); this.logger.fine( "Module installation: " + Arrays.toString( params )); int exitCode = ProgramUtils.executeCommand( this.logger, commands, null, null, this.applicationName, this.scopedInstancePath); if( exitCode != 0 ) throw new IOException( "Puppet modules could not be installed for " + instance + "." ); } }
java
void installPuppetModules( Instance instance ) throws IOException, InterruptedException { // Load the modules names File instanceDirectory = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); File modulesFile = new File( instanceDirectory, "modules.properties" ); if( ! modulesFile.exists()) return; Properties props = Utils.readPropertiesFile( modulesFile ); for( Map.Entry<Object,Object> entry : props.entrySet()) { List<String> commands = new ArrayList<> (); commands.add( "puppet" ); commands.add( "module" ); commands.add( "install" ); String value = entry.getValue().toString(); if( ! Utils.isEmptyOrWhitespaces( value )) { commands.add( "--version" ); commands.add( value ); } commands.add((String) entry.getKey()); commands.add( "--target-dir" ); commands.add( instanceDirectory.getAbsolutePath()); String[] params = commands.toArray( new String[ 0 ]); this.logger.fine( "Module installation: " + Arrays.toString( params )); int exitCode = ProgramUtils.executeCommand( this.logger, commands, null, null, this.applicationName, this.scopedInstancePath); if( exitCode != 0 ) throw new IOException( "Puppet modules could not be installed for " + instance + "." ); } }
[ "void", "installPuppetModules", "(", "Instance", "instance", ")", "throws", "IOException", ",", "InterruptedException", "{", "// Load the modules names", "File", "instanceDirectory", "=", "InstanceHelpers", ".", "findInstanceDirectoryOnAgent", "(", "instance", ")", ";", "...
Executes a Puppet command to install the required modules. @param instance the instance @throws IOException @throws InterruptedException @throws PluginException
[ "Executes", "a", "Puppet", "command", "to", "install", "the", "required", "modules", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-puppet/src/main/java/net/roboconf/plugin/puppet/internal/PluginPuppet.java#L207-L241
train
roboconf/roboconf-platform
core/roboconf-plugin-puppet/src/main/java/net/roboconf/plugin/puppet/internal/PluginPuppet.java
PluginPuppet.generateCodeToExecute
String generateCodeToExecute( String className, Instance instance, PuppetState puppetState, Import importChanged, boolean importAdded ) { // When executed by hand, the "apply" command would expect // this string to be returned to be between double quotes. // Example: "class{ 'roboconf_redis': ... }" // However, this does not work when executed from a Process builder. // The double quotes must be removed so that it works. StringBuilder sb = new StringBuilder(); sb.append( "class{'" ); sb.append( className ); sb.append( "': runningState => " ); sb.append( puppetState.toString().toLowerCase()); // Prepare the injection of variables into the Puppet receipt Map<String,String> exports = InstanceHelpers.findAllExportedVariables( instance ); String args = formatExportedVariables( exports ); String importedTypes = formatInstanceImports( instance ); if( ! Utils.isEmptyOrWhitespaces( args )) sb.append( ", " + args ); if( ! Utils.isEmptyOrWhitespaces( importedTypes )) sb.append( ", " + importedTypes ); if(importChanged != null) { String componentName = importChanged.getComponentName(); sb.append(", importDiff => {" + (importAdded ? "added => {" : "removed => {") + formatImport(importChanged) + "}, " + (importAdded ? "removed => undef" : "added => undef") + ", component => " + (componentName != null ? componentName : "undef") + "}"); } sb.append("}"); return sb.toString(); }
java
String generateCodeToExecute( String className, Instance instance, PuppetState puppetState, Import importChanged, boolean importAdded ) { // When executed by hand, the "apply" command would expect // this string to be returned to be between double quotes. // Example: "class{ 'roboconf_redis': ... }" // However, this does not work when executed from a Process builder. // The double quotes must be removed so that it works. StringBuilder sb = new StringBuilder(); sb.append( "class{'" ); sb.append( className ); sb.append( "': runningState => " ); sb.append( puppetState.toString().toLowerCase()); // Prepare the injection of variables into the Puppet receipt Map<String,String> exports = InstanceHelpers.findAllExportedVariables( instance ); String args = formatExportedVariables( exports ); String importedTypes = formatInstanceImports( instance ); if( ! Utils.isEmptyOrWhitespaces( args )) sb.append( ", " + args ); if( ! Utils.isEmptyOrWhitespaces( importedTypes )) sb.append( ", " + importedTypes ); if(importChanged != null) { String componentName = importChanged.getComponentName(); sb.append(", importDiff => {" + (importAdded ? "added => {" : "removed => {") + formatImport(importChanged) + "}, " + (importAdded ? "removed => undef" : "added => undef") + ", component => " + (componentName != null ? componentName : "undef") + "}"); } sb.append("}"); return sb.toString(); }
[ "String", "generateCodeToExecute", "(", "String", "className", ",", "Instance", "instance", ",", "PuppetState", "puppetState", ",", "Import", "importChanged", ",", "boolean", "importAdded", ")", "{", "// When executed by hand, the \"apply\" command would expect", "// this str...
Generates the code to be injected by Puppet into the manifest. @param instance the instance @param puppetState the Puppet state @param importChanged The import that changed (added or removed) upon update @param importAdded true if the changed import is added, false if it is removed @return a non-null string
[ "Generates", "the", "code", "to", "be", "injected", "by", "Puppet", "into", "the", "manifest", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-plugin-puppet/src/main/java/net/roboconf/plugin/puppet/internal/PluginPuppet.java#L363-L407
train
roboconf/roboconf-platform
core/roboconf-dm/src/main/java/net/roboconf/dm/internal/utils/TargetHelpers.java
TargetHelpers.verifyTargets
public static void verifyTargets( ITargetHandlerResolver targetHandlerResolver, ManagedApplication ma, ITargetsMngr targetsMngr ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); for( Instance inst : InstanceHelpers.getAllInstances( ma.getApplication())) { if( ! InstanceHelpers.isTarget( inst )) continue; try { String path = InstanceHelpers.computeInstancePath( inst ); Map<String,String> targetProperties = targetsMngr.findTargetProperties( ma.getApplication(), path ).asMap(); targetHandlerResolver.findTargetHandler( targetProperties ); } catch( TargetException e ) { logger.warning( e.getMessage()); } } }
java
public static void verifyTargets( ITargetHandlerResolver targetHandlerResolver, ManagedApplication ma, ITargetsMngr targetsMngr ) { Logger logger = Logger.getLogger( TargetHelpers.class.getName()); for( Instance inst : InstanceHelpers.getAllInstances( ma.getApplication())) { if( ! InstanceHelpers.isTarget( inst )) continue; try { String path = InstanceHelpers.computeInstancePath( inst ); Map<String,String> targetProperties = targetsMngr.findTargetProperties( ma.getApplication(), path ).asMap(); targetHandlerResolver.findTargetHandler( targetProperties ); } catch( TargetException e ) { logger.warning( e.getMessage()); } } }
[ "public", "static", "void", "verifyTargets", "(", "ITargetHandlerResolver", "targetHandlerResolver", ",", "ManagedApplication", "ma", ",", "ITargetsMngr", "targetsMngr", ")", "{", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "TargetHelpers", ".", "class",...
Verifies that all the target handlers an application needs are installed. @param targetHandlerResolver the DM's target resolver @param ma a managed application @param handlers a non-null list of handlers
[ "Verifies", "that", "all", "the", "target", "handlers", "an", "application", "needs", "are", "installed", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-dm/src/main/java/net/roboconf/dm/internal/utils/TargetHelpers.java#L62-L81
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/dsl/converters/FromGraphs.java
FromGraphs.buildFileDefinition
public FileDefinition buildFileDefinition( Graphs graphs, File targetFile, boolean addComment ) { // Build the global structure FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.GRAPH ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } // Process and serialize the components Set<String> alreadySerializedNames = new HashSet<> (); for( Component c : ComponentHelpers.findAllComponents( graphs )) { if( alreadySerializedNames.contains( c.getName())) continue; alreadySerializedNames.add( c.getName()); result.getBlocks().addAll( buildComponent( result, c, addComment )); for( Facet f : ComponentHelpers.findAllFacets( c )) { if( alreadySerializedNames.contains( f.getName())) continue; alreadySerializedNames.add( f.getName()); result.getBlocks().addAll( buildFacet( result, f, addComment )); } } // There may be orphan facets too for( Facet f : graphs.getFacetNameToFacet().values()) { if( alreadySerializedNames.contains( f.getName())) continue; alreadySerializedNames.add( f.getName()); result.getBlocks().addAll( buildFacet( result, f, addComment )); } return result; }
java
public FileDefinition buildFileDefinition( Graphs graphs, File targetFile, boolean addComment ) { // Build the global structure FileDefinition result = new FileDefinition( targetFile ); result.setFileType( FileDefinition.GRAPH ); if( addComment ) { String s = "# File created from an in-memory model,\n# without a binding to existing files."; BlockComment initialComment = new BlockComment( result, s ); result.getBlocks().add( initialComment ); result.getBlocks().add( new BlockBlank( result, "\n" )); } // Process and serialize the components Set<String> alreadySerializedNames = new HashSet<> (); for( Component c : ComponentHelpers.findAllComponents( graphs )) { if( alreadySerializedNames.contains( c.getName())) continue; alreadySerializedNames.add( c.getName()); result.getBlocks().addAll( buildComponent( result, c, addComment )); for( Facet f : ComponentHelpers.findAllFacets( c )) { if( alreadySerializedNames.contains( f.getName())) continue; alreadySerializedNames.add( f.getName()); result.getBlocks().addAll( buildFacet( result, f, addComment )); } } // There may be orphan facets too for( Facet f : graphs.getFacetNameToFacet().values()) { if( alreadySerializedNames.contains( f.getName())) continue; alreadySerializedNames.add( f.getName()); result.getBlocks().addAll( buildFacet( result, f, addComment )); } return result; }
[ "public", "FileDefinition", "buildFileDefinition", "(", "Graphs", "graphs", ",", "File", "targetFile", ",", "boolean", "addComment", ")", "{", "// Build the global structure", "FileDefinition", "result", "=", "new", "FileDefinition", "(", "targetFile", ")", ";", "resu...
Builds a file definition from a graph. @param graphs the graphs @param targetFile the target file (will not be written) @param addComment true to insert generated comments @return a non-null file definition
[ "Builds", "a", "file", "definition", "from", "a", "graph", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/dsl/converters/FromGraphs.java#L66-L105
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java
ResourceUtils.storeInstanceResources
public static Map<String,byte[]> storeInstanceResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Recipes Map<String,byte[]> result = new HashMap<> (); File instanceResourcesDirectory = findInstanceResourcesDirectory( applicationFilesDirectory, instance ); if( instanceResourcesDirectory.exists() && instanceResourcesDirectory.isDirectory()) result.putAll( Utils.storeDirectoryResourcesAsBytes( instanceResourcesDirectory )); // Probe files result.putAll( storeInstanceProbeResources( applicationFilesDirectory, instance )); return result; }
java
public static Map<String,byte[]> storeInstanceResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Recipes Map<String,byte[]> result = new HashMap<> (); File instanceResourcesDirectory = findInstanceResourcesDirectory( applicationFilesDirectory, instance ); if( instanceResourcesDirectory.exists() && instanceResourcesDirectory.isDirectory()) result.putAll( Utils.storeDirectoryResourcesAsBytes( instanceResourcesDirectory )); // Probe files result.putAll( storeInstanceProbeResources( applicationFilesDirectory, instance )); return result; }
[ "public", "static", "Map", "<", "String", ",", "byte", "[", "]", ">", "storeInstanceResources", "(", "File", "applicationFilesDirectory", ",", "Instance", "instance", ")", "throws", "IOException", "{", "// Recipes", "Map", "<", "String", ",", "byte", "[", "]",...
Stores the instance resources into a map. @param applicationFilesDirectory the application's directory @param instance an instance (not null) @return a non-null map (key = the file location, relative to the instance's directory, value = file content) @throws IOException if something went wrong while reading a file
[ "Stores", "the", "instance", "resources", "into", "a", "map", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java#L62-L75
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java
ResourceUtils.storeInstanceProbeResources
public static Map<String,byte[]> storeInstanceProbeResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Measure files (are not located with recipes, so no trouble with component inheritance). // There can also be a properties file to inject values. String[] exts = { Constants.FILE_EXT_MEASURES, Constants.FILE_EXT_MEASURES + ".properties" }; Map<String,byte[]> result = new HashMap<> (); for( String ext : exts ) { String fileName = instance.getComponent().getName() + ext; File autonomicMeasureFile = new File( applicationFilesDirectory, Constants.PROJECT_DIR_PROBES + "/" + fileName ); if( ! autonomicMeasureFile.exists()) break; ByteArrayOutputStream os = new ByteArrayOutputStream(); Utils.copyStream( autonomicMeasureFile, os ); result.put( autonomicMeasureFile.getName(), os.toByteArray()); } return result; }
java
public static Map<String,byte[]> storeInstanceProbeResources( File applicationFilesDirectory, Instance instance ) throws IOException { // Measure files (are not located with recipes, so no trouble with component inheritance). // There can also be a properties file to inject values. String[] exts = { Constants.FILE_EXT_MEASURES, Constants.FILE_EXT_MEASURES + ".properties" }; Map<String,byte[]> result = new HashMap<> (); for( String ext : exts ) { String fileName = instance.getComponent().getName() + ext; File autonomicMeasureFile = new File( applicationFilesDirectory, Constants.PROJECT_DIR_PROBES + "/" + fileName ); if( ! autonomicMeasureFile.exists()) break; ByteArrayOutputStream os = new ByteArrayOutputStream(); Utils.copyStream( autonomicMeasureFile, os ); result.put( autonomicMeasureFile.getName(), os.toByteArray()); } return result; }
[ "public", "static", "Map", "<", "String", ",", "byte", "[", "]", ">", "storeInstanceProbeResources", "(", "File", "applicationFilesDirectory", ",", "Instance", "instance", ")", "throws", "IOException", "{", "// Measure files (are not located with recipes, so no trouble with...
Stores the instance's resources related to probes into a map. @param applicationFilesDirectory the application's directory @param instance an instance (not null) @return a non-null map (key = the file location, relative to the instance's directory, value = file content) @throws IOException if something went wrong while reading a file
[ "Stores", "the", "instance", "s", "resources", "related", "to", "probes", "into", "a", "map", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java#L85-L107
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java
ResourceUtils.findInstanceResourcesDirectory
public static File findInstanceResourcesDirectory( File applicationFilesDirectory, Instance instance ) { return findInstanceResourcesDirectory( applicationFilesDirectory, instance.getComponent()); }
java
public static File findInstanceResourcesDirectory( File applicationFilesDirectory, Instance instance ) { return findInstanceResourcesDirectory( applicationFilesDirectory, instance.getComponent()); }
[ "public", "static", "File", "findInstanceResourcesDirectory", "(", "File", "applicationFilesDirectory", ",", "Instance", "instance", ")", "{", "return", "findInstanceResourcesDirectory", "(", "applicationFilesDirectory", ",", "instance", ".", "getComponent", "(", ")", ")"...
Finds the resource directory for an instance. @param applicationFilesDirectory the application's directory @param instance an instance @return a non-null file (that may not exist)
[ "Finds", "the", "resource", "directory", "for", "an", "instance", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java#L116-L118
train
roboconf/roboconf-platform
core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java
ResourceUtils.findScopedInstancesDirectories
public static Map<Component,File> findScopedInstancesDirectories( AbstractApplication absApp ) { Map<Component,File> result = new HashMap<> (); for( Component c : ComponentHelpers.findAllComponents( absApp.getGraphs())) { // Target? if( ! ComponentHelpers.isTarget( c )) continue; // Is there a resources directory? File dir = ResourceUtils.findInstanceResourcesDirectory( absApp.getDirectory(), c ); if( ! dir.exists()) continue; result.put( c, dir ); } return result; }
java
public static Map<Component,File> findScopedInstancesDirectories( AbstractApplication absApp ) { Map<Component,File> result = new HashMap<> (); for( Component c : ComponentHelpers.findAllComponents( absApp.getGraphs())) { // Target? if( ! ComponentHelpers.isTarget( c )) continue; // Is there a resources directory? File dir = ResourceUtils.findInstanceResourcesDirectory( absApp.getDirectory(), c ); if( ! dir.exists()) continue; result.put( c, dir ); } return result; }
[ "public", "static", "Map", "<", "Component", ",", "File", ">", "findScopedInstancesDirectories", "(", "AbstractApplication", "absApp", ")", "{", "Map", "<", "Component", ",", "File", ">", "result", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "C...
Finds the resource directories for scoped instances. @param applicationFilesDirectory the application's directory @param graph the graph @return a non-null map (key = component, value = directory)
[ "Finds", "the", "resource", "directories", "for", "scoped", "instances", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-core/src/main/java/net/roboconf/core/utils/ResourceUtils.java#L160-L178
train
roboconf/roboconf-platform
core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/extensions/AbstractRoutingClient.java
AbstractRoutingClient.subscribe
protected void subscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub == null ) { sub = new HashSet<> (); this.routingContext.subscriptions.put( id, sub ); } sub.add( ctx ); }
java
protected void subscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub == null ) { sub = new HashSet<> (); this.routingContext.subscriptions.put( id, sub ); } sub.add( ctx ); }
[ "protected", "void", "subscribe", "(", "String", "id", ",", "MessagingContext", "ctx", ")", "throws", "IOException", "{", "if", "(", "!", "canProceed", "(", ")", ")", "return", ";", "Set", "<", "MessagingContext", ">", "sub", "=", "this", ".", "routingCont...
Registers a subscription between an ID and a context. @param id a client ID @param ctx a messaging context @throws IOException
[ "Registers", "a", "subscription", "between", "an", "ID", "and", "a", "context", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/extensions/AbstractRoutingClient.java#L265-L277
train
roboconf/roboconf-platform
core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/extensions/AbstractRoutingClient.java
AbstractRoutingClient.unsubscribe
protected void unsubscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub != null ) { sub.remove( ctx ); if( sub.isEmpty()) this.routingContext.subscriptions.remove( id ); } }
java
protected void unsubscribe( String id, MessagingContext ctx ) throws IOException { if( ! canProceed()) return; Set<MessagingContext> sub = this.routingContext.subscriptions.get( id ); if( sub != null ) { sub.remove( ctx ); if( sub.isEmpty()) this.routingContext.subscriptions.remove( id ); } }
[ "protected", "void", "unsubscribe", "(", "String", "id", ",", "MessagingContext", "ctx", ")", "throws", "IOException", "{", "if", "(", "!", "canProceed", "(", ")", ")", "return", ";", "Set", "<", "MessagingContext", ">", "sub", "=", "this", ".", "routingCo...
Unregisters a subscription between an ID and a context. @param id a client ID @param ctx a messaging context @throws IOException
[ "Unregisters", "a", "subscription", "between", "an", "ID", "and", "a", "context", "." ]
add54eead479effb138d0ff53a2d637902b82702
https://github.com/roboconf/roboconf-platform/blob/add54eead479effb138d0ff53a2d637902b82702/core/roboconf-messaging-api/src/main/java/net/roboconf/messaging/api/extensions/AbstractRoutingClient.java#L286-L297
train