id
int32 0
165k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
16,000
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/DescribableServiceUtil.java
|
DescribableServiceUtil.descriptionForProvider
|
public static Description descriptionForProvider(
final boolean includeFieldProperties,
final Object providerForType
)
{
if (providerForType instanceof Describable) {
final Describable desc = (Describable) providerForType;
return desc.getDescription();
} else if (PluginAdapterUtility.canBuildDescription(providerForType)) {
return PluginAdapterUtility.buildDescription(providerForType, DescriptionBuilder.builder(),
includeFieldProperties
);
}
return null;
}
|
java
|
public static Description descriptionForProvider(
final boolean includeFieldProperties,
final Object providerForType
)
{
if (providerForType instanceof Describable) {
final Describable desc = (Describable) providerForType;
return desc.getDescription();
} else if (PluginAdapterUtility.canBuildDescription(providerForType)) {
return PluginAdapterUtility.buildDescription(providerForType, DescriptionBuilder.builder(),
includeFieldProperties
);
}
return null;
}
|
[
"public",
"static",
"Description",
"descriptionForProvider",
"(",
"final",
"boolean",
"includeFieldProperties",
",",
"final",
"Object",
"providerForType",
")",
"{",
"if",
"(",
"providerForType",
"instanceof",
"Describable",
")",
"{",
"final",
"Describable",
"desc",
"=",
"(",
"Describable",
")",
"providerForType",
";",
"return",
"desc",
".",
"getDescription",
"(",
")",
";",
"}",
"else",
"if",
"(",
"PluginAdapterUtility",
".",
"canBuildDescription",
"(",
"providerForType",
")",
")",
"{",
"return",
"PluginAdapterUtility",
".",
"buildDescription",
"(",
"providerForType",
",",
"DescriptionBuilder",
".",
"builder",
"(",
")",
",",
"includeFieldProperties",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get or build the description of a plugin instance of a given type
@param includeFieldProperties true to include introspected field properties
@param providerForType plugin instance
@return description, or null
|
[
"Get",
"or",
"build",
"the",
"description",
"of",
"a",
"plugin",
"instance",
"of",
"a",
"given",
"type"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/DescribableServiceUtil.java#L72-L86
|
16,001
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/cache/FileCache.java
|
FileCache.remove
|
public synchronized void remove(final File file) {
final T t = cache.get(file);
expiry.remove(file);
cache.remove(file);
if (null != t && t instanceof Expireable) {
final Expireable exp = (Expireable) t;
exp.expire();
}
}
|
java
|
public synchronized void remove(final File file) {
final T t = cache.get(file);
expiry.remove(file);
cache.remove(file);
if (null != t && t instanceof Expireable) {
final Expireable exp = (Expireable) t;
exp.expire();
}
}
|
[
"public",
"synchronized",
"void",
"remove",
"(",
"final",
"File",
"file",
")",
"{",
"final",
"T",
"t",
"=",
"cache",
".",
"get",
"(",
"file",
")",
";",
"expiry",
".",
"remove",
"(",
"file",
")",
";",
"cache",
".",
"remove",
"(",
"file",
")",
";",
"if",
"(",
"null",
"!=",
"t",
"&&",
"t",
"instanceof",
"Expireable",
")",
"{",
"final",
"Expireable",
"exp",
"=",
"(",
"Expireable",
")",
"t",
";",
"exp",
".",
"expire",
"(",
")",
";",
"}",
"}"
] |
Remove entry for a file.
@param file file
|
[
"Remove",
"entry",
"for",
"a",
"file",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/cache/FileCache.java#L60-L68
|
16,002
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java
|
FrameworkProjectConfig.create
|
public static FrameworkProjectConfig create(
final String name,
final File propertyFile,
final IFilesystemFramework filesystemFramework
)
{
return new FrameworkProjectConfig(name, propertyFile, filesystemFramework);
}
|
java
|
public static FrameworkProjectConfig create(
final String name,
final File propertyFile,
final IFilesystemFramework filesystemFramework
)
{
return new FrameworkProjectConfig(name, propertyFile, filesystemFramework);
}
|
[
"public",
"static",
"FrameworkProjectConfig",
"create",
"(",
"final",
"String",
"name",
",",
"final",
"File",
"propertyFile",
",",
"final",
"IFilesystemFramework",
"filesystemFramework",
")",
"{",
"return",
"new",
"FrameworkProjectConfig",
"(",
"name",
",",
"propertyFile",
",",
"filesystemFramework",
")",
";",
"}"
] |
Create from existing file
@param name
@param propertyFile
@param filesystemFramework
@return
|
[
"Create",
"from",
"existing",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java#L71-L78
|
16,003
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java
|
FrameworkProjectConfig.create
|
public static FrameworkProjectConfig create(
final String name,
final File propertyFile,
final Properties properties,
final IFilesystemFramework filesystemFramework
)
{
if (!propertyFile.exists() ) {
generateProjectPropertiesFile(name, propertyFile, false, properties, true);
}
return create(name, propertyFile, filesystemFramework);
}
|
java
|
public static FrameworkProjectConfig create(
final String name,
final File propertyFile,
final Properties properties,
final IFilesystemFramework filesystemFramework
)
{
if (!propertyFile.exists() ) {
generateProjectPropertiesFile(name, propertyFile, false, properties, true);
}
return create(name, propertyFile, filesystemFramework);
}
|
[
"public",
"static",
"FrameworkProjectConfig",
"create",
"(",
"final",
"String",
"name",
",",
"final",
"File",
"propertyFile",
",",
"final",
"Properties",
"properties",
",",
"final",
"IFilesystemFramework",
"filesystemFramework",
")",
"{",
"if",
"(",
"!",
"propertyFile",
".",
"exists",
"(",
")",
")",
"{",
"generateProjectPropertiesFile",
"(",
"name",
",",
"propertyFile",
",",
"false",
",",
"properties",
",",
"true",
")",
";",
"}",
"return",
"create",
"(",
"name",
",",
"propertyFile",
",",
"filesystemFramework",
")",
";",
"}"
] |
Create and generate file with the given properties if not null
@param name
@param propertyFile
@param properties
@param filesystemFramework
@return
|
[
"Create",
"and",
"generate",
"file",
"with",
"the",
"given",
"properties",
"if",
"not",
"null"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java#L88-L100
|
16,004
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java
|
FrameworkProjectConfig.setProjectProperties
|
public void setProjectProperties(final Properties properties) {
generateProjectPropertiesFile(getName(), propertyFile, true, properties, false, null, false);
loadProperties();
}
|
java
|
public void setProjectProperties(final Properties properties) {
generateProjectPropertiesFile(getName(), propertyFile, true, properties, false, null, false);
loadProperties();
}
|
[
"public",
"void",
"setProjectProperties",
"(",
"final",
"Properties",
"properties",
")",
"{",
"generateProjectPropertiesFile",
"(",
"getName",
"(",
")",
",",
"propertyFile",
",",
"true",
",",
"properties",
",",
"false",
",",
"null",
",",
"false",
")",
";",
"loadProperties",
"(",
")",
";",
"}"
] |
Set the project properties file contents exactly
@param properties new properties to use in the file
|
[
"Set",
"the",
"project",
"properties",
"file",
"contents",
"exactly"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProjectConfig.java#L138-L141
|
16,005
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/LogReformatter.java
|
LogReformatter.reformat
|
public String reformat(final Map<String, String> context, final String message) {
final HashMap<String, String> tokens = new HashMap<String, String>();
if (null != context) {
tokens.putAll(context);
}
if (null != generator) {
tokens.putAll(generator.getMap());
} else if(null!=data) {
tokens.putAll(data);
}
final String[] arr = {
null!= tokens.get("user")? tokens.get("user"):"",
null != tokens.get("node") ? tokens.get("node") : "",
null != tokens.get("command") ? tokens.get("command") : "",
tokens.get("level"),
message
};
synchronized (messageFormat){
return messageFormat.format(arr);
}
}
|
java
|
public String reformat(final Map<String, String> context, final String message) {
final HashMap<String, String> tokens = new HashMap<String, String>();
if (null != context) {
tokens.putAll(context);
}
if (null != generator) {
tokens.putAll(generator.getMap());
} else if(null!=data) {
tokens.putAll(data);
}
final String[] arr = {
null!= tokens.get("user")? tokens.get("user"):"",
null != tokens.get("node") ? tokens.get("node") : "",
null != tokens.get("command") ? tokens.get("command") : "",
tokens.get("level"),
message
};
synchronized (messageFormat){
return messageFormat.format(arr);
}
}
|
[
"public",
"String",
"reformat",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"context",
",",
"final",
"String",
"message",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"tokens",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"context",
")",
"{",
"tokens",
".",
"putAll",
"(",
"context",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"generator",
")",
"{",
"tokens",
".",
"putAll",
"(",
"generator",
".",
"getMap",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"null",
"!=",
"data",
")",
"{",
"tokens",
".",
"putAll",
"(",
"data",
")",
";",
"}",
"final",
"String",
"[",
"]",
"arr",
"=",
"{",
"null",
"!=",
"tokens",
".",
"get",
"(",
"\"user\"",
")",
"?",
"tokens",
".",
"get",
"(",
"\"user\"",
")",
":",
"\"\"",
",",
"null",
"!=",
"tokens",
".",
"get",
"(",
"\"node\"",
")",
"?",
"tokens",
".",
"get",
"(",
"\"node\"",
")",
":",
"\"\"",
",",
"null",
"!=",
"tokens",
".",
"get",
"(",
"\"command\"",
")",
"?",
"tokens",
".",
"get",
"(",
"\"command\"",
")",
":",
"\"\"",
",",
"tokens",
".",
"get",
"(",
"\"level\"",
")",
",",
"message",
"}",
";",
"synchronized",
"(",
"messageFormat",
")",
"{",
"return",
"messageFormat",
".",
"format",
"(",
"arr",
")",
";",
"}",
"}"
] |
Combines the context data, and the local static or dynamic context data, and reformats the message
@param context input data
@param message message string
@return reformatted message string
|
[
"Combines",
"the",
"context",
"data",
"and",
"the",
"local",
"static",
"or",
"dynamic",
"context",
"data",
"and",
"reformats",
"the",
"message"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/LogReformatter.java#L97-L117
|
16,006
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/States.java
|
States.state
|
public static StateObj state(StateObj... states) {
MutableStateObj mutable = mutable();
for (StateObj state : states) {
mutable.updateState(state);
}
return state(mutable.getState());
}
|
java
|
public static StateObj state(StateObj... states) {
MutableStateObj mutable = mutable();
for (StateObj state : states) {
mutable.updateState(state);
}
return state(mutable.getState());
}
|
[
"public",
"static",
"StateObj",
"state",
"(",
"StateObj",
"...",
"states",
")",
"{",
"MutableStateObj",
"mutable",
"=",
"mutable",
"(",
")",
";",
"for",
"(",
"StateObj",
"state",
":",
"states",
")",
"{",
"mutable",
".",
"updateState",
"(",
"state",
")",
";",
"}",
"return",
"state",
"(",
"mutable",
".",
"getState",
"(",
")",
")",
";",
"}"
] |
merge multiple state objects in order
@param states states
@return
|
[
"merge",
"multiple",
"state",
"objects",
"in",
"order"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/States.java#L29-L35
|
16,007
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/authorization/AclsUtil.java
|
AclsUtil.getGroups
|
public static Set<String> getGroups(AclRuleSetSource source){
HashSet<String> strings = new HashSet<>();
for (AclRule rule : source.getRuleSet().getRules()) {
if(rule.getGroup()!=null) {
strings.add(rule.getGroup());
}
}
return strings;
}
|
java
|
public static Set<String> getGroups(AclRuleSetSource source){
HashSet<String> strings = new HashSet<>();
for (AclRule rule : source.getRuleSet().getRules()) {
if(rule.getGroup()!=null) {
strings.add(rule.getGroup());
}
}
return strings;
}
|
[
"public",
"static",
"Set",
"<",
"String",
">",
"getGroups",
"(",
"AclRuleSetSource",
"source",
")",
"{",
"HashSet",
"<",
"String",
">",
"strings",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"AclRule",
"rule",
":",
"source",
".",
"getRuleSet",
"(",
")",
".",
"getRules",
"(",
")",
")",
"{",
"if",
"(",
"rule",
".",
"getGroup",
"(",
")",
"!=",
"null",
")",
"{",
"strings",
".",
"add",
"(",
"rule",
".",
"getGroup",
"(",
")",
")",
";",
"}",
"}",
"return",
"strings",
";",
"}"
] |
collect the set of groups used in a rule set
@param source source
@return group names
|
[
"collect",
"the",
"set",
"of",
"groups",
"used",
"in",
"a",
"rule",
"set"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/authorization/AclsUtil.java#L38-L46
|
16,008
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/authorization/AclsUtil.java
|
AclsUtil.append
|
public static Authorization append(Authorization a, Authorization b) {
if (a instanceof AclRuleSetSource && b instanceof AclRuleSetSource) {
return RuleEvaluator.createRuleEvaluator(
merge((AclRuleSetSource) a, (AclRuleSetSource) b)
);
}
return new MultiAuthorization(a, b);
}
|
java
|
public static Authorization append(Authorization a, Authorization b) {
if (a instanceof AclRuleSetSource && b instanceof AclRuleSetSource) {
return RuleEvaluator.createRuleEvaluator(
merge((AclRuleSetSource) a, (AclRuleSetSource) b)
);
}
return new MultiAuthorization(a, b);
}
|
[
"public",
"static",
"Authorization",
"append",
"(",
"Authorization",
"a",
",",
"Authorization",
"b",
")",
"{",
"if",
"(",
"a",
"instanceof",
"AclRuleSetSource",
"&&",
"b",
"instanceof",
"AclRuleSetSource",
")",
"{",
"return",
"RuleEvaluator",
".",
"createRuleEvaluator",
"(",
"merge",
"(",
"(",
"AclRuleSetSource",
")",
"a",
",",
"(",
"AclRuleSetSource",
")",
"b",
")",
")",
";",
"}",
"return",
"new",
"MultiAuthorization",
"(",
"a",
",",
"b",
")",
";",
"}"
] |
Merge to authorization resources
@param a authorization
@param b authorization
@return a new Authorization that merges both authorization a and b
|
[
"Merge",
"to",
"authorization",
"resources"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/authorization/AclsUtil.java#L54-L61
|
16,009
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/RuntimePropertyResolver.java
|
RuntimePropertyResolver.resolvePropertyValue
|
public String resolvePropertyValue(final String name, final PropertyScope scope) {
if (null == scope || scope == PropertyScope.Unspecified) {
throw new IllegalArgumentException("scope must be specified");
}
String value = null;
if (scope.isInstanceLevel()) {
if (null != instanceScopeResolver) {
value = instanceScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(I) " + name + " = " + value);
}
}
if (null != value || scope == PropertyScope.InstanceOnly) {
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
if (scope.isProjectLevel()) {
if (null != projectScopeResolver) {
value = projectScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(P) " + name + " = " + value);
}
}
if (null != value || scope == PropertyScope.ProjectOnly) {
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
if (null != frameworkScopeResolver) {
if (scope.isFrameworkLevel()) {
value = frameworkScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(F) " + name + " = " + value);
}
}
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
|
java
|
public String resolvePropertyValue(final String name, final PropertyScope scope) {
if (null == scope || scope == PropertyScope.Unspecified) {
throw new IllegalArgumentException("scope must be specified");
}
String value = null;
if (scope.isInstanceLevel()) {
if (null != instanceScopeResolver) {
value = instanceScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(I) " + name + " = " + value);
}
}
if (null != value || scope == PropertyScope.InstanceOnly) {
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
if (scope.isProjectLevel()) {
if (null != projectScopeResolver) {
value = projectScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(P) " + name + " = " + value);
}
}
if (null != value || scope == PropertyScope.ProjectOnly) {
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
if (null != frameworkScopeResolver) {
if (scope.isFrameworkLevel()) {
value = frameworkScopeResolver.getProperty(name);
log.trace("resolvePropertyValue(" + scope + ")(F) " + name + " = " + value);
}
}
log.debug("resolvePropertyValue(" + scope + ") " + name + " = " + value);
return value;
}
|
[
"public",
"String",
"resolvePropertyValue",
"(",
"final",
"String",
"name",
",",
"final",
"PropertyScope",
"scope",
")",
"{",
"if",
"(",
"null",
"==",
"scope",
"||",
"scope",
"==",
"PropertyScope",
".",
"Unspecified",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"scope must be specified\"",
")",
";",
"}",
"String",
"value",
"=",
"null",
";",
"if",
"(",
"scope",
".",
"isInstanceLevel",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"instanceScopeResolver",
")",
"{",
"value",
"=",
"instanceScopeResolver",
".",
"getProperty",
"(",
"name",
")",
";",
"log",
".",
"trace",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\")(I) \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"value",
"||",
"scope",
"==",
"PropertyScope",
".",
"InstanceOnly",
")",
"{",
"log",
".",
"debug",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\") \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"return",
"value",
";",
"}",
"if",
"(",
"scope",
".",
"isProjectLevel",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"projectScopeResolver",
")",
"{",
"value",
"=",
"projectScopeResolver",
".",
"getProperty",
"(",
"name",
")",
";",
"log",
".",
"trace",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\")(P) \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"value",
"||",
"scope",
"==",
"PropertyScope",
".",
"ProjectOnly",
")",
"{",
"log",
".",
"debug",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\") \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"return",
"value",
";",
"}",
"if",
"(",
"null",
"!=",
"frameworkScopeResolver",
")",
"{",
"if",
"(",
"scope",
".",
"isFrameworkLevel",
"(",
")",
")",
"{",
"value",
"=",
"frameworkScopeResolver",
".",
"getProperty",
"(",
"name",
")",
";",
"log",
".",
"trace",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\")(F) \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"}",
"}",
"log",
".",
"debug",
"(",
"\"resolvePropertyValue(\"",
"+",
"scope",
"+",
"\") \"",
"+",
"name",
"+",
"\" = \"",
"+",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Resolve the property value
@throws IllegalArgumentException if the scope is null or {@link PropertyScope#Unspecified}
|
[
"Resolve",
"the",
"property",
"value"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/RuntimePropertyResolver.java#L55-L89
|
16,010
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/steps/node/impl/ScriptURLNodeStepExecutor.java
|
ScriptURLNodeStepExecutor.expandUrlString
|
public static String expandUrlString(
final String urlString,
final MultiDataContext<ContextView, DataContext> dataContext,
final String nodename
)
{
final int qindex = urlString.indexOf('?');
final StringBuilder builder = new StringBuilder();
builder.append(
SharedDataContextUtils.replaceDataReferences(
qindex > 0 ? urlString.substring(0, qindex) : urlString,
dataContext,
ContextView.node(nodename),
ContextView::nodeStep,
urlPathEncoder,
true,
false
));
if (qindex > 0) {
builder.append("?");
if (qindex < urlString.length() - 1) {
builder.append(SharedDataContextUtils.replaceDataReferences(
urlString.substring(qindex + 1),
dataContext,
ContextView.node(nodename),
ContextView::nodeStep,
urlQueryEncoder,
true,
false
));
}
}
return builder.toString();
}
|
java
|
public static String expandUrlString(
final String urlString,
final MultiDataContext<ContextView, DataContext> dataContext,
final String nodename
)
{
final int qindex = urlString.indexOf('?');
final StringBuilder builder = new StringBuilder();
builder.append(
SharedDataContextUtils.replaceDataReferences(
qindex > 0 ? urlString.substring(0, qindex) : urlString,
dataContext,
ContextView.node(nodename),
ContextView::nodeStep,
urlPathEncoder,
true,
false
));
if (qindex > 0) {
builder.append("?");
if (qindex < urlString.length() - 1) {
builder.append(SharedDataContextUtils.replaceDataReferences(
urlString.substring(qindex + 1),
dataContext,
ContextView.node(nodename),
ContextView::nodeStep,
urlQueryEncoder,
true,
false
));
}
}
return builder.toString();
}
|
[
"public",
"static",
"String",
"expandUrlString",
"(",
"final",
"String",
"urlString",
",",
"final",
"MultiDataContext",
"<",
"ContextView",
",",
"DataContext",
">",
"dataContext",
",",
"final",
"String",
"nodename",
")",
"{",
"final",
"int",
"qindex",
"=",
"urlString",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"final",
"StringBuilder",
"builder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"builder",
".",
"append",
"(",
"SharedDataContextUtils",
".",
"replaceDataReferences",
"(",
"qindex",
">",
"0",
"?",
"urlString",
".",
"substring",
"(",
"0",
",",
"qindex",
")",
":",
"urlString",
",",
"dataContext",
",",
"ContextView",
".",
"node",
"(",
"nodename",
")",
",",
"ContextView",
"::",
"nodeStep",
",",
"urlPathEncoder",
",",
"true",
",",
"false",
")",
")",
";",
"if",
"(",
"qindex",
">",
"0",
")",
"{",
"builder",
".",
"append",
"(",
"\"?\"",
")",
";",
"if",
"(",
"qindex",
"<",
"urlString",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"builder",
".",
"append",
"(",
"SharedDataContextUtils",
".",
"replaceDataReferences",
"(",
"urlString",
".",
"substring",
"(",
"qindex",
"+",
"1",
")",
",",
"dataContext",
",",
"ContextView",
".",
"node",
"(",
"nodename",
")",
",",
"ContextView",
"::",
"nodeStep",
",",
"urlQueryEncoder",
",",
"true",
",",
"false",
")",
")",
";",
"}",
"}",
"return",
"builder",
".",
"toString",
"(",
")",
";",
"}"
] |
Expand data references in a URL string, using proper encoding for path and query parts.
@param urlString url
@param dataContext multi context
@param nodename default node context
@return expanded string
|
[
"Expand",
"data",
"references",
"in",
"a",
"URL",
"string",
"using",
"proper",
"encoding",
"for",
"path",
"and",
"query",
"parts",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/steps/node/impl/ScriptURLNodeStepExecutor.java#L235-L271
|
16,011
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-filesys/src/main/java/org/rundeck/storage/data/file/DirectFilepathMapper.java
|
DirectFilepathMapper.withPath
|
private File withPath(Path path, File dir) {
return new File(dir, path.getPath());
}
|
java
|
private File withPath(Path path, File dir) {
return new File(dir, path.getPath());
}
|
[
"private",
"File",
"withPath",
"(",
"Path",
"path",
",",
"File",
"dir",
")",
"{",
"return",
"new",
"File",
"(",
"dir",
",",
"path",
".",
"getPath",
"(",
")",
")",
";",
"}"
] |
file for a given path in the specified subdir
@param path path
@param dir dir
@return file
|
[
"file",
"for",
"a",
"given",
"path",
"in",
"the",
"specified",
"subdir"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-filesys/src/main/java/org/rundeck/storage/data/file/DirectFilepathMapper.java#L48-L50
|
16,012
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/BaseProviderRegistryService.java
|
BaseProviderRegistryService.providerOfType
|
public T providerOfType(final String providerName) throws ExecutionServiceException {
if (null == providerName) {
throw new NullPointerException("provider name was null for Service: " + getName());
}
if (isCacheInstances()) {
if (null == instanceregistry.get(providerName)) {
T instance = createProviderInstanceOfType(providerName);
instanceregistry.put(providerName, instance);
return instance;
}
return instanceregistry.get(providerName);
} else {
return createProviderInstanceOfType(providerName);
}
}
|
java
|
public T providerOfType(final String providerName) throws ExecutionServiceException {
if (null == providerName) {
throw new NullPointerException("provider name was null for Service: " + getName());
}
if (isCacheInstances()) {
if (null == instanceregistry.get(providerName)) {
T instance = createProviderInstanceOfType(providerName);
instanceregistry.put(providerName, instance);
return instance;
}
return instanceregistry.get(providerName);
} else {
return createProviderInstanceOfType(providerName);
}
}
|
[
"public",
"T",
"providerOfType",
"(",
"final",
"String",
"providerName",
")",
"throws",
"ExecutionServiceException",
"{",
"if",
"(",
"null",
"==",
"providerName",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"provider name was null for Service: \"",
"+",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"isCacheInstances",
"(",
")",
")",
"{",
"if",
"(",
"null",
"==",
"instanceregistry",
".",
"get",
"(",
"providerName",
")",
")",
"{",
"T",
"instance",
"=",
"createProviderInstanceOfType",
"(",
"providerName",
")",
";",
"instanceregistry",
".",
"put",
"(",
"providerName",
",",
"instance",
")",
";",
"return",
"instance",
";",
"}",
"return",
"instanceregistry",
".",
"get",
"(",
"providerName",
")",
";",
"}",
"else",
"{",
"return",
"createProviderInstanceOfType",
"(",
"providerName",
")",
";",
"}",
"}"
] |
Return the provider instance of the given name.
|
[
"Return",
"the",
"provider",
"instance",
"of",
"the",
"given",
"name",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/BaseProviderRegistryService.java#L92-L106
|
16,013
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/service/ScriptPluginFileCopier.java
|
ScriptPluginFileCopier.copyFile
|
public String copyFile(final ExecutionContext executionContext, final File file, final INodeEntry node,
final String destination) throws FileCopierException {
return copyFile(executionContext, file, null, null, node, destination);
}
|
java
|
public String copyFile(final ExecutionContext executionContext, final File file, final INodeEntry node,
final String destination) throws FileCopierException {
return copyFile(executionContext, file, null, null, node, destination);
}
|
[
"public",
"String",
"copyFile",
"(",
"final",
"ExecutionContext",
"executionContext",
",",
"final",
"File",
"file",
",",
"final",
"INodeEntry",
"node",
",",
"final",
"String",
"destination",
")",
"throws",
"FileCopierException",
"{",
"return",
"copyFile",
"(",
"executionContext",
",",
"file",
",",
"null",
",",
"null",
",",
"node",
",",
"destination",
")",
";",
"}"
] |
Copy existing file
|
[
"Copy",
"existing",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/service/ScriptPluginFileCopier.java#L95-L98
|
16,014
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/service/ScriptPluginFileCopier.java
|
ScriptPluginFileCopier.copyScriptContent
|
public String copyScriptContent(final ExecutionContext executionContext, final String s,
final INodeEntry node, final String destination) throws
FileCopierException {
return copyFile(executionContext, null, null, s, node, destination);
}
|
java
|
public String copyScriptContent(final ExecutionContext executionContext, final String s,
final INodeEntry node, final String destination) throws
FileCopierException {
return copyFile(executionContext, null, null, s, node, destination);
}
|
[
"public",
"String",
"copyScriptContent",
"(",
"final",
"ExecutionContext",
"executionContext",
",",
"final",
"String",
"s",
",",
"final",
"INodeEntry",
"node",
",",
"final",
"String",
"destination",
")",
"throws",
"FileCopierException",
"{",
"return",
"copyFile",
"(",
"executionContext",
",",
"null",
",",
"null",
",",
"s",
",",
"node",
",",
"destination",
")",
";",
"}"
] |
Copy string content
|
[
"Copy",
"string",
"content"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/service/ScriptPluginFileCopier.java#L103-L107
|
16,015
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/impl/URLFileUpdater.java
|
URLFileUpdater.loadCacheData
|
private Properties loadCacheData(final File cacheFile) {
final Properties cacheProperties = new Properties();
if (cacheFile.isFile()) {
//try to load cache data if present
try {
final FileInputStream fileInputStream = new FileInputStream(cacheFile);
try {
cacheProperties.load(fileInputStream);
} finally {
fileInputStream.close();
}
} catch (IOException e) {
logger.debug("failed to load cache data from file: " + cacheFile);
}
}
return cacheProperties;
}
|
java
|
private Properties loadCacheData(final File cacheFile) {
final Properties cacheProperties = new Properties();
if (cacheFile.isFile()) {
//try to load cache data if present
try {
final FileInputStream fileInputStream = new FileInputStream(cacheFile);
try {
cacheProperties.load(fileInputStream);
} finally {
fileInputStream.close();
}
} catch (IOException e) {
logger.debug("failed to load cache data from file: " + cacheFile);
}
}
return cacheProperties;
}
|
[
"private",
"Properties",
"loadCacheData",
"(",
"final",
"File",
"cacheFile",
")",
"{",
"final",
"Properties",
"cacheProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"cacheFile",
".",
"isFile",
"(",
")",
")",
"{",
"//try to load cache data if present",
"try",
"{",
"final",
"FileInputStream",
"fileInputStream",
"=",
"new",
"FileInputStream",
"(",
"cacheFile",
")",
";",
"try",
"{",
"cacheProperties",
".",
"load",
"(",
"fileInputStream",
")",
";",
"}",
"finally",
"{",
"fileInputStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"debug",
"(",
"\"failed to load cache data from file: \"",
"+",
"cacheFile",
")",
";",
"}",
"}",
"return",
"cacheProperties",
";",
"}"
] |
Load properties file with some cache data
@param cacheFile file
|
[
"Load",
"properties",
"file",
"with",
"some",
"cache",
"data"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/impl/URLFileUpdater.java#L356-L372
|
16,016
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/impl/URLFileUpdater.java
|
URLFileUpdater.cacheResponseInfo
|
private void cacheResponseInfo(final httpClientInteraction method, final File cacheFile) {
//write cache data to file if present
Properties newprops = new Properties();
if (null != method.getResponseHeader(LAST_MODIFIED)) {
newprops.setProperty(LAST_MODIFIED, method.getResponseHeader(LAST_MODIFIED).getValue());
}
if (null != method.getResponseHeader(E_TAG)) {
newprops.setProperty(E_TAG, method.getResponseHeader(E_TAG).getValue());
}
if (null != method.getResponseHeader(CONTENT_TYPE)) {
newprops.setProperty(CONTENT_TYPE, method.getResponseHeader(CONTENT_TYPE).getValue());
}
if (newprops.size() > 0) {
try {
final FileOutputStream fileOutputStream = new FileOutputStream(cacheFile);
try {
newprops.store(fileOutputStream, "URLFileUpdater cache data for URL: "+url);
} finally {
fileOutputStream.close();
}
} catch (IOException e) {
logger.debug(
"Failed to write cache header info to file: " + cacheFile + ", " + e.getMessage(), e);
}
} else if (cacheFile.exists()) {
if(!cacheFile.delete()) {
logger.warn("Unable to delete cachefile: " + cacheFile.getAbsolutePath());
}
}
}
|
java
|
private void cacheResponseInfo(final httpClientInteraction method, final File cacheFile) {
//write cache data to file if present
Properties newprops = new Properties();
if (null != method.getResponseHeader(LAST_MODIFIED)) {
newprops.setProperty(LAST_MODIFIED, method.getResponseHeader(LAST_MODIFIED).getValue());
}
if (null != method.getResponseHeader(E_TAG)) {
newprops.setProperty(E_TAG, method.getResponseHeader(E_TAG).getValue());
}
if (null != method.getResponseHeader(CONTENT_TYPE)) {
newprops.setProperty(CONTENT_TYPE, method.getResponseHeader(CONTENT_TYPE).getValue());
}
if (newprops.size() > 0) {
try {
final FileOutputStream fileOutputStream = new FileOutputStream(cacheFile);
try {
newprops.store(fileOutputStream, "URLFileUpdater cache data for URL: "+url);
} finally {
fileOutputStream.close();
}
} catch (IOException e) {
logger.debug(
"Failed to write cache header info to file: " + cacheFile + ", " + e.getMessage(), e);
}
} else if (cacheFile.exists()) {
if(!cacheFile.delete()) {
logger.warn("Unable to delete cachefile: " + cacheFile.getAbsolutePath());
}
}
}
|
[
"private",
"void",
"cacheResponseInfo",
"(",
"final",
"httpClientInteraction",
"method",
",",
"final",
"File",
"cacheFile",
")",
"{",
"//write cache data to file if present",
"Properties",
"newprops",
"=",
"new",
"Properties",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"method",
".",
"getResponseHeader",
"(",
"LAST_MODIFIED",
")",
")",
"{",
"newprops",
".",
"setProperty",
"(",
"LAST_MODIFIED",
",",
"method",
".",
"getResponseHeader",
"(",
"LAST_MODIFIED",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"method",
".",
"getResponseHeader",
"(",
"E_TAG",
")",
")",
"{",
"newprops",
".",
"setProperty",
"(",
"E_TAG",
",",
"method",
".",
"getResponseHeader",
"(",
"E_TAG",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"method",
".",
"getResponseHeader",
"(",
"CONTENT_TYPE",
")",
")",
"{",
"newprops",
".",
"setProperty",
"(",
"CONTENT_TYPE",
",",
"method",
".",
"getResponseHeader",
"(",
"CONTENT_TYPE",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"newprops",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"try",
"{",
"final",
"FileOutputStream",
"fileOutputStream",
"=",
"new",
"FileOutputStream",
"(",
"cacheFile",
")",
";",
"try",
"{",
"newprops",
".",
"store",
"(",
"fileOutputStream",
",",
"\"URLFileUpdater cache data for URL: \"",
"+",
"url",
")",
";",
"}",
"finally",
"{",
"fileOutputStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Failed to write cache header info to file: \"",
"+",
"cacheFile",
"+",
"\", \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"cacheFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"cacheFile",
".",
"delete",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Unable to delete cachefile: \"",
"+",
"cacheFile",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Cache etag and last-modified header info for a response
|
[
"Cache",
"etag",
"and",
"last",
"-",
"modified",
"header",
"info",
"for",
"a",
"response"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/impl/URLFileUpdater.java#L377-L407
|
16,017
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java
|
ParallelNodeDispatcher.configureNodeContextThreadLocalsForProject
|
public static void configureNodeContextThreadLocalsForProject(final Project project) {
final InheritableThreadLocal<String> localNodeName = new InheritableThreadLocal<>();
final InheritableThreadLocal<String> localUserName = new InheritableThreadLocal<>();
if (null == project.getReference(NODE_NAME_LOCAL_REF_ID)) {
project.addReference(NODE_NAME_LOCAL_REF_ID, localNodeName);
}
if (null == project.getReference(NODE_USER_LOCAL_REF_ID)) {
project.addReference(NODE_USER_LOCAL_REF_ID, localUserName);
}
}
|
java
|
public static void configureNodeContextThreadLocalsForProject(final Project project) {
final InheritableThreadLocal<String> localNodeName = new InheritableThreadLocal<>();
final InheritableThreadLocal<String> localUserName = new InheritableThreadLocal<>();
if (null == project.getReference(NODE_NAME_LOCAL_REF_ID)) {
project.addReference(NODE_NAME_LOCAL_REF_ID, localNodeName);
}
if (null == project.getReference(NODE_USER_LOCAL_REF_ID)) {
project.addReference(NODE_USER_LOCAL_REF_ID, localUserName);
}
}
|
[
"public",
"static",
"void",
"configureNodeContextThreadLocalsForProject",
"(",
"final",
"Project",
"project",
")",
"{",
"final",
"InheritableThreadLocal",
"<",
"String",
">",
"localNodeName",
"=",
"new",
"InheritableThreadLocal",
"<>",
"(",
")",
";",
"final",
"InheritableThreadLocal",
"<",
"String",
">",
"localUserName",
"=",
"new",
"InheritableThreadLocal",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"==",
"project",
".",
"getReference",
"(",
"NODE_NAME_LOCAL_REF_ID",
")",
")",
"{",
"project",
".",
"addReference",
"(",
"NODE_NAME_LOCAL_REF_ID",
",",
"localNodeName",
")",
";",
"}",
"if",
"(",
"null",
"==",
"project",
".",
"getReference",
"(",
"NODE_USER_LOCAL_REF_ID",
")",
")",
"{",
"project",
".",
"addReference",
"(",
"NODE_USER_LOCAL_REF_ID",
",",
"localUserName",
")",
";",
"}",
"}"
] |
Adds InheritableNodeLocal references to the Project for use by the node context tasks
@param project the project
|
[
"Adds",
"InheritableNodeLocal",
"references",
"to",
"the",
"Project",
"for",
"use",
"by",
"the",
"node",
"context",
"tasks"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java#L265-L274
|
16,018
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java
|
ParallelNodeDispatcher.getThreadLocalForProject
|
public static String getThreadLocalForProject(final String nodeNameLocalRefId, final Project project) {
final Object o = project.getReference(nodeNameLocalRefId);
String thrNode = null;
if (null != o && o instanceof InheritableThreadLocal) {
InheritableThreadLocal<String> local = (InheritableThreadLocal<String>) o;
thrNode = local.get();
}
return thrNode;
}
|
java
|
public static String getThreadLocalForProject(final String nodeNameLocalRefId, final Project project) {
final Object o = project.getReference(nodeNameLocalRefId);
String thrNode = null;
if (null != o && o instanceof InheritableThreadLocal) {
InheritableThreadLocal<String> local = (InheritableThreadLocal<String>) o;
thrNode = local.get();
}
return thrNode;
}
|
[
"public",
"static",
"String",
"getThreadLocalForProject",
"(",
"final",
"String",
"nodeNameLocalRefId",
",",
"final",
"Project",
"project",
")",
"{",
"final",
"Object",
"o",
"=",
"project",
".",
"getReference",
"(",
"nodeNameLocalRefId",
")",
";",
"String",
"thrNode",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"o",
"&&",
"o",
"instanceof",
"InheritableThreadLocal",
")",
"{",
"InheritableThreadLocal",
"<",
"String",
">",
"local",
"=",
"(",
"InheritableThreadLocal",
"<",
"String",
">",
")",
"o",
";",
"thrNode",
"=",
"local",
".",
"get",
"(",
")",
";",
"}",
"return",
"thrNode",
";",
"}"
] |
Extract the threadlocal stored as a reference in the project, and return the string value or null.
@param nodeNameLocalRefId refid for the thread local variable
@param project Project
@return value of the variable, or null if it is not found or the refid doesn't refer to a valid thread local
|
[
"Extract",
"the",
"threadlocal",
"stored",
"as",
"a",
"reference",
"in",
"the",
"project",
"and",
"return",
"the",
"string",
"value",
"or",
"null",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java#L284-L292
|
16,019
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java
|
ParallelNodeDispatcher.addNodeContextTasks
|
public static void addNodeContextTasks(final INodeEntry nodeentry, final Project project,
final Sequential seq) {
//set thread local node name
final Task nodenamelocal = genSetThreadLocalRefValue(NODE_NAME_LOCAL_REF_ID, nodeentry.getNodename());
nodenamelocal.setProject(project);
seq.addTask(nodenamelocal);
if (null != nodeentry.extractUserName()) {
//set thread local username
final Task userlocal = genSetThreadLocalRefValue(NODE_USER_LOCAL_REF_ID, nodeentry.extractUserName());
userlocal.setProject(project);
seq.addTask(userlocal);
}
}
|
java
|
public static void addNodeContextTasks(final INodeEntry nodeentry, final Project project,
final Sequential seq) {
//set thread local node name
final Task nodenamelocal = genSetThreadLocalRefValue(NODE_NAME_LOCAL_REF_ID, nodeentry.getNodename());
nodenamelocal.setProject(project);
seq.addTask(nodenamelocal);
if (null != nodeentry.extractUserName()) {
//set thread local username
final Task userlocal = genSetThreadLocalRefValue(NODE_USER_LOCAL_REF_ID, nodeentry.extractUserName());
userlocal.setProject(project);
seq.addTask(userlocal);
}
}
|
[
"public",
"static",
"void",
"addNodeContextTasks",
"(",
"final",
"INodeEntry",
"nodeentry",
",",
"final",
"Project",
"project",
",",
"final",
"Sequential",
"seq",
")",
"{",
"//set thread local node name",
"final",
"Task",
"nodenamelocal",
"=",
"genSetThreadLocalRefValue",
"(",
"NODE_NAME_LOCAL_REF_ID",
",",
"nodeentry",
".",
"getNodename",
"(",
")",
")",
";",
"nodenamelocal",
".",
"setProject",
"(",
"project",
")",
";",
"seq",
".",
"addTask",
"(",
"nodenamelocal",
")",
";",
"if",
"(",
"null",
"!=",
"nodeentry",
".",
"extractUserName",
"(",
")",
")",
"{",
"//set thread local username",
"final",
"Task",
"userlocal",
"=",
"genSetThreadLocalRefValue",
"(",
"NODE_USER_LOCAL_REF_ID",
",",
"nodeentry",
".",
"extractUserName",
"(",
")",
")",
";",
"userlocal",
".",
"setProject",
"(",
"project",
")",
";",
"seq",
".",
"addTask",
"(",
"userlocal",
")",
";",
"}",
"}"
] |
Add tasks to the Sequential to set threadlocal values for the node name and username
@param nodeentry node entry
@param project ant Project
@param seq Sequential
|
[
"Add",
"tasks",
"to",
"the",
"Sequential",
"to",
"set",
"threadlocal",
"values",
"for",
"the",
"node",
"name",
"and",
"username"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java#L301-L315
|
16,020
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java
|
ParallelNodeDispatcher.genSetThreadLocalRefValue
|
private static Task genSetThreadLocalRefValue(final String refid, final String value) {
final SetThreadLocalTask task = new SetThreadLocalTask();
task.setRefid(refid);
task.setValue(value);
return task;
}
|
java
|
private static Task genSetThreadLocalRefValue(final String refid, final String value) {
final SetThreadLocalTask task = new SetThreadLocalTask();
task.setRefid(refid);
task.setValue(value);
return task;
}
|
[
"private",
"static",
"Task",
"genSetThreadLocalRefValue",
"(",
"final",
"String",
"refid",
",",
"final",
"String",
"value",
")",
"{",
"final",
"SetThreadLocalTask",
"task",
"=",
"new",
"SetThreadLocalTask",
"(",
")",
";",
"task",
".",
"setRefid",
"(",
"refid",
")",
";",
"task",
".",
"setValue",
"(",
"value",
")",
";",
"return",
"task",
";",
"}"
] |
Return a task configured to set the thread local value for a particular refid
@param refid the refid
@param value the value to set
@return the Task
|
[
"Return",
"a",
"task",
"configured",
"to",
"set",
"the",
"thread",
"local",
"value",
"for",
"a",
"particular",
"refid"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/dispatch/ParallelNodeDispatcher.java#L325-L330
|
16,021
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FormattedOutputStream.java
|
FormattedOutputStream.formatMessage
|
private String formatMessage(final String message) {
if (null != reformatter) {
return reformatter.reformat(context, message);
} else {
return message;
}
}
|
java
|
private String formatMessage(final String message) {
if (null != reformatter) {
return reformatter.reformat(context, message);
} else {
return message;
}
}
|
[
"private",
"String",
"formatMessage",
"(",
"final",
"String",
"message",
")",
"{",
"if",
"(",
"null",
"!=",
"reformatter",
")",
"{",
"return",
"reformatter",
".",
"reformat",
"(",
"context",
",",
"message",
")",
";",
"}",
"else",
"{",
"return",
"message",
";",
"}",
"}"
] |
Return the reformatted message, or the original if no reformatter is specified.
@param message input message
@return reformatted result
|
[
"Return",
"the",
"reformatted",
"message",
"or",
"the",
"original",
"if",
"no",
"reformatter",
"is",
"specified",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FormattedOutputStream.java#L65-L71
|
16,022
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FormattedOutputStream.java
|
FormattedOutputStream.writeBufferedData
|
private void writeBufferedData() throws IOException {
if (buffer.length() > 0) {
out.write(formatMessage(buffer.toString()).getBytes());
out.write('\n');
buffer = new StringBuffer();
}
}
|
java
|
private void writeBufferedData() throws IOException {
if (buffer.length() > 0) {
out.write(formatMessage(buffer.toString()).getBytes());
out.write('\n');
buffer = new StringBuffer();
}
}
|
[
"private",
"void",
"writeBufferedData",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"buffer",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"out",
".",
"write",
"(",
"formatMessage",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
".",
"getBytes",
"(",
")",
")",
";",
"out",
".",
"write",
"(",
"'",
"'",
")",
";",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"}",
"}"
] |
If the buffer has content, then reformat and write the content to the output stream.
@throws IOException
|
[
"If",
"the",
"buffer",
"has",
"content",
"then",
"reformat",
"and",
"write",
"the",
"content",
"to",
"the",
"output",
"stream",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FormattedOutputStream.java#L92-L98
|
16,023
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java
|
ProjectNodeSupport.getNodeSet
|
@Override
public INodeSet getNodeSet() {
//iterate through sources, and add nodes
final NodeSetMerge list = getNodeSetMerge();
Map<String,Exception> exceptions = Collections.synchronizedMap(new HashMap<>());
int index=1;
nodesSourceExceptions.clear();
for (final ResourceModelSource nodesSource : getResourceModelSourcesInternal()) {
try {
INodeSet nodes = nodesSource.getNodes();
if (null == nodes) {
logger.warn("Empty nodes result from [" + nodesSource.toString() + "]");
} else {
list.addNodeSet(nodes);
}
if(nodesSource instanceof ResourceModelSourceErrors){
ResourceModelSourceErrors nodeerrors = (ResourceModelSourceErrors) nodesSource;
List<String> modelSourceErrors = nodeerrors.getModelSourceErrors();
if(modelSourceErrors!=null && modelSourceErrors.size()>0){
logger.error("Some errors getting nodes from [" +
nodesSource.toString() +
"]: " +
modelSourceErrors);
exceptions.put(
index + ".source",
new ResourceModelSourceException(
TextUtils.join(
modelSourceErrors.toArray(new String[0]),
';'
)
)
);
}
}
} catch (ResourceModelSourceException | RuntimeException e) {
logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage());
logger.debug("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e);
exceptions.put(
index+".source",
new ResourceModelSourceException(
e.getMessage(), e
)
);
} catch (Throwable e) {
logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage());
logger.debug("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e);
exceptions.put(
index+".source",
new ResourceModelSourceException(
e.getMessage()
)
);
}
index++;
}
synchronized (nodesSourceExceptions){
nodesSourceExceptions.putAll(exceptions);
}
return list;
}
|
java
|
@Override
public INodeSet getNodeSet() {
//iterate through sources, and add nodes
final NodeSetMerge list = getNodeSetMerge();
Map<String,Exception> exceptions = Collections.synchronizedMap(new HashMap<>());
int index=1;
nodesSourceExceptions.clear();
for (final ResourceModelSource nodesSource : getResourceModelSourcesInternal()) {
try {
INodeSet nodes = nodesSource.getNodes();
if (null == nodes) {
logger.warn("Empty nodes result from [" + nodesSource.toString() + "]");
} else {
list.addNodeSet(nodes);
}
if(nodesSource instanceof ResourceModelSourceErrors){
ResourceModelSourceErrors nodeerrors = (ResourceModelSourceErrors) nodesSource;
List<String> modelSourceErrors = nodeerrors.getModelSourceErrors();
if(modelSourceErrors!=null && modelSourceErrors.size()>0){
logger.error("Some errors getting nodes from [" +
nodesSource.toString() +
"]: " +
modelSourceErrors);
exceptions.put(
index + ".source",
new ResourceModelSourceException(
TextUtils.join(
modelSourceErrors.toArray(new String[0]),
';'
)
)
);
}
}
} catch (ResourceModelSourceException | RuntimeException e) {
logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage());
logger.debug("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e);
exceptions.put(
index+".source",
new ResourceModelSourceException(
e.getMessage(), e
)
);
} catch (Throwable e) {
logger.error("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage());
logger.debug("Cannot get nodes from [" + nodesSource.toString() + "]: " + e.getMessage(), e);
exceptions.put(
index+".source",
new ResourceModelSourceException(
e.getMessage()
)
);
}
index++;
}
synchronized (nodesSourceExceptions){
nodesSourceExceptions.putAll(exceptions);
}
return list;
}
|
[
"@",
"Override",
"public",
"INodeSet",
"getNodeSet",
"(",
")",
"{",
"//iterate through sources, and add nodes",
"final",
"NodeSetMerge",
"list",
"=",
"getNodeSetMerge",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Exception",
">",
"exceptions",
"=",
"Collections",
".",
"synchronizedMap",
"(",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"int",
"index",
"=",
"1",
";",
"nodesSourceExceptions",
".",
"clear",
"(",
")",
";",
"for",
"(",
"final",
"ResourceModelSource",
"nodesSource",
":",
"getResourceModelSourcesInternal",
"(",
")",
")",
"{",
"try",
"{",
"INodeSet",
"nodes",
"=",
"nodesSource",
".",
"getNodes",
"(",
")",
";",
"if",
"(",
"null",
"==",
"nodes",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Empty nodes result from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"else",
"{",
"list",
".",
"addNodeSet",
"(",
"nodes",
")",
";",
"}",
"if",
"(",
"nodesSource",
"instanceof",
"ResourceModelSourceErrors",
")",
"{",
"ResourceModelSourceErrors",
"nodeerrors",
"=",
"(",
"ResourceModelSourceErrors",
")",
"nodesSource",
";",
"List",
"<",
"String",
">",
"modelSourceErrors",
"=",
"nodeerrors",
".",
"getModelSourceErrors",
"(",
")",
";",
"if",
"(",
"modelSourceErrors",
"!=",
"null",
"&&",
"modelSourceErrors",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"logger",
".",
"error",
"(",
"\"Some errors getting nodes from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]: \"",
"+",
"modelSourceErrors",
")",
";",
"exceptions",
".",
"put",
"(",
"index",
"+",
"\".source\"",
",",
"new",
"ResourceModelSourceException",
"(",
"TextUtils",
".",
"join",
"(",
"modelSourceErrors",
".",
"toArray",
"(",
"new",
"String",
"[",
"0",
"]",
")",
",",
"'",
"'",
")",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"ResourceModelSourceException",
"|",
"RuntimeException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Cannot get nodes from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Cannot get nodes from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"exceptions",
".",
"put",
"(",
"index",
"+",
"\".source\"",
",",
"new",
"ResourceModelSourceException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Cannot get nodes from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"Cannot get nodes from [\"",
"+",
"nodesSource",
".",
"toString",
"(",
")",
"+",
"\"]: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"exceptions",
".",
"put",
"(",
"index",
"+",
"\".source\"",
",",
"new",
"ResourceModelSourceException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"index",
"++",
";",
"}",
"synchronized",
"(",
"nodesSourceExceptions",
")",
"{",
"nodesSourceExceptions",
".",
"putAll",
"(",
"exceptions",
")",
";",
"}",
"return",
"list",
";",
"}"
] |
Returns the set of nodes for the project
@return an instance of {@link INodeSet}
|
[
"Returns",
"the",
"set",
"of",
"nodes",
"for",
"the",
"project"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java#L126-L188
|
16,024
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java
|
ProjectNodeSupport.unloadSources
|
private synchronized void unloadSources() {
nodesSourceList = new ArrayList<>();
Closeables.closeQuietly(nodeSourceReferences);
nodeSourceReferences = new HashSet<>();
sourcesOpened = false;
}
|
java
|
private synchronized void unloadSources() {
nodesSourceList = new ArrayList<>();
Closeables.closeQuietly(nodeSourceReferences);
nodeSourceReferences = new HashSet<>();
sourcesOpened = false;
}
|
[
"private",
"synchronized",
"void",
"unloadSources",
"(",
")",
"{",
"nodesSourceList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Closeables",
".",
"closeQuietly",
"(",
"nodeSourceReferences",
")",
";",
"nodeSourceReferences",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"sourcesOpened",
"=",
"false",
";",
"}"
] |
Clear the sources list and close all plugin loader references
|
[
"Clear",
"the",
"sources",
"list",
"and",
"close",
"all",
"plugin",
"loader",
"references"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java#L255-L260
|
16,025
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java
|
ProjectNodeSupport.listNodeEnhancerConfigurations
|
@Override
public synchronized List<ExtPluginConfiguration> listNodeEnhancerConfigurations() {
return listPluginConfigurations(
projectConfig.getProjectProperties(),
NODE_ENHANCER_PROP_PREFIX,
ServiceNameConstants.NodeEnhancer
);
}
|
java
|
@Override
public synchronized List<ExtPluginConfiguration> listNodeEnhancerConfigurations() {
return listPluginConfigurations(
projectConfig.getProjectProperties(),
NODE_ENHANCER_PROP_PREFIX,
ServiceNameConstants.NodeEnhancer
);
}
|
[
"@",
"Override",
"public",
"synchronized",
"List",
"<",
"ExtPluginConfiguration",
">",
"listNodeEnhancerConfigurations",
"(",
")",
"{",
"return",
"listPluginConfigurations",
"(",
"projectConfig",
".",
"getProjectProperties",
"(",
")",
",",
"NODE_ENHANCER_PROP_PREFIX",
",",
"ServiceNameConstants",
".",
"NodeEnhancer",
")",
";",
"}"
] |
list the configurations of node enhancer providers.
@return a list of PluginConfiguration
|
[
"list",
"the",
"configurations",
"of",
"node",
"enhancer",
"providers",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/ProjectNodeSupport.java#L555-L562
|
16,026
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.addNode
|
public void addNode(final INodeEntry node) {
//convert to entity
final ResourceXMLParser.Entity entity = createEntity(node);
addEntity(entity);
}
|
java
|
public void addNode(final INodeEntry node) {
//convert to entity
final ResourceXMLParser.Entity entity = createEntity(node);
addEntity(entity);
}
|
[
"public",
"void",
"addNode",
"(",
"final",
"INodeEntry",
"node",
")",
"{",
"//convert to entity",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
"=",
"createEntity",
"(",
"node",
")",
";",
"addEntity",
"(",
"entity",
")",
";",
"}"
] |
Add Node object
@param node node
|
[
"Add",
"Node",
"object"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L103-L107
|
16,027
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.createEntity
|
private ResourceXMLParser.Entity createEntity(final INodeEntry node) {
final ResourceXMLParser.Entity ent = new ResourceXMLParser.Entity();
ent.setName(node.getNodename());
ent.setResourceType(NODE_ENTITY_TAG);
if(null!=node.getAttributes()){
for (final String setName : node.getAttributes().keySet()) {
String value = node.getAttributes().get(setName);
ent.setProperty(setName, value);
}
}
if(null!=node.getTags()){
ent.setProperty("tags", joinStrings(node.getTags(), ", "));
}
return ent;
}
|
java
|
private ResourceXMLParser.Entity createEntity(final INodeEntry node) {
final ResourceXMLParser.Entity ent = new ResourceXMLParser.Entity();
ent.setName(node.getNodename());
ent.setResourceType(NODE_ENTITY_TAG);
if(null!=node.getAttributes()){
for (final String setName : node.getAttributes().keySet()) {
String value = node.getAttributes().get(setName);
ent.setProperty(setName, value);
}
}
if(null!=node.getTags()){
ent.setProperty("tags", joinStrings(node.getTags(), ", "));
}
return ent;
}
|
[
"private",
"ResourceXMLParser",
".",
"Entity",
"createEntity",
"(",
"final",
"INodeEntry",
"node",
")",
"{",
"final",
"ResourceXMLParser",
".",
"Entity",
"ent",
"=",
"new",
"ResourceXMLParser",
".",
"Entity",
"(",
")",
";",
"ent",
".",
"setName",
"(",
"node",
".",
"getNodename",
"(",
")",
")",
";",
"ent",
".",
"setResourceType",
"(",
"NODE_ENTITY_TAG",
")",
";",
"if",
"(",
"null",
"!=",
"node",
".",
"getAttributes",
"(",
")",
")",
"{",
"for",
"(",
"final",
"String",
"setName",
":",
"node",
".",
"getAttributes",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"String",
"value",
"=",
"node",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"setName",
")",
";",
"ent",
".",
"setProperty",
"(",
"setName",
",",
"value",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"node",
".",
"getTags",
"(",
")",
")",
"{",
"ent",
".",
"setProperty",
"(",
"\"tags\"",
",",
"joinStrings",
"(",
"node",
".",
"getTags",
"(",
")",
",",
"\", \"",
")",
")",
";",
"}",
"return",
"ent",
";",
"}"
] |
Create entity from Node
@param node node
@return entity
|
[
"Create",
"entity",
"from",
"Node"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L122-L141
|
16,028
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.joinStrings
|
private static String joinStrings(final Set tags, final String delim) {
ArrayList<String> strings = new ArrayList<String>(tags);
String[] objects = strings.toArray(new String[strings.size()]);
Arrays.sort(objects);
final StringBuffer sb = new StringBuffer();
for (final String tag : objects) {
if (sb.length() > 0) {
sb.append(delim);
}
sb.append(tag);
}
return sb.toString();
}
|
java
|
private static String joinStrings(final Set tags, final String delim) {
ArrayList<String> strings = new ArrayList<String>(tags);
String[] objects = strings.toArray(new String[strings.size()]);
Arrays.sort(objects);
final StringBuffer sb = new StringBuffer();
for (final String tag : objects) {
if (sb.length() > 0) {
sb.append(delim);
}
sb.append(tag);
}
return sb.toString();
}
|
[
"private",
"static",
"String",
"joinStrings",
"(",
"final",
"Set",
"tags",
",",
"final",
"String",
"delim",
")",
"{",
"ArrayList",
"<",
"String",
">",
"strings",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"tags",
")",
";",
"String",
"[",
"]",
"objects",
"=",
"strings",
".",
"toArray",
"(",
"new",
"String",
"[",
"strings",
".",
"size",
"(",
")",
"]",
")",
";",
"Arrays",
".",
"sort",
"(",
"objects",
")",
";",
"final",
"StringBuffer",
"sb",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"for",
"(",
"final",
"String",
"tag",
":",
"objects",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"delim",
")",
";",
"}",
"sb",
".",
"append",
"(",
"tag",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
utility to join tags into string
@param tags tags set
@param delim delimiter string
@return joined string
|
[
"utility",
"to",
"join",
"tags",
"into",
"string"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L151-L164
|
16,029
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.generate
|
public void generate() throws IOException {
final Document doc = DocumentFactory.getInstance().createDocument();
final Element root = doc.addElement("project");
//iterate through entities in correct order
for (final ResourceXMLParser.Entity entity : entities) {
if (NODE_ENTITY_TAG.equals(entity.getResourceType())) {
final Element ent = genEntityCommon(root, entity);
genNode(ent, entity);
}
}
if (null != file) {
FileOutputStream out=new FileOutputStream(file);
try{
serializeDocToStream(out, doc);
}finally{
out.close();
}
} else if (null != output) {
serializeDocToStream(output, doc);
}
}
|
java
|
public void generate() throws IOException {
final Document doc = DocumentFactory.getInstance().createDocument();
final Element root = doc.addElement("project");
//iterate through entities in correct order
for (final ResourceXMLParser.Entity entity : entities) {
if (NODE_ENTITY_TAG.equals(entity.getResourceType())) {
final Element ent = genEntityCommon(root, entity);
genNode(ent, entity);
}
}
if (null != file) {
FileOutputStream out=new FileOutputStream(file);
try{
serializeDocToStream(out, doc);
}finally{
out.close();
}
} else if (null != output) {
serializeDocToStream(output, doc);
}
}
|
[
"public",
"void",
"generate",
"(",
")",
"throws",
"IOException",
"{",
"final",
"Document",
"doc",
"=",
"DocumentFactory",
".",
"getInstance",
"(",
")",
".",
"createDocument",
"(",
")",
";",
"final",
"Element",
"root",
"=",
"doc",
".",
"addElement",
"(",
"\"project\"",
")",
";",
"//iterate through entities in correct order",
"for",
"(",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
":",
"entities",
")",
"{",
"if",
"(",
"NODE_ENTITY_TAG",
".",
"equals",
"(",
"entity",
".",
"getResourceType",
"(",
")",
")",
")",
"{",
"final",
"Element",
"ent",
"=",
"genEntityCommon",
"(",
"root",
",",
"entity",
")",
";",
"genNode",
"(",
"ent",
",",
"entity",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"file",
")",
"{",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"try",
"{",
"serializeDocToStream",
"(",
"out",
",",
"doc",
")",
";",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"null",
"!=",
"output",
")",
"{",
"serializeDocToStream",
"(",
"output",
",",
"doc",
")",
";",
"}",
"}"
] |
Generate and store the XML file
@throws IOException on error
|
[
"Generate",
"and",
"store",
"the",
"XML",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L171-L192
|
16,030
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.genAttributes
|
private void genAttributes(final Element ent, final ResourceXMLParser.Entity entity) {
if (null == entity.getProperties() ) {
return;
}
for (final String key:entity.getProperties().stringPropertyNames()){
if (!ResourceXMLConstants.allPropSet.contains(key)) {
//test attribute name is a valid XML attribute name
if (isValidName(key)) {
ent.addAttribute(key, entity.getProperties().getProperty(key));
} else {
//add sub element
final Element atelm = ent.addElement(ATTRIBUTE_TAG);
atelm.addAttribute(ATTRIBUTE_NAME_ATTR, key);
atelm.addAttribute(ATTRIBUTE_VALUE_ATTR, entity.getProperties().getProperty(key));
}
}
}
}
|
java
|
private void genAttributes(final Element ent, final ResourceXMLParser.Entity entity) {
if (null == entity.getProperties() ) {
return;
}
for (final String key:entity.getProperties().stringPropertyNames()){
if (!ResourceXMLConstants.allPropSet.contains(key)) {
//test attribute name is a valid XML attribute name
if (isValidName(key)) {
ent.addAttribute(key, entity.getProperties().getProperty(key));
} else {
//add sub element
final Element atelm = ent.addElement(ATTRIBUTE_TAG);
atelm.addAttribute(ATTRIBUTE_NAME_ATTR, key);
atelm.addAttribute(ATTRIBUTE_VALUE_ATTR, entity.getProperties().getProperty(key));
}
}
}
}
|
[
"private",
"void",
"genAttributes",
"(",
"final",
"Element",
"ent",
",",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
")",
"{",
"if",
"(",
"null",
"==",
"entity",
".",
"getProperties",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"final",
"String",
"key",
":",
"entity",
".",
"getProperties",
"(",
")",
".",
"stringPropertyNames",
"(",
")",
")",
"{",
"if",
"(",
"!",
"ResourceXMLConstants",
".",
"allPropSet",
".",
"contains",
"(",
"key",
")",
")",
"{",
"//test attribute name is a valid XML attribute name",
"if",
"(",
"isValidName",
"(",
"key",
")",
")",
"{",
"ent",
".",
"addAttribute",
"(",
"key",
",",
"entity",
".",
"getProperties",
"(",
")",
".",
"getProperty",
"(",
"key",
")",
")",
";",
"}",
"else",
"{",
"//add sub element",
"final",
"Element",
"atelm",
"=",
"ent",
".",
"addElement",
"(",
"ATTRIBUTE_TAG",
")",
";",
"atelm",
".",
"addAttribute",
"(",
"ATTRIBUTE_NAME_ATTR",
",",
"key",
")",
";",
"atelm",
".",
"addAttribute",
"(",
"ATTRIBUTE_VALUE_ATTR",
",",
"entity",
".",
"getProperties",
"(",
")",
".",
"getProperty",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Generate resources section and resource references
@param ent element
@param entity entity
|
[
"Generate",
"resources",
"section",
"and",
"resource",
"references"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L200-L218
|
16,031
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.genNode
|
private void genNode(final Element ent, final ResourceXMLParser.Entity entity) {
for (final String nodeProp : nodeProps) {
ent.addAttribute(nodeProp, notNull(entity.getProperty(nodeProp)));
}
genAttributes(ent, entity);
}
|
java
|
private void genNode(final Element ent, final ResourceXMLParser.Entity entity) {
for (final String nodeProp : nodeProps) {
ent.addAttribute(nodeProp, notNull(entity.getProperty(nodeProp)));
}
genAttributes(ent, entity);
}
|
[
"private",
"void",
"genNode",
"(",
"final",
"Element",
"ent",
",",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
")",
"{",
"for",
"(",
"final",
"String",
"nodeProp",
":",
"nodeProps",
")",
"{",
"ent",
".",
"addAttribute",
"(",
"nodeProp",
",",
"notNull",
"(",
"entity",
".",
"getProperty",
"(",
"nodeProp",
")",
")",
")",
";",
"}",
"genAttributes",
"(",
"ent",
",",
"entity",
")",
";",
"}"
] |
Gen "node" tag contents
@param ent element
@param entity entity
|
[
"Gen",
"node",
"tag",
"contents"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L253-L258
|
16,032
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.genEntityCommon
|
private Element genEntityCommon(final Element root, final ResourceXMLParser.Entity entity) {
final Element tag = root.addElement(entity.getResourceType());
tag.addAttribute(COMMON_NAME, entity.getName());
tag.addAttribute(COMMON_DESCRIPTION, notNull(entity.getProperty(COMMON_DESCRIPTION)));
tag.addAttribute(COMMON_TAGS, notNull(entity.getProperty(COMMON_TAGS)));
return tag;
}
|
java
|
private Element genEntityCommon(final Element root, final ResourceXMLParser.Entity entity) {
final Element tag = root.addElement(entity.getResourceType());
tag.addAttribute(COMMON_NAME, entity.getName());
tag.addAttribute(COMMON_DESCRIPTION, notNull(entity.getProperty(COMMON_DESCRIPTION)));
tag.addAttribute(COMMON_TAGS, notNull(entity.getProperty(COMMON_TAGS)));
return tag;
}
|
[
"private",
"Element",
"genEntityCommon",
"(",
"final",
"Element",
"root",
",",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
")",
"{",
"final",
"Element",
"tag",
"=",
"root",
".",
"addElement",
"(",
"entity",
".",
"getResourceType",
"(",
")",
")",
";",
"tag",
".",
"addAttribute",
"(",
"COMMON_NAME",
",",
"entity",
".",
"getName",
"(",
")",
")",
";",
"tag",
".",
"addAttribute",
"(",
"COMMON_DESCRIPTION",
",",
"notNull",
"(",
"entity",
".",
"getProperty",
"(",
"COMMON_DESCRIPTION",
")",
")",
")",
";",
"tag",
".",
"addAttribute",
"(",
"COMMON_TAGS",
",",
"notNull",
"(",
"entity",
".",
"getProperty",
"(",
"COMMON_TAGS",
")",
")",
")",
";",
"return",
"tag",
";",
"}"
] |
Create entity tag based on resourceType of entity, and add common attributes
@param root element
@param entity entity
@return element
|
[
"Create",
"entity",
"tag",
"based",
"on",
"resourceType",
"of",
"entity",
"and",
"add",
"common",
"attributes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L271-L277
|
16,033
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java
|
ResourceXMLGenerator.serializeDocToStream
|
private static void serializeDocToStream(final OutputStream output, final Document doc) throws IOException {
final OutputFormat format = OutputFormat.createPrettyPrint();
final XMLWriter writer = new XMLWriter(output, format);
writer.write(doc);
writer.flush();
}
|
java
|
private static void serializeDocToStream(final OutputStream output, final Document doc) throws IOException {
final OutputFormat format = OutputFormat.createPrettyPrint();
final XMLWriter writer = new XMLWriter(output, format);
writer.write(doc);
writer.flush();
}
|
[
"private",
"static",
"void",
"serializeDocToStream",
"(",
"final",
"OutputStream",
"output",
",",
"final",
"Document",
"doc",
")",
"throws",
"IOException",
"{",
"final",
"OutputFormat",
"format",
"=",
"OutputFormat",
".",
"createPrettyPrint",
"(",
")",
";",
"final",
"XMLWriter",
"writer",
"=",
"new",
"XMLWriter",
"(",
"output",
",",
"format",
")",
";",
"writer",
".",
"write",
"(",
"doc",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"}"
] |
Write Document to a file
@param output stream
@param doc document
@throws IOException on error
|
[
"Write",
"Document",
"to",
"a",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/shared/resources/ResourceXMLGenerator.java#L300-L305
|
16,034
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundOutputStream.java
|
ThreadBoundOutputStream.removeThreadStream
|
public OutputStream removeThreadStream() {
final OutputStream orig = inheritOutputStream.get();
inheritOutputStream.set(null);
return orig;
}
|
java
|
public OutputStream removeThreadStream() {
final OutputStream orig = inheritOutputStream.get();
inheritOutputStream.set(null);
return orig;
}
|
[
"public",
"OutputStream",
"removeThreadStream",
"(",
")",
"{",
"final",
"OutputStream",
"orig",
"=",
"inheritOutputStream",
".",
"get",
"(",
")",
";",
"inheritOutputStream",
".",
"set",
"(",
"null",
")",
";",
"return",
"orig",
";",
"}"
] |
Remove the custom stream for the current thread.
@return thread bound OutputStream or null if none exists
|
[
"Remove",
"the",
"custom",
"stream",
"for",
"the",
"current",
"thread",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundOutputStream.java#L98-L102
|
16,035
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.errorReport
|
public static Report errorReport(String key, String message) {
return buildReport().error(key, message).build();
}
|
java
|
public static Report errorReport(String key, String message) {
return buildReport().error(key, message).build();
}
|
[
"public",
"static",
"Report",
"errorReport",
"(",
"String",
"key",
",",
"String",
"message",
")",
"{",
"return",
"buildReport",
"(",
")",
".",
"error",
"(",
"key",
",",
"message",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Return a report for a single error item
@param key key
@param message message
@return report
|
[
"Return",
"a",
"report",
"for",
"a",
"single",
"error",
"item"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L41-L43
|
16,036
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.validate
|
private static void validate(Properties props, Report report, List<Property> properties, PropertyScope ignoredScope) {
if(null!=properties){
for (final Property property : properties) {
if (null != ignoredScope && property.getScope() != null
&& property.getScope().compareTo(ignoredScope) <= 0) {
continue;
}
final String key = property.getName();
final String value = props.getProperty(key);
if (null == value || "".equals(value)) {
if (property.isRequired()) {
report.errors.put(key, "required");
continue;
}
} else {
//try to validate
final PropertyValidator validator = property.getValidator();
if (null != validator) {
try {
if (!validator.isValid(value)) {
report.errors.put(key, "Invalid value: " + value);
}
} catch (ValidationException e) {
report.errors.put(key, "Invalid value: " + e.getMessage());
}
}
}
}
}
}
|
java
|
private static void validate(Properties props, Report report, List<Property> properties, PropertyScope ignoredScope) {
if(null!=properties){
for (final Property property : properties) {
if (null != ignoredScope && property.getScope() != null
&& property.getScope().compareTo(ignoredScope) <= 0) {
continue;
}
final String key = property.getName();
final String value = props.getProperty(key);
if (null == value || "".equals(value)) {
if (property.isRequired()) {
report.errors.put(key, "required");
continue;
}
} else {
//try to validate
final PropertyValidator validator = property.getValidator();
if (null != validator) {
try {
if (!validator.isValid(value)) {
report.errors.put(key, "Invalid value: " + value);
}
} catch (ValidationException e) {
report.errors.put(key, "Invalid value: " + e.getMessage());
}
}
}
}
}
}
|
[
"private",
"static",
"void",
"validate",
"(",
"Properties",
"props",
",",
"Report",
"report",
",",
"List",
"<",
"Property",
">",
"properties",
",",
"PropertyScope",
"ignoredScope",
")",
"{",
"if",
"(",
"null",
"!=",
"properties",
")",
"{",
"for",
"(",
"final",
"Property",
"property",
":",
"properties",
")",
"{",
"if",
"(",
"null",
"!=",
"ignoredScope",
"&&",
"property",
".",
"getScope",
"(",
")",
"!=",
"null",
"&&",
"property",
".",
"getScope",
"(",
")",
".",
"compareTo",
"(",
"ignoredScope",
")",
"<=",
"0",
")",
"{",
"continue",
";",
"}",
"final",
"String",
"key",
"=",
"property",
".",
"getName",
"(",
")",
";",
"final",
"String",
"value",
"=",
"props",
".",
"getProperty",
"(",
"key",
")",
";",
"if",
"(",
"null",
"==",
"value",
"||",
"\"\"",
".",
"equals",
"(",
"value",
")",
")",
"{",
"if",
"(",
"property",
".",
"isRequired",
"(",
")",
")",
"{",
"report",
".",
"errors",
".",
"put",
"(",
"key",
",",
"\"required\"",
")",
";",
"continue",
";",
"}",
"}",
"else",
"{",
"//try to validate",
"final",
"PropertyValidator",
"validator",
"=",
"property",
".",
"getValidator",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"validator",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"validator",
".",
"isValid",
"(",
"value",
")",
")",
"{",
"report",
".",
"errors",
".",
"put",
"(",
"key",
",",
"\"Invalid value: \"",
"+",
"value",
")",
";",
"}",
"}",
"catch",
"(",
"ValidationException",
"e",
")",
"{",
"report",
".",
"errors",
".",
"put",
"(",
"key",
",",
"\"Invalid value: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] |
Validate, ignoring properties below a scope, if set
@param props input properties
@param report report
@param properties property definitions
@param ignoredScope ignore scope
|
[
"Validate",
"ignoring",
"properties",
"below",
"a",
"scope",
"if",
"set"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L136-L165
|
16,037
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.mapProperties
|
public static Map<String, String> mapProperties(final Map<String, String> input, final Description desc) {
final Map<String, String> mapping = desc.getPropertiesMapping();
if (null == mapping) {
return input;
}
return performMapping(input, mapping, false);
}
|
java
|
public static Map<String, String> mapProperties(final Map<String, String> input, final Description desc) {
final Map<String, String> mapping = desc.getPropertiesMapping();
if (null == mapping) {
return input;
}
return performMapping(input, mapping, false);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"mapProperties",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"input",
",",
"final",
"Description",
"desc",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"mapping",
"=",
"desc",
".",
"getPropertiesMapping",
"(",
")",
";",
"if",
"(",
"null",
"==",
"mapping",
")",
"{",
"return",
"input",
";",
"}",
"return",
"performMapping",
"(",
"input",
",",
"mapping",
",",
"false",
")",
";",
"}"
] |
Converts a set of input configuration keys using the description's configuration to property mapping, or the same
input if the description has no mapping
@param input input map
@param desc plugin description
@return mapped values
|
[
"Converts",
"a",
"set",
"of",
"input",
"configuration",
"keys",
"using",
"the",
"description",
"s",
"configuration",
"to",
"property",
"mapping",
"or",
"the",
"same",
"input",
"if",
"the",
"description",
"has",
"no",
"mapping"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L240-L246
|
16,038
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.performMapping
|
public static Map<String, String> performMapping(final Map<String, String> input,
final Map<String, String> mapping, final boolean skip) {
final Map<String, String> props = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : input.entrySet()) {
if (null != mapping.get(entry.getKey())) {
props.put(mapping.get(entry.getKey()), entry.getValue());
} else if(!skip) {
props.put(entry.getKey(), entry.getValue());
}
}
return props;
}
|
java
|
public static Map<String, String> performMapping(final Map<String, String> input,
final Map<String, String> mapping, final boolean skip) {
final Map<String, String> props = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : input.entrySet()) {
if (null != mapping.get(entry.getKey())) {
props.put(mapping.get(entry.getKey()), entry.getValue());
} else if(!skip) {
props.put(entry.getKey(), entry.getValue());
}
}
return props;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"performMapping",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"input",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"mapping",
",",
"final",
"boolean",
"skip",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"props",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"input",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"mapping",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"props",
".",
"put",
"(",
"mapping",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"skip",
")",
"{",
"props",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"props",
";",
"}"
] |
Convert input keys via the supplied mapping.
@param input data
@param mapping map to convert key names
@param skip if true, ignore input entries when the key is not present in the mapping
|
[
"Convert",
"input",
"keys",
"via",
"the",
"supplied",
"mapping",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L254-L268
|
16,039
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.demapProperties
|
public static Map<String, String> demapProperties(final Map<String, String> input, final Description desc) {
final Map<String, String> mapping = desc.getPropertiesMapping();
return demapProperties(input, mapping, true);
}
|
java
|
public static Map<String, String> demapProperties(final Map<String, String> input, final Description desc) {
final Map<String, String> mapping = desc.getPropertiesMapping();
return demapProperties(input, mapping, true);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"demapProperties",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"input",
",",
"final",
"Description",
"desc",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"mapping",
"=",
"desc",
".",
"getPropertiesMapping",
"(",
")",
";",
"return",
"demapProperties",
"(",
"input",
",",
"mapping",
",",
"true",
")",
";",
"}"
] |
Reverses a set of properties mapped using the description's configuration to property mapping, or the same input
if the description has no mapping
@param input input map
@param desc plugin description
@return mapped values
|
[
"Reverses",
"a",
"set",
"of",
"properties",
"mapped",
"using",
"the",
"description",
"s",
"configuration",
"to",
"property",
"mapping",
"or",
"the",
"same",
"input",
"if",
"the",
"description",
"has",
"no",
"mapping"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L277-L280
|
16,040
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java
|
Validator.demapProperties
|
public static Map<String, String> demapProperties(
final Map<String, String> input,
final Map<String, String> mapping,
final boolean skip
)
{
if (null == mapping) {
return input;
}
final Map<String, String> rev = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : mapping.entrySet()) {
rev.put(entry.getValue(), entry.getKey());
}
return performMapping(input, rev, skip);
}
|
java
|
public static Map<String, String> demapProperties(
final Map<String, String> input,
final Map<String, String> mapping,
final boolean skip
)
{
if (null == mapping) {
return input;
}
final Map<String, String> rev = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : mapping.entrySet()) {
rev.put(entry.getValue(), entry.getKey());
}
return performMapping(input, rev, skip);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"demapProperties",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"input",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"mapping",
",",
"final",
"boolean",
"skip",
")",
"{",
"if",
"(",
"null",
"==",
"mapping",
")",
"{",
"return",
"input",
";",
"}",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"rev",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"mapping",
".",
"entrySet",
"(",
")",
")",
"{",
"rev",
".",
"put",
"(",
"entry",
".",
"getValue",
"(",
")",
",",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"performMapping",
"(",
"input",
",",
"rev",
",",
"skip",
")",
";",
"}"
] |
Reverses a set of properties mapped using the specified property mapping, or the same input
if the description has no mapping
@param input input map
@param mapping key value mapping
@param skip if true, ignore input entries when the key is not present in the mapping
@return mapped values
|
[
"Reverses",
"a",
"set",
"of",
"properties",
"mapped",
"using",
"the",
"specified",
"property",
"mapping",
"or",
"the",
"same",
"input",
"if",
"the",
"description",
"has",
"no",
"mapping"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/Validator.java#L290-L304
|
16,041
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Streams.java
|
Streams.copyStreamCount
|
public static int copyStreamCount(final InputStream in, final OutputStream out) throws IOException {
final byte[] buffer = new byte[10240];
int tot=0;
int c;
c = in.read(buffer);
while (c >= 0) {
if (c > 0) {
out.write(buffer, 0, c);
tot += c;
}
c = in.read(buffer);
}
return tot;
}
|
java
|
public static int copyStreamCount(final InputStream in, final OutputStream out) throws IOException {
final byte[] buffer = new byte[10240];
int tot=0;
int c;
c = in.read(buffer);
while (c >= 0) {
if (c > 0) {
out.write(buffer, 0, c);
tot += c;
}
c = in.read(buffer);
}
return tot;
}
|
[
"public",
"static",
"int",
"copyStreamCount",
"(",
"final",
"InputStream",
"in",
",",
"final",
"OutputStream",
"out",
")",
"throws",
"IOException",
"{",
"final",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"10240",
"]",
";",
"int",
"tot",
"=",
"0",
";",
"int",
"c",
";",
"c",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"while",
"(",
"c",
">=",
"0",
")",
"{",
"if",
"(",
"c",
">",
"0",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"c",
")",
";",
"tot",
"+=",
"c",
";",
"}",
"c",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"}",
"return",
"tot",
";",
"}"
] |
Read the data from the input stream and copy to the outputstream.
@param in inputstream
@param out outpustream
@return number of bytes copied
@throws java.io.IOException if thrown by underlying io operations
|
[
"Read",
"the",
"data",
"from",
"the",
"input",
"stream",
"and",
"copy",
"to",
"the",
"outputstream",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Streams.java#L60-L73
|
16,042
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Streams.java
|
Streams.copyWriterCount
|
public static int copyWriterCount(final Reader in, final Writer out) throws IOException {
final char[] buffer = new char[10240];
int tot=0;
int c;
c = in.read(buffer);
while (c >= 0) {
if (c > 0) {
out.write(buffer, 0, c);
tot += c;
}
c = in.read(buffer);
}
return tot;
}
|
java
|
public static int copyWriterCount(final Reader in, final Writer out) throws IOException {
final char[] buffer = new char[10240];
int tot=0;
int c;
c = in.read(buffer);
while (c >= 0) {
if (c > 0) {
out.write(buffer, 0, c);
tot += c;
}
c = in.read(buffer);
}
return tot;
}
|
[
"public",
"static",
"int",
"copyWriterCount",
"(",
"final",
"Reader",
"in",
",",
"final",
"Writer",
"out",
")",
"throws",
"IOException",
"{",
"final",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"10240",
"]",
";",
"int",
"tot",
"=",
"0",
";",
"int",
"c",
";",
"c",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"while",
"(",
"c",
">=",
"0",
")",
"{",
"if",
"(",
"c",
">",
"0",
")",
"{",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"c",
")",
";",
"tot",
"+=",
"c",
";",
"}",
"c",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"}",
"return",
"tot",
";",
"}"
] |
Read the data from the reader and copy to the writer.
@param in inputstream
@param out outpustream
@return number of bytes copied
@throws java.io.IOException if thrown by underlying io operations
|
[
"Read",
"the",
"data",
"from",
"the",
"reader",
"and",
"copy",
"to",
"the",
"writer",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Streams.java#L83-L96
|
16,043
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Streams.java
|
Streams.copyStreamWithFilterSet
|
public static void copyStreamWithFilterSet(final InputStream in, final OutputStream out, final FilterSet set)
throws IOException {
final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
String lSep = System.getProperty("line.separator");
String line = reader.readLine();
while (null != line) {
writer.write(set.replaceTokens(line));
writer.write(lSep);
line = reader.readLine();
}
writer.flush();
}
|
java
|
public static void copyStreamWithFilterSet(final InputStream in, final OutputStream out, final FilterSet set)
throws IOException {
final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
String lSep = System.getProperty("line.separator");
String line = reader.readLine();
while (null != line) {
writer.write(set.replaceTokens(line));
writer.write(lSep);
line = reader.readLine();
}
writer.flush();
}
|
[
"public",
"static",
"void",
"copyStreamWithFilterSet",
"(",
"final",
"InputStream",
"in",
",",
"final",
"OutputStream",
"out",
",",
"final",
"FilterSet",
"set",
")",
"throws",
"IOException",
"{",
"final",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"in",
")",
")",
";",
"final",
"BufferedWriter",
"writer",
"=",
"new",
"BufferedWriter",
"(",
"new",
"OutputStreamWriter",
"(",
"out",
")",
")",
";",
"String",
"lSep",
"=",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
";",
"String",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"null",
"!=",
"line",
")",
"{",
"writer",
".",
"write",
"(",
"set",
".",
"replaceTokens",
"(",
"line",
")",
")",
";",
"writer",
".",
"write",
"(",
"lSep",
")",
";",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
";",
"}",
"writer",
".",
"flush",
"(",
")",
";",
"}"
] |
Read the data from the input stream and write to the outputstream, filtering with an Ant FilterSet.
@param in inputstream
@param out outputstream
@param set FilterSet to use
@throws java.io.IOException if thrown by underlying io operations
|
[
"Read",
"the",
"data",
"from",
"the",
"input",
"stream",
"and",
"write",
"to",
"the",
"outputstream",
"filtering",
"with",
"an",
"Ant",
"FilterSet",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Streams.java#L148-L160
|
16,044
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.concat
|
public static Mapper concat(final Mapper first, final Mapper second){
return new ConcatMapper(new Mapper[]{first,second});
}
|
java
|
public static Mapper concat(final Mapper first, final Mapper second){
return new ConcatMapper(new Mapper[]{first,second});
}
|
[
"public",
"static",
"Mapper",
"concat",
"(",
"final",
"Mapper",
"first",
",",
"final",
"Mapper",
"second",
")",
"{",
"return",
"new",
"ConcatMapper",
"(",
"new",
"Mapper",
"[",
"]",
"{",
"first",
",",
"second",
"}",
")",
";",
"}"
] |
Concatenate two Mappers.
@param first first mapper to apply
@param second second mapper to apply
@return mapper
|
[
"Concatenate",
"two",
"Mappers",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L155-L157
|
16,045
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.map
|
public static Collection map(Mapper mapper, Object o) {
return java.util.Collections.singleton(mapper.map(o));
}
|
java
|
public static Collection map(Mapper mapper, Object o) {
return java.util.Collections.singleton(mapper.map(o));
}
|
[
"public",
"static",
"Collection",
"map",
"(",
"Mapper",
"mapper",
",",
"Object",
"o",
")",
"{",
"return",
"java",
".",
"util",
".",
"Collections",
".",
"singleton",
"(",
"mapper",
".",
"map",
"(",
"o",
")",
")",
";",
"}"
] |
Trivial case of a single object.
@param mapper an Mapper
@param o an Object
@return a Collection of the results.
|
[
"Trivial",
"case",
"of",
"a",
"single",
"object",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L266-L268
|
16,046
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Object[] a) {
return makeMap(mapper, java.util.Arrays.asList(a), false);
}
|
java
|
public static Map makeMap(Mapper mapper, Object[] a) {
return makeMap(mapper, java.util.Arrays.asList(a), false);
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Object",
"[",
"]",
"a",
")",
"{",
"return",
"makeMap",
"(",
"mapper",
",",
"java",
".",
"util",
".",
"Arrays",
".",
"asList",
"(",
"a",
")",
",",
"false",
")",
";",
"}"
] |
Create a new Map by using the array objects as keys, and the mapping result as values. Discard keys which return
null values from the mapper.
@param mapper a Mapper to map the values
@param a array of items
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"array",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
".",
"Discard",
"keys",
"which",
"return",
"null",
"values",
"from",
"the",
"mapper",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L488-L490
|
16,047
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Collection c) {
return makeMap(mapper, c.iterator(), false);
}
|
java
|
public static Map makeMap(Mapper mapper, Collection c) {
return makeMap(mapper, c.iterator(), false);
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Collection",
"c",
")",
"{",
"return",
"makeMap",
"(",
"mapper",
",",
"c",
".",
"iterator",
"(",
")",
",",
"false",
")",
";",
"}"
] |
Create a new Map by using the collection objects as keys, and the mapping result as values. Discard keys which
return null values from the mapper.
@param mapper a Mapper to map the values
@param c Collection of items
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"collection",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
".",
"Discard",
"keys",
"which",
"return",
"null",
"values",
"from",
"the",
"mapper",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L519-L521
|
16,048
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Collection c, boolean includeNull) {
return makeMap(mapper, c.iterator(), includeNull);
}
|
java
|
public static Map makeMap(Mapper mapper, Collection c, boolean includeNull) {
return makeMap(mapper, c.iterator(), includeNull);
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Collection",
"c",
",",
"boolean",
"includeNull",
")",
"{",
"return",
"makeMap",
"(",
"mapper",
",",
"c",
".",
"iterator",
"(",
")",
",",
"includeNull",
")",
";",
"}"
] |
Create a new Map by using the collection objects as keys, and the mapping result as values.
@param mapper a Mapper to map the values
@param c Collection of items
@param includeNull true to include null
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"collection",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L535-L537
|
16,049
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Iterator i) {
return makeMap(mapper, i, false);
}
|
java
|
public static Map makeMap(Mapper mapper, Iterator i) {
return makeMap(mapper, i, false);
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Iterator",
"i",
")",
"{",
"return",
"makeMap",
"(",
"mapper",
",",
"i",
",",
"false",
")",
";",
"}"
] |
Create a new Map by using the iterator objects as keys, and the mapping result as values. Discard keys which
return null values from the mapper.
@param mapper a Mapper to map the values
@param i Iterator
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"iterator",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
".",
"Discard",
"keys",
"which",
"return",
"null",
"values",
"from",
"the",
"mapper",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L548-L550
|
16,050
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Iterator i, boolean includeNull) {
HashMap h = new HashMap();
for (; i.hasNext();) {
Object k = i.next();
Object v = mapper.map(k);
if (includeNull || v != null) {
h.put(k, v);
}
}
return h;
}
|
java
|
public static Map makeMap(Mapper mapper, Iterator i, boolean includeNull) {
HashMap h = new HashMap();
for (; i.hasNext();) {
Object k = i.next();
Object v = mapper.map(k);
if (includeNull || v != null) {
h.put(k, v);
}
}
return h;
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Iterator",
"i",
",",
"boolean",
"includeNull",
")",
"{",
"HashMap",
"h",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"Object",
"k",
"=",
"i",
".",
"next",
"(",
")",
";",
"Object",
"v",
"=",
"mapper",
".",
"map",
"(",
"k",
")",
";",
"if",
"(",
"includeNull",
"||",
"v",
"!=",
"null",
")",
"{",
"h",
".",
"put",
"(",
"k",
",",
"v",
")",
";",
"}",
"}",
"return",
"h",
";",
"}"
] |
Create a new Map by using the iterator objects as keys, and the mapping result as values.
@param mapper a Mapper to map the values
@param i Iterator
@param includeNull true to include null
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"iterator",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L564-L574
|
16,051
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Enumeration en) {
return makeMap(mapper, en, false);
}
|
java
|
public static Map makeMap(Mapper mapper, Enumeration en) {
return makeMap(mapper, en, false);
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Enumeration",
"en",
")",
"{",
"return",
"makeMap",
"(",
"mapper",
",",
"en",
",",
"false",
")",
";",
"}"
] |
Create a new Map by using the enumeration objects as keys, and the mapping result as values. Discard keys which
return null values from the mapper.
@param mapper a Mapper to map the values
@param en Enumeration
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"enumeration",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
".",
"Discard",
"keys",
"which",
"return",
"null",
"values",
"from",
"the",
"mapper",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L585-L587
|
16,052
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.makeMap
|
public static Map makeMap(Mapper mapper, Enumeration en, boolean includeNull) {
HashMap h = new HashMap();
for (; en.hasMoreElements();) {
Object k = en.nextElement();
Object v = mapper.map(k);
if (includeNull || v != null) {
h.put(k, v);
}
}
return h;
}
|
java
|
public static Map makeMap(Mapper mapper, Enumeration en, boolean includeNull) {
HashMap h = new HashMap();
for (; en.hasMoreElements();) {
Object k = en.nextElement();
Object v = mapper.map(k);
if (includeNull || v != null) {
h.put(k, v);
}
}
return h;
}
|
[
"public",
"static",
"Map",
"makeMap",
"(",
"Mapper",
"mapper",
",",
"Enumeration",
"en",
",",
"boolean",
"includeNull",
")",
"{",
"HashMap",
"h",
"=",
"new",
"HashMap",
"(",
")",
";",
"for",
"(",
";",
"en",
".",
"hasMoreElements",
"(",
")",
";",
")",
"{",
"Object",
"k",
"=",
"en",
".",
"nextElement",
"(",
")",
";",
"Object",
"v",
"=",
"mapper",
".",
"map",
"(",
"k",
")",
";",
"if",
"(",
"includeNull",
"||",
"v",
"!=",
"null",
")",
"{",
"h",
".",
"put",
"(",
"k",
",",
"v",
")",
";",
"}",
"}",
"return",
"h",
";",
"}"
] |
Create a new Map by using the enumeration objects as keys, and the mapping result as values.
@param mapper a Mapper to map the values
@param en Enumeration
@param includeNull true to include null
@return a new Map with values mapped
|
[
"Create",
"a",
"new",
"Map",
"by",
"using",
"the",
"enumeration",
"objects",
"as",
"keys",
"and",
"the",
"mapping",
"result",
"as",
"values",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L601-L611
|
16,053
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.beanMapper
|
public static Mapper beanMapper(final String property){
return new Mapper() {
public Object map(Object a) {
try {
return BeanUtils.getProperty(a, property);
} catch (Exception e) {
throw new ClassCastException("Object was not the expected class: " + a.getClass());
}
}
};
}
|
java
|
public static Mapper beanMapper(final String property){
return new Mapper() {
public Object map(Object a) {
try {
return BeanUtils.getProperty(a, property);
} catch (Exception e) {
throw new ClassCastException("Object was not the expected class: " + a.getClass());
}
}
};
}
|
[
"public",
"static",
"Mapper",
"beanMapper",
"(",
"final",
"String",
"property",
")",
"{",
"return",
"new",
"Mapper",
"(",
")",
"{",
"public",
"Object",
"map",
"(",
"Object",
"a",
")",
"{",
"try",
"{",
"return",
"BeanUtils",
".",
"getProperty",
"(",
"a",
",",
"property",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"\"Object was not the expected class: \"",
"+",
"a",
".",
"getClass",
"(",
")",
")",
";",
"}",
"}",
"}",
";",
"}"
] |
Create a mapper for bean properties
@param property name of the bean property
@return mapper
|
[
"Create",
"a",
"mapper",
"for",
"bean",
"properties"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L710-L720
|
16,054
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/utils/Mapper.java
|
Mapper.filterMapper
|
public static Mapper filterMapper(final Predicate pred){
return new Mapper(){
public Object map(Object a) {
return pred.evaluate(a) ? a : null;
}
};
}
|
java
|
public static Mapper filterMapper(final Predicate pred){
return new Mapper(){
public Object map(Object a) {
return pred.evaluate(a) ? a : null;
}
};
}
|
[
"public",
"static",
"Mapper",
"filterMapper",
"(",
"final",
"Predicate",
"pred",
")",
"{",
"return",
"new",
"Mapper",
"(",
")",
"{",
"public",
"Object",
"map",
"(",
"Object",
"a",
")",
"{",
"return",
"pred",
".",
"evaluate",
"(",
"a",
")",
"?",
"a",
":",
"null",
";",
"}",
"}",
";",
"}"
] |
Return a mapper than maps an object to itself if the predicate evaluates to true,
and to null otherwise.
@param pred predicate
@return mapper
|
[
"Return",
"a",
"mapper",
"than",
"maps",
"an",
"object",
"to",
"itself",
"if",
"the",
"predicate",
"evaluates",
"to",
"true",
"and",
"to",
"null",
"otherwise",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/utils/Mapper.java#L742-L748
|
16,055
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java
|
ResourceFormatGeneratorService.getGeneratorForFileExtension
|
public ResourceFormatGenerator getGeneratorForFileExtension(final File file) throws UnsupportedFormatException {
String extension = file.getName().lastIndexOf(".") > 0 ? file.getName().substring(file.getName().lastIndexOf(
".") + 1) : null;
if (null != extension) {
return getGeneratorForFileExtension(extension);
} else {
throw new UnsupportedFormatException("Could not determine format for file: " + file.getAbsolutePath());
}
}
|
java
|
public ResourceFormatGenerator getGeneratorForFileExtension(final File file) throws UnsupportedFormatException {
String extension = file.getName().lastIndexOf(".") > 0 ? file.getName().substring(file.getName().lastIndexOf(
".") + 1) : null;
if (null != extension) {
return getGeneratorForFileExtension(extension);
} else {
throw new UnsupportedFormatException("Could not determine format for file: " + file.getAbsolutePath());
}
}
|
[
"public",
"ResourceFormatGenerator",
"getGeneratorForFileExtension",
"(",
"final",
"File",
"file",
")",
"throws",
"UnsupportedFormatException",
"{",
"String",
"extension",
"=",
"file",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"\".\"",
")",
">",
"0",
"?",
"file",
".",
"getName",
"(",
")",
".",
"substring",
"(",
"file",
".",
"getName",
"(",
")",
".",
"lastIndexOf",
"(",
"\".\"",
")",
"+",
"1",
")",
":",
"null",
";",
"if",
"(",
"null",
"!=",
"extension",
")",
"{",
"return",
"getGeneratorForFileExtension",
"(",
"extension",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"UnsupportedFormatException",
"(",
"\"Could not determine format for file: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] |
Return a generator for a file, based on the file extension.
@param file the file
@return the generator found for the extension
@throws UnsupportedFormatException if the file extension does not match an available generator, or if the file
has no extension
|
[
"Return",
"a",
"generator",
"for",
"a",
"file",
"based",
"on",
"the",
"file",
"extension",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java#L89-L97
|
16,056
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java
|
ResourceFormatGeneratorService.getGeneratorForFileExtension
|
public ResourceFormatGenerator getGeneratorForFileExtension(final String extension) throws
UnsupportedFormatException {
for (final ResourceFormatGenerator generator : listGenerators()) {
if (generator.getFileExtensions().contains(extension)) {
return generator;
}
}
throw new UnsupportedFormatException("No provider available to parse file extension: " + extension);
}
|
java
|
public ResourceFormatGenerator getGeneratorForFileExtension(final String extension) throws
UnsupportedFormatException {
for (final ResourceFormatGenerator generator : listGenerators()) {
if (generator.getFileExtensions().contains(extension)) {
return generator;
}
}
throw new UnsupportedFormatException("No provider available to parse file extension: " + extension);
}
|
[
"public",
"ResourceFormatGenerator",
"getGeneratorForFileExtension",
"(",
"final",
"String",
"extension",
")",
"throws",
"UnsupportedFormatException",
"{",
"for",
"(",
"final",
"ResourceFormatGenerator",
"generator",
":",
"listGenerators",
"(",
")",
")",
"{",
"if",
"(",
"generator",
".",
"getFileExtensions",
"(",
")",
".",
"contains",
"(",
"extension",
")",
")",
"{",
"return",
"generator",
";",
"}",
"}",
"throw",
"new",
"UnsupportedFormatException",
"(",
"\"No provider available to parse file extension: \"",
"+",
"extension",
")",
";",
"}"
] |
Return a generator for a file, based on the bare file extension.
@param extension the file extension string
@return the generator found for the extension
@throws UnsupportedFormatException if the file extension does not match an available generator
|
[
"Return",
"a",
"generator",
"for",
"a",
"file",
"based",
"on",
"the",
"bare",
"file",
"extension",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java#L108-L116
|
16,057
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java
|
ResourceFormatGeneratorService.getGeneratorForMIMEType
|
public ResourceFormatGenerator getGeneratorForMIMEType(final String mimeType) throws UnsupportedFormatException {
//clean up encoding
final String cleanMime;
if (mimeType.indexOf(";") > 0) {
cleanMime = mimeType.substring(0, mimeType.indexOf(";"));
} else {
cleanMime = mimeType;
}
if (!ResourceFormatParserService.validMimeType(cleanMime)) {
throw new IllegalArgumentException("Invalid MIME type: " + mimeType);
}
for (final ResourceFormatGenerator generator : listGenerators()) {
if (null != generator.getMIMETypes()) {
if (generator.getMIMETypes().contains(cleanMime)) {
return generator;
} else {
for (final String s : generator.getMIMETypes()) {
if (ResourceFormatParserService.validMimeType(s) && cleanMime.startsWith("*/")) {
String t1 = cleanMime.substring(2);
String t2 = s.substring(s.indexOf("/") + 1);
if (t1.equals(t2)) {
return generator;
}
}
}
}
}
}
throw new UnsupportedFormatException("No provider available to parse MIME type: " + mimeType);
}
|
java
|
public ResourceFormatGenerator getGeneratorForMIMEType(final String mimeType) throws UnsupportedFormatException {
//clean up encoding
final String cleanMime;
if (mimeType.indexOf(";") > 0) {
cleanMime = mimeType.substring(0, mimeType.indexOf(";"));
} else {
cleanMime = mimeType;
}
if (!ResourceFormatParserService.validMimeType(cleanMime)) {
throw new IllegalArgumentException("Invalid MIME type: " + mimeType);
}
for (final ResourceFormatGenerator generator : listGenerators()) {
if (null != generator.getMIMETypes()) {
if (generator.getMIMETypes().contains(cleanMime)) {
return generator;
} else {
for (final String s : generator.getMIMETypes()) {
if (ResourceFormatParserService.validMimeType(s) && cleanMime.startsWith("*/")) {
String t1 = cleanMime.substring(2);
String t2 = s.substring(s.indexOf("/") + 1);
if (t1.equals(t2)) {
return generator;
}
}
}
}
}
}
throw new UnsupportedFormatException("No provider available to parse MIME type: " + mimeType);
}
|
[
"public",
"ResourceFormatGenerator",
"getGeneratorForMIMEType",
"(",
"final",
"String",
"mimeType",
")",
"throws",
"UnsupportedFormatException",
"{",
"//clean up encoding",
"final",
"String",
"cleanMime",
";",
"if",
"(",
"mimeType",
".",
"indexOf",
"(",
"\";\"",
")",
">",
"0",
")",
"{",
"cleanMime",
"=",
"mimeType",
".",
"substring",
"(",
"0",
",",
"mimeType",
".",
"indexOf",
"(",
"\";\"",
")",
")",
";",
"}",
"else",
"{",
"cleanMime",
"=",
"mimeType",
";",
"}",
"if",
"(",
"!",
"ResourceFormatParserService",
".",
"validMimeType",
"(",
"cleanMime",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid MIME type: \"",
"+",
"mimeType",
")",
";",
"}",
"for",
"(",
"final",
"ResourceFormatGenerator",
"generator",
":",
"listGenerators",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"generator",
".",
"getMIMETypes",
"(",
")",
")",
"{",
"if",
"(",
"generator",
".",
"getMIMETypes",
"(",
")",
".",
"contains",
"(",
"cleanMime",
")",
")",
"{",
"return",
"generator",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"String",
"s",
":",
"generator",
".",
"getMIMETypes",
"(",
")",
")",
"{",
"if",
"(",
"ResourceFormatParserService",
".",
"validMimeType",
"(",
"s",
")",
"&&",
"cleanMime",
".",
"startsWith",
"(",
"\"*/\"",
")",
")",
"{",
"String",
"t1",
"=",
"cleanMime",
".",
"substring",
"(",
"2",
")",
";",
"String",
"t2",
"=",
"s",
".",
"substring",
"(",
"s",
".",
"indexOf",
"(",
"\"/\"",
")",
"+",
"1",
")",
";",
"if",
"(",
"t1",
".",
"equals",
"(",
"t2",
")",
")",
"{",
"return",
"generator",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"throw",
"new",
"UnsupportedFormatException",
"(",
"\"No provider available to parse MIME type: \"",
"+",
"mimeType",
")",
";",
"}"
] |
Return a generator for a mime type.
@param mimeType the MIME type string
@return The first matching parser for the mime type
@throws UnsupportedFormatException if no generators are available for the MIME type
|
[
"Return",
"a",
"generator",
"for",
"a",
"mime",
"type",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/resources/format/ResourceFormatGeneratorService.java#L146-L175
|
16,058
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.builder
|
public static <T extends ContentMeta> TreeBuilder<T> builder() {
return new TreeBuilder<T>().base(new EmptyTree<T>());
}
|
java
|
public static <T extends ContentMeta> TreeBuilder<T> builder() {
return new TreeBuilder<T>().base(new EmptyTree<T>());
}
|
[
"public",
"static",
"<",
"T",
"extends",
"ContentMeta",
">",
"TreeBuilder",
"<",
"T",
">",
"builder",
"(",
")",
"{",
"return",
"new",
"TreeBuilder",
"<",
"T",
">",
"(",
")",
".",
"base",
"(",
"new",
"EmptyTree",
"<",
"T",
">",
"(",
")",
")",
";",
"}"
] |
Build a new tree with an empty base
@param <T> content type
@return builder
|
[
"Build",
"a",
"new",
"tree",
"with",
"an",
"empty",
"base"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L45-L47
|
16,059
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.builder
|
public static <T extends ContentMeta> TreeBuilder<T> builder(Tree<T> base) {
return new TreeBuilder<T>().base(base);
}
|
java
|
public static <T extends ContentMeta> TreeBuilder<T> builder(Tree<T> base) {
return new TreeBuilder<T>().base(base);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"ContentMeta",
">",
"TreeBuilder",
"<",
"T",
">",
"builder",
"(",
"Tree",
"<",
"T",
">",
"base",
")",
"{",
"return",
"new",
"TreeBuilder",
"<",
"T",
">",
"(",
")",
".",
"base",
"(",
"base",
")",
";",
"}"
] |
Build a new tree with given base
@param base base tree
@param <T> content type
@return builder
|
[
"Build",
"a",
"new",
"tree",
"with",
"given",
"base"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L57-L59
|
16,060
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.subTree
|
public TreeBuilder<T> subTree(Path path, Tree<T> subtree, boolean fullPath) {
treeStack.add(new SubPathTree<T>(subtree, path, fullPath));
return this;
}
|
java
|
public TreeBuilder<T> subTree(Path path, Tree<T> subtree, boolean fullPath) {
treeStack.add(new SubPathTree<T>(subtree, path, fullPath));
return this;
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"subTree",
"(",
"Path",
"path",
",",
"Tree",
"<",
"T",
">",
"subtree",
",",
"boolean",
"fullPath",
")",
"{",
"treeStack",
".",
"add",
"(",
"new",
"SubPathTree",
"<",
"T",
">",
"(",
"subtree",
",",
"path",
",",
"fullPath",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add a tree responsible for a subpath of the base tree.
@param path sub path to handle
@param subtree tree to delegate to for the path
@param fullPath if true, send resources to the subtree with the original full path, otherwise store with a path
relative to the path
@return builder
|
[
"Add",
"a",
"tree",
"responsible",
"for",
"a",
"subpath",
"of",
"the",
"base",
"tree",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L83-L86
|
16,061
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.convert
|
public TreeBuilder<T> convert(ContentConverter<T> converter, Path path) {
return convert(converter, PathUtil.subpathSelector(path));
}
|
java
|
public TreeBuilder<T> convert(ContentConverter<T> converter, Path path) {
return convert(converter, PathUtil.subpathSelector(path));
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"convert",
"(",
"ContentConverter",
"<",
"T",
">",
"converter",
",",
"Path",
"path",
")",
"{",
"return",
"convert",
"(",
"converter",
",",
"PathUtil",
".",
"subpathSelector",
"(",
"path",
")",
")",
";",
"}"
] |
Convert data content for all resources below the given path
@param converter content converter
@param path sub path to convert data
@return builder
|
[
"Convert",
"data",
"content",
"for",
"all",
"resources",
"below",
"the",
"given",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L96-L98
|
16,062
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.convert
|
public TreeBuilder<T> convert(ContentConverter<T> converter, PathSelector selector) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, selector));
}
|
java
|
public TreeBuilder<T> convert(ContentConverter<T> converter, PathSelector selector) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, selector));
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"convert",
"(",
"ContentConverter",
"<",
"T",
">",
"converter",
",",
"PathSelector",
"selector",
")",
"{",
"return",
"TreeBuilder",
".",
"<",
"T",
">",
"builder",
"(",
"new",
"ConverterTree",
"<",
"T",
">",
"(",
"build",
"(",
")",
",",
"converter",
",",
"selector",
")",
")",
";",
"}"
] |
Convert data content for all resource paths matched by the path selector
@param converter content converter
@param selector path selection
@return builder
|
[
"Convert",
"data",
"content",
"for",
"all",
"resource",
"paths",
"matched",
"by",
"the",
"path",
"selector"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L108-L110
|
16,063
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.convert
|
public TreeBuilder<T> convert(ContentConverter<T> converter, Path subpath,
ResourceSelector<T> resourceSelector) {
return convert(converter, PathUtil.subpathSelector(subpath), resourceSelector);
}
|
java
|
public TreeBuilder<T> convert(ContentConverter<T> converter, Path subpath,
ResourceSelector<T> resourceSelector) {
return convert(converter, PathUtil.subpathSelector(subpath), resourceSelector);
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"convert",
"(",
"ContentConverter",
"<",
"T",
">",
"converter",
",",
"Path",
"subpath",
",",
"ResourceSelector",
"<",
"T",
">",
"resourceSelector",
")",
"{",
"return",
"convert",
"(",
"converter",
",",
"PathUtil",
".",
"subpathSelector",
"(",
"subpath",
")",
",",
"resourceSelector",
")",
";",
"}"
] |
Convert data content for all resources matching the resource selector and within the sub path
@param converter content converter
@param subpath sub path
@param resourceSelector resource selector
@return builder
|
[
"Convert",
"data",
"content",
"for",
"all",
"resources",
"matching",
"the",
"resource",
"selector",
"and",
"within",
"the",
"sub",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L133-L136
|
16,064
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.convert
|
public TreeBuilder<T> convert(ContentConverter<T> converter, PathSelector pathSelector,
ResourceSelector<T> resourceSelector) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, pathSelector, resourceSelector));
}
|
java
|
public TreeBuilder<T> convert(ContentConverter<T> converter, PathSelector pathSelector,
ResourceSelector<T> resourceSelector) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, pathSelector, resourceSelector));
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"convert",
"(",
"ContentConverter",
"<",
"T",
">",
"converter",
",",
"PathSelector",
"pathSelector",
",",
"ResourceSelector",
"<",
"T",
">",
"resourceSelector",
")",
"{",
"return",
"TreeBuilder",
".",
"<",
"T",
">",
"builder",
"(",
"new",
"ConverterTree",
"<",
"T",
">",
"(",
"build",
"(",
")",
",",
"converter",
",",
"pathSelector",
",",
"resourceSelector",
")",
")",
";",
"}"
] |
Convert data content for all resources matching the resource selector and the path selector
@param converter content converter
@param pathSelector path selector
@param resourceSelector resource selector
@return builder
|
[
"Convert",
"data",
"content",
"for",
"all",
"resources",
"matching",
"the",
"resource",
"selector",
"and",
"the",
"path",
"selector"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L147-L150
|
16,065
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.convert
|
public TreeBuilder<T> convert(ContentConverter<T> converter) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, PathUtil.allpathSelector()));
}
|
java
|
public TreeBuilder<T> convert(ContentConverter<T> converter) {
return TreeBuilder.<T>builder(new ConverterTree<T>(build(), converter, PathUtil.allpathSelector()));
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"convert",
"(",
"ContentConverter",
"<",
"T",
">",
"converter",
")",
"{",
"return",
"TreeBuilder",
".",
"<",
"T",
">",
"builder",
"(",
"new",
"ConverterTree",
"<",
"T",
">",
"(",
"build",
"(",
")",
",",
"converter",
",",
"PathUtil",
".",
"allpathSelector",
"(",
")",
")",
")",
";",
"}"
] |
Convert all content in the tree
@param converter converter
@return builder
|
[
"Convert",
"all",
"content",
"in",
"the",
"tree"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L159-L161
|
16,066
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.listen
|
public TreeBuilder<T> listen(Listener<T> listener) {
return listen(listener, PathUtil.allpathSelector());
}
|
java
|
public TreeBuilder<T> listen(Listener<T> listener) {
return listen(listener, PathUtil.allpathSelector());
}
|
[
"public",
"TreeBuilder",
"<",
"T",
">",
"listen",
"(",
"Listener",
"<",
"T",
">",
"listener",
")",
"{",
"return",
"listen",
"(",
"listener",
",",
"PathUtil",
".",
"allpathSelector",
"(",
")",
")",
";",
"}"
] |
Listen to events on all paths of the tree
@param listener listener
@return builder
|
[
"Listen",
"to",
"events",
"on",
"all",
"paths",
"of",
"the",
"tree"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L170-L172
|
16,067
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.listen
|
private TreeBuilder<T> listen(Listener<T> listener, String resourceSelector) {
return TreeBuilder.<T>builder(new ListenerTree<T>(build(), listener,
PathUtil.<T>resourceSelector(resourceSelector)));
}
|
java
|
private TreeBuilder<T> listen(Listener<T> listener, String resourceSelector) {
return TreeBuilder.<T>builder(new ListenerTree<T>(build(), listener,
PathUtil.<T>resourceSelector(resourceSelector)));
}
|
[
"private",
"TreeBuilder",
"<",
"T",
">",
"listen",
"(",
"Listener",
"<",
"T",
">",
"listener",
",",
"String",
"resourceSelector",
")",
"{",
"return",
"TreeBuilder",
".",
"<",
"T",
">",
"builder",
"(",
"new",
"ListenerTree",
"<",
"T",
">",
"(",
"build",
"(",
")",
",",
"listener",
",",
"PathUtil",
".",
"<",
"T",
">",
"resourceSelector",
"(",
"resourceSelector",
")",
")",
")",
";",
"}"
] |
Listen to events on selective resources of the tree
@param listener listener
@param resourceSelector resource selector
@return builder
|
[
"Listen",
"to",
"events",
"on",
"selective",
"resources",
"of",
"the",
"tree"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L212-L215
|
16,068
|
rundeck/rundeck
|
rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java
|
TreeBuilder.build
|
public Tree<T> build() {
Tree<T> result = base;
if (null == base && treeStack.size() == 1) {
result = treeStack.get(0);
} else if (treeStack.size() > 0) {
result = new TreeStack<T>(treeStack, base);
}else if(null==base) {
throw new IllegalArgumentException("base tree was not set");
}
return result;
}
|
java
|
public Tree<T> build() {
Tree<T> result = base;
if (null == base && treeStack.size() == 1) {
result = treeStack.get(0);
} else if (treeStack.size() > 0) {
result = new TreeStack<T>(treeStack, base);
}else if(null==base) {
throw new IllegalArgumentException("base tree was not set");
}
return result;
}
|
[
"public",
"Tree",
"<",
"T",
">",
"build",
"(",
")",
"{",
"Tree",
"<",
"T",
">",
"result",
"=",
"base",
";",
"if",
"(",
"null",
"==",
"base",
"&&",
"treeStack",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"result",
"=",
"treeStack",
".",
"get",
"(",
"0",
")",
";",
"}",
"else",
"if",
"(",
"treeStack",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"result",
"=",
"new",
"TreeStack",
"<",
"T",
">",
"(",
"treeStack",
",",
"base",
")",
";",
"}",
"else",
"if",
"(",
"null",
"==",
"base",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"base tree was not set\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Build the tree
@return the tree
|
[
"Build",
"the",
"tree"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeck-storage/rundeck-storage-conf/src/main/java/org/rundeck/storage/conf/TreeBuilder.java#L237-L248
|
16,069
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/PropertiesCache.java
|
PropertiesCache.needsReload
|
public synchronized boolean needsReload(final File file) throws IOException {
final long lastMod = file.lastModified();
if (!file.exists()) {
mtimes.remove(file);
}
final Long aLong = mtimes.get(file);
return null == aLong || lastMod > aLong;
}
|
java
|
public synchronized boolean needsReload(final File file) throws IOException {
final long lastMod = file.lastModified();
if (!file.exists()) {
mtimes.remove(file);
}
final Long aLong = mtimes.get(file);
return null == aLong || lastMod > aLong;
}
|
[
"public",
"synchronized",
"boolean",
"needsReload",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"final",
"long",
"lastMod",
"=",
"file",
".",
"lastModified",
"(",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"mtimes",
".",
"remove",
"(",
"file",
")",
";",
"}",
"final",
"Long",
"aLong",
"=",
"mtimes",
".",
"get",
"(",
"file",
")",
";",
"return",
"null",
"==",
"aLong",
"||",
"lastMod",
">",
"aLong",
";",
"}"
] |
Returns true if the file does not exist, or has been modified since the last time it was loaded.
@param file File to check
@return true if the file needs to be reloaded.
@throws IOException on io error
|
[
"Returns",
"true",
"if",
"the",
"file",
"does",
"not",
"exist",
"or",
"has",
"been",
"modified",
"since",
"the",
"last",
"time",
"it",
"was",
"loaded",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/PropertiesCache.java#L50-L57
|
16,070
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/PropertiesCache.java
|
PropertiesCache.getProperties
|
public synchronized Properties getProperties(final File file) throws IOException {
final Properties fileprops;
if (needsReload(file)) {
fileprops = new Properties();
final InputStream is = new FileInputStream(file);
try {
fileprops.load(is);
} finally {
if (null != is) {
is.close();
}
}
mtimes.put(file, file.lastModified());
props.put(file, fileprops);
return fileprops;
}
return props.get(file);
}
|
java
|
public synchronized Properties getProperties(final File file) throws IOException {
final Properties fileprops;
if (needsReload(file)) {
fileprops = new Properties();
final InputStream is = new FileInputStream(file);
try {
fileprops.load(is);
} finally {
if (null != is) {
is.close();
}
}
mtimes.put(file, file.lastModified());
props.put(file, fileprops);
return fileprops;
}
return props.get(file);
}
|
[
"public",
"synchronized",
"Properties",
"getProperties",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"final",
"Properties",
"fileprops",
";",
"if",
"(",
"needsReload",
"(",
"file",
")",
")",
"{",
"fileprops",
"=",
"new",
"Properties",
"(",
")",
";",
"final",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"file",
")",
";",
"try",
"{",
"fileprops",
".",
"load",
"(",
"is",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"null",
"!=",
"is",
")",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"}",
"mtimes",
".",
"put",
"(",
"file",
",",
"file",
".",
"lastModified",
"(",
")",
")",
";",
"props",
".",
"put",
"(",
"file",
",",
"fileprops",
")",
";",
"return",
"fileprops",
";",
"}",
"return",
"props",
".",
"get",
"(",
"file",
")",
";",
"}"
] |
Get the java Properties stored in the file, loading from disk only if the file has been modified
since the last read, or the cached data has been invalidated.
@param file java properties file
@return java Properties
@throws IOException due to file read or find error
|
[
"Get",
"the",
"java",
"Properties",
"stored",
"in",
"the",
"file",
"loading",
"from",
"disk",
"only",
"if",
"the",
"file",
"has",
"been",
"modified",
"since",
"the",
"last",
"read",
"or",
"the",
"cached",
"data",
"has",
"been",
"invalidated",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/PropertiesCache.java#L66-L84
|
16,071
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java
|
Rules.equalsCondition
|
public static Condition equalsCondition(final StateObj state) {
return new Condition() {
@Override
public boolean test(final StateObj input) {
return input.hasState(state);
}
@Override
public String toString() {
return "(State equals: " + state + ")";
}
};
}
|
java
|
public static Condition equalsCondition(final StateObj state) {
return new Condition() {
@Override
public boolean test(final StateObj input) {
return input.hasState(state);
}
@Override
public String toString() {
return "(State equals: " + state + ")";
}
};
}
|
[
"public",
"static",
"Condition",
"equalsCondition",
"(",
"final",
"StateObj",
"state",
")",
"{",
"return",
"new",
"Condition",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"test",
"(",
"final",
"StateObj",
"input",
")",
"{",
"return",
"input",
".",
"hasState",
"(",
"state",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"(State equals: \"",
"+",
"state",
"+",
"\")\"",
";",
"}",
"}",
";",
"}"
] |
Create a condition when the given state is set
@param state state
@return new condition
|
[
"Create",
"a",
"condition",
"when",
"the",
"given",
"state",
"is",
"set"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java#L49-L61
|
16,072
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java
|
Rules.matchesCondition
|
public static Condition matchesCondition(String key, boolean keyRegex, String value, boolean valueRegex) {
return new MatchesCondition(key, keyRegex, value, valueRegex);
}
|
java
|
public static Condition matchesCondition(String key, boolean keyRegex, String value, boolean valueRegex) {
return new MatchesCondition(key, keyRegex, value, valueRegex);
}
|
[
"public",
"static",
"Condition",
"matchesCondition",
"(",
"String",
"key",
",",
"boolean",
"keyRegex",
",",
"String",
"value",
",",
"boolean",
"valueRegex",
")",
"{",
"return",
"new",
"MatchesCondition",
"(",
"key",
",",
"keyRegex",
",",
"value",
",",
"valueRegex",
")",
";",
"}"
] |
Create a single match condition
@param key key name or regular expression
@param keyRegex true if the key is a regular expression key match, false for an equals match
@param value value value string
@param valueRegex true if the value is a regular expression match, false for an equals match
@return new condition
|
[
"Create",
"a",
"single",
"match",
"condition"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java#L85-L87
|
16,073
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java
|
Rules.update
|
public static boolean update(RuleEngine ruleEngine, MutableStateObj state) {
StateObj newState = ruleEngine.evaluateRules(state);
state.updateState(newState);
return newState.getState().size() > 0;
}
|
java
|
public static boolean update(RuleEngine ruleEngine, MutableStateObj state) {
StateObj newState = ruleEngine.evaluateRules(state);
state.updateState(newState);
return newState.getState().size() > 0;
}
|
[
"public",
"static",
"boolean",
"update",
"(",
"RuleEngine",
"ruleEngine",
",",
"MutableStateObj",
"state",
")",
"{",
"StateObj",
"newState",
"=",
"ruleEngine",
".",
"evaluateRules",
"(",
"state",
")",
";",
"state",
".",
"updateState",
"(",
"newState",
")",
";",
"return",
"newState",
".",
"getState",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
";",
"}"
] |
Update the state by evaluating the rules, and applying state changes
@param ruleEngine rule engine
@param state state
@return true if state was modified, false if no state change occured
|
[
"Update",
"the",
"state",
"by",
"evaluating",
"the",
"rules",
"and",
"applying",
"state",
"changes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/Rules.java#L200-L205
|
16,074
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.merge
|
public static Map<String, Map<String, String>> merge(
final Map<String, Map<String, String>> targetContext,
final Map<String, Map<String, String>> newContext
)
{
final HashMap<String, Map<String, String>> result = deepCopy(targetContext);
for (final Map.Entry<String, Map<String, String>> entry : newContext.entrySet()) {
if (!targetContext.containsKey(entry.getKey())) {
result.put(entry.getKey(), new HashMap<>());
} else {
result.put(entry.getKey(), new HashMap<>(targetContext.get(entry.getKey())));
}
result.get(entry.getKey()).putAll(entry.getValue());
}
return result;
}
|
java
|
public static Map<String, Map<String, String>> merge(
final Map<String, Map<String, String>> targetContext,
final Map<String, Map<String, String>> newContext
)
{
final HashMap<String, Map<String, String>> result = deepCopy(targetContext);
for (final Map.Entry<String, Map<String, String>> entry : newContext.entrySet()) {
if (!targetContext.containsKey(entry.getKey())) {
result.put(entry.getKey(), new HashMap<>());
} else {
result.put(entry.getKey(), new HashMap<>(targetContext.get(entry.getKey())));
}
result.get(entry.getKey()).putAll(entry.getValue());
}
return result;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"merge",
"(",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"targetContext",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"newContext",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"result",
"=",
"deepCopy",
"(",
"targetContext",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"entry",
":",
"newContext",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"targetContext",
".",
"containsKey",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"result",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"}",
"else",
"{",
"result",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"new",
"HashMap",
"<>",
"(",
"targetContext",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
")",
";",
"}",
"result",
".",
"get",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"putAll",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Merge one context onto another by adding or replacing values in a new map
@param targetContext the target of the merge
@param newContext context to merge
@return merged data in a new map
|
[
"Merge",
"one",
"context",
"onto",
"another",
"by",
"adding",
"or",
"replacing",
"values",
"in",
"a",
"new",
"map"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L391-L407
|
16,075
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.addContext
|
public static Map<String, Map<String, String>> addContext(final String key, final Map<String, String> data,
final Map<String, Map<String, String>> context) {
final Map<String, Map<String, String>> newdata = new HashMap<>();
if (null != context) {
newdata.putAll(context);
}
newdata.put(key, data);
return newdata;
}
|
java
|
public static Map<String, Map<String, String>> addContext(final String key, final Map<String, String> data,
final Map<String, Map<String, String>> context) {
final Map<String, Map<String, String>> newdata = new HashMap<>();
if (null != context) {
newdata.putAll(context);
}
newdata.put(key, data);
return newdata;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"addContext",
"(",
"final",
"String",
"key",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"data",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"context",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"newdata",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"context",
")",
"{",
"newdata",
".",
"putAll",
"(",
"context",
")",
";",
"}",
"newdata",
".",
"put",
"(",
"key",
",",
"data",
")",
";",
"return",
"newdata",
";",
"}"
] |
Return a new context with appended data set
@param key data key
@param data data content
@param context original context
@return new context containing original data and the new dataset
|
[
"Return",
"a",
"new",
"context",
"with",
"appended",
"data",
"set"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L500-L508
|
16,076
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.generateEnvVarsFromData
|
public static Map<String, String> generateEnvVarsFromData(final Map<String, String> options, final String prefix) {
if (null == options) {
return null;
}
final HashMap<String, String> envs = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : options.entrySet()) {
if (null != entry.getKey() && null != entry.getValue()) {
envs.put(generateEnvVarName(prefix + "." + entry.getKey()), entry.getValue());
}
}
return envs;
}
|
java
|
public static Map<String, String> generateEnvVarsFromData(final Map<String, String> options, final String prefix) {
if (null == options) {
return null;
}
final HashMap<String, String> envs = new HashMap<String, String>();
for (final Map.Entry<String, String> entry : options.entrySet()) {
if (null != entry.getKey() && null != entry.getValue()) {
envs.put(generateEnvVarName(prefix + "." + entry.getKey()), entry.getValue());
}
}
return envs;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"generateEnvVarsFromData",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"options",
",",
"final",
"String",
"prefix",
")",
"{",
"if",
"(",
"null",
"==",
"options",
")",
"{",
"return",
"null",
";",
"}",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"envs",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"options",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"entry",
".",
"getKey",
"(",
")",
"&&",
"null",
"!=",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"envs",
".",
"put",
"(",
"generateEnvVarName",
"(",
"prefix",
"+",
"\".\"",
"+",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"envs",
";",
"}"
] |
Convert option keys into environment variable names. Convert to uppercase and prepend "RD_"
@param options the input options
@param prefix prefix
@return map of environment variable names to values, or null if options was null
|
[
"Convert",
"option",
"keys",
"into",
"environment",
"variable",
"names",
".",
"Convert",
"to",
"uppercase",
"and",
"prepend",
"RD_"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L518-L529
|
16,077
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.addEnvVars
|
public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
sshexecTask.addEnv(env);
}
}
}
}
|
java
|
public static void addEnvVars( final EnvironmentConfigurable sshexecTask, final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
sshexecTask.addEnv(env);
}
}
}
}
|
[
"public",
"static",
"void",
"addEnvVars",
"(",
"final",
"EnvironmentConfigurable",
"sshexecTask",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"environment",
"=",
"generateEnvVarsFromContext",
"(",
"dataContext",
")",
";",
"if",
"(",
"null",
"!=",
"environment",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"environment",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"key",
"&&",
"null",
"!=",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"final",
"Environment",
".",
"Variable",
"env",
"=",
"new",
"Environment",
".",
"Variable",
"(",
")",
";",
"env",
".",
"setKey",
"(",
"key",
")",
";",
"env",
".",
"setValue",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"sshexecTask",
".",
"addEnv",
"(",
"env",
")",
";",
"}",
"}",
"}",
"}"
] |
add Env elements to pass environment variables to the ExtSSHExec
@param sshexecTask task
@param dataContext data
|
[
"add",
"Env",
"elements",
"to",
"pass",
"environment",
"variables",
"to",
"the",
"ExtSSHExec"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L537-L550
|
16,078
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.nodeData
|
public static Map<String, String> nodeData(final INodeEntry nodeentry) {
final HashMap<String, String> data = new HashMap<String, String>();
if(null!=nodeentry) {
HashSet<String> skipProps = new HashSet<String>();
skipProps.addAll(Arrays.asList("nodename", "osName", "osVersion", "osArch", "osFamily"));
data.put("name", notNull(nodeentry.getNodename()));
data.put("hostname", notNull(nodeentry.getHostname()));
data.put("os-name", notNull(nodeentry.getOsName()));
data.put("os-version", notNull(nodeentry.getOsVersion()));
data.put("os-arch", notNull(nodeentry.getOsArch()));
data.put("os-family", notNull(nodeentry.getOsFamily()));
data.put("username", notNull(nodeentry.getUsername()));
data.put("description", notNull(nodeentry.getDescription()));
data.put("tags", null != nodeentry.getTags() ? join(nodeentry.getTags(), ",") : "");
//include attributes data
if (null != nodeentry.getAttributes()) {
for (final String name : nodeentry.getAttributes().keySet()) {
if (null != nodeentry.getAttributes().get(name) && !data.containsKey(name) && !skipProps.contains(
name)) {
data.put(name, notNull(nodeentry.getAttributes().get(name)));
}
}
}
}
return data;
}
|
java
|
public static Map<String, String> nodeData(final INodeEntry nodeentry) {
final HashMap<String, String> data = new HashMap<String, String>();
if(null!=nodeentry) {
HashSet<String> skipProps = new HashSet<String>();
skipProps.addAll(Arrays.asList("nodename", "osName", "osVersion", "osArch", "osFamily"));
data.put("name", notNull(nodeentry.getNodename()));
data.put("hostname", notNull(nodeentry.getHostname()));
data.put("os-name", notNull(nodeentry.getOsName()));
data.put("os-version", notNull(nodeentry.getOsVersion()));
data.put("os-arch", notNull(nodeentry.getOsArch()));
data.put("os-family", notNull(nodeentry.getOsFamily()));
data.put("username", notNull(nodeentry.getUsername()));
data.put("description", notNull(nodeentry.getDescription()));
data.put("tags", null != nodeentry.getTags() ? join(nodeentry.getTags(), ",") : "");
//include attributes data
if (null != nodeentry.getAttributes()) {
for (final String name : nodeentry.getAttributes().keySet()) {
if (null != nodeentry.getAttributes().get(name) && !data.containsKey(name) && !skipProps.contains(
name)) {
data.put(name, notNull(nodeentry.getAttributes().get(name)));
}
}
}
}
return data;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"nodeData",
"(",
"final",
"INodeEntry",
"nodeentry",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"data",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"nodeentry",
")",
"{",
"HashSet",
"<",
"String",
">",
"skipProps",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"skipProps",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"\"nodename\"",
",",
"\"osName\"",
",",
"\"osVersion\"",
",",
"\"osArch\"",
",",
"\"osFamily\"",
")",
")",
";",
"data",
".",
"put",
"(",
"\"name\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getNodename",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"hostname\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getHostname",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"os-name\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getOsName",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"os-version\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getOsVersion",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"os-arch\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getOsArch",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"os-family\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getOsFamily",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"username\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getUsername",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"description\"",
",",
"notNull",
"(",
"nodeentry",
".",
"getDescription",
"(",
")",
")",
")",
";",
"data",
".",
"put",
"(",
"\"tags\"",
",",
"null",
"!=",
"nodeentry",
".",
"getTags",
"(",
")",
"?",
"join",
"(",
"nodeentry",
".",
"getTags",
"(",
")",
",",
"\",\"",
")",
":",
"\"\"",
")",
";",
"//include attributes data",
"if",
"(",
"null",
"!=",
"nodeentry",
".",
"getAttributes",
"(",
")",
")",
"{",
"for",
"(",
"final",
"String",
"name",
":",
"nodeentry",
".",
"getAttributes",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"null",
"!=",
"nodeentry",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
"&&",
"!",
"data",
".",
"containsKey",
"(",
"name",
")",
"&&",
"!",
"skipProps",
".",
"contains",
"(",
"name",
")",
")",
"{",
"data",
".",
"put",
"(",
"name",
",",
"notNull",
"(",
"nodeentry",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"name",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"data",
";",
"}"
] |
Generate a dataset for a INodeEntry
@param nodeentry node
@return dataset
|
[
"Generate",
"a",
"dataset",
"for",
"a",
"INodeEntry"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L585-L611
|
16,079
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.join
|
public static String join(final Collection<String> list, final String separator) {
final StringBuilder sb = new StringBuilder();
for (final String s : list) {
if (sb.length() > 0) {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
java
|
public static String join(final Collection<String> list, final String separator) {
final StringBuilder sb = new StringBuilder();
for (final String s : list) {
if (sb.length() > 0) {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"join",
"(",
"final",
"Collection",
"<",
"String",
">",
"list",
",",
"final",
"String",
"separator",
")",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"list",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"separator",
")",
";",
"}",
"sb",
".",
"append",
"(",
"s",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Join a list of strings into a single string with a separator
@param list strings
@param separator separator
@return joined string
|
[
"Join",
"a",
"list",
"of",
"strings",
"into",
"a",
"single",
"string",
"with",
"a",
"separator"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L632-L641
|
16,080
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java
|
DataContextUtils.addEnvVarsFromContextForExec
|
public static void addEnvVarsFromContextForExec(final ExecTask execTask,
final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
execTask.addEnv(env);
}
}
}
}
|
java
|
public static void addEnvVarsFromContextForExec(final ExecTask execTask,
final Map<String, Map<String, String>> dataContext) {
final Map<String, String> environment = generateEnvVarsFromContext(dataContext);
if (null != environment) {
for (final Map.Entry<String, String> entry : environment.entrySet()) {
final String key = entry.getKey();
if (null != key && null != entry.getValue()) {
final Environment.Variable env = new Environment.Variable();
env.setKey(key);
env.setValue(entry.getValue());
execTask.addEnv(env);
}
}
}
}
|
[
"public",
"static",
"void",
"addEnvVarsFromContextForExec",
"(",
"final",
"ExecTask",
"execTask",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"environment",
"=",
"generateEnvVarsFromContext",
"(",
"dataContext",
")",
";",
"if",
"(",
"null",
"!=",
"environment",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"environment",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"key",
"&&",
"null",
"!=",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"final",
"Environment",
".",
"Variable",
"env",
"=",
"new",
"Environment",
".",
"Variable",
"(",
")",
";",
"env",
".",
"setKey",
"(",
"key",
")",
";",
"env",
".",
"setValue",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"execTask",
".",
"addEnv",
"(",
"env",
")",
";",
"}",
"}",
"}",
"}"
] |
Add embedded env elements for any included context data for the script
@param dataContext data
@param execTask execTask
|
[
"Add",
"embedded",
"env",
"elements",
"for",
"any",
"included",
"context",
"data",
"for",
"the",
"script"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/dispatcher/DataContextUtils.java#L649-L664
|
16,081
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/org/rundeck/jaas/AbstractBaseLoginModule.java
|
AbstractBaseLoginModule.setSubjectPrincipals
|
private void setSubjectPrincipals() {
if (null != userPrincipal) {
this.subject.getPrincipals().add(userPrincipal);
}
if (null != rolePrincipals) {
for (Principal rolePrincipal : rolePrincipals) {
this.subject.getPrincipals().add(rolePrincipal);
}
}
}
|
java
|
private void setSubjectPrincipals() {
if (null != userPrincipal) {
this.subject.getPrincipals().add(userPrincipal);
}
if (null != rolePrincipals) {
for (Principal rolePrincipal : rolePrincipals) {
this.subject.getPrincipals().add(rolePrincipal);
}
}
}
|
[
"private",
"void",
"setSubjectPrincipals",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"userPrincipal",
")",
"{",
"this",
".",
"subject",
".",
"getPrincipals",
"(",
")",
".",
"add",
"(",
"userPrincipal",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"rolePrincipals",
")",
"{",
"for",
"(",
"Principal",
"rolePrincipal",
":",
"rolePrincipals",
")",
"{",
"this",
".",
"subject",
".",
"getPrincipals",
"(",
")",
".",
"add",
"(",
"rolePrincipal",
")",
";",
"}",
"}",
"}"
] |
Set the principals for the Subject
|
[
"Set",
"the",
"principals",
"for",
"the",
"Subject"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/org/rundeck/jaas/AbstractBaseLoginModule.java#L112-L121
|
16,082
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/Pairs.java
|
Pairs.listFirst
|
public static <T,W> List<T> listFirst(List<Pair<T, W>> list) {
ArrayList<T> ts = new ArrayList<T>();
for (Pair<T, W> twPair : list) {
ts.add(twPair.getFirst());
}
return ts;
}
|
java
|
public static <T,W> List<T> listFirst(List<Pair<T, W>> list) {
ArrayList<T> ts = new ArrayList<T>();
for (Pair<T, W> twPair : list) {
ts.add(twPair.getFirst());
}
return ts;
}
|
[
"public",
"static",
"<",
"T",
",",
"W",
">",
"List",
"<",
"T",
">",
"listFirst",
"(",
"List",
"<",
"Pair",
"<",
"T",
",",
"W",
">",
">",
"list",
")",
"{",
"ArrayList",
"<",
"T",
">",
"ts",
"=",
"new",
"ArrayList",
"<",
"T",
">",
"(",
")",
";",
"for",
"(",
"Pair",
"<",
"T",
",",
"W",
">",
"twPair",
":",
"list",
")",
"{",
"ts",
".",
"add",
"(",
"twPair",
".",
"getFirst",
"(",
")",
")",
";",
"}",
"return",
"ts",
";",
"}"
] |
Return a List of the first items from a list of pairs
@param list list
@param <T> first type
@param <W> second type
@return list of firsts
|
[
"Return",
"a",
"List",
"of",
"the",
"first",
"items",
"from",
"a",
"list",
"of",
"pairs"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/Pairs.java#L36-L42
|
16,083
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/Pairs.java
|
Pairs.listSecond
|
public static <T,W> List<W> listSecond(List<Pair<T, W>> list) {
ArrayList<W> ts = new ArrayList<W>();
for (Pair<T, W> twPair : list) {
ts.add(twPair.getSecond());
}
return ts;
}
|
java
|
public static <T,W> List<W> listSecond(List<Pair<T, W>> list) {
ArrayList<W> ts = new ArrayList<W>();
for (Pair<T, W> twPair : list) {
ts.add(twPair.getSecond());
}
return ts;
}
|
[
"public",
"static",
"<",
"T",
",",
"W",
">",
"List",
"<",
"W",
">",
"listSecond",
"(",
"List",
"<",
"Pair",
"<",
"T",
",",
"W",
">",
">",
"list",
")",
"{",
"ArrayList",
"<",
"W",
">",
"ts",
"=",
"new",
"ArrayList",
"<",
"W",
">",
"(",
")",
";",
"for",
"(",
"Pair",
"<",
"T",
",",
"W",
">",
"twPair",
":",
"list",
")",
"{",
"ts",
".",
"add",
"(",
"twPair",
".",
"getSecond",
"(",
")",
")",
";",
"}",
"return",
"ts",
";",
"}"
] |
Return a List of the second items from a list of pairs
@param list list
@param <T> first type
@param <W> second type
@return list of seconds
|
[
"Return",
"a",
"List",
"of",
"the",
"second",
"items",
"from",
"a",
"list",
"of",
"pairs"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/Pairs.java#L51-L57
|
16,084
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/plugins/step/GeneratedScriptBuilder.java
|
GeneratedScriptBuilder.script
|
public static GeneratedScript script(final String script, final String[] args, final String fileExtension) {
return new GeneratedScriptBuilder(script, args, fileExtension);
}
|
java
|
public static GeneratedScript script(final String script, final String[] args, final String fileExtension) {
return new GeneratedScriptBuilder(script, args, fileExtension);
}
|
[
"public",
"static",
"GeneratedScript",
"script",
"(",
"final",
"String",
"script",
",",
"final",
"String",
"[",
"]",
"args",
",",
"final",
"String",
"fileExtension",
")",
"{",
"return",
"new",
"GeneratedScriptBuilder",
"(",
"script",
",",
"args",
",",
"fileExtension",
")",
";",
"}"
] |
Create a script
@param script the script text
@param args the arguments for the script
@param fileExtension file extension
@return the generated script
|
[
"Create",
"a",
"script"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/plugins/step/GeneratedScriptBuilder.java#L92-L94
|
16,085
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/launcher/Preferences.java
|
Preferences.convert2PropName
|
private static String convert2PropName(String argProp) throws Exception {
//System.out.println("argProp: " + argProp);
if (!argProp.startsWith("--")) {
throw new Exception("argument: " + argProp + " does not start with --");
}
if (argProp.indexOf("=") == -1) {
throw new Exception("argument: " + argProp + " does not contain an = sign");
}
// remove hyphens
String argProperty = argProp.substring(2);
if (null == argProperty || "".equals(argProperty))
throw new Exception("argument: " + argProp + " not valid");
// get the lhs of =, the property name
String argPropName = argProperty.split("=")[0];
if (null == argPropName || "".equals(argPropName))
throw new Exception("argument: " + argProp + " not valid");
// get the rhs of =, the property value
int equalsAt = argProperty.indexOf('=');
String argPropValue = argProperty.substring(equalsAt + 1);
if (null == argPropValue || "".equals(argPropValue))
throw new Exception("argument: " + argProp + " not valid");
//System.out.println("argPropName: " + argPropName);
// ensure this type of prop is one that we will handle
//String[] dotSplit = argPropName.split("\\.");
//String propType = dotSplit[0];
//if (Arrays.binarySearch(PREFS_ALLOWED_PROP_TYPES, propType) < 0) {
//StringBuffer allowedProps = new StringBuffer();
//for (int i = 0; i < PREFS_ALLOWED_PROP_TYPES.length; i++) {
//allowedProps.append(PREFS_ALLOWED_PROP_TYPES[i]);
//allowedProps.append(" ");
//}
//throw new Exception("argument: " + argProp + " not allowed, " +
//allowedProps.toString());
//}
return argPropName;
}
|
java
|
private static String convert2PropName(String argProp) throws Exception {
//System.out.println("argProp: " + argProp);
if (!argProp.startsWith("--")) {
throw new Exception("argument: " + argProp + " does not start with --");
}
if (argProp.indexOf("=") == -1) {
throw new Exception("argument: " + argProp + " does not contain an = sign");
}
// remove hyphens
String argProperty = argProp.substring(2);
if (null == argProperty || "".equals(argProperty))
throw new Exception("argument: " + argProp + " not valid");
// get the lhs of =, the property name
String argPropName = argProperty.split("=")[0];
if (null == argPropName || "".equals(argPropName))
throw new Exception("argument: " + argProp + " not valid");
// get the rhs of =, the property value
int equalsAt = argProperty.indexOf('=');
String argPropValue = argProperty.substring(equalsAt + 1);
if (null == argPropValue || "".equals(argPropValue))
throw new Exception("argument: " + argProp + " not valid");
//System.out.println("argPropName: " + argPropName);
// ensure this type of prop is one that we will handle
//String[] dotSplit = argPropName.split("\\.");
//String propType = dotSplit[0];
//if (Arrays.binarySearch(PREFS_ALLOWED_PROP_TYPES, propType) < 0) {
//StringBuffer allowedProps = new StringBuffer();
//for (int i = 0; i < PREFS_ALLOWED_PROP_TYPES.length; i++) {
//allowedProps.append(PREFS_ALLOWED_PROP_TYPES[i]);
//allowedProps.append(" ");
//}
//throw new Exception("argument: " + argProp + " not allowed, " +
//allowedProps.toString());
//}
return argPropName;
}
|
[
"private",
"static",
"String",
"convert2PropName",
"(",
"String",
"argProp",
")",
"throws",
"Exception",
"{",
"//System.out.println(\"argProp: \" + argProp);",
"if",
"(",
"!",
"argProp",
".",
"startsWith",
"(",
"\"--\"",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"argument: \"",
"+",
"argProp",
"+",
"\" does not start with --\"",
")",
";",
"}",
"if",
"(",
"argProp",
".",
"indexOf",
"(",
"\"=\"",
")",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"argument: \"",
"+",
"argProp",
"+",
"\" does not contain an = sign\"",
")",
";",
"}",
"// remove hyphens",
"String",
"argProperty",
"=",
"argProp",
".",
"substring",
"(",
"2",
")",
";",
"if",
"(",
"null",
"==",
"argProperty",
"||",
"\"\"",
".",
"equals",
"(",
"argProperty",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"argument: \"",
"+",
"argProp",
"+",
"\" not valid\"",
")",
";",
"// get the lhs of =, the property name",
"String",
"argPropName",
"=",
"argProperty",
".",
"split",
"(",
"\"=\"",
")",
"[",
"0",
"]",
";",
"if",
"(",
"null",
"==",
"argPropName",
"||",
"\"\"",
".",
"equals",
"(",
"argPropName",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"argument: \"",
"+",
"argProp",
"+",
"\" not valid\"",
")",
";",
"// get the rhs of =, the property value",
"int",
"equalsAt",
"=",
"argProperty",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"String",
"argPropValue",
"=",
"argProperty",
".",
"substring",
"(",
"equalsAt",
"+",
"1",
")",
";",
"if",
"(",
"null",
"==",
"argPropValue",
"||",
"\"\"",
".",
"equals",
"(",
"argPropValue",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"argument: \"",
"+",
"argProp",
"+",
"\" not valid\"",
")",
";",
"//System.out.println(\"argPropName: \" + argPropName);",
"// ensure this type of prop is one that we will handle",
"//String[] dotSplit = argPropName.split(\"\\\\.\");",
"//String propType = dotSplit[0];",
"//if (Arrays.binarySearch(PREFS_ALLOWED_PROP_TYPES, propType) < 0) {",
"//StringBuffer allowedProps = new StringBuffer();",
"//for (int i = 0; i < PREFS_ALLOWED_PROP_TYPES.length; i++) {",
"//allowedProps.append(PREFS_ALLOWED_PROP_TYPES[i]);",
"//allowedProps.append(\" \");",
"//}",
"//throw new Exception(\"argument: \" + argProp + \" not allowed, \" +",
"//allowedProps.toString());",
"//}",
"return",
"argPropName",
";",
"}"
] |
also check if it is a valid type of property
|
[
"also",
"check",
"if",
"it",
"is",
"a",
"valid",
"type",
"of",
"property"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/launcher/Preferences.java#L225-L274
|
16,086
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCachingLdapLoginModule.java
|
JettyCachingLdapLoginModule.getUserRoles
|
@SuppressWarnings("unchecked")
protected List getUserRoles(DirContext dirContext, String username) throws LoginException,
NamingException {
String userDn = _userRdnAttribute + "=" + username + "," + _userBaseDn;
return getUserRolesByDn(dirContext, userDn, username);
}
|
java
|
@SuppressWarnings("unchecked")
protected List getUserRoles(DirContext dirContext, String username) throws LoginException,
NamingException {
String userDn = _userRdnAttribute + "=" + username + "," + _userBaseDn;
return getUserRolesByDn(dirContext, userDn, username);
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"List",
"getUserRoles",
"(",
"DirContext",
"dirContext",
",",
"String",
"username",
")",
"throws",
"LoginException",
",",
"NamingException",
"{",
"String",
"userDn",
"=",
"_userRdnAttribute",
"+",
"\"=\"",
"+",
"username",
"+",
"\",\"",
"+",
"_userBaseDn",
";",
"return",
"getUserRolesByDn",
"(",
"dirContext",
",",
"userDn",
",",
"username",
")",
";",
"}"
] |
attempts to get the users roles from the root context
NOTE: this is not an user authenticated operation
@param dirContext
@param username
@return
@throws LoginException
|
[
"attempts",
"to",
"get",
"the",
"users",
"roles",
"from",
"the",
"root",
"context"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCachingLdapLoginModule.java#L437-L443
|
16,087
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCachingLdapLoginModule.java
|
JettyCachingLdapLoginModule.getEnvironment
|
@SuppressWarnings("unchecked")
public Hashtable getEnvironment() {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, _contextFactory);
String url = null;
if(_providerUrl != null) {
url = _providerUrl;
} else {
if (_hostname != null) {
url = "ldap://" + _hostname + "/";
if (_port != 0) {
url += ":" + _port + "/";
}
LOG.warn("Using hostname and port. Use providerUrl instead: " + url);
}
}
env.put(Context.PROVIDER_URL, url);
if (_authenticationMethod != null) {
env.put(Context.SECURITY_AUTHENTICATION, _authenticationMethod);
}
if (_bindDn != null) {
env.put(Context.SECURITY_PRINCIPAL, _bindDn);
}
if (_bindPassword != null) {
env.put(Context.SECURITY_CREDENTIALS, _bindPassword);
}
env.put("com.sun.jndi.ldap.read.timeout", Long.toString(_timeoutRead));
env.put("com.sun.jndi.ldap.connect.timeout", Long.toString(_timeoutConnect));
// Set the SSLContextFactory to implementation that validates cert subject
if (url != null && url.startsWith("ldaps") && _ldapsVerifyHostname) {
try {
URI uri = new URI(url);
HostnameVerifyingSSLSocketFactory.setTargetHost(uri.getHost());
env.put("java.naming.ldap.factory.socket",
"com.dtolabs.rundeck.jetty.jaas.HostnameVerifyingSSLSocketFactory");
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
return env;
}
|
java
|
@SuppressWarnings("unchecked")
public Hashtable getEnvironment() {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, _contextFactory);
String url = null;
if(_providerUrl != null) {
url = _providerUrl;
} else {
if (_hostname != null) {
url = "ldap://" + _hostname + "/";
if (_port != 0) {
url += ":" + _port + "/";
}
LOG.warn("Using hostname and port. Use providerUrl instead: " + url);
}
}
env.put(Context.PROVIDER_URL, url);
if (_authenticationMethod != null) {
env.put(Context.SECURITY_AUTHENTICATION, _authenticationMethod);
}
if (_bindDn != null) {
env.put(Context.SECURITY_PRINCIPAL, _bindDn);
}
if (_bindPassword != null) {
env.put(Context.SECURITY_CREDENTIALS, _bindPassword);
}
env.put("com.sun.jndi.ldap.read.timeout", Long.toString(_timeoutRead));
env.put("com.sun.jndi.ldap.connect.timeout", Long.toString(_timeoutConnect));
// Set the SSLContextFactory to implementation that validates cert subject
if (url != null && url.startsWith("ldaps") && _ldapsVerifyHostname) {
try {
URI uri = new URI(url);
HostnameVerifyingSSLSocketFactory.setTargetHost(uri.getHost());
env.put("java.naming.ldap.factory.socket",
"com.dtolabs.rundeck.jetty.jaas.HostnameVerifyingSSLSocketFactory");
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
return env;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"Hashtable",
"getEnvironment",
"(",
")",
"{",
"Properties",
"env",
"=",
"new",
"Properties",
"(",
")",
";",
"env",
".",
"put",
"(",
"Context",
".",
"INITIAL_CONTEXT_FACTORY",
",",
"_contextFactory",
")",
";",
"String",
"url",
"=",
"null",
";",
"if",
"(",
"_providerUrl",
"!=",
"null",
")",
"{",
"url",
"=",
"_providerUrl",
";",
"}",
"else",
"{",
"if",
"(",
"_hostname",
"!=",
"null",
")",
"{",
"url",
"=",
"\"ldap://\"",
"+",
"_hostname",
"+",
"\"/\"",
";",
"if",
"(",
"_port",
"!=",
"0",
")",
"{",
"url",
"+=",
"\":\"",
"+",
"_port",
"+",
"\"/\"",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Using hostname and port. Use providerUrl instead: \"",
"+",
"url",
")",
";",
"}",
"}",
"env",
".",
"put",
"(",
"Context",
".",
"PROVIDER_URL",
",",
"url",
")",
";",
"if",
"(",
"_authenticationMethod",
"!=",
"null",
")",
"{",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_AUTHENTICATION",
",",
"_authenticationMethod",
")",
";",
"}",
"if",
"(",
"_bindDn",
"!=",
"null",
")",
"{",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_PRINCIPAL",
",",
"_bindDn",
")",
";",
"}",
"if",
"(",
"_bindPassword",
"!=",
"null",
")",
"{",
"env",
".",
"put",
"(",
"Context",
".",
"SECURITY_CREDENTIALS",
",",
"_bindPassword",
")",
";",
"}",
"env",
".",
"put",
"(",
"\"com.sun.jndi.ldap.read.timeout\"",
",",
"Long",
".",
"toString",
"(",
"_timeoutRead",
")",
")",
";",
"env",
".",
"put",
"(",
"\"com.sun.jndi.ldap.connect.timeout\"",
",",
"Long",
".",
"toString",
"(",
"_timeoutConnect",
")",
")",
";",
"// Set the SSLContextFactory to implementation that validates cert subject",
"if",
"(",
"url",
"!=",
"null",
"&&",
"url",
".",
"startsWith",
"(",
"\"ldaps\"",
")",
"&&",
"_ldapsVerifyHostname",
")",
"{",
"try",
"{",
"URI",
"uri",
"=",
"new",
"URI",
"(",
"url",
")",
";",
"HostnameVerifyingSSLSocketFactory",
".",
"setTargetHost",
"(",
"uri",
".",
"getHost",
"(",
")",
")",
";",
"env",
".",
"put",
"(",
"\"java.naming.ldap.factory.socket\"",
",",
"\"com.dtolabs.rundeck.jetty.jaas.HostnameVerifyingSSLSocketFactory\"",
")",
";",
"}",
"catch",
"(",
"URISyntaxException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"return",
"env",
";",
"}"
] |
get the context for connection
@return
|
[
"get",
"the",
"context",
"for",
"connection"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCachingLdapLoginModule.java#L1056-L1104
|
16,088
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java
|
DescriptionBuilder.buildDescriptionWith
|
public static Description buildDescriptionWith(Consumer<DescriptionBuilder> builder) {
DescriptionBuilder builder1 = builder();
builder.accept(builder1);
return builder1.build();
}
|
java
|
public static Description buildDescriptionWith(Consumer<DescriptionBuilder> builder) {
DescriptionBuilder builder1 = builder();
builder.accept(builder1);
return builder1.build();
}
|
[
"public",
"static",
"Description",
"buildDescriptionWith",
"(",
"Consumer",
"<",
"DescriptionBuilder",
">",
"builder",
")",
"{",
"DescriptionBuilder",
"builder1",
"=",
"builder",
"(",
")",
";",
"builder",
".",
"accept",
"(",
"builder1",
")",
";",
"return",
"builder1",
".",
"build",
"(",
")",
";",
"}"
] |
Build a description
@param builder new DescriptionBuilder to build with
@return built description
|
[
"Build",
"a",
"description"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java#L82-L86
|
16,089
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java
|
DescriptionBuilder.property
|
public DescriptionBuilder property(final Consumer<PropertyBuilder> builder) {
PropertyBuilder propertyBuilder = PropertyBuilder.builder();
builder.accept(propertyBuilder);
replaceOrAddProperty(propertyBuilder.build());
return this;
}
|
java
|
public DescriptionBuilder property(final Consumer<PropertyBuilder> builder) {
PropertyBuilder propertyBuilder = PropertyBuilder.builder();
builder.accept(propertyBuilder);
replaceOrAddProperty(propertyBuilder.build());
return this;
}
|
[
"public",
"DescriptionBuilder",
"property",
"(",
"final",
"Consumer",
"<",
"PropertyBuilder",
">",
"builder",
")",
"{",
"PropertyBuilder",
"propertyBuilder",
"=",
"PropertyBuilder",
".",
"builder",
"(",
")",
";",
"builder",
".",
"accept",
"(",
"propertyBuilder",
")",
";",
"replaceOrAddProperty",
"(",
"propertyBuilder",
".",
"build",
"(",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Add a new property, or replace an existing property with the same name, with a
consumer
@param builder a new PropertyBuilder to modify
@return this builder
|
[
"Add",
"a",
"new",
"property",
"or",
"replace",
"an",
"existing",
"property",
"with",
"the",
"same",
"name",
"with",
"a",
"consumer"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java#L287-L292
|
16,090
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java
|
DescriptionBuilder.removeProperty
|
public DescriptionBuilder removeProperty(final String name) {
final Property found = findProperty(name);
if (null != found) {
properties.remove(found);
}
return this;
}
|
java
|
public DescriptionBuilder removeProperty(final String name) {
final Property found = findProperty(name);
if (null != found) {
properties.remove(found);
}
return this;
}
|
[
"public",
"DescriptionBuilder",
"removeProperty",
"(",
"final",
"String",
"name",
")",
"{",
"final",
"Property",
"found",
"=",
"findProperty",
"(",
"name",
")",
";",
"if",
"(",
"null",
"!=",
"found",
")",
"{",
"properties",
".",
"remove",
"(",
"found",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Remove a previously defined property by name
@param name property name
@return this builder
|
[
"Remove",
"a",
"previously",
"defined",
"property",
"by",
"name"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java#L299-L305
|
16,091
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java
|
DescriptionBuilder.metadata
|
public DescriptionBuilder metadata(final String key, final String value) {
metadata.put(key, value);
return this;
}
|
java
|
public DescriptionBuilder metadata(final String key, final String value) {
metadata.put(key, value);
return this;
}
|
[
"public",
"DescriptionBuilder",
"metadata",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"metadata",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] |
Set a metadata value
@param key metadata key
@param value metadata value
@return this builder
|
[
"Set",
"a",
"metadata",
"value"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/plugins/util/DescriptionBuilder.java#L352-L355
|
16,092
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProject.java
|
FrameworkProject.authorizationEnvironment
|
public static Set<Attribute> authorizationEnvironment(final String project) {
return Collections.singleton(new Attribute(URI.create(EnvironmentalContext.URI_BASE + "project"),
project));
}
|
java
|
public static Set<Attribute> authorizationEnvironment(final String project) {
return Collections.singleton(new Attribute(URI.create(EnvironmentalContext.URI_BASE + "project"),
project));
}
|
[
"public",
"static",
"Set",
"<",
"Attribute",
">",
"authorizationEnvironment",
"(",
"final",
"String",
"project",
")",
"{",
"return",
"Collections",
".",
"singleton",
"(",
"new",
"Attribute",
"(",
"URI",
".",
"create",
"(",
"EnvironmentalContext",
".",
"URI_BASE",
"+",
"\"project\"",
")",
",",
"project",
")",
")",
";",
"}"
] |
Creates an authorization environment for a project.
@param project project name
@return environment to evaluate authorization for a project
|
[
"Creates",
"an",
"authorization",
"environment",
"for",
"a",
"project",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProject.java#L51-L54
|
16,093
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProject.java
|
FrameworkProject.createFileStructure
|
public static void createFileStructure(final File projectDir) throws IOException {
/*
* create an empty project file structure
*/
if (! projectDir.exists() && ! projectDir.mkdirs()) {
throw new IOException("failed creating project base dir: " + projectDir.getAbsolutePath());
}
/**
* Create project etc directory for configuration data
*/
final File etcDir = new File(projectDir, FrameworkProject.ETC_DIR_NAME);
if (! etcDir.exists() && ! etcDir.mkdirs()) {
throw new IOException("failed creating project etc dir: " + etcDir.getAbsolutePath());
}
}
|
java
|
public static void createFileStructure(final File projectDir) throws IOException {
/*
* create an empty project file structure
*/
if (! projectDir.exists() && ! projectDir.mkdirs()) {
throw new IOException("failed creating project base dir: " + projectDir.getAbsolutePath());
}
/**
* Create project etc directory for configuration data
*/
final File etcDir = new File(projectDir, FrameworkProject.ETC_DIR_NAME);
if (! etcDir.exists() && ! etcDir.mkdirs()) {
throw new IOException("failed creating project etc dir: " + etcDir.getAbsolutePath());
}
}
|
[
"public",
"static",
"void",
"createFileStructure",
"(",
"final",
"File",
"projectDir",
")",
"throws",
"IOException",
"{",
"/*\n * create an empty project file structure\n */",
"if",
"(",
"!",
"projectDir",
".",
"exists",
"(",
")",
"&&",
"!",
"projectDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"failed creating project base dir: \"",
"+",
"projectDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"/**\n * Create project etc directory for configuration data\n */",
"final",
"File",
"etcDir",
"=",
"new",
"File",
"(",
"projectDir",
",",
"FrameworkProject",
".",
"ETC_DIR_NAME",
")",
";",
"if",
"(",
"!",
"etcDir",
".",
"exists",
"(",
")",
"&&",
"!",
"etcDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"failed creating project etc dir: \"",
"+",
"etcDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}"
] |
Creates the file structure for a project
@param projectDir The project base directory
@throws IOException on io error
|
[
"Creates",
"the",
"file",
"structure",
"for",
"a",
"project"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/FrameworkProject.java#L309-L324
|
16,094
|
rundeck/rundeck
|
plugins/orchestrator-plugin/src/main/java/org/rundeck/plugin/example/RandomSubsetOrchestrator.java
|
RandomSubsetOrchestrator.select
|
private List<INodeEntry> select(final int count, final Collection<INodeEntry> nodes) {
List<INodeEntry> source = new ArrayList<>(nodes);
List<INodeEntry> selected = new ArrayList<>();
int total = Math.min(count, nodes.size());
for (int i = 0; i < total; i++) {
selected.add(source.remove(random.nextInt(source.size())));
}
return selected;
}
|
java
|
private List<INodeEntry> select(final int count, final Collection<INodeEntry> nodes) {
List<INodeEntry> source = new ArrayList<>(nodes);
List<INodeEntry> selected = new ArrayList<>();
int total = Math.min(count, nodes.size());
for (int i = 0; i < total; i++) {
selected.add(source.remove(random.nextInt(source.size())));
}
return selected;
}
|
[
"private",
"List",
"<",
"INodeEntry",
">",
"select",
"(",
"final",
"int",
"count",
",",
"final",
"Collection",
"<",
"INodeEntry",
">",
"nodes",
")",
"{",
"List",
"<",
"INodeEntry",
">",
"source",
"=",
"new",
"ArrayList",
"<>",
"(",
"nodes",
")",
";",
"List",
"<",
"INodeEntry",
">",
"selected",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"int",
"total",
"=",
"Math",
".",
"min",
"(",
"count",
",",
"nodes",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"total",
";",
"i",
"++",
")",
"{",
"selected",
".",
"add",
"(",
"source",
".",
"remove",
"(",
"random",
".",
"nextInt",
"(",
"source",
".",
"size",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"selected",
";",
"}"
] |
Select count random items from the input nodes, or if nodes is smaller than count, reorders them
@param count number of nodes
@param nodes input nodes
@return list of count nodes
|
[
"Select",
"count",
"random",
"items",
"from",
"the",
"input",
"nodes",
"or",
"if",
"nodes",
"is",
"smaller",
"than",
"count",
"reorders",
"them"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/plugins/orchestrator-plugin/src/main/java/org/rundeck/plugin/example/RandomSubsetOrchestrator.java#L57-L65
|
16,095
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/utils/ResponderTask.java
|
ResponderTask.createSequence
|
public Callable<ResponderResult> createSequence(final Responder responder, final ResultHandler resultHandler) {
return new Sequence<>(this, this.chainResponder(responder, resultHandler));
}
|
java
|
public Callable<ResponderResult> createSequence(final Responder responder, final ResultHandler resultHandler) {
return new Sequence<>(this, this.chainResponder(responder, resultHandler));
}
|
[
"public",
"Callable",
"<",
"ResponderResult",
">",
"createSequence",
"(",
"final",
"Responder",
"responder",
",",
"final",
"ResultHandler",
"resultHandler",
")",
"{",
"return",
"new",
"Sequence",
"<>",
"(",
"this",
",",
"this",
".",
"chainResponder",
"(",
"responder",
",",
"resultHandler",
")",
")",
";",
"}"
] |
Create a Callable that will execute another responder if this one is successful, with a specified resultHandler for the
second one.
@param responder responder
@param resultHandler handler
@return sequence
|
[
"Create",
"a",
"Callable",
"that",
"will",
"execute",
"another",
"responder",
"if",
"this",
"one",
"is",
"successful",
"with",
"a",
"specified",
"resultHandler",
"for",
"the",
"second",
"one",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/utils/ResponderTask.java#L238-L240
|
16,096
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/authorization/RuleEvaluator.java
|
RuleEvaluator.evaluate
|
private Decision evaluate(
Map<String, String> resource, Subject subject,
String action, Set<Attribute> environment, List<AclRule> matchedRules
)
{
Decision decision = internalEvaluate(resource, subject, action, environment, matchedRules);
if(decision.isAuthorized()) {
logger.info(MessageFormat.format("Evaluating {0} ({1}ms)", decision, decision.evaluationDuration()));
}else{
logger.warn(MessageFormat.format("Evaluating {0} ({1}ms)", decision, decision.evaluationDuration()));
}
return decision;
}
|
java
|
private Decision evaluate(
Map<String, String> resource, Subject subject,
String action, Set<Attribute> environment, List<AclRule> matchedRules
)
{
Decision decision = internalEvaluate(resource, subject, action, environment, matchedRules);
if(decision.isAuthorized()) {
logger.info(MessageFormat.format("Evaluating {0} ({1}ms)", decision, decision.evaluationDuration()));
}else{
logger.warn(MessageFormat.format("Evaluating {0} ({1}ms)", decision, decision.evaluationDuration()));
}
return decision;
}
|
[
"private",
"Decision",
"evaluate",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"resource",
",",
"Subject",
"subject",
",",
"String",
"action",
",",
"Set",
"<",
"Attribute",
">",
"environment",
",",
"List",
"<",
"AclRule",
">",
"matchedRules",
")",
"{",
"Decision",
"decision",
"=",
"internalEvaluate",
"(",
"resource",
",",
"subject",
",",
"action",
",",
"environment",
",",
"matchedRules",
")",
";",
"if",
"(",
"decision",
".",
"isAuthorized",
"(",
")",
")",
"{",
"logger",
".",
"info",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Evaluating {0} ({1}ms)\"",
",",
"decision",
",",
"decision",
".",
"evaluationDuration",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"logger",
".",
"warn",
"(",
"MessageFormat",
".",
"format",
"(",
"\"Evaluating {0} ({1}ms)\"",
",",
"decision",
",",
"decision",
".",
"evaluationDuration",
"(",
")",
")",
")",
";",
"}",
"return",
"decision",
";",
"}"
] |
Return the evaluation decision for the resource, subject, action, environment and contexts
|
[
"Return",
"the",
"evaluation",
"decision",
"for",
"the",
"resource",
"subject",
"action",
"environment",
"and",
"contexts"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/authorization/RuleEvaluator.java#L245-L258
|
16,097
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/authorization/RuleEvaluator.java
|
RuleEvaluator.predicateMatchRules
|
@SuppressWarnings("rawtypes")
boolean predicateMatchRules(
final Map<String, String> resource,
final Function<String, Predicate<String>> predicateTransformer,
final Function<List, Predicate<String>> listpred,
final Map<String, Object> ruleResource, final String sourceIdentity
)
{
for (final Object o : ruleResource.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final Object test = entry.getValue();
final boolean matched = applyTest(resource, predicateTransformer, key, test, listpred, sourceIdentity);
if (!matched) {
return false;
}
}
return true;
}
|
java
|
@SuppressWarnings("rawtypes")
boolean predicateMatchRules(
final Map<String, String> resource,
final Function<String, Predicate<String>> predicateTransformer,
final Function<List, Predicate<String>> listpred,
final Map<String, Object> ruleResource, final String sourceIdentity
)
{
for (final Object o : ruleResource.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final Object test = entry.getValue();
final boolean matched = applyTest(resource, predicateTransformer, key, test, listpred, sourceIdentity);
if (!matched) {
return false;
}
}
return true;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"rawtypes\"",
")",
"boolean",
"predicateMatchRules",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"resource",
",",
"final",
"Function",
"<",
"String",
",",
"Predicate",
"<",
"String",
">",
">",
"predicateTransformer",
",",
"final",
"Function",
"<",
"List",
",",
"Predicate",
"<",
"String",
">",
">",
"listpred",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"ruleResource",
",",
"final",
"String",
"sourceIdentity",
")",
"{",
"for",
"(",
"final",
"Object",
"o",
":",
"ruleResource",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"o",
";",
"final",
"String",
"key",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"Object",
"test",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"final",
"boolean",
"matched",
"=",
"applyTest",
"(",
"resource",
",",
"predicateTransformer",
",",
"key",
",",
"test",
",",
"listpred",
",",
"sourceIdentity",
")",
";",
"if",
"(",
"!",
"matched",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Return true if all entries in the "match" map pass the predicate tests for the resource
@param resource the resource
@param predicateTransformer transformer to convert a String into a Predicate check
@param listpred
@param ruleResource
@param sourceIdentity
|
[
"Return",
"true",
"if",
"all",
"entries",
"in",
"the",
"match",
"map",
"pass",
"the",
"predicate",
"tests",
"for",
"the",
"resource"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/authorization/RuleEvaluator.java#L787-L806
|
16,098
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/DirPluginScanner.java
|
DirPluginScanner.resolveProviderConflict
|
File resolveProviderConflict(final Collection<FileCache.MemoFile> matched){
final HashMap<File, VersionCompare> versions = new HashMap<File, VersionCompare>();
final ArrayList<File> toCompare = new ArrayList<File>();
for (final FileCache.MemoFile file : matched) {
final String vers = getVersionForFile(file.getFile());
if (null != vers) {
versions.put(file.getFile(), VersionCompare.forString(vers));
toCompare.add(file.getFile());
}
}
//currently resolve via filename
final Comparator<File> c = new VersionCompare.fileComparator(versions);
final List<File> sorted = new ArrayList<File>(toCompare);
Collections.sort(sorted, c);
if (sorted.size() > 0) {
return sorted.get(sorted.size() - 1);
}
return null;
}
|
java
|
File resolveProviderConflict(final Collection<FileCache.MemoFile> matched){
final HashMap<File, VersionCompare> versions = new HashMap<File, VersionCompare>();
final ArrayList<File> toCompare = new ArrayList<File>();
for (final FileCache.MemoFile file : matched) {
final String vers = getVersionForFile(file.getFile());
if (null != vers) {
versions.put(file.getFile(), VersionCompare.forString(vers));
toCompare.add(file.getFile());
}
}
//currently resolve via filename
final Comparator<File> c = new VersionCompare.fileComparator(versions);
final List<File> sorted = new ArrayList<File>(toCompare);
Collections.sort(sorted, c);
if (sorted.size() > 0) {
return sorted.get(sorted.size() - 1);
}
return null;
}
|
[
"File",
"resolveProviderConflict",
"(",
"final",
"Collection",
"<",
"FileCache",
".",
"MemoFile",
">",
"matched",
")",
"{",
"final",
"HashMap",
"<",
"File",
",",
"VersionCompare",
">",
"versions",
"=",
"new",
"HashMap",
"<",
"File",
",",
"VersionCompare",
">",
"(",
")",
";",
"final",
"ArrayList",
"<",
"File",
">",
"toCompare",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
")",
";",
"for",
"(",
"final",
"FileCache",
".",
"MemoFile",
"file",
":",
"matched",
")",
"{",
"final",
"String",
"vers",
"=",
"getVersionForFile",
"(",
"file",
".",
"getFile",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"vers",
")",
"{",
"versions",
".",
"put",
"(",
"file",
".",
"getFile",
"(",
")",
",",
"VersionCompare",
".",
"forString",
"(",
"vers",
")",
")",
";",
"toCompare",
".",
"add",
"(",
"file",
".",
"getFile",
"(",
")",
")",
";",
"}",
"}",
"//currently resolve via filename",
"final",
"Comparator",
"<",
"File",
">",
"c",
"=",
"new",
"VersionCompare",
".",
"fileComparator",
"(",
"versions",
")",
";",
"final",
"List",
"<",
"File",
">",
"sorted",
"=",
"new",
"ArrayList",
"<",
"File",
">",
"(",
"toCompare",
")",
";",
"Collections",
".",
"sort",
"(",
"sorted",
",",
"c",
")",
";",
"if",
"(",
"sorted",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"return",
"sorted",
".",
"get",
"(",
"sorted",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Return a single file that should be used among all te files matching a single provider identity, or null if
the conflict cannot be resolved.
|
[
"Return",
"a",
"single",
"file",
"that",
"should",
"be",
"used",
"among",
"all",
"te",
"files",
"matching",
"a",
"single",
"provider",
"identity",
"or",
"null",
"if",
"the",
"conflict",
"cannot",
"be",
"resolved",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/DirPluginScanner.java#L76-L94
|
16,099
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/DirPluginScanner.java
|
DirPluginScanner.scanForFile
|
public final File scanForFile(final ProviderIdent ident) throws PluginScannerException {
if (!extdir.exists() || !extdir.isDirectory()) {
return null;
}
return scanFor(ident, extdir.listFiles(getFileFilter()));
}
|
java
|
public final File scanForFile(final ProviderIdent ident) throws PluginScannerException {
if (!extdir.exists() || !extdir.isDirectory()) {
return null;
}
return scanFor(ident, extdir.listFiles(getFileFilter()));
}
|
[
"public",
"final",
"File",
"scanForFile",
"(",
"final",
"ProviderIdent",
"ident",
")",
"throws",
"PluginScannerException",
"{",
"if",
"(",
"!",
"extdir",
".",
"exists",
"(",
")",
"||",
"!",
"extdir",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"scanFor",
"(",
"ident",
",",
"extdir",
".",
"listFiles",
"(",
"getFileFilter",
"(",
")",
")",
")",
";",
"}"
] |
scan for matching file for the provider def
|
[
"scan",
"for",
"matching",
"file",
"for",
"the",
"provider",
"def"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/DirPluginScanner.java#L104-L109
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.