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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
15,800
|
yidongnan/grpc-spring-boot-starter
|
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/security/CallCredentialsHelper.java
|
CallCredentialsHelper.bearerAuth
|
public static CallCredentials bearerAuth(final String token) {
final Metadata extraHeaders = new Metadata();
extraHeaders.put(AUTHORIZATION_HEADER, BEARER_AUTH_PREFIX + token);
return new StaticSecurityHeaderCallCredentials(extraHeaders);
}
|
java
|
public static CallCredentials bearerAuth(final String token) {
final Metadata extraHeaders = new Metadata();
extraHeaders.put(AUTHORIZATION_HEADER, BEARER_AUTH_PREFIX + token);
return new StaticSecurityHeaderCallCredentials(extraHeaders);
}
|
[
"public",
"static",
"CallCredentials",
"bearerAuth",
"(",
"final",
"String",
"token",
")",
"{",
"final",
"Metadata",
"extraHeaders",
"=",
"new",
"Metadata",
"(",
")",
";",
"extraHeaders",
".",
"put",
"(",
"AUTHORIZATION_HEADER",
",",
"BEARER_AUTH_PREFIX",
"+",
"token",
")",
";",
"return",
"new",
"StaticSecurityHeaderCallCredentials",
"(",
"extraHeaders",
")",
";",
"}"
] |
Creates a new call credential with the given token for bearer auth.
<p>
<b>Note:</b> This method uses experimental grpc-java-API features.
</p>
@param token the bearer token to use
@return The newly created bearer auth credentials.
|
[
"Creates",
"a",
"new",
"call",
"credential",
"with",
"the",
"given",
"token",
"for",
"bearer",
"auth",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/security/CallCredentialsHelper.java#L170-L174
|
15,801
|
yidongnan/grpc-spring-boot-starter
|
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/security/CallCredentialsHelper.java
|
CallCredentialsHelper.basicAuth
|
public static CallCredentials basicAuth(final String username, final String password) {
final Metadata extraHeaders = new Metadata();
extraHeaders.put(AUTHORIZATION_HEADER, encodeBasicAuth(username, password));
return new StaticSecurityHeaderCallCredentials(extraHeaders);
}
|
java
|
public static CallCredentials basicAuth(final String username, final String password) {
final Metadata extraHeaders = new Metadata();
extraHeaders.put(AUTHORIZATION_HEADER, encodeBasicAuth(username, password));
return new StaticSecurityHeaderCallCredentials(extraHeaders);
}
|
[
"public",
"static",
"CallCredentials",
"basicAuth",
"(",
"final",
"String",
"username",
",",
"final",
"String",
"password",
")",
"{",
"final",
"Metadata",
"extraHeaders",
"=",
"new",
"Metadata",
"(",
")",
";",
"extraHeaders",
".",
"put",
"(",
"AUTHORIZATION_HEADER",
",",
"encodeBasicAuth",
"(",
"username",
",",
"password",
")",
")",
";",
"return",
"new",
"StaticSecurityHeaderCallCredentials",
"(",
"extraHeaders",
")",
";",
"}"
] |
Creates a new call credential with the given username and password for basic auth.
<p>
<b>Note:</b> This method uses experimental grpc-java-API features.
</p>
@param username The username to use.
@param password The password to use.
@return The newly created basic auth credentials.
|
[
"Creates",
"a",
"new",
"call",
"credential",
"with",
"the",
"given",
"username",
"and",
"password",
"for",
"basic",
"auth",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/security/CallCredentialsHelper.java#L187-L191
|
15,802
|
yidongnan/grpc-spring-boot-starter
|
examples/security-grpc-bearerAuth-server/src/main/java/net/devh/boot/grpc/examples/security/server/GrpcServerService.java
|
GrpcServerService.sayHello
|
@Override
@Secured("ROLE_TEST")
public void sayHello(final HelloRequest req, final StreamObserver<HelloReply> responseObserver) {
final HelloReply reply = HelloReply.newBuilder().setMessage("Hello ==> " + req.getName()).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
|
java
|
@Override
@Secured("ROLE_TEST")
public void sayHello(final HelloRequest req, final StreamObserver<HelloReply> responseObserver) {
final HelloReply reply = HelloReply.newBuilder().setMessage("Hello ==> " + req.getName()).build();
responseObserver.onNext(reply);
responseObserver.onCompleted();
}
|
[
"@",
"Override",
"@",
"Secured",
"(",
"\"ROLE_TEST\"",
")",
"public",
"void",
"sayHello",
"(",
"final",
"HelloRequest",
"req",
",",
"final",
"StreamObserver",
"<",
"HelloReply",
">",
"responseObserver",
")",
"{",
"final",
"HelloReply",
"reply",
"=",
"HelloReply",
".",
"newBuilder",
"(",
")",
".",
"setMessage",
"(",
"\"Hello ==> \"",
"+",
"req",
".",
"getName",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"responseObserver",
".",
"onNext",
"(",
"reply",
")",
";",
"responseObserver",
".",
"onCompleted",
"(",
")",
";",
"}"
] |
A grpc method that requests the user to be authenticated and have the role "ROLE_GREET".
|
[
"A",
"grpc",
"method",
"that",
"requests",
"the",
"user",
"to",
"be",
"authenticated",
"and",
"have",
"the",
"role",
"ROLE_GREET",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/examples/security-grpc-bearerAuth-server/src/main/java/net/devh/boot/grpc/examples/security/server/GrpcServerService.java#L37-L43
|
15,803
|
yidongnan/grpc-spring-boot-starter
|
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java
|
GrpcClientBeanPostProcessor.processInjectionPoint
|
protected <T> T processInjectionPoint(final Member injectionTarget, final Class<T> injectionType,
final GrpcClient annotation) {
final List<ClientInterceptor> interceptors = interceptorsFromAnnotation(annotation);
final String name = annotation.value();
final Channel channel;
try {
channel = getChannelFactory().createChannel(name, interceptors);
if (channel == null) {
throw new IllegalStateException("Channel factory created a null channel for " + name);
}
} catch (final RuntimeException e) {
throw new IllegalStateException("Failed to create channel: " + name, e);
}
final T value = valueForMember(name, injectionTarget, injectionType, channel);
if (value == null) {
throw new IllegalStateException(
"Injection value is null unexpectedly for " + name + " at " + injectionTarget);
}
return value;
}
|
java
|
protected <T> T processInjectionPoint(final Member injectionTarget, final Class<T> injectionType,
final GrpcClient annotation) {
final List<ClientInterceptor> interceptors = interceptorsFromAnnotation(annotation);
final String name = annotation.value();
final Channel channel;
try {
channel = getChannelFactory().createChannel(name, interceptors);
if (channel == null) {
throw new IllegalStateException("Channel factory created a null channel for " + name);
}
} catch (final RuntimeException e) {
throw new IllegalStateException("Failed to create channel: " + name, e);
}
final T value = valueForMember(name, injectionTarget, injectionType, channel);
if (value == null) {
throw new IllegalStateException(
"Injection value is null unexpectedly for " + name + " at " + injectionTarget);
}
return value;
}
|
[
"protected",
"<",
"T",
">",
"T",
"processInjectionPoint",
"(",
"final",
"Member",
"injectionTarget",
",",
"final",
"Class",
"<",
"T",
">",
"injectionType",
",",
"final",
"GrpcClient",
"annotation",
")",
"{",
"final",
"List",
"<",
"ClientInterceptor",
">",
"interceptors",
"=",
"interceptorsFromAnnotation",
"(",
"annotation",
")",
";",
"final",
"String",
"name",
"=",
"annotation",
".",
"value",
"(",
")",
";",
"final",
"Channel",
"channel",
";",
"try",
"{",
"channel",
"=",
"getChannelFactory",
"(",
")",
".",
"createChannel",
"(",
"name",
",",
"interceptors",
")",
";",
"if",
"(",
"channel",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Channel factory created a null channel for \"",
"+",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Failed to create channel: \"",
"+",
"name",
",",
"e",
")",
";",
"}",
"final",
"T",
"value",
"=",
"valueForMember",
"(",
"name",
",",
"injectionTarget",
",",
"injectionType",
",",
"channel",
")",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Injection value is null unexpectedly for \"",
"+",
"name",
"+",
"\" at \"",
"+",
"injectionTarget",
")",
";",
"}",
"return",
"value",
";",
"}"
] |
Processes the given injection point and computes the appropriate value for the injection.
@param <T> The type of the value to be injected.
@param injectionTarget The target of the injection.
@param injectionType The class that will be used to compute injection.
@param annotation The annotation on the target with the metadata for the injection.
@return The value to be injected for the given injection point.
|
[
"Processes",
"the",
"given",
"injection",
"point",
"and",
"computes",
"the",
"appropriate",
"value",
"for",
"the",
"injection",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java#L107-L127
|
15,804
|
yidongnan/grpc-spring-boot-starter
|
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java
|
GrpcClientBeanPostProcessor.valueForMember
|
protected <T> T valueForMember(final String name, final Member injectionTarget, final Class<T> injectionType,
final Channel channel) throws BeansException {
if (Channel.class.equals(injectionType)) {
return injectionType.cast(channel);
} else if (AbstractStub.class.isAssignableFrom(injectionType)) {
try {
@SuppressWarnings("unchecked")
final Class<? extends AbstractStub<?>> stubClass =
(Class<? extends AbstractStub<?>>) injectionType.asSubclass(AbstractStub.class);
final Constructor<? extends AbstractStub<?>> constructor =
ReflectionUtils.accessibleConstructor(stubClass, Channel.class);
AbstractStub<?> stub = constructor.newInstance(channel);
for (final StubTransformer stubTransformer : getStubTransformers()) {
stub = stubTransformer.transform(name, stub);
}
return injectionType.cast(stub);
} catch (final NoSuchMethodException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
throw new BeanInstantiationException(injectionType,
"Failed to create gRPC client for : " + injectionTarget, e);
}
} else {
throw new InvalidPropertyException(injectionTarget.getDeclaringClass(), injectionTarget.getName(),
"Unsupported type " + injectionType.getName());
}
}
|
java
|
protected <T> T valueForMember(final String name, final Member injectionTarget, final Class<T> injectionType,
final Channel channel) throws BeansException {
if (Channel.class.equals(injectionType)) {
return injectionType.cast(channel);
} else if (AbstractStub.class.isAssignableFrom(injectionType)) {
try {
@SuppressWarnings("unchecked")
final Class<? extends AbstractStub<?>> stubClass =
(Class<? extends AbstractStub<?>>) injectionType.asSubclass(AbstractStub.class);
final Constructor<? extends AbstractStub<?>> constructor =
ReflectionUtils.accessibleConstructor(stubClass, Channel.class);
AbstractStub<?> stub = constructor.newInstance(channel);
for (final StubTransformer stubTransformer : getStubTransformers()) {
stub = stubTransformer.transform(name, stub);
}
return injectionType.cast(stub);
} catch (final NoSuchMethodException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
throw new BeanInstantiationException(injectionType,
"Failed to create gRPC client for : " + injectionTarget, e);
}
} else {
throw new InvalidPropertyException(injectionTarget.getDeclaringClass(), injectionTarget.getName(),
"Unsupported type " + injectionType.getName());
}
}
|
[
"protected",
"<",
"T",
">",
"T",
"valueForMember",
"(",
"final",
"String",
"name",
",",
"final",
"Member",
"injectionTarget",
",",
"final",
"Class",
"<",
"T",
">",
"injectionType",
",",
"final",
"Channel",
"channel",
")",
"throws",
"BeansException",
"{",
"if",
"(",
"Channel",
".",
"class",
".",
"equals",
"(",
"injectionType",
")",
")",
"{",
"return",
"injectionType",
".",
"cast",
"(",
"channel",
")",
";",
"}",
"else",
"if",
"(",
"AbstractStub",
".",
"class",
".",
"isAssignableFrom",
"(",
"injectionType",
")",
")",
"{",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"Class",
"<",
"?",
"extends",
"AbstractStub",
"<",
"?",
">",
">",
"stubClass",
"=",
"(",
"Class",
"<",
"?",
"extends",
"AbstractStub",
"<",
"?",
">",
">",
")",
"injectionType",
".",
"asSubclass",
"(",
"AbstractStub",
".",
"class",
")",
";",
"final",
"Constructor",
"<",
"?",
"extends",
"AbstractStub",
"<",
"?",
">",
">",
"constructor",
"=",
"ReflectionUtils",
".",
"accessibleConstructor",
"(",
"stubClass",
",",
"Channel",
".",
"class",
")",
";",
"AbstractStub",
"<",
"?",
">",
"stub",
"=",
"constructor",
".",
"newInstance",
"(",
"channel",
")",
";",
"for",
"(",
"final",
"StubTransformer",
"stubTransformer",
":",
"getStubTransformers",
"(",
")",
")",
"{",
"stub",
"=",
"stubTransformer",
".",
"transform",
"(",
"name",
",",
"stub",
")",
";",
"}",
"return",
"injectionType",
".",
"cast",
"(",
"stub",
")",
";",
"}",
"catch",
"(",
"final",
"NoSuchMethodException",
"|",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"IllegalArgumentException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"BeanInstantiationException",
"(",
"injectionType",
",",
"\"Failed to create gRPC client for : \"",
"+",
"injectionTarget",
",",
"e",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"InvalidPropertyException",
"(",
"injectionTarget",
".",
"getDeclaringClass",
"(",
")",
",",
"injectionTarget",
".",
"getName",
"(",
")",
",",
"\"Unsupported type \"",
"+",
"injectionType",
".",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Creates the instance to be injected for the given member.
@param name The name that was used to create the channel.
@param <T> The type of the instance to be injected.
@param injectionTarget The target member for the injection.
@param injectionType The class that should injected.
@param channel The channel that should be used to create the instance.
@return The value that matches the type of the given field.
@throws BeansException If the value of the field could not be created or the type of the field is unsupported.
|
[
"Creates",
"the",
"instance",
"to",
"be",
"injected",
"for",
"the",
"given",
"member",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java#L202-L227
|
15,805
|
yidongnan/grpc-spring-boot-starter
|
grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/AccessPredicateVoter.java
|
AccessPredicateVoter.find
|
private AccessPredicateConfigAttribute find(final Collection<ConfigAttribute> attributes) {
for (final ConfigAttribute attribute : attributes) {
if (attribute instanceof AccessPredicateConfigAttribute) {
return (AccessPredicateConfigAttribute) attribute;
}
}
return null;
}
|
java
|
private AccessPredicateConfigAttribute find(final Collection<ConfigAttribute> attributes) {
for (final ConfigAttribute attribute : attributes) {
if (attribute instanceof AccessPredicateConfigAttribute) {
return (AccessPredicateConfigAttribute) attribute;
}
}
return null;
}
|
[
"private",
"AccessPredicateConfigAttribute",
"find",
"(",
"final",
"Collection",
"<",
"ConfigAttribute",
">",
"attributes",
")",
"{",
"for",
"(",
"final",
"ConfigAttribute",
"attribute",
":",
"attributes",
")",
"{",
"if",
"(",
"attribute",
"instanceof",
"AccessPredicateConfigAttribute",
")",
"{",
"return",
"(",
"AccessPredicateConfigAttribute",
")",
"attribute",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Finds the first AccessPredicateConfigAttribute in the given collection.
@param attributes The attributes to search in.
@return The first found AccessPredicateConfigAttribute or null, if no such elements were found.
|
[
"Finds",
"the",
"first",
"AccessPredicateConfigAttribute",
"in",
"the",
"given",
"collection",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/check/AccessPredicateVoter.java#L60-L67
|
15,806
|
yidongnan/grpc-spring-boot-starter
|
grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/nameresolver/DiscoveryClientResolverFactory.java
|
DiscoveryClientResolverFactory.heartbeat
|
@EventListener(HeartbeatEvent.class)
public void heartbeat(final HeartbeatEvent event) {
if (this.monitor.update(event.getValue())) {
for (final DiscoveryClientNameResolver discoveryClientNameResolver : this.discoveryClientNameResolvers) {
discoveryClientNameResolver.refresh();
}
}
}
|
java
|
@EventListener(HeartbeatEvent.class)
public void heartbeat(final HeartbeatEvent event) {
if (this.monitor.update(event.getValue())) {
for (final DiscoveryClientNameResolver discoveryClientNameResolver : this.discoveryClientNameResolvers) {
discoveryClientNameResolver.refresh();
}
}
}
|
[
"@",
"EventListener",
"(",
"HeartbeatEvent",
".",
"class",
")",
"public",
"void",
"heartbeat",
"(",
"final",
"HeartbeatEvent",
"event",
")",
"{",
"if",
"(",
"this",
".",
"monitor",
".",
"update",
"(",
"event",
".",
"getValue",
"(",
")",
")",
")",
"{",
"for",
"(",
"final",
"DiscoveryClientNameResolver",
"discoveryClientNameResolver",
":",
"this",
".",
"discoveryClientNameResolvers",
")",
"{",
"discoveryClientNameResolver",
".",
"refresh",
"(",
")",
";",
"}",
"}",
"}"
] |
Triggers a refresh of the registered name resolvers.
@param event The event that triggered the update.
|
[
"Triggers",
"a",
"refresh",
"of",
"the",
"registered",
"name",
"resolvers",
"."
] |
07f8853cfafc9707584f2371aff012e590217b85
|
https://github.com/yidongnan/grpc-spring-boot-starter/blob/07f8853cfafc9707584f2371aff012e590217b85/grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/nameresolver/DiscoveryClientResolverFactory.java#L100-L107
|
15,807
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PropertyResolverFactory.java
|
PropertyResolverFactory.mapPropertyValues
|
public static Map<String, Object> mapPropertyValues(final List<Property> list, final PropertyResolver resolver) {
final Map<String, Object> inputConfig = new HashMap<String, Object>();
for (final Property property : list) {
final Object value = resolver.resolvePropertyValue(property.getName(), property.getScope());
if (null == value) {
continue;
}
inputConfig.put(property.getName(), value);
}
return inputConfig;
}
|
java
|
public static Map<String, Object> mapPropertyValues(final List<Property> list, final PropertyResolver resolver) {
final Map<String, Object> inputConfig = new HashMap<String, Object>();
for (final Property property : list) {
final Object value = resolver.resolvePropertyValue(property.getName(), property.getScope());
if (null == value) {
continue;
}
inputConfig.put(property.getName(), value);
}
return inputConfig;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"mapPropertyValues",
"(",
"final",
"List",
"<",
"Property",
">",
"list",
",",
"final",
"PropertyResolver",
"resolver",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"inputConfig",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"for",
"(",
"final",
"Property",
"property",
":",
"list",
")",
"{",
"final",
"Object",
"value",
"=",
"resolver",
".",
"resolvePropertyValue",
"(",
"property",
".",
"getName",
"(",
")",
",",
"property",
".",
"getScope",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"value",
")",
"{",
"continue",
";",
"}",
"inputConfig",
".",
"put",
"(",
"property",
".",
"getName",
"(",
")",
",",
"value",
")",
";",
"}",
"return",
"inputConfig",
";",
"}"
] |
Return All property values for the input property set mapped by name to value.
@param list property list
@param resolver property resolver
@return All mapped properties by name and value.
|
[
"Return",
"All",
"property",
"values",
"for",
"the",
"input",
"property",
"set",
"mapped",
"by",
"name",
"to",
"value",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PropertyResolverFactory.java#L70-L80
|
15,808
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/execution/ExecutionItemFactory.java
|
ExecutionItemFactory.createPluginNodeStepItem
|
public static StepExecutionItem createPluginNodeStepItem(
final String type,
final Map configuration,
final boolean keepgoingOnSuccess,
final StepExecutionItem handler,
final String label,
final List<PluginConfiguration> filterConfigurations
)
{
return new PluginNodeStepExecutionItemImpl(
type,
configuration,
keepgoingOnSuccess,
handler,
label,
filterConfigurations
);
}
|
java
|
public static StepExecutionItem createPluginNodeStepItem(
final String type,
final Map configuration,
final boolean keepgoingOnSuccess,
final StepExecutionItem handler,
final String label,
final List<PluginConfiguration> filterConfigurations
)
{
return new PluginNodeStepExecutionItemImpl(
type,
configuration,
keepgoingOnSuccess,
handler,
label,
filterConfigurations
);
}
|
[
"public",
"static",
"StepExecutionItem",
"createPluginNodeStepItem",
"(",
"final",
"String",
"type",
",",
"final",
"Map",
"configuration",
",",
"final",
"boolean",
"keepgoingOnSuccess",
",",
"final",
"StepExecutionItem",
"handler",
",",
"final",
"String",
"label",
",",
"final",
"List",
"<",
"PluginConfiguration",
">",
"filterConfigurations",
")",
"{",
"return",
"new",
"PluginNodeStepExecutionItemImpl",
"(",
"type",
",",
"configuration",
",",
"keepgoingOnSuccess",
",",
"handler",
",",
"label",
",",
"filterConfigurations",
")",
";",
"}"
] |
Create a workflow execution item for a plugin node step.
|
[
"Create",
"a",
"workflow",
"execution",
"item",
"for",
"a",
"plugin",
"node",
"step",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/execution/ExecutionItemFactory.java#L323-L341
|
15,809
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/VersionCompare.java
|
VersionCompare.comp
|
public static int comp(Integer v1, String s1, Integer v2, String s2) {
if (v1 != null && v2 != null) {
return v1.compareTo(v2);
}else if(v1!=null){
return 1;
}else if(v2!=null){
return -1;
} else if (null == s1 && null == s2) {
return 0;
} else if (null == s1) {
return -1;
} else if (null == s2) {
return 1;
} else {
//compare lexicographically
return s1.compareTo(s2);
}
}
|
java
|
public static int comp(Integer v1, String s1, Integer v2, String s2) {
if (v1 != null && v2 != null) {
return v1.compareTo(v2);
}else if(v1!=null){
return 1;
}else if(v2!=null){
return -1;
} else if (null == s1 && null == s2) {
return 0;
} else if (null == s1) {
return -1;
} else if (null == s2) {
return 1;
} else {
//compare lexicographically
return s1.compareTo(s2);
}
}
|
[
"public",
"static",
"int",
"comp",
"(",
"Integer",
"v1",
",",
"String",
"s1",
",",
"Integer",
"v2",
",",
"String",
"s2",
")",
"{",
"if",
"(",
"v1",
"!=",
"null",
"&&",
"v2",
"!=",
"null",
")",
"{",
"return",
"v1",
".",
"compareTo",
"(",
"v2",
")",
";",
"}",
"else",
"if",
"(",
"v1",
"!=",
"null",
")",
"{",
"return",
"1",
";",
"}",
"else",
"if",
"(",
"v2",
"!=",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"null",
"==",
"s1",
"&&",
"null",
"==",
"s2",
")",
"{",
"return",
"0",
";",
"}",
"else",
"if",
"(",
"null",
"==",
"s1",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"null",
"==",
"s2",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"//compare lexicographically",
"return",
"s1",
".",
"compareTo",
"(",
"s2",
")",
";",
"}",
"}"
] |
Compares two version strings and their parsed integer values if available. Returns -1,0 or 1, if
value 1 is less than, equal to, or greater than value 2, respectively. Compares integers if both are available,
otherwise compares non-integer as less than integer. if no integers are available, comparse strings, and treats null strings as less than non-null strings.
|
[
"Compares",
"two",
"version",
"strings",
"and",
"their",
"parsed",
"integer",
"values",
"if",
"available",
".",
"Returns",
"-",
"1",
"0",
"or",
"1",
"if",
"value",
"1",
"is",
"less",
"than",
"equal",
"to",
"or",
"greater",
"than",
"value",
"2",
"respectively",
".",
"Compares",
"integers",
"if",
"both",
"are",
"available",
"otherwise",
"compares",
"non",
"-",
"integer",
"as",
"less",
"than",
"integer",
".",
"if",
"no",
"integers",
"are",
"available",
"comparse",
"strings",
"and",
"treats",
"null",
"strings",
"as",
"less",
"than",
"non",
"-",
"null",
"strings",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/VersionCompare.java#L48-L65
|
15,810
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/VersionCompare.java
|
VersionCompare.forString
|
public static VersionCompare forString(final String value) {
VersionCompare vers = new VersionCompare();
if (null == value || "".equals(value)) {
return vers;
}
String[] parr1 = value.split("-", 2);
String[] v1arr = parr1[0].split("\\.", 3);
if (v1arr.length > 0) {
vers.majString = v1arr[0];
try {
vers.maj = Integer.parseInt(vers.majString);
} catch (NumberFormatException e) {
}
}
if (v1arr.length > 1) {
vers.minString = v1arr[1];
try {
vers.min = Integer.parseInt(vers.minString);
} catch (NumberFormatException e) {
}
}
if (v1arr.length > 2) {
vers.patchString = v1arr[2];
try {
vers.patch = Integer.parseInt(vers.patchString);
} catch (NumberFormatException e) {
}
}
if (parr1.length > 1) {
vers.tag = parr1[1];
}
return vers;
}
|
java
|
public static VersionCompare forString(final String value) {
VersionCompare vers = new VersionCompare();
if (null == value || "".equals(value)) {
return vers;
}
String[] parr1 = value.split("-", 2);
String[] v1arr = parr1[0].split("\\.", 3);
if (v1arr.length > 0) {
vers.majString = v1arr[0];
try {
vers.maj = Integer.parseInt(vers.majString);
} catch (NumberFormatException e) {
}
}
if (v1arr.length > 1) {
vers.minString = v1arr[1];
try {
vers.min = Integer.parseInt(vers.minString);
} catch (NumberFormatException e) {
}
}
if (v1arr.length > 2) {
vers.patchString = v1arr[2];
try {
vers.patch = Integer.parseInt(vers.patchString);
} catch (NumberFormatException e) {
}
}
if (parr1.length > 1) {
vers.tag = parr1[1];
}
return vers;
}
|
[
"public",
"static",
"VersionCompare",
"forString",
"(",
"final",
"String",
"value",
")",
"{",
"VersionCompare",
"vers",
"=",
"new",
"VersionCompare",
"(",
")",
";",
"if",
"(",
"null",
"==",
"value",
"||",
"\"\"",
".",
"equals",
"(",
"value",
")",
")",
"{",
"return",
"vers",
";",
"}",
"String",
"[",
"]",
"parr1",
"=",
"value",
".",
"split",
"(",
"\"-\"",
",",
"2",
")",
";",
"String",
"[",
"]",
"v1arr",
"=",
"parr1",
"[",
"0",
"]",
".",
"split",
"(",
"\"\\\\.\"",
",",
"3",
")",
";",
"if",
"(",
"v1arr",
".",
"length",
">",
"0",
")",
"{",
"vers",
".",
"majString",
"=",
"v1arr",
"[",
"0",
"]",
";",
"try",
"{",
"vers",
".",
"maj",
"=",
"Integer",
".",
"parseInt",
"(",
"vers",
".",
"majString",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"v1arr",
".",
"length",
">",
"1",
")",
"{",
"vers",
".",
"minString",
"=",
"v1arr",
"[",
"1",
"]",
";",
"try",
"{",
"vers",
".",
"min",
"=",
"Integer",
".",
"parseInt",
"(",
"vers",
".",
"minString",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"v1arr",
".",
"length",
">",
"2",
")",
"{",
"vers",
".",
"patchString",
"=",
"v1arr",
"[",
"2",
"]",
";",
"try",
"{",
"vers",
".",
"patch",
"=",
"Integer",
".",
"parseInt",
"(",
"vers",
".",
"patchString",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"}",
"}",
"if",
"(",
"parr1",
".",
"length",
">",
"1",
")",
"{",
"vers",
".",
"tag",
"=",
"parr1",
"[",
"1",
"]",
";",
"}",
"return",
"vers",
";",
"}"
] |
Return a VersionCompare for the string
|
[
"Return",
"a",
"VersionCompare",
"for",
"the",
"string"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/VersionCompare.java#L103-L137
|
15,811
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java
|
JNDILoginModule.getUserInfo
|
public UserInfo getUserInfo(String username) throws Exception {
DirContext dir = context();
ArrayList roleList = new ArrayList(getUserRoles(username));
String credentials = getUserCredentials(username);
return new UserInfo(username, Credential.getCredential(credentials), roleList);
}
|
java
|
public UserInfo getUserInfo(String username) throws Exception {
DirContext dir = context();
ArrayList roleList = new ArrayList(getUserRoles(username));
String credentials = getUserCredentials(username);
return new UserInfo(username, Credential.getCredential(credentials), roleList);
}
|
[
"public",
"UserInfo",
"getUserInfo",
"(",
"String",
"username",
")",
"throws",
"Exception",
"{",
"DirContext",
"dir",
"=",
"context",
"(",
")",
";",
"ArrayList",
"roleList",
"=",
"new",
"ArrayList",
"(",
"getUserRoles",
"(",
"username",
")",
")",
";",
"String",
"credentials",
"=",
"getUserCredentials",
"(",
"username",
")",
";",
"return",
"new",
"UserInfo",
"(",
"username",
",",
"Credential",
".",
"getCredential",
"(",
"credentials",
")",
",",
"roleList",
")",
";",
"}"
] |
Get the UserInfo for a specified username
@param username username
@return the UserInfo
@throws Exception
|
[
"Get",
"the",
"UserInfo",
"for",
"a",
"specified",
"username"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java#L64-L70
|
15,812
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java
|
JNDILoginModule.initialize
|
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map sharedState, Map options) {
super.initialize(subject, callbackHandler, sharedState, options);
Properties props = loadProperties((String) options.get("file"));
initWithProps(props);
}
|
java
|
public void initialize(Subject subject, CallbackHandler callbackHandler,
Map sharedState, Map options) {
super.initialize(subject, callbackHandler, sharedState, options);
Properties props = loadProperties((String) options.get("file"));
initWithProps(props);
}
|
[
"public",
"void",
"initialize",
"(",
"Subject",
"subject",
",",
"CallbackHandler",
"callbackHandler",
",",
"Map",
"sharedState",
",",
"Map",
"options",
")",
"{",
"super",
".",
"initialize",
"(",
"subject",
",",
"callbackHandler",
",",
"sharedState",
",",
"options",
")",
";",
"Properties",
"props",
"=",
"loadProperties",
"(",
"(",
"String",
")",
"options",
".",
"get",
"(",
"\"file\"",
")",
")",
";",
"initWithProps",
"(",
"props",
")",
";",
"}"
] |
Read contents of the configured property file.
@param subject
@param callbackHandler
@param sharedState
@param options
@see javax.security.auth.spi.LoginModule#initialize(javax.security.auth.Subject,
javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
|
[
"Read",
"contents",
"of",
"the",
"configured",
"property",
"file",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java#L121-L126
|
15,813
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java
|
JNDILoginModule.getUserRoles
|
private Collection getUserRoles(String userName) throws NamingException {
log.debug("Obtaining roles for userName: " + userName);
// filter expression: all roles with uniqueMember matching user DN
// (uniqueMember=cn=userName,dc=company,dc=com)
String filter = "(" + roleMemberRDN + "=" + userNameRDN + "=" + userName + "," + userBase + ")";
//search directory
NamingEnumeration roleResults = this.search(roleBase,
filter,
new String[]{
roleMemberRDN
});
ArrayList results = new ArrayList();
while (roleResults != null && roleResults.hasMore()) {
SearchResult roleResult = (SearchResult) roleResults.next();
String roleResultName = roleResult.getName();
if ("".equals(roleResultName)) {
//logger.debug("ignoring empty result");
continue;
}
String roleResultValue = (roleResultName.split("="))[1];
results.add(roleResultValue);
}
return results;
}
|
java
|
private Collection getUserRoles(String userName) throws NamingException {
log.debug("Obtaining roles for userName: " + userName);
// filter expression: all roles with uniqueMember matching user DN
// (uniqueMember=cn=userName,dc=company,dc=com)
String filter = "(" + roleMemberRDN + "=" + userNameRDN + "=" + userName + "," + userBase + ")";
//search directory
NamingEnumeration roleResults = this.search(roleBase,
filter,
new String[]{
roleMemberRDN
});
ArrayList results = new ArrayList();
while (roleResults != null && roleResults.hasMore()) {
SearchResult roleResult = (SearchResult) roleResults.next();
String roleResultName = roleResult.getName();
if ("".equals(roleResultName)) {
//logger.debug("ignoring empty result");
continue;
}
String roleResultValue = (roleResultName.split("="))[1];
results.add(roleResultValue);
}
return results;
}
|
[
"private",
"Collection",
"getUserRoles",
"(",
"String",
"userName",
")",
"throws",
"NamingException",
"{",
"log",
".",
"debug",
"(",
"\"Obtaining roles for userName: \"",
"+",
"userName",
")",
";",
"// filter expression: all roles with uniqueMember matching user DN",
"// (uniqueMember=cn=userName,dc=company,dc=com)",
"String",
"filter",
"=",
"\"(\"",
"+",
"roleMemberRDN",
"+",
"\"=\"",
"+",
"userNameRDN",
"+",
"\"=\"",
"+",
"userName",
"+",
"\",\"",
"+",
"userBase",
"+",
"\")\"",
";",
"//search directory",
"NamingEnumeration",
"roleResults",
"=",
"this",
".",
"search",
"(",
"roleBase",
",",
"filter",
",",
"new",
"String",
"[",
"]",
"{",
"roleMemberRDN",
"}",
")",
";",
"ArrayList",
"results",
"=",
"new",
"ArrayList",
"(",
")",
";",
"while",
"(",
"roleResults",
"!=",
"null",
"&&",
"roleResults",
".",
"hasMore",
"(",
")",
")",
"{",
"SearchResult",
"roleResult",
"=",
"(",
"SearchResult",
")",
"roleResults",
".",
"next",
"(",
")",
";",
"String",
"roleResultName",
"=",
"roleResult",
".",
"getName",
"(",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"roleResultName",
")",
")",
"{",
"//logger.debug(\"ignoring empty result\");",
"continue",
";",
"}",
"String",
"roleResultValue",
"=",
"(",
"roleResultName",
".",
"split",
"(",
"\"=\"",
")",
")",
"[",
"1",
"]",
";",
"results",
".",
"add",
"(",
"roleResultValue",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Get the collection of role names for the user
@param userName name of the user
@return Collection of String
@throws javax.naming.NamingException
|
[
"Get",
"the",
"collection",
"of",
"role",
"names",
"for",
"the",
"user"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java#L285-L312
|
15,814
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java
|
JNDILoginModule.getUsers
|
private Map getUsers() throws NamingException {
String filter = "(" + roleNameRDN + "=*)";
HashMap users = new HashMap();
NamingEnumeration results = this.search(roleBase, filter, new String[]{roleMemberRDN});
while (results != null && results.hasMore()) {
SearchResult roleResult = (SearchResult) results.next();
String roleResultName = roleResult.getName();
if ("".equals(roleResultName)) {
continue;
}
String roleResultValue = (roleResultName.split("="))[1];
Attributes roleAttrs = roleResult.getAttributes();
Attribute roleAttr = roleAttrs.get(roleMemberRDN);
NamingEnumeration valueEnum = roleAttr.getAll();
while (valueEnum != null && valueEnum.hasMore()) {
String value = (String) valueEnum.next();
String name;
if (value.endsWith("," + userBase)) {
name = value.substring(0, value.length() - userBase.length() - 1);
name = name.split("=")[1];
} else {
log.debug("found unrecognized DN: " + value);
continue;
}
if (users.containsKey(name)) {
HashSet roles = (HashSet) users.get(name);
roles.add(roleResultValue);
} else {
HashSet roles = new HashSet();
roles.add(roleResultValue);
users.put(name, roles);
}
}
}
return users;
}
|
java
|
private Map getUsers() throws NamingException {
String filter = "(" + roleNameRDN + "=*)";
HashMap users = new HashMap();
NamingEnumeration results = this.search(roleBase, filter, new String[]{roleMemberRDN});
while (results != null && results.hasMore()) {
SearchResult roleResult = (SearchResult) results.next();
String roleResultName = roleResult.getName();
if ("".equals(roleResultName)) {
continue;
}
String roleResultValue = (roleResultName.split("="))[1];
Attributes roleAttrs = roleResult.getAttributes();
Attribute roleAttr = roleAttrs.get(roleMemberRDN);
NamingEnumeration valueEnum = roleAttr.getAll();
while (valueEnum != null && valueEnum.hasMore()) {
String value = (String) valueEnum.next();
String name;
if (value.endsWith("," + userBase)) {
name = value.substring(0, value.length() - userBase.length() - 1);
name = name.split("=")[1];
} else {
log.debug("found unrecognized DN: " + value);
continue;
}
if (users.containsKey(name)) {
HashSet roles = (HashSet) users.get(name);
roles.add(roleResultValue);
} else {
HashSet roles = new HashSet();
roles.add(roleResultValue);
users.put(name, roles);
}
}
}
return users;
}
|
[
"private",
"Map",
"getUsers",
"(",
")",
"throws",
"NamingException",
"{",
"String",
"filter",
"=",
"\"(\"",
"+",
"roleNameRDN",
"+",
"\"=*)\"",
";",
"HashMap",
"users",
"=",
"new",
"HashMap",
"(",
")",
";",
"NamingEnumeration",
"results",
"=",
"this",
".",
"search",
"(",
"roleBase",
",",
"filter",
",",
"new",
"String",
"[",
"]",
"{",
"roleMemberRDN",
"}",
")",
";",
"while",
"(",
"results",
"!=",
"null",
"&&",
"results",
".",
"hasMore",
"(",
")",
")",
"{",
"SearchResult",
"roleResult",
"=",
"(",
"SearchResult",
")",
"results",
".",
"next",
"(",
")",
";",
"String",
"roleResultName",
"=",
"roleResult",
".",
"getName",
"(",
")",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"roleResultName",
")",
")",
"{",
"continue",
";",
"}",
"String",
"roleResultValue",
"=",
"(",
"roleResultName",
".",
"split",
"(",
"\"=\"",
")",
")",
"[",
"1",
"]",
";",
"Attributes",
"roleAttrs",
"=",
"roleResult",
".",
"getAttributes",
"(",
")",
";",
"Attribute",
"roleAttr",
"=",
"roleAttrs",
".",
"get",
"(",
"roleMemberRDN",
")",
";",
"NamingEnumeration",
"valueEnum",
"=",
"roleAttr",
".",
"getAll",
"(",
")",
";",
"while",
"(",
"valueEnum",
"!=",
"null",
"&&",
"valueEnum",
".",
"hasMore",
"(",
")",
")",
"{",
"String",
"value",
"=",
"(",
"String",
")",
"valueEnum",
".",
"next",
"(",
")",
";",
"String",
"name",
";",
"if",
"(",
"value",
".",
"endsWith",
"(",
"\",\"",
"+",
"userBase",
")",
")",
"{",
"name",
"=",
"value",
".",
"substring",
"(",
"0",
",",
"value",
".",
"length",
"(",
")",
"-",
"userBase",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"name",
"=",
"name",
".",
"split",
"(",
"\"=\"",
")",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"log",
".",
"debug",
"(",
"\"found unrecognized DN: \"",
"+",
"value",
")",
";",
"continue",
";",
"}",
"if",
"(",
"users",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"HashSet",
"roles",
"=",
"(",
"HashSet",
")",
"users",
".",
"get",
"(",
"name",
")",
";",
"roles",
".",
"add",
"(",
"roleResultValue",
")",
";",
"}",
"else",
"{",
"HashSet",
"roles",
"=",
"new",
"HashSet",
"(",
")",
";",
"roles",
".",
"add",
"(",
"roleResultValue",
")",
";",
"users",
".",
"put",
"(",
"name",
",",
"roles",
")",
";",
"}",
"}",
"}",
"return",
"users",
";",
"}"
] |
Return a Map of usernames to role sets.
@return Mapping of usernames (String) to set of roles (Set of String)
@throws javax.naming.NamingException
|
[
"Return",
"a",
"Map",
"of",
"usernames",
"to",
"role",
"sets",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java#L338-L384
|
15,815
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java
|
JNDILoginModule.search
|
private NamingEnumeration search(String base, String filter,
String[] returnAttrs)
throws NamingException {
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
constraints.setReturningAttributes(returnAttrs);
// search the directory based on base, filter, and contraints
//logger.debug("searching, base: " + base + " using filter: " + filter);
DirContext dirContext = context();
// get established jndi connection
return dirContext.search(base, filter, constraints);
}
|
java
|
private NamingEnumeration search(String base, String filter,
String[] returnAttrs)
throws NamingException {
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
constraints.setReturningAttributes(returnAttrs);
// search the directory based on base, filter, and contraints
//logger.debug("searching, base: " + base + " using filter: " + filter);
DirContext dirContext = context();
// get established jndi connection
return dirContext.search(base, filter, constraints);
}
|
[
"private",
"NamingEnumeration",
"search",
"(",
"String",
"base",
",",
"String",
"filter",
",",
"String",
"[",
"]",
"returnAttrs",
")",
"throws",
"NamingException",
"{",
"SearchControls",
"constraints",
"=",
"new",
"SearchControls",
"(",
")",
";",
"constraints",
".",
"setSearchScope",
"(",
"SearchControls",
".",
"SUBTREE_SCOPE",
")",
";",
"constraints",
".",
"setReturningAttributes",
"(",
"returnAttrs",
")",
";",
"// search the directory based on base, filter, and contraints",
"//logger.debug(\"searching, base: \" + base + \" using filter: \" + filter);",
"DirContext",
"dirContext",
"=",
"context",
"(",
")",
";",
"// get established jndi connection",
"return",
"dirContext",
".",
"search",
"(",
"base",
",",
"filter",
",",
"constraints",
")",
";",
"}"
] |
search using search base, filter, and declared return attributes
|
[
"search",
"using",
"search",
"base",
"filter",
"and",
"declared",
"return",
"attributes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JNDILoginModule.java#L388-L401
|
15,816
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PartialLineBuffer.java
|
PartialLineBuffer.read
|
public int read(final Reader reader) throws IOException {
final int c = reader.read(cbuf);
if (c > 0) {
addData(cbuf, 0, c);
}
return c;
}
|
java
|
public int read(final Reader reader) throws IOException {
final int c = reader.read(cbuf);
if (c > 0) {
addData(cbuf, 0, c);
}
return c;
}
|
[
"public",
"int",
"read",
"(",
"final",
"Reader",
"reader",
")",
"throws",
"IOException",
"{",
"final",
"int",
"c",
"=",
"reader",
".",
"read",
"(",
"cbuf",
")",
";",
"if",
"(",
"c",
">",
"0",
")",
"{",
"addData",
"(",
"cbuf",
",",
"0",
",",
"c",
")",
";",
"}",
"return",
"c",
";",
"}"
] |
Read some chars from a reader, and return the number of characters read
@param reader input reader
@return characters read
@throws IOException if thrown by underlying read action
|
[
"Read",
"some",
"chars",
"from",
"a",
"reader",
"and",
"return",
"the",
"number",
"of",
"characters",
"read"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PartialLineBuffer.java#L91-L97
|
15,817
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PartialLineBuffer.java
|
PartialLineBuffer.addData
|
public void addData(final char[] data, final int off, final int size) {
if(size<1){
return;
}
final String str = new String(data, off, size);
if (str.contains("\n")) {
final String[] lines = str.split("\\r?\\n", -1);
for (int i = 0 ; i < lines.length - 1 ; i++) {
appendString(lines[i], true);
}
if (lines.length > 0) {
final String last = lines[lines.length - 1];
if ("".equals(last)) {
//end of previous line
} else {
appendString(last, false);
}
}
} else if (str.contains("\r")) {
final String[] lines = str.split("\\r", -1);
for (int i = 0 ; i < lines.length - 2 ; i++) {
appendString(lines[i], true);
}
//last two split strings
//a: 1,1: yes,no
//b: 0,1: yes,no
//c: 0,0: yes(pass),no
//d: 1,0: yes(pass),
if (lines.length >= 2) {
final String last2 = lines[lines.length - 2];
final String last = lines[lines.length - 1];
if (!"".equals(last)) {
appendString(last2, true);
appendString(last, false);
} else {
//pass \r for later \r\n resolution
appendString(last2 + "\r", false);
}
}
} else {
appendString(str, false);
}
}
|
java
|
public void addData(final char[] data, final int off, final int size) {
if(size<1){
return;
}
final String str = new String(data, off, size);
if (str.contains("\n")) {
final String[] lines = str.split("\\r?\\n", -1);
for (int i = 0 ; i < lines.length - 1 ; i++) {
appendString(lines[i], true);
}
if (lines.length > 0) {
final String last = lines[lines.length - 1];
if ("".equals(last)) {
//end of previous line
} else {
appendString(last, false);
}
}
} else if (str.contains("\r")) {
final String[] lines = str.split("\\r", -1);
for (int i = 0 ; i < lines.length - 2 ; i++) {
appendString(lines[i], true);
}
//last two split strings
//a: 1,1: yes,no
//b: 0,1: yes,no
//c: 0,0: yes(pass),no
//d: 1,0: yes(pass),
if (lines.length >= 2) {
final String last2 = lines[lines.length - 2];
final String last = lines[lines.length - 1];
if (!"".equals(last)) {
appendString(last2, true);
appendString(last, false);
} else {
//pass \r for later \r\n resolution
appendString(last2 + "\r", false);
}
}
} else {
appendString(str, false);
}
}
|
[
"public",
"void",
"addData",
"(",
"final",
"char",
"[",
"]",
"data",
",",
"final",
"int",
"off",
",",
"final",
"int",
"size",
")",
"{",
"if",
"(",
"size",
"<",
"1",
")",
"{",
"return",
";",
"}",
"final",
"String",
"str",
"=",
"new",
"String",
"(",
"data",
",",
"off",
",",
"size",
")",
";",
"if",
"(",
"str",
".",
"contains",
"(",
"\"\\n\"",
")",
")",
"{",
"final",
"String",
"[",
"]",
"lines",
"=",
"str",
".",
"split",
"(",
"\"\\\\r?\\\\n\"",
",",
"-",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lines",
".",
"length",
"-",
"1",
";",
"i",
"++",
")",
"{",
"appendString",
"(",
"lines",
"[",
"i",
"]",
",",
"true",
")",
";",
"}",
"if",
"(",
"lines",
".",
"length",
">",
"0",
")",
"{",
"final",
"String",
"last",
"=",
"lines",
"[",
"lines",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"last",
")",
")",
"{",
"//end of previous line",
"}",
"else",
"{",
"appendString",
"(",
"last",
",",
"false",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"str",
".",
"contains",
"(",
"\"\\r\"",
")",
")",
"{",
"final",
"String",
"[",
"]",
"lines",
"=",
"str",
".",
"split",
"(",
"\"\\\\r\"",
",",
"-",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lines",
".",
"length",
"-",
"2",
";",
"i",
"++",
")",
"{",
"appendString",
"(",
"lines",
"[",
"i",
"]",
",",
"true",
")",
";",
"}",
"//last two split strings",
"//a: 1,1: yes,no",
"//b: 0,1: yes,no",
"//c: 0,0: yes(pass),no",
"//d: 1,0: yes(pass),",
"if",
"(",
"lines",
".",
"length",
">=",
"2",
")",
"{",
"final",
"String",
"last2",
"=",
"lines",
"[",
"lines",
".",
"length",
"-",
"2",
"]",
";",
"final",
"String",
"last",
"=",
"lines",
"[",
"lines",
".",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"!",
"\"\"",
".",
"equals",
"(",
"last",
")",
")",
"{",
"appendString",
"(",
"last2",
",",
"true",
")",
";",
"appendString",
"(",
"last",
",",
"false",
")",
";",
"}",
"else",
"{",
"//pass \\r for later \\r\\n resolution",
"appendString",
"(",
"last2",
"+",
"\"\\r\"",
",",
"false",
")",
";",
"}",
"}",
"}",
"else",
"{",
"appendString",
"(",
"str",
",",
"false",
")",
";",
"}",
"}"
] |
Add character data to the buffer
@param data data
@param off offset
@param size length
|
[
"Add",
"character",
"data",
"to",
"the",
"buffer"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PartialLineBuffer.java#L105-L148
|
15,818
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.load
|
public synchronized <T> T load(final PluggableService<T> service, final String providerName) throws
ProviderLoaderException {
if (!(service instanceof ScriptPluginProviderLoadable)) {
return null;
}
ScriptPluginProviderLoadable<T> loader =(ScriptPluginProviderLoadable<T>) service;
final ProviderIdent ident = new ProviderIdent(service.getName(), providerName);
if (null == pluginProviderDefs.get(ident)) {
//look for plugin def
final PluginMeta pluginMeta;
try {
pluginMeta = getPluginMeta();
} catch (IOException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
if (null == pluginMeta) {
throw new ProviderLoaderException("Unable to load plugin metadata for file: " + file, service.getName(),
providerName);
}
for (final ProviderDef pluginDef : pluginMeta.getPluginDefs()) {
if (matchesProvider(ident, pluginDef)) {
final ScriptPluginProvider provider;
try {
provider = getPlugin(pluginMeta, file, pluginDef, ident);
} catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
pluginProviderDefs.put(ident, provider);
break;
}
}
}
final ScriptPluginProvider scriptPluginProvider = pluginProviderDefs.get(ident);
try {
getResourceLoader().listResources();
} catch(IOException iex) {
throw new ProviderLoaderException(iex,service.getName(),providerName);
}
catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
if (null != scriptPluginProvider) {
try {
return loader.createScriptProviderInstance(scriptPluginProvider);
} catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
}
return null;
}
|
java
|
public synchronized <T> T load(final PluggableService<T> service, final String providerName) throws
ProviderLoaderException {
if (!(service instanceof ScriptPluginProviderLoadable)) {
return null;
}
ScriptPluginProviderLoadable<T> loader =(ScriptPluginProviderLoadable<T>) service;
final ProviderIdent ident = new ProviderIdent(service.getName(), providerName);
if (null == pluginProviderDefs.get(ident)) {
//look for plugin def
final PluginMeta pluginMeta;
try {
pluginMeta = getPluginMeta();
} catch (IOException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
if (null == pluginMeta) {
throw new ProviderLoaderException("Unable to load plugin metadata for file: " + file, service.getName(),
providerName);
}
for (final ProviderDef pluginDef : pluginMeta.getPluginDefs()) {
if (matchesProvider(ident, pluginDef)) {
final ScriptPluginProvider provider;
try {
provider = getPlugin(pluginMeta, file, pluginDef, ident);
} catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
pluginProviderDefs.put(ident, provider);
break;
}
}
}
final ScriptPluginProvider scriptPluginProvider = pluginProviderDefs.get(ident);
try {
getResourceLoader().listResources();
} catch(IOException iex) {
throw new ProviderLoaderException(iex,service.getName(),providerName);
}
catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
if (null != scriptPluginProvider) {
try {
return loader.createScriptProviderInstance(scriptPluginProvider);
} catch (PluginException e) {
throw new ProviderLoaderException(e, service.getName(), providerName);
}
}
return null;
}
|
[
"public",
"synchronized",
"<",
"T",
">",
"T",
"load",
"(",
"final",
"PluggableService",
"<",
"T",
">",
"service",
",",
"final",
"String",
"providerName",
")",
"throws",
"ProviderLoaderException",
"{",
"if",
"(",
"!",
"(",
"service",
"instanceof",
"ScriptPluginProviderLoadable",
")",
")",
"{",
"return",
"null",
";",
"}",
"ScriptPluginProviderLoadable",
"<",
"T",
">",
"loader",
"=",
"(",
"ScriptPluginProviderLoadable",
"<",
"T",
">",
")",
"service",
";",
"final",
"ProviderIdent",
"ident",
"=",
"new",
"ProviderIdent",
"(",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"if",
"(",
"null",
"==",
"pluginProviderDefs",
".",
"get",
"(",
"ident",
")",
")",
"{",
"//look for plugin def",
"final",
"PluginMeta",
"pluginMeta",
";",
"try",
"{",
"pluginMeta",
"=",
"getPluginMeta",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"e",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"if",
"(",
"null",
"==",
"pluginMeta",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"\"Unable to load plugin metadata for file: \"",
"+",
"file",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"for",
"(",
"final",
"ProviderDef",
"pluginDef",
":",
"pluginMeta",
".",
"getPluginDefs",
"(",
")",
")",
"{",
"if",
"(",
"matchesProvider",
"(",
"ident",
",",
"pluginDef",
")",
")",
"{",
"final",
"ScriptPluginProvider",
"provider",
";",
"try",
"{",
"provider",
"=",
"getPlugin",
"(",
"pluginMeta",
",",
"file",
",",
"pluginDef",
",",
"ident",
")",
";",
"}",
"catch",
"(",
"PluginException",
"e",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"e",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"pluginProviderDefs",
".",
"put",
"(",
"ident",
",",
"provider",
")",
";",
"break",
";",
"}",
"}",
"}",
"final",
"ScriptPluginProvider",
"scriptPluginProvider",
"=",
"pluginProviderDefs",
".",
"get",
"(",
"ident",
")",
";",
"try",
"{",
"getResourceLoader",
"(",
")",
".",
"listResources",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"iex",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"iex",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"catch",
"(",
"PluginException",
"e",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"e",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"scriptPluginProvider",
")",
"{",
"try",
"{",
"return",
"loader",
".",
"createScriptProviderInstance",
"(",
"scriptPluginProvider",
")",
";",
"}",
"catch",
"(",
"PluginException",
"e",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"e",
",",
"service",
".",
"getName",
"(",
")",
",",
"providerName",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Load a provider instance for the service by name
|
[
"Load",
"a",
"provider",
"instance",
"for",
"the",
"service",
"by",
"name"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L145-L196
|
15,819
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.getPluginMeta
|
private PluginMeta getPluginMeta() throws IOException {
if (null != metadata) {
return metadata;
}
metadata = loadMeta(file);
metadata.setId(PluginUtils.generateShaIdFromName(metadata.getName()));
dateLoaded = new Date();
return metadata;
}
|
java
|
private PluginMeta getPluginMeta() throws IOException {
if (null != metadata) {
return metadata;
}
metadata = loadMeta(file);
metadata.setId(PluginUtils.generateShaIdFromName(metadata.getName()));
dateLoaded = new Date();
return metadata;
}
|
[
"private",
"PluginMeta",
"getPluginMeta",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"null",
"!=",
"metadata",
")",
"{",
"return",
"metadata",
";",
"}",
"metadata",
"=",
"loadMeta",
"(",
"file",
")",
";",
"metadata",
".",
"setId",
"(",
"PluginUtils",
".",
"generateShaIdFromName",
"(",
"metadata",
".",
"getName",
"(",
")",
")",
")",
";",
"dateLoaded",
"=",
"new",
"Date",
"(",
")",
";",
"return",
"metadata",
";",
"}"
] |
Get the plugin metadata, loading from the file if necessary
@return loaded metadata or null if not found
@throws IOException if an error occurs trying to load from the file
|
[
"Get",
"the",
"plugin",
"metadata",
"loading",
"from",
"the",
"file",
"if",
"necessary"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L218-L226
|
15,820
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.getPlugin
|
private ScriptPluginProvider getPlugin(
final PluginMeta pluginMeta,
final File file,
final ProviderDef pluginDef,
final ProviderIdent ident
) throws
ProviderLoaderException, PluginException
{
if (null == fileExpandedDir) {
final File dir;
try {
dir = expandScriptPlugin(file);
} catch (IOException e) {
throw new ProviderLoaderException(e, ident.getService(), ident.getProviderName());
}
fileExpandedDir = dir;
if (pluginDef.getPluginType().equals("script")) {
final File script = new File(fileExpandedDir, pluginDef.getScriptFile());
//set executable bit for script-file of the provider
try {
ScriptfileUtils.setExecutePermissions(script);
} catch (IOException e) {
log.warn("Unable to set executable bit for script file: " + script + ": " + e.getMessage());
}
}
debug("expanded plugin dir! " + fileExpandedDir);
} else {
debug("expanded plugin dir: " + fileExpandedDir);
}
if (pluginDef.getPluginType().equals("script")) {
final File script = new File(fileExpandedDir, pluginDef.getScriptFile());
if (!script.exists() || !script.isFile()) {
throw new PluginException("Script file was not found: " + script.getAbsolutePath());
}
}
return new ScriptPluginProviderImpl(pluginMeta, pluginDef, file, fileExpandedDir);
}
|
java
|
private ScriptPluginProvider getPlugin(
final PluginMeta pluginMeta,
final File file,
final ProviderDef pluginDef,
final ProviderIdent ident
) throws
ProviderLoaderException, PluginException
{
if (null == fileExpandedDir) {
final File dir;
try {
dir = expandScriptPlugin(file);
} catch (IOException e) {
throw new ProviderLoaderException(e, ident.getService(), ident.getProviderName());
}
fileExpandedDir = dir;
if (pluginDef.getPluginType().equals("script")) {
final File script = new File(fileExpandedDir, pluginDef.getScriptFile());
//set executable bit for script-file of the provider
try {
ScriptfileUtils.setExecutePermissions(script);
} catch (IOException e) {
log.warn("Unable to set executable bit for script file: " + script + ": " + e.getMessage());
}
}
debug("expanded plugin dir! " + fileExpandedDir);
} else {
debug("expanded plugin dir: " + fileExpandedDir);
}
if (pluginDef.getPluginType().equals("script")) {
final File script = new File(fileExpandedDir, pluginDef.getScriptFile());
if (!script.exists() || !script.isFile()) {
throw new PluginException("Script file was not found: " + script.getAbsolutePath());
}
}
return new ScriptPluginProviderImpl(pluginMeta, pluginDef, file, fileExpandedDir);
}
|
[
"private",
"ScriptPluginProvider",
"getPlugin",
"(",
"final",
"PluginMeta",
"pluginMeta",
",",
"final",
"File",
"file",
",",
"final",
"ProviderDef",
"pluginDef",
",",
"final",
"ProviderIdent",
"ident",
")",
"throws",
"ProviderLoaderException",
",",
"PluginException",
"{",
"if",
"(",
"null",
"==",
"fileExpandedDir",
")",
"{",
"final",
"File",
"dir",
";",
"try",
"{",
"dir",
"=",
"expandScriptPlugin",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"e",
",",
"ident",
".",
"getService",
"(",
")",
",",
"ident",
".",
"getProviderName",
"(",
")",
")",
";",
"}",
"fileExpandedDir",
"=",
"dir",
";",
"if",
"(",
"pluginDef",
".",
"getPluginType",
"(",
")",
".",
"equals",
"(",
"\"script\"",
")",
")",
"{",
"final",
"File",
"script",
"=",
"new",
"File",
"(",
"fileExpandedDir",
",",
"pluginDef",
".",
"getScriptFile",
"(",
")",
")",
";",
"//set executable bit for script-file of the provider",
"try",
"{",
"ScriptfileUtils",
".",
"setExecutePermissions",
"(",
"script",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to set executable bit for script file: \"",
"+",
"script",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"debug",
"(",
"\"expanded plugin dir! \"",
"+",
"fileExpandedDir",
")",
";",
"}",
"else",
"{",
"debug",
"(",
"\"expanded plugin dir: \"",
"+",
"fileExpandedDir",
")",
";",
"}",
"if",
"(",
"pluginDef",
".",
"getPluginType",
"(",
")",
".",
"equals",
"(",
"\"script\"",
")",
")",
"{",
"final",
"File",
"script",
"=",
"new",
"File",
"(",
"fileExpandedDir",
",",
"pluginDef",
".",
"getScriptFile",
"(",
")",
")",
";",
"if",
"(",
"!",
"script",
".",
"exists",
"(",
")",
"||",
"!",
"script",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"PluginException",
"(",
"\"Script file was not found: \"",
"+",
"script",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"return",
"new",
"ScriptPluginProviderImpl",
"(",
"pluginMeta",
",",
"pluginDef",
",",
"file",
",",
"fileExpandedDir",
")",
";",
"}"
] |
Get the ScriptPluginProvider definition from the file for the given provider def and ident
|
[
"Get",
"the",
"ScriptPluginProvider",
"definition",
"from",
"the",
"file",
"for",
"the",
"given",
"provider",
"def",
"and",
"ident"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L231-L268
|
15,821
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.matchesProvider
|
private boolean matchesProvider(final ProviderIdent ident, final ProviderDef pluginDef) {
return ident.getService().equals(pluginDef.getService()) && ident.getProviderName().equals(pluginDef.getName());
}
|
java
|
private boolean matchesProvider(final ProviderIdent ident, final ProviderDef pluginDef) {
return ident.getService().equals(pluginDef.getService()) && ident.getProviderName().equals(pluginDef.getName());
}
|
[
"private",
"boolean",
"matchesProvider",
"(",
"final",
"ProviderIdent",
"ident",
",",
"final",
"ProviderDef",
"pluginDef",
")",
"{",
"return",
"ident",
".",
"getService",
"(",
")",
".",
"equals",
"(",
"pluginDef",
".",
"getService",
"(",
")",
")",
"&&",
"ident",
".",
"getProviderName",
"(",
")",
".",
"equals",
"(",
"pluginDef",
".",
"getName",
"(",
")",
")",
";",
"}"
] |
Return true if the ident matches the provider def metadata
|
[
"Return",
"true",
"if",
"the",
"ident",
"matches",
"the",
"provider",
"def",
"metadata"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L273-L275
|
15,822
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.isLoaderFor
|
public synchronized boolean isLoaderFor(final ProviderIdent ident) {
final PluginMeta pluginMeta;
try {
pluginMeta = getPluginMeta();
} catch (IOException e) {
log.warn("Unable to load file meta: " + e.getMessage());
return false;
}
if (null == pluginMeta) {
return false;
}
for (final ProviderDef pluginDef : pluginMeta.getPluginDefs()) {
if (matchesProvider(ident, pluginDef)) {
return true;
}
}
return false;
}
|
java
|
public synchronized boolean isLoaderFor(final ProviderIdent ident) {
final PluginMeta pluginMeta;
try {
pluginMeta = getPluginMeta();
} catch (IOException e) {
log.warn("Unable to load file meta: " + e.getMessage());
return false;
}
if (null == pluginMeta) {
return false;
}
for (final ProviderDef pluginDef : pluginMeta.getPluginDefs()) {
if (matchesProvider(ident, pluginDef)) {
return true;
}
}
return false;
}
|
[
"public",
"synchronized",
"boolean",
"isLoaderFor",
"(",
"final",
"ProviderIdent",
"ident",
")",
"{",
"final",
"PluginMeta",
"pluginMeta",
";",
"try",
"{",
"pluginMeta",
"=",
"getPluginMeta",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to load file meta: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"null",
"==",
"pluginMeta",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"final",
"ProviderDef",
"pluginDef",
":",
"pluginMeta",
".",
"getPluginDefs",
"(",
")",
")",
"{",
"if",
"(",
"matchesProvider",
"(",
"ident",
",",
"pluginDef",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Return true if the plugin file can loade a provider for the ident
|
[
"Return",
"true",
"if",
"the",
"plugin",
"file",
"can",
"loade",
"a",
"provider",
"for",
"the",
"ident"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L280-L298
|
15,823
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.loadMeta
|
static PluginMeta loadMeta(final File jar) throws IOException {
FileInputStream fileInputStream = new FileInputStream(jar);
try{
final ZipInputStream zipinput = new ZipInputStream(fileInputStream);
final PluginMeta metadata = ScriptPluginProviderLoader.loadMeta(jar, zipinput);
return metadata;
}finally {
fileInputStream.close();
}
}
|
java
|
static PluginMeta loadMeta(final File jar) throws IOException {
FileInputStream fileInputStream = new FileInputStream(jar);
try{
final ZipInputStream zipinput = new ZipInputStream(fileInputStream);
final PluginMeta metadata = ScriptPluginProviderLoader.loadMeta(jar, zipinput);
return metadata;
}finally {
fileInputStream.close();
}
}
|
[
"static",
"PluginMeta",
"loadMeta",
"(",
"final",
"File",
"jar",
")",
"throws",
"IOException",
"{",
"FileInputStream",
"fileInputStream",
"=",
"new",
"FileInputStream",
"(",
"jar",
")",
";",
"try",
"{",
"final",
"ZipInputStream",
"zipinput",
"=",
"new",
"ZipInputStream",
"(",
"fileInputStream",
")",
";",
"final",
"PluginMeta",
"metadata",
"=",
"ScriptPluginProviderLoader",
".",
"loadMeta",
"(",
"jar",
",",
"zipinput",
")",
";",
"return",
"metadata",
";",
"}",
"finally",
"{",
"fileInputStream",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Get plugin metadatat from a zip file
|
[
"Get",
"plugin",
"metadatat",
"from",
"a",
"zip",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L321-L330
|
15,824
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.loadMeta
|
static PluginMeta loadMeta(final File jar, final ZipInputStream zipinput) throws IOException {
final String basename = basename(jar);
PluginMeta metadata = null;
boolean topfound = false;
boolean found = false;
boolean dirfound = false;
boolean resfound = false;
ZipEntry nextEntry = zipinput.getNextEntry();
Set<String> paths = new HashSet<>();
while (null != nextEntry) {
paths.add(nextEntry.getName());
if (!found && !nextEntry.isDirectory() && nextEntry.getName().equals(basename + "/plugin.yaml")) {
// debug("Found metadata: " + nextEntry.getName());
try {
metadata = loadMetadataYaml(zipinput);
found = true;
} catch (Throwable e) {
log.error("Error parsing metadata file plugin.yaml: " + e.getMessage(), e);
}
}
nextEntry = zipinput.getNextEntry();
}
if (!found || metadata == null) {
log.error("Plugin not loaded: Found no " + basename + "/plugin.yaml within: " + jar.getAbsolutePath());
}
String resdir = null != metadata ? getResourcesBasePath(metadata) : null;
for (String path : paths) {
if (!topfound && path.startsWith(basename + "/")) {
topfound = true;
}
if (!dirfound && (path.startsWith(basename + "/contents/") || path.equals(basename + "/contents"))) {
dirfound = true;
}
if (!resfound
&& resdir != null
&& (path.startsWith(basename + "/" + resdir + "/") || path.equals(basename + "/" + resdir))) {
resfound = true;
}
}
if (!topfound) {
log.error("Plugin not loaded: Found no " + basename + "/ dir within file: " + jar.getAbsolutePath());
}
if (!dirfound && !resfound) {
log.error("Plugin not loaded: Found no " +
basename +
"/contents or " +
basename +
"/" + resdir + " dir within: " +
jar.getAbsolutePath());
}
if (found && (dirfound || resfound)) {
return metadata;
}
return null;
}
|
java
|
static PluginMeta loadMeta(final File jar, final ZipInputStream zipinput) throws IOException {
final String basename = basename(jar);
PluginMeta metadata = null;
boolean topfound = false;
boolean found = false;
boolean dirfound = false;
boolean resfound = false;
ZipEntry nextEntry = zipinput.getNextEntry();
Set<String> paths = new HashSet<>();
while (null != nextEntry) {
paths.add(nextEntry.getName());
if (!found && !nextEntry.isDirectory() && nextEntry.getName().equals(basename + "/plugin.yaml")) {
// debug("Found metadata: " + nextEntry.getName());
try {
metadata = loadMetadataYaml(zipinput);
found = true;
} catch (Throwable e) {
log.error("Error parsing metadata file plugin.yaml: " + e.getMessage(), e);
}
}
nextEntry = zipinput.getNextEntry();
}
if (!found || metadata == null) {
log.error("Plugin not loaded: Found no " + basename + "/plugin.yaml within: " + jar.getAbsolutePath());
}
String resdir = null != metadata ? getResourcesBasePath(metadata) : null;
for (String path : paths) {
if (!topfound && path.startsWith(basename + "/")) {
topfound = true;
}
if (!dirfound && (path.startsWith(basename + "/contents/") || path.equals(basename + "/contents"))) {
dirfound = true;
}
if (!resfound
&& resdir != null
&& (path.startsWith(basename + "/" + resdir + "/") || path.equals(basename + "/" + resdir))) {
resfound = true;
}
}
if (!topfound) {
log.error("Plugin not loaded: Found no " + basename + "/ dir within file: " + jar.getAbsolutePath());
}
if (!dirfound && !resfound) {
log.error("Plugin not loaded: Found no " +
basename +
"/contents or " +
basename +
"/" + resdir + " dir within: " +
jar.getAbsolutePath());
}
if (found && (dirfound || resfound)) {
return metadata;
}
return null;
}
|
[
"static",
"PluginMeta",
"loadMeta",
"(",
"final",
"File",
"jar",
",",
"final",
"ZipInputStream",
"zipinput",
")",
"throws",
"IOException",
"{",
"final",
"String",
"basename",
"=",
"basename",
"(",
"jar",
")",
";",
"PluginMeta",
"metadata",
"=",
"null",
";",
"boolean",
"topfound",
"=",
"false",
";",
"boolean",
"found",
"=",
"false",
";",
"boolean",
"dirfound",
"=",
"false",
";",
"boolean",
"resfound",
"=",
"false",
";",
"ZipEntry",
"nextEntry",
"=",
"zipinput",
".",
"getNextEntry",
"(",
")",
";",
"Set",
"<",
"String",
">",
"paths",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"while",
"(",
"null",
"!=",
"nextEntry",
")",
"{",
"paths",
".",
"add",
"(",
"nextEntry",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"!",
"found",
"&&",
"!",
"nextEntry",
".",
"isDirectory",
"(",
")",
"&&",
"nextEntry",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"basename",
"+",
"\"/plugin.yaml\"",
")",
")",
"{",
"// debug(\"Found metadata: \" + nextEntry.getName());",
"try",
"{",
"metadata",
"=",
"loadMetadataYaml",
"(",
"zipinput",
")",
";",
"found",
"=",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"log",
".",
"error",
"(",
"\"Error parsing metadata file plugin.yaml: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"nextEntry",
"=",
"zipinput",
".",
"getNextEntry",
"(",
")",
";",
"}",
"if",
"(",
"!",
"found",
"||",
"metadata",
"==",
"null",
")",
"{",
"log",
".",
"error",
"(",
"\"Plugin not loaded: Found no \"",
"+",
"basename",
"+",
"\"/plugin.yaml within: \"",
"+",
"jar",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"String",
"resdir",
"=",
"null",
"!=",
"metadata",
"?",
"getResourcesBasePath",
"(",
"metadata",
")",
":",
"null",
";",
"for",
"(",
"String",
"path",
":",
"paths",
")",
"{",
"if",
"(",
"!",
"topfound",
"&&",
"path",
".",
"startsWith",
"(",
"basename",
"+",
"\"/\"",
")",
")",
"{",
"topfound",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"dirfound",
"&&",
"(",
"path",
".",
"startsWith",
"(",
"basename",
"+",
"\"/contents/\"",
")",
"||",
"path",
".",
"equals",
"(",
"basename",
"+",
"\"/contents\"",
")",
")",
")",
"{",
"dirfound",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"resfound",
"&&",
"resdir",
"!=",
"null",
"&&",
"(",
"path",
".",
"startsWith",
"(",
"basename",
"+",
"\"/\"",
"+",
"resdir",
"+",
"\"/\"",
")",
"||",
"path",
".",
"equals",
"(",
"basename",
"+",
"\"/\"",
"+",
"resdir",
")",
")",
")",
"{",
"resfound",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"topfound",
")",
"{",
"log",
".",
"error",
"(",
"\"Plugin not loaded: Found no \"",
"+",
"basename",
"+",
"\"/ dir within file: \"",
"+",
"jar",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"dirfound",
"&&",
"!",
"resfound",
")",
"{",
"log",
".",
"error",
"(",
"\"Plugin not loaded: Found no \"",
"+",
"basename",
"+",
"\"/contents or \"",
"+",
"basename",
"+",
"\"/\"",
"+",
"resdir",
"+",
"\" dir within: \"",
"+",
"jar",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"if",
"(",
"found",
"&&",
"(",
"dirfound",
"||",
"resfound",
")",
")",
"{",
"return",
"metadata",
";",
"}",
"return",
"null",
";",
"}"
] |
Load plugin metadata for a file and zip inputstream
@param jar the file
@param zipinput zip input stream
@return loaded metadata, or null if it is invalid or not found
|
[
"Load",
"plugin",
"metadata",
"for",
"a",
"file",
"and",
"zip",
"inputstream"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L338-L394
|
15,825
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.loadMetadataYaml
|
static PluginMeta loadMetadataYaml(final InputStream stream) {
final Yaml yaml = new Yaml();
return yaml.loadAs(stream, PluginMeta.class);
}
|
java
|
static PluginMeta loadMetadataYaml(final InputStream stream) {
final Yaml yaml = new Yaml();
return yaml.loadAs(stream, PluginMeta.class);
}
|
[
"static",
"PluginMeta",
"loadMetadataYaml",
"(",
"final",
"InputStream",
"stream",
")",
"{",
"final",
"Yaml",
"yaml",
"=",
"new",
"Yaml",
"(",
")",
";",
"return",
"yaml",
".",
"loadAs",
"(",
"stream",
",",
"PluginMeta",
".",
"class",
")",
";",
"}"
] |
return loaded yaml plugin metadata from the stream
|
[
"return",
"loaded",
"yaml",
"plugin",
"metadata",
"from",
"the",
"stream"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L399-L403
|
15,826
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.validatePluginMeta
|
static PluginValidation validatePluginMeta(final PluginMeta pluginList, final File file) {
PluginValidation.State state = PluginValidation.State.VALID;
if (pluginList == null) {
return PluginValidation.builder()
.message("No metadata")
.state(PluginValidation.State.INVALID)
.build();
}
List<String> messages = new ArrayList<>();
if (null == pluginList.getName()) {
messages.add("'name' not found in metadata");
state = PluginValidation.State.INVALID;
}
if (null == pluginList.getVersion()) {
messages.add("'version' not found in metadata");
state = PluginValidation.State.INVALID;
}
if (null == pluginList.getRundeckPluginVersion()) {
messages.add("'rundeckPluginVersion' not found in metadata");
state = PluginValidation.State.INVALID;
} else if (!SUPPORTED_PLUGIN_VERSIONS.contains(pluginList.getRundeckPluginVersion())) {
messages.add("'rundeckPluginVersion': \"" + pluginList.getRundeckPluginVersion() + "\" is not supported");
state = PluginValidation.State.INVALID;
}
if(pluginList.getRundeckPluginVersion().equals(VERSION_2_0)) {
List<String> validationErrors = new ArrayList<>();
PluginValidation.State
hostCompatState =
PluginMetadataValidator.validateTargetHostCompatibility(
validationErrors,
pluginList.getTargetHostCompatibility()
);
PluginValidation.State
versCompatState = PluginMetadataValidator.validateRundeckCompatibility(
validationErrors,
pluginList.getRundeckCompatibilityVersion()
);
messages.addAll(validationErrors);
state = state.or(hostCompatState)
.or(versCompatState);
}
final List<ProviderDef> pluginDefs = pluginList.getPluginDefs();
for (final ProviderDef pluginDef : pluginDefs) {
try {
validateProviderDef(pluginDef);
} catch (PluginException e) {
messages.add(e.getMessage());
state = PluginValidation.State.INVALID;
}
}
return PluginValidation.builder()
.state(state)
.messages(messages)
.build();
}
|
java
|
static PluginValidation validatePluginMeta(final PluginMeta pluginList, final File file) {
PluginValidation.State state = PluginValidation.State.VALID;
if (pluginList == null) {
return PluginValidation.builder()
.message("No metadata")
.state(PluginValidation.State.INVALID)
.build();
}
List<String> messages = new ArrayList<>();
if (null == pluginList.getName()) {
messages.add("'name' not found in metadata");
state = PluginValidation.State.INVALID;
}
if (null == pluginList.getVersion()) {
messages.add("'version' not found in metadata");
state = PluginValidation.State.INVALID;
}
if (null == pluginList.getRundeckPluginVersion()) {
messages.add("'rundeckPluginVersion' not found in metadata");
state = PluginValidation.State.INVALID;
} else if (!SUPPORTED_PLUGIN_VERSIONS.contains(pluginList.getRundeckPluginVersion())) {
messages.add("'rundeckPluginVersion': \"" + pluginList.getRundeckPluginVersion() + "\" is not supported");
state = PluginValidation.State.INVALID;
}
if(pluginList.getRundeckPluginVersion().equals(VERSION_2_0)) {
List<String> validationErrors = new ArrayList<>();
PluginValidation.State
hostCompatState =
PluginMetadataValidator.validateTargetHostCompatibility(
validationErrors,
pluginList.getTargetHostCompatibility()
);
PluginValidation.State
versCompatState = PluginMetadataValidator.validateRundeckCompatibility(
validationErrors,
pluginList.getRundeckCompatibilityVersion()
);
messages.addAll(validationErrors);
state = state.or(hostCompatState)
.or(versCompatState);
}
final List<ProviderDef> pluginDefs = pluginList.getPluginDefs();
for (final ProviderDef pluginDef : pluginDefs) {
try {
validateProviderDef(pluginDef);
} catch (PluginException e) {
messages.add(e.getMessage());
state = PluginValidation.State.INVALID;
}
}
return PluginValidation.builder()
.state(state)
.messages(messages)
.build();
}
|
[
"static",
"PluginValidation",
"validatePluginMeta",
"(",
"final",
"PluginMeta",
"pluginList",
",",
"final",
"File",
"file",
")",
"{",
"PluginValidation",
".",
"State",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"VALID",
";",
"if",
"(",
"pluginList",
"==",
"null",
")",
"{",
"return",
"PluginValidation",
".",
"builder",
"(",
")",
".",
"message",
"(",
"\"No metadata\"",
")",
".",
"state",
"(",
"PluginValidation",
".",
"State",
".",
"INVALID",
")",
".",
"build",
"(",
")",
";",
"}",
"List",
"<",
"String",
">",
"messages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"==",
"pluginList",
".",
"getName",
"(",
")",
")",
"{",
"messages",
".",
"add",
"(",
"\"'name' not found in metadata\"",
")",
";",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"INVALID",
";",
"}",
"if",
"(",
"null",
"==",
"pluginList",
".",
"getVersion",
"(",
")",
")",
"{",
"messages",
".",
"add",
"(",
"\"'version' not found in metadata\"",
")",
";",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"INVALID",
";",
"}",
"if",
"(",
"null",
"==",
"pluginList",
".",
"getRundeckPluginVersion",
"(",
")",
")",
"{",
"messages",
".",
"add",
"(",
"\"'rundeckPluginVersion' not found in metadata\"",
")",
";",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"INVALID",
";",
"}",
"else",
"if",
"(",
"!",
"SUPPORTED_PLUGIN_VERSIONS",
".",
"contains",
"(",
"pluginList",
".",
"getRundeckPluginVersion",
"(",
")",
")",
")",
"{",
"messages",
".",
"add",
"(",
"\"'rundeckPluginVersion': \\\"\"",
"+",
"pluginList",
".",
"getRundeckPluginVersion",
"(",
")",
"+",
"\"\\\" is not supported\"",
")",
";",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"INVALID",
";",
"}",
"if",
"(",
"pluginList",
".",
"getRundeckPluginVersion",
"(",
")",
".",
"equals",
"(",
"VERSION_2_0",
")",
")",
"{",
"List",
"<",
"String",
">",
"validationErrors",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"PluginValidation",
".",
"State",
"hostCompatState",
"=",
"PluginMetadataValidator",
".",
"validateTargetHostCompatibility",
"(",
"validationErrors",
",",
"pluginList",
".",
"getTargetHostCompatibility",
"(",
")",
")",
";",
"PluginValidation",
".",
"State",
"versCompatState",
"=",
"PluginMetadataValidator",
".",
"validateRundeckCompatibility",
"(",
"validationErrors",
",",
"pluginList",
".",
"getRundeckCompatibilityVersion",
"(",
")",
")",
";",
"messages",
".",
"addAll",
"(",
"validationErrors",
")",
";",
"state",
"=",
"state",
".",
"or",
"(",
"hostCompatState",
")",
".",
"or",
"(",
"versCompatState",
")",
";",
"}",
"final",
"List",
"<",
"ProviderDef",
">",
"pluginDefs",
"=",
"pluginList",
".",
"getPluginDefs",
"(",
")",
";",
"for",
"(",
"final",
"ProviderDef",
"pluginDef",
":",
"pluginDefs",
")",
"{",
"try",
"{",
"validateProviderDef",
"(",
"pluginDef",
")",
";",
"}",
"catch",
"(",
"PluginException",
"e",
")",
"{",
"messages",
".",
"add",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"state",
"=",
"PluginValidation",
".",
"State",
".",
"INVALID",
";",
"}",
"}",
"return",
"PluginValidation",
".",
"builder",
"(",
")",
".",
"state",
"(",
"state",
")",
".",
"messages",
"(",
"messages",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Return true if loaded metadata about the plugin file is valid.
|
[
"Return",
"true",
"if",
"loaded",
"metadata",
"about",
"the",
"plugin",
"file",
"is",
"valid",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L408-L465
|
15,827
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.expandScriptPlugin
|
private File expandScriptPlugin(final File file) throws IOException {
if (!cachedir.exists()) {
if (!cachedir.mkdirs()) {
log.warn("Unable to create cache dir: " + cachedir.getAbsolutePath());
}
}
final File jardir = getFileCacheDir();
if (!jardir.exists()) {
if (!jardir.mkdir()) {
log.warn("Unable to create cache dir for plugin: " + jardir.getAbsolutePath());
}
}
final String prefix = getFileBasename() + "/contents";
debug("Expand zip " + file.getAbsolutePath() + " to dir: " + jardir + ", prefix: " + prefix);
ZipUtil.extractZip(file.getAbsolutePath(), jardir, prefix, prefix + "/");
return jardir;
}
|
java
|
private File expandScriptPlugin(final File file) throws IOException {
if (!cachedir.exists()) {
if (!cachedir.mkdirs()) {
log.warn("Unable to create cache dir: " + cachedir.getAbsolutePath());
}
}
final File jardir = getFileCacheDir();
if (!jardir.exists()) {
if (!jardir.mkdir()) {
log.warn("Unable to create cache dir for plugin: " + jardir.getAbsolutePath());
}
}
final String prefix = getFileBasename() + "/contents";
debug("Expand zip " + file.getAbsolutePath() + " to dir: " + jardir + ", prefix: " + prefix);
ZipUtil.extractZip(file.getAbsolutePath(), jardir, prefix, prefix + "/");
return jardir;
}
|
[
"private",
"File",
"expandScriptPlugin",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"cachedir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"cachedir",
".",
"mkdirs",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to create cache dir: \"",
"+",
"cachedir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"final",
"File",
"jardir",
"=",
"getFileCacheDir",
"(",
")",
";",
"if",
"(",
"!",
"jardir",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"jardir",
".",
"mkdir",
"(",
")",
")",
"{",
"log",
".",
"warn",
"(",
"\"Unable to create cache dir for plugin: \"",
"+",
"jardir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"final",
"String",
"prefix",
"=",
"getFileBasename",
"(",
")",
"+",
"\"/contents\"",
";",
"debug",
"(",
"\"Expand zip \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" to dir: \"",
"+",
"jardir",
"+",
"\", prefix: \"",
"+",
"prefix",
")",
";",
"ZipUtil",
".",
"extractZip",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
",",
"jardir",
",",
"prefix",
",",
"prefix",
"+",
"\"/\"",
")",
";",
"return",
"jardir",
";",
"}"
] |
Expand zip file into plugin cache dir
@param file zip file
@return cache dir for the contents of the plugin zip
|
[
"Expand",
"zip",
"file",
"into",
"plugin",
"cache",
"dir"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L474-L492
|
15,828
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.removeScriptPluginCache
|
private synchronized boolean removeScriptPluginCache() {
if (null != fileExpandedDir && fileExpandedDir.exists()) {
debug("removeScriptPluginCache: " + fileExpandedDir);
return FileUtils.deleteDir(fileExpandedDir);
}
return true;
}
|
java
|
private synchronized boolean removeScriptPluginCache() {
if (null != fileExpandedDir && fileExpandedDir.exists()) {
debug("removeScriptPluginCache: " + fileExpandedDir);
return FileUtils.deleteDir(fileExpandedDir);
}
return true;
}
|
[
"private",
"synchronized",
"boolean",
"removeScriptPluginCache",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"fileExpandedDir",
"&&",
"fileExpandedDir",
".",
"exists",
"(",
")",
")",
"{",
"debug",
"(",
"\"removeScriptPluginCache: \"",
"+",
"fileExpandedDir",
")",
";",
"return",
"FileUtils",
".",
"deleteDir",
"(",
"fileExpandedDir",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Remove any cache dir for the file
|
[
"Remove",
"any",
"cache",
"dir",
"for",
"the",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L497-L503
|
15,829
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.basename
|
private static String basename(final File file) {
final String name = file.getName();
if(name.contains(".")) {
return name.substring(0, name.lastIndexOf("."));
}
return name;
}
|
java
|
private static String basename(final File file) {
final String name = file.getName();
if(name.contains(".")) {
return name.substring(0, name.lastIndexOf("."));
}
return name;
}
|
[
"private",
"static",
"String",
"basename",
"(",
"final",
"File",
"file",
")",
"{",
"final",
"String",
"name",
"=",
"file",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"contains",
"(",
"\".\"",
")",
")",
"{",
"return",
"name",
".",
"substring",
"(",
"0",
",",
"name",
".",
"lastIndexOf",
"(",
"\".\"",
")",
")",
";",
"}",
"return",
"name",
";",
"}"
] |
Get basename of a file
|
[
"Get",
"basename",
"of",
"a",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L515-L521
|
15,830
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.validateProviderDef
|
private static void validateProviderDef(final ProviderDef pluginDef) throws PluginException {
if (null == pluginDef.getPluginType() || "".equals(pluginDef.getPluginType())) {
throw new PluginException("Script plugin missing plugin-type");
}
if ("script".equals(pluginDef.getPluginType())) {
validateScriptProviderDef(pluginDef);
} else if ("ui".equals(pluginDef.getPluginType())) {
validateUIProviderDef(pluginDef);
} else {
throw new PluginException("Script plugin has invalid plugin-type: " + pluginDef.getPluginType());
}
}
|
java
|
private static void validateProviderDef(final ProviderDef pluginDef) throws PluginException {
if (null == pluginDef.getPluginType() || "".equals(pluginDef.getPluginType())) {
throw new PluginException("Script plugin missing plugin-type");
}
if ("script".equals(pluginDef.getPluginType())) {
validateScriptProviderDef(pluginDef);
} else if ("ui".equals(pluginDef.getPluginType())) {
validateUIProviderDef(pluginDef);
} else {
throw new PluginException("Script plugin has invalid plugin-type: " + pluginDef.getPluginType());
}
}
|
[
"private",
"static",
"void",
"validateProviderDef",
"(",
"final",
"ProviderDef",
"pluginDef",
")",
"throws",
"PluginException",
"{",
"if",
"(",
"null",
"==",
"pluginDef",
".",
"getPluginType",
"(",
")",
"||",
"\"\"",
".",
"equals",
"(",
"pluginDef",
".",
"getPluginType",
"(",
")",
")",
")",
"{",
"throw",
"new",
"PluginException",
"(",
"\"Script plugin missing plugin-type\"",
")",
";",
"}",
"if",
"(",
"\"script\"",
".",
"equals",
"(",
"pluginDef",
".",
"getPluginType",
"(",
")",
")",
")",
"{",
"validateScriptProviderDef",
"(",
"pluginDef",
")",
";",
"}",
"else",
"if",
"(",
"\"ui\"",
".",
"equals",
"(",
"pluginDef",
".",
"getPluginType",
"(",
")",
")",
")",
"{",
"validateUIProviderDef",
"(",
"pluginDef",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PluginException",
"(",
"\"Script plugin has invalid plugin-type: \"",
"+",
"pluginDef",
".",
"getPluginType",
"(",
")",
")",
";",
"}",
"}"
] |
Validate provider def
|
[
"Validate",
"provider",
"def"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L534-L546
|
15,831
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java
|
ScriptPluginProviderLoader.getVersionForFile
|
static String getVersionForFile(final File file) {
try {
final PluginMeta pluginMeta = loadMeta(file);
return pluginMeta.getVersion();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
|
java
|
static String getVersionForFile(final File file) {
try {
final PluginMeta pluginMeta = loadMeta(file);
return pluginMeta.getVersion();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
|
[
"static",
"String",
"getVersionForFile",
"(",
"final",
"File",
"file",
")",
"{",
"try",
"{",
"final",
"PluginMeta",
"pluginMeta",
"=",
"loadMeta",
"(",
"file",
")",
";",
"return",
"pluginMeta",
".",
"getVersion",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Return the version string metadata value for the plugin file, or null if it is not available or could not
loaded
@param file file
@return version string
|
[
"Return",
"the",
"version",
"string",
"metadata",
"value",
"for",
"the",
"plugin",
"file",
"or",
"null",
"if",
"it",
"is",
"not",
"available",
"or",
"could",
"not",
"loaded"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ScriptPluginProviderLoader.java#L641-L649
|
15,832
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ExecToolCommandLogger.java
|
ExecToolCommandLogger.expandMessage
|
private String expandMessage(final BuildEvent event, final String message) {
final HashMap<String,String> data=new HashMap<String, String>();
final String user = retrieveUserName(event);
if(null!=user){
data.put("user", user);
}
final String node = retrieveNodeName(event);
if(null!=node){
data.put("node", node);
}
data.put("level", logLevelToString(event.getPriority()));
if(null!=formatter){
return formatter.reformat(data, message);
}else {
return message;
}
}
|
java
|
private String expandMessage(final BuildEvent event, final String message) {
final HashMap<String,String> data=new HashMap<String, String>();
final String user = retrieveUserName(event);
if(null!=user){
data.put("user", user);
}
final String node = retrieveNodeName(event);
if(null!=node){
data.put("node", node);
}
data.put("level", logLevelToString(event.getPriority()));
if(null!=formatter){
return formatter.reformat(data, message);
}else {
return message;
}
}
|
[
"private",
"String",
"expandMessage",
"(",
"final",
"BuildEvent",
"event",
",",
"final",
"String",
"message",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"data",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"final",
"String",
"user",
"=",
"retrieveUserName",
"(",
"event",
")",
";",
"if",
"(",
"null",
"!=",
"user",
")",
"{",
"data",
".",
"put",
"(",
"\"user\"",
",",
"user",
")",
";",
"}",
"final",
"String",
"node",
"=",
"retrieveNodeName",
"(",
"event",
")",
";",
"if",
"(",
"null",
"!=",
"node",
")",
"{",
"data",
".",
"put",
"(",
"\"node\"",
",",
"node",
")",
";",
"}",
"data",
".",
"put",
"(",
"\"level\"",
",",
"logLevelToString",
"(",
"event",
".",
"getPriority",
"(",
")",
")",
")",
";",
"if",
"(",
"null",
"!=",
"formatter",
")",
"{",
"return",
"formatter",
".",
"reformat",
"(",
"data",
",",
"message",
")",
";",
"}",
"else",
"{",
"return",
"message",
";",
"}",
"}"
] |
Process string specified by the framework.log.dispatch.console.format property replacing any well known tokens with values
from the event.
@param event The BuildEvent
@param message The concatenated message
@return message string with tokens replaced by values.
|
[
"Process",
"string",
"specified",
"by",
"the",
"framework",
".",
"log",
".",
"dispatch",
".",
"console",
".",
"format",
"property",
"replacing",
"any",
"well",
"known",
"tokens",
"with",
"values",
"from",
"the",
"event",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ExecToolCommandLogger.java#L76-L94
|
15,833
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ExecToolCommandLogger.java
|
ExecToolCommandLogger.logLevelToString
|
public static String logLevelToString(final int level) {
String logLevel;
switch (level) {
case Project.MSG_DEBUG:
logLevel = "DEBUG";
break;
case Project.MSG_VERBOSE:
logLevel = "VERBOSE";
break;
case Project.MSG_INFO:
logLevel = "INFO";
break;
case Project.MSG_WARN:
logLevel = "WARN";
break;
case Project.MSG_ERR:
logLevel = "ERROR";
break;
default:
logLevel = "UNKNOWN";
break;
}
return logLevel;
}
|
java
|
public static String logLevelToString(final int level) {
String logLevel;
switch (level) {
case Project.MSG_DEBUG:
logLevel = "DEBUG";
break;
case Project.MSG_VERBOSE:
logLevel = "VERBOSE";
break;
case Project.MSG_INFO:
logLevel = "INFO";
break;
case Project.MSG_WARN:
logLevel = "WARN";
break;
case Project.MSG_ERR:
logLevel = "ERROR";
break;
default:
logLevel = "UNKNOWN";
break;
}
return logLevel;
}
|
[
"public",
"static",
"String",
"logLevelToString",
"(",
"final",
"int",
"level",
")",
"{",
"String",
"logLevel",
";",
"switch",
"(",
"level",
")",
"{",
"case",
"Project",
".",
"MSG_DEBUG",
":",
"logLevel",
"=",
"\"DEBUG\"",
";",
"break",
";",
"case",
"Project",
".",
"MSG_VERBOSE",
":",
"logLevel",
"=",
"\"VERBOSE\"",
";",
"break",
";",
"case",
"Project",
".",
"MSG_INFO",
":",
"logLevel",
"=",
"\"INFO\"",
";",
"break",
";",
"case",
"Project",
".",
"MSG_WARN",
":",
"logLevel",
"=",
"\"WARN\"",
";",
"break",
";",
"case",
"Project",
".",
"MSG_ERR",
":",
"logLevel",
"=",
"\"ERROR\"",
";",
"break",
";",
"default",
":",
"logLevel",
"=",
"\"UNKNOWN\"",
";",
"break",
";",
"}",
"return",
"logLevel",
";",
"}"
] |
Returns a string representing the specified log level
@param level Log level
@return log level name in string form
|
[
"Returns",
"a",
"string",
"representing",
"the",
"specified",
"log",
"level"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ExecToolCommandLogger.java#L138-L162
|
15,834
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.buildFieldProperties
|
public static void buildFieldProperties(final Class<?> aClass, final DescriptionBuilder builder) {
for (final Field field : collectClassFields(aClass)) {
final PluginProperty annotation = field.getAnnotation(PluginProperty.class);
if (null == annotation) {
continue;
}
final Property pbuild = propertyFromField(field, annotation);
if (null == pbuild) {
continue;
}
builder.property(pbuild);
}
}
|
java
|
public static void buildFieldProperties(final Class<?> aClass, final DescriptionBuilder builder) {
for (final Field field : collectClassFields(aClass)) {
final PluginProperty annotation = field.getAnnotation(PluginProperty.class);
if (null == annotation) {
continue;
}
final Property pbuild = propertyFromField(field, annotation);
if (null == pbuild) {
continue;
}
builder.property(pbuild);
}
}
|
[
"public",
"static",
"void",
"buildFieldProperties",
"(",
"final",
"Class",
"<",
"?",
">",
"aClass",
",",
"final",
"DescriptionBuilder",
"builder",
")",
"{",
"for",
"(",
"final",
"Field",
"field",
":",
"collectClassFields",
"(",
"aClass",
")",
")",
"{",
"final",
"PluginProperty",
"annotation",
"=",
"field",
".",
"getAnnotation",
"(",
"PluginProperty",
".",
"class",
")",
";",
"if",
"(",
"null",
"==",
"annotation",
")",
"{",
"continue",
";",
"}",
"final",
"Property",
"pbuild",
"=",
"propertyFromField",
"(",
"field",
",",
"annotation",
")",
";",
"if",
"(",
"null",
"==",
"pbuild",
")",
"{",
"continue",
";",
"}",
"builder",
".",
"property",
"(",
"pbuild",
")",
";",
"}",
"}"
] |
Add properties based on introspection of a class
@param aClass class
@param builder builder
|
[
"Add",
"properties",
"based",
"on",
"introspection",
"of",
"a",
"class"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L151-L163
|
15,835
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.configureProperties
|
public static Map<String, Object> configureProperties(final PropertyResolver resolver,
final Object object) {
//use a default scope of InstanceOnly if the Property doesn't specify it
return configureProperties(resolver, buildDescription(object, DescriptionBuilder.builder()), object,
PropertyScope.InstanceOnly);
}
|
java
|
public static Map<String, Object> configureProperties(final PropertyResolver resolver,
final Object object) {
//use a default scope of InstanceOnly if the Property doesn't specify it
return configureProperties(resolver, buildDescription(object, DescriptionBuilder.builder()), object,
PropertyScope.InstanceOnly);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"configureProperties",
"(",
"final",
"PropertyResolver",
"resolver",
",",
"final",
"Object",
"object",
")",
"{",
"//use a default scope of InstanceOnly if the Property doesn't specify it",
"return",
"configureProperties",
"(",
"resolver",
",",
"buildDescription",
"(",
"object",
",",
"DescriptionBuilder",
".",
"builder",
"(",
")",
")",
",",
"object",
",",
"PropertyScope",
".",
"InstanceOnly",
")",
";",
"}"
] |
Set field values on a plugin object by using annotated field values to create a Description, and setting field
values to resolved property values. Any resolved properties that are not mapped to a field will be included in
the return result.
@param resolver property resolver
@param object plugin object
@return Map of resolved properties that were not configured in the object's fields
|
[
"Set",
"field",
"values",
"on",
"a",
"plugin",
"object",
"by",
"using",
"annotated",
"field",
"values",
"to",
"create",
"a",
"Description",
"and",
"setting",
"field",
"values",
"to",
"resolved",
"property",
"values",
".",
"Any",
"resolved",
"properties",
"that",
"are",
"not",
"mapped",
"to",
"a",
"field",
"will",
"be",
"included",
"in",
"the",
"return",
"result",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L337-L342
|
15,836
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.configureProperties
|
public static Map<String, Object> configureProperties(final PropertyResolver resolver,
final Description description,
final Object object, PropertyScope defaultScope) {
Map<String, Object> inputConfig = mapDescribedProperties(resolver, description, defaultScope);
if (object instanceof Configurable) {
Configurable configObject = (Configurable) object;
Properties configuration = new Properties();
configuration.putAll(inputConfig);
try {
configObject.configure(configuration);
} catch (ConfigurationException e) {
}
} else {
inputConfig = configureObjectFieldsWithProperties(object, description.getProperties(), inputConfig);
}
return inputConfig;
}
|
java
|
public static Map<String, Object> configureProperties(final PropertyResolver resolver,
final Description description,
final Object object, PropertyScope defaultScope) {
Map<String, Object> inputConfig = mapDescribedProperties(resolver, description, defaultScope);
if (object instanceof Configurable) {
Configurable configObject = (Configurable) object;
Properties configuration = new Properties();
configuration.putAll(inputConfig);
try {
configObject.configure(configuration);
} catch (ConfigurationException e) {
}
} else {
inputConfig = configureObjectFieldsWithProperties(object, description.getProperties(), inputConfig);
}
return inputConfig;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"configureProperties",
"(",
"final",
"PropertyResolver",
"resolver",
",",
"final",
"Description",
"description",
",",
"final",
"Object",
"object",
",",
"PropertyScope",
"defaultScope",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"inputConfig",
"=",
"mapDescribedProperties",
"(",
"resolver",
",",
"description",
",",
"defaultScope",
")",
";",
"if",
"(",
"object",
"instanceof",
"Configurable",
")",
"{",
"Configurable",
"configObject",
"=",
"(",
"Configurable",
")",
"object",
";",
"Properties",
"configuration",
"=",
"new",
"Properties",
"(",
")",
";",
"configuration",
".",
"putAll",
"(",
"inputConfig",
")",
";",
"try",
"{",
"configObject",
".",
"configure",
"(",
"configuration",
")",
";",
"}",
"catch",
"(",
"ConfigurationException",
"e",
")",
"{",
"}",
"}",
"else",
"{",
"inputConfig",
"=",
"configureObjectFieldsWithProperties",
"(",
"object",
",",
"description",
".",
"getProperties",
"(",
")",
",",
"inputConfig",
")",
";",
"}",
"return",
"inputConfig",
";",
"}"
] |
Set field values on a plugin object by using a Description, and setting field values to resolved property values.
Any resolved properties that are not mapped to a field will be included in the return result.
@param resolver the property resolver
@param description the property descriptions
@param object the target object, which can implement {@link Configurable}, otherwise introspection will be used
@param defaultScope a default property scope to assume for unspecified properties
@return Map of resolved properties that were not configured in the object's fields
|
[
"Set",
"field",
"values",
"on",
"a",
"plugin",
"object",
"by",
"using",
"a",
"Description",
"and",
"setting",
"field",
"values",
"to",
"resolved",
"property",
"values",
".",
"Any",
"resolved",
"properties",
"that",
"are",
"not",
"mapped",
"to",
"a",
"field",
"will",
"be",
"included",
"in",
"the",
"return",
"result",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L355-L372
|
15,837
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.configureObjectFieldsWithProperties
|
public static Map<String, Object> configureObjectFieldsWithProperties(
final Object object,
final Map<String, Object> inputConfig
)
{
return configureObjectFieldsWithProperties(object, buildFieldProperties(object), inputConfig);
}
|
java
|
public static Map<String, Object> configureObjectFieldsWithProperties(
final Object object,
final Map<String, Object> inputConfig
)
{
return configureObjectFieldsWithProperties(object, buildFieldProperties(object), inputConfig);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"configureObjectFieldsWithProperties",
"(",
"final",
"Object",
"object",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"inputConfig",
")",
"{",
"return",
"configureObjectFieldsWithProperties",
"(",
"object",
",",
"buildFieldProperties",
"(",
"object",
")",
",",
"inputConfig",
")",
";",
"}"
] |
Set field values on an object using introspection and input values for those properties
@param object object
@param inputConfig input
@return Map of resolved properties that were not configured in the object's fields
|
[
"Set",
"field",
"values",
"on",
"an",
"object",
"using",
"introspection",
"and",
"input",
"values",
"for",
"those",
"properties"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L380-L386
|
15,838
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.configureObjectFieldsWithProperties
|
public static Map<String, Object> configureObjectFieldsWithProperties(
final Object object,
final List<Property> properties,
final Map<String, Object> inputConfig
)
{
HashMap<String, Object> modified = new HashMap<>(inputConfig);
for (final Property property : properties) {
if (null != modified.get(property.getName())) {
if (setValueForProperty(property, modified.get(property.getName()), object)) {
modified.remove(property.getName());
}
}
}
return modified;
}
|
java
|
public static Map<String, Object> configureObjectFieldsWithProperties(
final Object object,
final List<Property> properties,
final Map<String, Object> inputConfig
)
{
HashMap<String, Object> modified = new HashMap<>(inputConfig);
for (final Property property : properties) {
if (null != modified.get(property.getName())) {
if (setValueForProperty(property, modified.get(property.getName()), object)) {
modified.remove(property.getName());
}
}
}
return modified;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"configureObjectFieldsWithProperties",
"(",
"final",
"Object",
"object",
",",
"final",
"List",
"<",
"Property",
">",
"properties",
",",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"inputConfig",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"modified",
"=",
"new",
"HashMap",
"<>",
"(",
"inputConfig",
")",
";",
"for",
"(",
"final",
"Property",
"property",
":",
"properties",
")",
"{",
"if",
"(",
"null",
"!=",
"modified",
".",
"get",
"(",
"property",
".",
"getName",
"(",
")",
")",
")",
"{",
"if",
"(",
"setValueForProperty",
"(",
"property",
",",
"modified",
".",
"get",
"(",
"property",
".",
"getName",
"(",
")",
")",
",",
"object",
")",
")",
"{",
"modified",
".",
"remove",
"(",
"property",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"modified",
";",
"}"
] |
Set field values on an object given a list of properties and input values for those properties
@param object object
@param properties properties
@param inputConfig input
@return Map of resolved properties that were not configured in the object's fields
|
[
"Set",
"field",
"values",
"on",
"an",
"object",
"given",
"a",
"list",
"of",
"properties",
"and",
"input",
"values",
"for",
"those",
"properties"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L395-L410
|
15,839
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java
|
PluginAdapterUtility.mapDescribedProperties
|
public static Map<String, Object> mapDescribedProperties(final PropertyResolver resolver,
final Description description) {
//use a default scope of InstanceOnly if the Property doesn't specify it
//use property default value if otherwise not resolved
return mapDescribedProperties(resolver, description, null);
}
|
java
|
public static Map<String, Object> mapDescribedProperties(final PropertyResolver resolver,
final Description description) {
//use a default scope of InstanceOnly if the Property doesn't specify it
//use property default value if otherwise not resolved
return mapDescribedProperties(resolver, description, null);
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"mapDescribedProperties",
"(",
"final",
"PropertyResolver",
"resolver",
",",
"final",
"Description",
"description",
")",
"{",
"//use a default scope of InstanceOnly if the Property doesn't specify it",
"//use property default value if otherwise not resolved",
"return",
"mapDescribedProperties",
"(",
"resolver",
",",
"description",
",",
"null",
")",
";",
"}"
] |
Retrieve the Description's Properties mapped to resolved values given the resolver, using InsanceOnly default scope.
@param resolver property resolver
@param description plugin description
@return All mapped properties by name and value.
|
[
"Retrieve",
"the",
"Description",
"s",
"Properties",
"mapped",
"to",
"resolved",
"values",
"given",
"the",
"resolver",
"using",
"InsanceOnly",
"default",
"scope",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/configuration/PluginAdapterUtility.java#L437-L442
|
15,840
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java
|
PropertyLookup.create
|
public static PropertyLookup create(final File propfile, final Map defaults, final IPropertyLookup defaultsLookup) {
return new PropertyLookup(propfile, defaults, defaultsLookup);
}
|
java
|
public static PropertyLookup create(final File propfile, final Map defaults, final IPropertyLookup defaultsLookup) {
return new PropertyLookup(propfile, defaults, defaultsLookup);
}
|
[
"public",
"static",
"PropertyLookup",
"create",
"(",
"final",
"File",
"propfile",
",",
"final",
"Map",
"defaults",
",",
"final",
"IPropertyLookup",
"defaultsLookup",
")",
"{",
"return",
"new",
"PropertyLookup",
"(",
"propfile",
",",
"defaults",
",",
"defaultsLookup",
")",
";",
"}"
] |
Calls base constructor feeding defaults from Map and IPropertyLookup params
@param propfile File containing property data
@param defaults Map of default properties
@param defaultsLookup IPropertyLookup of default properties
@return lookup
|
[
"Calls",
"base",
"constructor",
"feeding",
"defaults",
"from",
"Map",
"and",
"IPropertyLookup",
"params"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java#L179-L181
|
15,841
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java
|
PropertyLookup.getProperty
|
public String getProperty(final String key) {
if (hasProperty(key)) {
return properties.getProperty(key);
} else {
throw new PropertyLookupException("property not found: " + key);
}
}
|
java
|
public String getProperty(final String key) {
if (hasProperty(key)) {
return properties.getProperty(key);
} else {
throw new PropertyLookupException("property not found: " + key);
}
}
|
[
"public",
"String",
"getProperty",
"(",
"final",
"String",
"key",
")",
"{",
"if",
"(",
"hasProperty",
"(",
"key",
")",
")",
"{",
"return",
"properties",
".",
"getProperty",
"(",
"key",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropertyLookupException",
"(",
"\"property not found: \"",
"+",
"key",
")",
";",
"}",
"}"
] |
Get the property per specified key
@param key name of the property
@return Value of the property
@throws PropertyLookupException thrown if lookup fails for specified key
|
[
"Get",
"the",
"property",
"per",
"specified",
"key"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java#L190-L196
|
15,842
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java
|
PropertyLookup.fetchProperties
|
public static Properties fetchProperties(final File propFile) {
final Properties properties = new Properties();
try {
FileInputStream fis = new FileInputStream(propFile);
try {
properties.load(fis);
} finally {
if(null!=fis){
fis.close();
}
}
} catch (IOException e) {
throw new PropertyLookupException("failed loading properties from file: " + propFile, e);
}
return properties;
}
|
java
|
public static Properties fetchProperties(final File propFile) {
final Properties properties = new Properties();
try {
FileInputStream fis = new FileInputStream(propFile);
try {
properties.load(fis);
} finally {
if(null!=fis){
fis.close();
}
}
} catch (IOException e) {
throw new PropertyLookupException("failed loading properties from file: " + propFile, e);
}
return properties;
}
|
[
"public",
"static",
"Properties",
"fetchProperties",
"(",
"final",
"File",
"propFile",
")",
"{",
"final",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"{",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"propFile",
")",
";",
"try",
"{",
"properties",
".",
"load",
"(",
"fis",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"null",
"!=",
"fis",
")",
"{",
"fis",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"PropertyLookupException",
"(",
"\"failed loading properties from file: \"",
"+",
"propFile",
",",
"e",
")",
";",
"}",
"return",
"properties",
";",
"}"
] |
given a file reads in its properties
@param propFile File to read
@return a Properties object with data filled from propFile
@throws PropertyLookupException thrown if error loading property file
|
[
"given",
"a",
"file",
"reads",
"in",
"its",
"properties"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java#L250-L265
|
15,843
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java
|
PropertyLookup.difference
|
protected Properties difference(final Map map) {
final Properties difference = new Properties();
for (final Object o : map.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final String val = (String) entry.getValue();
if (!properties.containsKey(key)) {
difference.setProperty(key, val);
}
}
return difference;
}
|
java
|
protected Properties difference(final Map map) {
final Properties difference = new Properties();
for (final Object o : map.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final String val = (String) entry.getValue();
if (!properties.containsKey(key)) {
difference.setProperty(key, val);
}
}
return difference;
}
|
[
"protected",
"Properties",
"difference",
"(",
"final",
"Map",
"map",
")",
"{",
"final",
"Properties",
"difference",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"final",
"Object",
"o",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"o",
";",
"final",
"String",
"key",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"String",
"val",
"=",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"properties",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"difference",
".",
"setProperty",
"(",
"key",
",",
"val",
")",
";",
"}",
"}",
"return",
"difference",
";",
"}"
] |
Reads map of input properties and returns a collection of those that are unique
to that input set.
@param map Map of key/value pairs
@return Properties unique to map
|
[
"Reads",
"map",
"of",
"input",
"properties",
"and",
"returns",
"a",
"collection",
"of",
"those",
"that",
"are",
"unique",
"to",
"that",
"input",
"set",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java#L303-L314
|
15,844
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java
|
PropertyLookup.hasProperty
|
public static boolean hasProperty(final String propKey, final File propFile) {
if (null == propKey) throw new IllegalArgumentException("propKey param was null");
if (null == propFile) throw new IllegalArgumentException("propFile param was null");
if (propFile.exists()) {
final Properties p = new Properties();
try {
FileInputStream fis = new FileInputStream(propFile);
try {
p.load(fis);
} finally {
if (null != fis) {
fis.close();
}
}
return p.containsKey(propKey);
} catch (IOException e) {
return false;
}
} else {
return false;
}
}
|
java
|
public static boolean hasProperty(final String propKey, final File propFile) {
if (null == propKey) throw new IllegalArgumentException("propKey param was null");
if (null == propFile) throw new IllegalArgumentException("propFile param was null");
if (propFile.exists()) {
final Properties p = new Properties();
try {
FileInputStream fis = new FileInputStream(propFile);
try {
p.load(fis);
} finally {
if (null != fis) {
fis.close();
}
}
return p.containsKey(propKey);
} catch (IOException e) {
return false;
}
} else {
return false;
}
}
|
[
"public",
"static",
"boolean",
"hasProperty",
"(",
"final",
"String",
"propKey",
",",
"final",
"File",
"propFile",
")",
"{",
"if",
"(",
"null",
"==",
"propKey",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"propKey param was null\"",
")",
";",
"if",
"(",
"null",
"==",
"propFile",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"propFile param was null\"",
")",
";",
"if",
"(",
"propFile",
".",
"exists",
"(",
")",
")",
"{",
"final",
"Properties",
"p",
"=",
"new",
"Properties",
"(",
")",
";",
"try",
"{",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"propFile",
")",
";",
"try",
"{",
"p",
".",
"load",
"(",
"fis",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"null",
"!=",
"fis",
")",
"{",
"fis",
".",
"close",
"(",
")",
";",
"}",
"}",
"return",
"p",
".",
"containsKey",
"(",
"propKey",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Reads propFile and then checks if specified key exists.
@param propKey property name
@param propFile property file
@return file if a property with that name exists. If an exception occurs while reading
the file, false is returned.
|
[
"Reads",
"propFile",
"and",
"then",
"checks",
"if",
"specified",
"key",
"exists",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyLookup.java#L333-L354
|
15,845
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java
|
PropertyUtil.expand
|
public static Properties expand(final Map properties) {
final Properties expandedProperties = new Properties();
for (final Object o : properties.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final String keyValue = (String) entry.getValue();
final String expandedKeyValue = expand(keyValue, properties);
expandedProperties.setProperty(key, expandedKeyValue);
}
return expandedProperties;
}
|
java
|
public static Properties expand(final Map properties) {
final Properties expandedProperties = new Properties();
for (final Object o : properties.entrySet()) {
final Map.Entry entry = (Map.Entry) o;
final String key = (String) entry.getKey();
final String keyValue = (String) entry.getValue();
final String expandedKeyValue = expand(keyValue, properties);
expandedProperties.setProperty(key, expandedKeyValue);
}
return expandedProperties;
}
|
[
"public",
"static",
"Properties",
"expand",
"(",
"final",
"Map",
"properties",
")",
"{",
"final",
"Properties",
"expandedProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"final",
"Object",
"o",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"Map",
".",
"Entry",
"entry",
"=",
"(",
"Map",
".",
"Entry",
")",
"o",
";",
"final",
"String",
"key",
"=",
"(",
"String",
")",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"String",
"keyValue",
"=",
"(",
"String",
")",
"entry",
".",
"getValue",
"(",
")",
";",
"final",
"String",
"expandedKeyValue",
"=",
"expand",
"(",
"keyValue",
",",
"properties",
")",
";",
"expandedProperties",
".",
"setProperty",
"(",
"key",
",",
"expandedKeyValue",
")",
";",
"}",
"return",
"expandedProperties",
";",
"}"
] |
expand a given Properties object and return a new one.
This will process each key to a given Properties object, get its value
and expand it. Each value may contain references to other keys within this
given Properties object, and if so, all keys and their expanded keyValues will be resolved
into a new Properties object that will be returned.
@return properties
@param properties input
|
[
"expand",
"a",
"given",
"Properties",
"object",
"and",
"return",
"a",
"new",
"one",
".",
"This",
"will",
"process",
"each",
"key",
"to",
"a",
"given",
"Properties",
"object",
"get",
"its",
"value",
"and",
"expand",
"it",
".",
"Each",
"value",
"may",
"contain",
"references",
"to",
"other",
"keys",
"within",
"this",
"given",
"Properties",
"object",
"and",
"if",
"so",
"all",
"keys",
"and",
"their",
"expanded",
"keyValues",
"will",
"be",
"resolved",
"into",
"a",
"new",
"Properties",
"object",
"that",
"will",
"be",
"returned",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java#L42-L53
|
15,846
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java
|
PropertyUtil.expand
|
public static String expand(String keyString, Properties properties) {
return PropertyUtil.expand(keyString, (Map) properties);
}
|
java
|
public static String expand(String keyString, Properties properties) {
return PropertyUtil.expand(keyString, (Map) properties);
}
|
[
"public",
"static",
"String",
"expand",
"(",
"String",
"keyString",
",",
"Properties",
"properties",
")",
"{",
"return",
"PropertyUtil",
".",
"expand",
"(",
"keyString",
",",
"(",
"Map",
")",
"properties",
")",
";",
"}"
] |
expand a keyString that may contain references to properties
located in provided Properties object
@return expanded
@param keyString string
@param properties properties
|
[
"expand",
"a",
"keyString",
"that",
"may",
"contain",
"references",
"to",
"properties",
"located",
"in",
"provided",
"Properties",
"object"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java#L62-L64
|
15,847
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java
|
PropertyUtil.expand
|
public static String expand(String keyString, Project project) {
return expand(keyString, project.getProperties());
}
|
java
|
public static String expand(String keyString, Project project) {
return expand(keyString, project.getProperties());
}
|
[
"public",
"static",
"String",
"expand",
"(",
"String",
"keyString",
",",
"Project",
"project",
")",
"{",
"return",
"expand",
"(",
"keyString",
",",
"project",
".",
"getProperties",
"(",
")",
")",
";",
"}"
] |
expand a keyString that may contain referecnes to other properties
@param keyString string containing props
@param project Ant project
@return expanded string
|
[
"expand",
"a",
"keyString",
"that",
"may",
"contain",
"referecnes",
"to",
"other",
"properties"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/PropertyUtil.java#L89-L91
|
15,848
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/NodeEntryFactory.java
|
NodeEntryFactory.createFromMap
|
@SuppressWarnings ("unchecked")
public static NodeEntryImpl createFromMap(final Map<String, Object> map) throws IllegalArgumentException {
final NodeEntryImpl nodeEntry = new NodeEntryImpl();
final HashMap<String, Object> newmap = new HashMap<String, Object>(map);
for (final String excludeProp : excludeProps) {
newmap.remove(excludeProp);
}
if (null != newmap.get("tags") && newmap.get("tags") instanceof String) {
String tags = (String) newmap.get("tags");
String[] data;
if ("".equals(tags.trim())) {
data = new String[0];
} else {
data = tags.split(",");
}
final HashSet set = new HashSet();
for (final String s : data) {
if (null != s && !"".equals(s.trim())) {
set.add(s.trim());
}
}
newmap.put("tags", set);
} else if (null != newmap.get("tags") && newmap.get("tags") instanceof Collection) {
Collection tags = (Collection) newmap.get("tags");
HashSet data = new HashSet();
for (final Object tag : tags) {
if(null!=tag && !"".equals(tag.toString().trim())){
data.add(tag.toString().trim());
}
}
newmap.put("tags", data);
}else if (null != newmap.get("tags")) {
Object o = newmap.get("tags");
newmap.put("tags", new HashSet(Arrays.asList(o.toString().trim())));
}
try {
BeanUtils.populate(nodeEntry, newmap);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
if (null == nodeEntry.getNodename()) {
throw new IllegalArgumentException("Required property 'nodename' was not specified");
}
if (null == nodeEntry.getAttributes()) {
nodeEntry.setAttributes(new HashMap<String, String>());
}
//populate attributes with any keys outside of nodeprops
for (final Map.Entry<String, Object> entry : newmap.entrySet()) {
if (!ResourceXMLConstants.allPropSet.contains(entry.getKey())) {
Object value = entry.getValue();
if (null != value) {
nodeEntry.setAttribute(entry.getKey(), value.toString());
}
}
}
return nodeEntry;
}
|
java
|
@SuppressWarnings ("unchecked")
public static NodeEntryImpl createFromMap(final Map<String, Object> map) throws IllegalArgumentException {
final NodeEntryImpl nodeEntry = new NodeEntryImpl();
final HashMap<String, Object> newmap = new HashMap<String, Object>(map);
for (final String excludeProp : excludeProps) {
newmap.remove(excludeProp);
}
if (null != newmap.get("tags") && newmap.get("tags") instanceof String) {
String tags = (String) newmap.get("tags");
String[] data;
if ("".equals(tags.trim())) {
data = new String[0];
} else {
data = tags.split(",");
}
final HashSet set = new HashSet();
for (final String s : data) {
if (null != s && !"".equals(s.trim())) {
set.add(s.trim());
}
}
newmap.put("tags", set);
} else if (null != newmap.get("tags") && newmap.get("tags") instanceof Collection) {
Collection tags = (Collection) newmap.get("tags");
HashSet data = new HashSet();
for (final Object tag : tags) {
if(null!=tag && !"".equals(tag.toString().trim())){
data.add(tag.toString().trim());
}
}
newmap.put("tags", data);
}else if (null != newmap.get("tags")) {
Object o = newmap.get("tags");
newmap.put("tags", new HashSet(Arrays.asList(o.toString().trim())));
}
try {
BeanUtils.populate(nodeEntry, newmap);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
if (null == nodeEntry.getNodename()) {
throw new IllegalArgumentException("Required property 'nodename' was not specified");
}
if (null == nodeEntry.getAttributes()) {
nodeEntry.setAttributes(new HashMap<String, String>());
}
//populate attributes with any keys outside of nodeprops
for (final Map.Entry<String, Object> entry : newmap.entrySet()) {
if (!ResourceXMLConstants.allPropSet.contains(entry.getKey())) {
Object value = entry.getValue();
if (null != value) {
nodeEntry.setAttribute(entry.getKey(), value.toString());
}
}
}
return nodeEntry;
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"NodeEntryImpl",
"createFromMap",
"(",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
")",
"throws",
"IllegalArgumentException",
"{",
"final",
"NodeEntryImpl",
"nodeEntry",
"=",
"new",
"NodeEntryImpl",
"(",
")",
";",
"final",
"HashMap",
"<",
"String",
",",
"Object",
">",
"newmap",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"map",
")",
";",
"for",
"(",
"final",
"String",
"excludeProp",
":",
"excludeProps",
")",
"{",
"newmap",
".",
"remove",
"(",
"excludeProp",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
"&&",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
"instanceof",
"String",
")",
"{",
"String",
"tags",
"=",
"(",
"String",
")",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
";",
"String",
"[",
"]",
"data",
";",
"if",
"(",
"\"\"",
".",
"equals",
"(",
"tags",
".",
"trim",
"(",
")",
")",
")",
"{",
"data",
"=",
"new",
"String",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"data",
"=",
"tags",
".",
"split",
"(",
"\",\"",
")",
";",
"}",
"final",
"HashSet",
"set",
"=",
"new",
"HashSet",
"(",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"data",
")",
"{",
"if",
"(",
"null",
"!=",
"s",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"s",
".",
"trim",
"(",
")",
")",
")",
"{",
"set",
".",
"add",
"(",
"s",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"newmap",
".",
"put",
"(",
"\"tags\"",
",",
"set",
")",
";",
"}",
"else",
"if",
"(",
"null",
"!=",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
"&&",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
"instanceof",
"Collection",
")",
"{",
"Collection",
"tags",
"=",
"(",
"Collection",
")",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
";",
"HashSet",
"data",
"=",
"new",
"HashSet",
"(",
")",
";",
"for",
"(",
"final",
"Object",
"tag",
":",
"tags",
")",
"{",
"if",
"(",
"null",
"!=",
"tag",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"tag",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
")",
")",
"{",
"data",
".",
"add",
"(",
"tag",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"newmap",
".",
"put",
"(",
"\"tags\"",
",",
"data",
")",
";",
"}",
"else",
"if",
"(",
"null",
"!=",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
")",
"{",
"Object",
"o",
"=",
"newmap",
".",
"get",
"(",
"\"tags\"",
")",
";",
"newmap",
".",
"put",
"(",
"\"tags\"",
",",
"new",
"HashSet",
"(",
"Arrays",
".",
"asList",
"(",
"o",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
")",
")",
")",
";",
"}",
"try",
"{",
"BeanUtils",
".",
"populate",
"(",
"nodeEntry",
",",
"newmap",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"if",
"(",
"null",
"==",
"nodeEntry",
".",
"getNodename",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Required property 'nodename' was not specified\"",
")",
";",
"}",
"if",
"(",
"null",
"==",
"nodeEntry",
".",
"getAttributes",
"(",
")",
")",
"{",
"nodeEntry",
".",
"setAttributes",
"(",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}",
"//populate attributes with any keys outside of nodeprops",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"Object",
">",
"entry",
":",
"newmap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"!",
"ResourceXMLConstants",
".",
"allPropSet",
".",
"contains",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
")",
"{",
"Object",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"nodeEntry",
".",
"setAttribute",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"nodeEntry",
";",
"}"
] |
Create NodeEntryImpl from map data. It will convert "tags" of type String as a comma separated list of tags, or
"tags" a collection of strings into a set. It will remove properties excluded from allowed import.
@param map input map data
@return new entry
@throws IllegalArgumentException if name is not set
|
[
"Create",
"NodeEntryImpl",
"from",
"map",
"data",
".",
"It",
"will",
"convert",
"tags",
"of",
"type",
"String",
"as",
"a",
"comma",
"separated",
"list",
"of",
"tags",
"or",
"tags",
"a",
"collection",
"of",
"strings",
"into",
"a",
"set",
".",
"It",
"will",
"remove",
"properties",
"excluded",
"from",
"allowed",
"import",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/NodeEntryFactory.java#L59-L117
|
15,849
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.setCharset
|
public Charset setCharset(Charset charset) {
Charset prev = this.charset.get();
this.charset.set(charset);
return prev;
}
|
java
|
public Charset setCharset(Charset charset) {
Charset prev = this.charset.get();
this.charset.set(charset);
return prev;
}
|
[
"public",
"Charset",
"setCharset",
"(",
"Charset",
"charset",
")",
"{",
"Charset",
"prev",
"=",
"this",
".",
"charset",
".",
"get",
"(",
")",
";",
"this",
".",
"charset",
".",
"set",
"(",
"charset",
")",
";",
"return",
"prev",
";",
"}"
] |
Set the charset to use
@param charset new charset
@return previous charset
|
[
"Set",
"the",
"charset",
"to",
"use"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L77-L81
|
15,850
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.installManager
|
public LogBufferManager<D,T> installManager() {
LogBufferManager<D,T> manager = factory.apply(charset.get());
this.manager.set(manager);
return manager;
}
|
java
|
public LogBufferManager<D,T> installManager() {
LogBufferManager<D,T> manager = factory.apply(charset.get());
this.manager.set(manager);
return manager;
}
|
[
"public",
"LogBufferManager",
"<",
"D",
",",
"T",
">",
"installManager",
"(",
")",
"{",
"LogBufferManager",
"<",
"D",
",",
"T",
">",
"manager",
"=",
"factory",
".",
"apply",
"(",
"charset",
".",
"get",
"(",
")",
")",
";",
"this",
".",
"manager",
".",
"set",
"(",
"manager",
")",
";",
"return",
"manager",
";",
"}"
] |
Install a new inherited thread local buffer manager and return it
@return manager
|
[
"Install",
"a",
"new",
"inherited",
"thread",
"local",
"buffer",
"manager",
"and",
"return",
"it"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L87-L91
|
15,851
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.getOrCreateManager
|
private LogBufferManager<D,T> getOrCreateManager() {
if (null == manager.get()) {
installManager();
}
return manager.get();
}
|
java
|
private LogBufferManager<D,T> getOrCreateManager() {
if (null == manager.get()) {
installManager();
}
return manager.get();
}
|
[
"private",
"LogBufferManager",
"<",
"D",
",",
"T",
">",
"getOrCreateManager",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"manager",
".",
"get",
"(",
")",
")",
"{",
"installManager",
"(",
")",
";",
"}",
"return",
"manager",
".",
"get",
"(",
")",
";",
"}"
] |
If no manager is set, install one, otherwise return the existing one
@return
|
[
"If",
"no",
"manager",
"is",
"set",
"install",
"one",
"otherwise",
"return",
"the",
"existing",
"one"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L97-L102
|
15,852
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.getOrReset
|
private Holder<T> getOrReset() {
if (buffer.get() == null || buffer.get().getBuffer().isEmpty()) {
resetEventBuffer();
}
return buffer.get();
}
|
java
|
private Holder<T> getOrReset() {
if (buffer.get() == null || buffer.get().getBuffer().isEmpty()) {
resetEventBuffer();
}
return buffer.get();
}
|
[
"private",
"Holder",
"<",
"T",
">",
"getOrReset",
"(",
")",
"{",
"if",
"(",
"buffer",
".",
"get",
"(",
")",
"==",
"null",
"||",
"buffer",
".",
"get",
"(",
")",
".",
"getBuffer",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"resetEventBuffer",
"(",
")",
";",
"}",
"return",
"buffer",
".",
"get",
"(",
")",
";",
"}"
] |
get the thread's event buffer, reset it if it is empty
@return
|
[
"get",
"the",
"thread",
"s",
"event",
"buffer",
"reset",
"it",
"if",
"it",
"is",
"empty"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L128-L133
|
15,853
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.resetEventBuffer
|
private void resetEventBuffer() {
if (buffer.get() == null) {
buffer.set(new Holder<>(getOrCreateManager().create(charset.get())));
} else {
buffer.get().reset();
}
}
|
java
|
private void resetEventBuffer() {
if (buffer.get() == null) {
buffer.set(new Holder<>(getOrCreateManager().create(charset.get())));
} else {
buffer.get().reset();
}
}
|
[
"private",
"void",
"resetEventBuffer",
"(",
")",
"{",
"if",
"(",
"buffer",
".",
"get",
"(",
")",
"==",
"null",
")",
"{",
"buffer",
".",
"set",
"(",
"new",
"Holder",
"<>",
"(",
"getOrCreateManager",
"(",
")",
".",
"create",
"(",
"charset",
".",
"get",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"get",
"(",
")",
".",
"reset",
"(",
")",
";",
"}",
"}"
] |
reset existing or create a new buffer with the current context
|
[
"reset",
"existing",
"or",
"create",
"a",
"new",
"buffer",
"with",
"the",
"current",
"context"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L138-L144
|
15,854
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java
|
ThreadBoundLogOutputStream.flushEventBuffer
|
private void flushEventBuffer() {
Holder<T> holder = buffer.get();
logger.accept(holder.getBuffer().get());
holder.clear();
}
|
java
|
private void flushEventBuffer() {
Holder<T> holder = buffer.get();
logger.accept(holder.getBuffer().get());
holder.clear();
}
|
[
"private",
"void",
"flushEventBuffer",
"(",
")",
"{",
"Holder",
"<",
"T",
">",
"holder",
"=",
"buffer",
".",
"get",
"(",
")",
";",
"logger",
".",
"accept",
"(",
"holder",
".",
"getBuffer",
"(",
")",
".",
"get",
"(",
")",
")",
";",
"holder",
".",
"clear",
"(",
")",
";",
"}"
] |
emit a log event for the current contents of the buffer
|
[
"emit",
"a",
"log",
"event",
"for",
"the",
"current",
"contents",
"of",
"the",
"buffer"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/ThreadBoundLogOutputStream.java#L149-L153
|
15,855
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/logging/OverridableStreamingLogWriter.java
|
OverridableStreamingLogWriter.removeOverride
|
public StreamingLogWriter removeOverride() {
StreamingLogWriter previous = override.get().pop().orElse(null);
return previous;
}
|
java
|
public StreamingLogWriter removeOverride() {
StreamingLogWriter previous = override.get().pop().orElse(null);
return previous;
}
|
[
"public",
"StreamingLogWriter",
"removeOverride",
"(",
")",
"{",
"StreamingLogWriter",
"previous",
"=",
"override",
".",
"get",
"(",
")",
".",
"pop",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"return",
"previous",
";",
"}"
] |
Remove the overriding writer, if any
@return overriding writer, or null
|
[
"Remove",
"the",
"overriding",
"writer",
"if",
"any"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/logging/OverridableStreamingLogWriter.java#L106-L109
|
15,856
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/state/StateUtils.java
|
StateUtils.parameterString
|
public static String parameterString(StepContextId contextId) {
return null != contextId.getParams() ? "@" + parameterString(contextId.getParams()) : "";
}
|
java
|
public static String parameterString(StepContextId contextId) {
return null != contextId.getParams() ? "@" + parameterString(contextId.getParams()) : "";
}
|
[
"public",
"static",
"String",
"parameterString",
"(",
"StepContextId",
"contextId",
")",
"{",
"return",
"null",
"!=",
"contextId",
".",
"getParams",
"(",
")",
"?",
"\"@\"",
"+",
"parameterString",
"(",
"contextId",
".",
"getParams",
"(",
")",
")",
":",
"\"\"",
";",
"}"
] |
Generate string for a context id's parameter section, if present
@param contextId context id
@return parameter string, or blank string
|
[
"Generate",
"string",
"for",
"a",
"context",
"id",
"s",
"parameter",
"section",
"if",
"present"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/state/StateUtils.java#L139-L141
|
15,857
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/state/StateUtils.java
|
StateUtils.setupNodeStates
|
private static void setupNodeStates(WorkflowState current, WorkflowStateImpl parent, StepIdentifier ident) {
//create a new mutable map
HashMap<String, WorkflowNodeState> nodeStates = new HashMap<>();
if (null != parent.getNodeStates()) {
//include original states
nodeStates.putAll(parent.getNodeStates());
}
ArrayList<String> allNodes = new ArrayList<>();
if(null!=parent.getNodeSet()) {
allNodes.addAll(parent.getNodeSet());
}
parent.setNodeStates(nodeStates);
parent.setAllNodes(allNodes);
for (WorkflowStepState workflowStepState : current.getStepStates()) {
StepIdentifier thisident = stepIdentifierAppend(ident, workflowStepState.getStepIdentifier());
if (workflowStepState.isNodeStep()) {
//add node states for this step
for (String nodeName : current.getNodeSet()) {
//new mutable map to store step states for this node
HashMap<StepIdentifier, StepState> stepStatesForNode = new HashMap<>();
//get node state for this step
StepState state = workflowStepState.getNodeStateMap().get(nodeName);
stepStatesForNode.put(thisident, state);
//if already exists an entry for this node in the workflow's node states, import the states
WorkflowNodeState orig = nodeStates.get(nodeName);
if (null != orig && null != orig.getStepStateMap()) {
stepStatesForNode.putAll(orig.getStepStateMap());
}
if (!allNodes.contains(nodeName)) {
allNodes.add(nodeName);
}
//create new workflowNodeState for this node
WorkflowNodeState workflowNodeState = workflowNodeState(nodeName, state, thisident,
stepStatesForNode);
nodeStates.put(nodeName, workflowNodeState);
}
} else if (workflowStepState.hasSubWorkflow()) {
//descend
setupNodeStates(workflowStepState.getSubWorkflowState(), parent, thisident);
}
}
}
|
java
|
private static void setupNodeStates(WorkflowState current, WorkflowStateImpl parent, StepIdentifier ident) {
//create a new mutable map
HashMap<String, WorkflowNodeState> nodeStates = new HashMap<>();
if (null != parent.getNodeStates()) {
//include original states
nodeStates.putAll(parent.getNodeStates());
}
ArrayList<String> allNodes = new ArrayList<>();
if(null!=parent.getNodeSet()) {
allNodes.addAll(parent.getNodeSet());
}
parent.setNodeStates(nodeStates);
parent.setAllNodes(allNodes);
for (WorkflowStepState workflowStepState : current.getStepStates()) {
StepIdentifier thisident = stepIdentifierAppend(ident, workflowStepState.getStepIdentifier());
if (workflowStepState.isNodeStep()) {
//add node states for this step
for (String nodeName : current.getNodeSet()) {
//new mutable map to store step states for this node
HashMap<StepIdentifier, StepState> stepStatesForNode = new HashMap<>();
//get node state for this step
StepState state = workflowStepState.getNodeStateMap().get(nodeName);
stepStatesForNode.put(thisident, state);
//if already exists an entry for this node in the workflow's node states, import the states
WorkflowNodeState orig = nodeStates.get(nodeName);
if (null != orig && null != orig.getStepStateMap()) {
stepStatesForNode.putAll(orig.getStepStateMap());
}
if (!allNodes.contains(nodeName)) {
allNodes.add(nodeName);
}
//create new workflowNodeState for this node
WorkflowNodeState workflowNodeState = workflowNodeState(nodeName, state, thisident,
stepStatesForNode);
nodeStates.put(nodeName, workflowNodeState);
}
} else if (workflowStepState.hasSubWorkflow()) {
//descend
setupNodeStates(workflowStepState.getSubWorkflowState(), parent, thisident);
}
}
}
|
[
"private",
"static",
"void",
"setupNodeStates",
"(",
"WorkflowState",
"current",
",",
"WorkflowStateImpl",
"parent",
",",
"StepIdentifier",
"ident",
")",
"{",
"//create a new mutable map",
"HashMap",
"<",
"String",
",",
"WorkflowNodeState",
">",
"nodeStates",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"parent",
".",
"getNodeStates",
"(",
")",
")",
"{",
"//include original states",
"nodeStates",
".",
"putAll",
"(",
"parent",
".",
"getNodeStates",
"(",
")",
")",
";",
"}",
"ArrayList",
"<",
"String",
">",
"allNodes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"parent",
".",
"getNodeSet",
"(",
")",
")",
"{",
"allNodes",
".",
"addAll",
"(",
"parent",
".",
"getNodeSet",
"(",
")",
")",
";",
"}",
"parent",
".",
"setNodeStates",
"(",
"nodeStates",
")",
";",
"parent",
".",
"setAllNodes",
"(",
"allNodes",
")",
";",
"for",
"(",
"WorkflowStepState",
"workflowStepState",
":",
"current",
".",
"getStepStates",
"(",
")",
")",
"{",
"StepIdentifier",
"thisident",
"=",
"stepIdentifierAppend",
"(",
"ident",
",",
"workflowStepState",
".",
"getStepIdentifier",
"(",
")",
")",
";",
"if",
"(",
"workflowStepState",
".",
"isNodeStep",
"(",
")",
")",
"{",
"//add node states for this step",
"for",
"(",
"String",
"nodeName",
":",
"current",
".",
"getNodeSet",
"(",
")",
")",
"{",
"//new mutable map to store step states for this node",
"HashMap",
"<",
"StepIdentifier",
",",
"StepState",
">",
"stepStatesForNode",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"//get node state for this step",
"StepState",
"state",
"=",
"workflowStepState",
".",
"getNodeStateMap",
"(",
")",
".",
"get",
"(",
"nodeName",
")",
";",
"stepStatesForNode",
".",
"put",
"(",
"thisident",
",",
"state",
")",
";",
"//if already exists an entry for this node in the workflow's node states, import the states",
"WorkflowNodeState",
"orig",
"=",
"nodeStates",
".",
"get",
"(",
"nodeName",
")",
";",
"if",
"(",
"null",
"!=",
"orig",
"&&",
"null",
"!=",
"orig",
".",
"getStepStateMap",
"(",
")",
")",
"{",
"stepStatesForNode",
".",
"putAll",
"(",
"orig",
".",
"getStepStateMap",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"allNodes",
".",
"contains",
"(",
"nodeName",
")",
")",
"{",
"allNodes",
".",
"add",
"(",
"nodeName",
")",
";",
"}",
"//create new workflowNodeState for this node",
"WorkflowNodeState",
"workflowNodeState",
"=",
"workflowNodeState",
"(",
"nodeName",
",",
"state",
",",
"thisident",
",",
"stepStatesForNode",
")",
";",
"nodeStates",
".",
"put",
"(",
"nodeName",
",",
"workflowNodeState",
")",
";",
"}",
"}",
"else",
"if",
"(",
"workflowStepState",
".",
"hasSubWorkflow",
"(",
")",
")",
"{",
"//descend",
"setupNodeStates",
"(",
"workflowStepState",
".",
"getSubWorkflowState",
"(",
")",
",",
"parent",
",",
"thisident",
")",
";",
"}",
"}",
"}"
] |
Configure the nodeStates map for the workflow, by visiting each step in the workflow, and connecting the
step+node state for nodeSteps to the nodeStates map
@param current workflow to visit
@param parent root workflow impl
@param ident parent workflow ident or null
|
[
"Configure",
"the",
"nodeStates",
"map",
"for",
"the",
"workflow",
"by",
"visiting",
"each",
"step",
"in",
"the",
"workflow",
"and",
"connecting",
"the",
"step",
"+",
"node",
"state",
"for",
"nodeSteps",
"to",
"the",
"nodeStates",
"map"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/state/StateUtils.java#L414-L459
|
15,858
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/NodeEntryImpl.java
|
NodeEntryImpl.setAttribute
|
public String setAttribute(final String name, final String value) {
if(null!=value){
return getAttributes().put(name, value);
}else{
getAttributes().remove(name);
return value;
}
}
|
java
|
public String setAttribute(final String name, final String value) {
if(null!=value){
return getAttributes().put(name, value);
}else{
getAttributes().remove(name);
return value;
}
}
|
[
"public",
"String",
"setAttribute",
"(",
"final",
"String",
"name",
",",
"final",
"String",
"value",
")",
"{",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"return",
"getAttributes",
"(",
")",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"}",
"else",
"{",
"getAttributes",
"(",
")",
".",
"remove",
"(",
"name",
")",
";",
"return",
"value",
";",
"}",
"}"
] |
Set the value for a specific attribute
@param name attribute name
@param value attribute value
@return value
|
[
"Set",
"the",
"value",
"for",
"a",
"specific",
"attribute"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/NodeEntryImpl.java#L411-L418
|
15,859
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/launcher/Setup.java
|
Setup.getTemplateFile
|
private File getTemplateFile(String filename) throws IOException {
File templateFile=null;
final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename;
InputStream is = Setup.class.getClassLoader().getResourceAsStream(resource);
if (null == is) {
throw new RuntimeException("Unable to load required template: " + resource);
}
templateFile = File.createTempFile("temp", filename);
templateFile.deleteOnExit();
try {
return copyToNativeLineEndings(is, templateFile);
} finally {
is.close();
}
}
|
java
|
private File getTemplateFile(String filename) throws IOException {
File templateFile=null;
final String resource = TEMPLATE_RESOURCES_PATH + "/" + filename;
InputStream is = Setup.class.getClassLoader().getResourceAsStream(resource);
if (null == is) {
throw new RuntimeException("Unable to load required template: " + resource);
}
templateFile = File.createTempFile("temp", filename);
templateFile.deleteOnExit();
try {
return copyToNativeLineEndings(is, templateFile);
} finally {
is.close();
}
}
|
[
"private",
"File",
"getTemplateFile",
"(",
"String",
"filename",
")",
"throws",
"IOException",
"{",
"File",
"templateFile",
"=",
"null",
";",
"final",
"String",
"resource",
"=",
"TEMPLATE_RESOURCES_PATH",
"+",
"\"/\"",
"+",
"filename",
";",
"InputStream",
"is",
"=",
"Setup",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"resource",
")",
";",
"if",
"(",
"null",
"==",
"is",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unable to load required template: \"",
"+",
"resource",
")",
";",
"}",
"templateFile",
"=",
"File",
".",
"createTempFile",
"(",
"\"temp\"",
",",
"filename",
")",
";",
"templateFile",
".",
"deleteOnExit",
"(",
")",
";",
"try",
"{",
"return",
"copyToNativeLineEndings",
"(",
"is",
",",
"templateFile",
")",
";",
"}",
"finally",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Look for template in the jar resources, otherwise look for it on filepath
@param filename template name
@return file
@throws java.io.IOException on io error
|
[
"Look",
"for",
"template",
"in",
"the",
"jar",
"resources",
"otherwise",
"look",
"for",
"it",
"on",
"filepath"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/launcher/Setup.java#L215-L229
|
15,860
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/launcher/Setup.java
|
Setup.validateInstall
|
private void validateInstall() throws SetupException {
// check if rdeck.base is defined.
if (null == parameters.getBaseDir() || parameters.getBaseDir().equals("")) {
throw new SetupException("rdeck.base property not defined or is the empty string");
}
if (!checkIfDir("rdeck.base", parameters.getBaseDir())) {
throw new SetupException(parameters.getBaseDir() + " is not a valid rdeck install");
}
}
|
java
|
private void validateInstall() throws SetupException {
// check if rdeck.base is defined.
if (null == parameters.getBaseDir() || parameters.getBaseDir().equals("")) {
throw new SetupException("rdeck.base property not defined or is the empty string");
}
if (!checkIfDir("rdeck.base", parameters.getBaseDir())) {
throw new SetupException(parameters.getBaseDir() + " is not a valid rdeck install");
}
}
|
[
"private",
"void",
"validateInstall",
"(",
")",
"throws",
"SetupException",
"{",
"// check if rdeck.base is defined.",
"if",
"(",
"null",
"==",
"parameters",
".",
"getBaseDir",
"(",
")",
"||",
"parameters",
".",
"getBaseDir",
"(",
")",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"\"rdeck.base property not defined or is the empty string\"",
")",
";",
"}",
"if",
"(",
"!",
"checkIfDir",
"(",
"\"rdeck.base\"",
",",
"parameters",
".",
"getBaseDir",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"parameters",
".",
"getBaseDir",
"(",
")",
"+",
"\" is not a valid rdeck install\"",
")",
";",
"}",
"}"
] |
Checks the basic install assumptions
|
[
"Checks",
"the",
"basic",
"install",
"assumptions"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/launcher/Setup.java#L253-L261
|
15,861
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/launcher/Setup.java
|
Setup.checkIfDir
|
private boolean checkIfDir(final String propName, final String path) {
if (null == path || path.equals("")) {
throw new IllegalArgumentException(propName + "property had null or empty value");
}
return new File(path).exists();
}
|
java
|
private boolean checkIfDir(final String propName, final String path) {
if (null == path || path.equals("")) {
throw new IllegalArgumentException(propName + "property had null or empty value");
}
return new File(path).exists();
}
|
[
"private",
"boolean",
"checkIfDir",
"(",
"final",
"String",
"propName",
",",
"final",
"String",
"path",
")",
"{",
"if",
"(",
"null",
"==",
"path",
"||",
"path",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"propName",
"+",
"\"property had null or empty value\"",
")",
";",
"}",
"return",
"new",
"File",
"(",
"path",
")",
".",
"exists",
"(",
")",
";",
"}"
] |
check if path exists as a directory
|
[
"check",
"if",
"path",
"exists",
"as",
"a",
"directory"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/launcher/Setup.java#L264-L269
|
15,862
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/launcher/Setup.java
|
Setup.generatePreferences
|
private void generatePreferences(final String args[], Properties input) throws SetupException {
File frameworkPreferences = new File(Constants.getFrameworkPreferences(parameters.getBaseDir()));
try {
Preferences.generate(args, frameworkPreferences.getAbsolutePath(), input);
} catch (Exception e) {
throw new SetupException("failed generating setup preferences: " + e.getMessage(), e);
}
// check the preferences.properties file
if (!frameworkPreferences.exists()) {
throw new SetupException("Unable to generate preferences file: " + frameworkPreferences);
}
if (!frameworkPreferences.isFile()) {
throw new SetupException(frameworkPreferences + " preferences file is not a regular file");
}
}
|
java
|
private void generatePreferences(final String args[], Properties input) throws SetupException {
File frameworkPreferences = new File(Constants.getFrameworkPreferences(parameters.getBaseDir()));
try {
Preferences.generate(args, frameworkPreferences.getAbsolutePath(), input);
} catch (Exception e) {
throw new SetupException("failed generating setup preferences: " + e.getMessage(), e);
}
// check the preferences.properties file
if (!frameworkPreferences.exists()) {
throw new SetupException("Unable to generate preferences file: " + frameworkPreferences);
}
if (!frameworkPreferences.isFile()) {
throw new SetupException(frameworkPreferences + " preferences file is not a regular file");
}
}
|
[
"private",
"void",
"generatePreferences",
"(",
"final",
"String",
"args",
"[",
"]",
",",
"Properties",
"input",
")",
"throws",
"SetupException",
"{",
"File",
"frameworkPreferences",
"=",
"new",
"File",
"(",
"Constants",
".",
"getFrameworkPreferences",
"(",
"parameters",
".",
"getBaseDir",
"(",
")",
")",
")",
";",
"try",
"{",
"Preferences",
".",
"generate",
"(",
"args",
",",
"frameworkPreferences",
".",
"getAbsolutePath",
"(",
")",
",",
"input",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"\"failed generating setup preferences: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"// check the preferences.properties file",
"if",
"(",
"!",
"frameworkPreferences",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"\"Unable to generate preferences file: \"",
"+",
"frameworkPreferences",
")",
";",
"}",
"if",
"(",
"!",
"frameworkPreferences",
".",
"isFile",
"(",
")",
")",
"{",
"throw",
"new",
"SetupException",
"(",
"frameworkPreferences",
"+",
"\" preferences file is not a regular file\"",
")",
";",
"}",
"}"
] |
generate the preferences.properties file
|
[
"generate",
"the",
"preferences",
".",
"properties",
"file"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/launcher/Setup.java#L273-L288
|
15,863
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/BaseRuleEngine.java
|
BaseRuleEngine.evaluateRules
|
@Override
public StateObj evaluateRules(final StateObj state) {
MutableStateObj dataState = States.mutable();
getRuleSet().stream()
//filter rules that apply given the state
.filter(i -> i.test(state))
//evaluate the applicable rules
.map(input -> Optional.ofNullable(input.evaluate(state)))
//exclude empty results
.flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
//update the state with each result
.forEach(dataState::updateState);
return dataState;
}
|
java
|
@Override
public StateObj evaluateRules(final StateObj state) {
MutableStateObj dataState = States.mutable();
getRuleSet().stream()
//filter rules that apply given the state
.filter(i -> i.test(state))
//evaluate the applicable rules
.map(input -> Optional.ofNullable(input.evaluate(state)))
//exclude empty results
.flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
//update the state with each result
.forEach(dataState::updateState);
return dataState;
}
|
[
"@",
"Override",
"public",
"StateObj",
"evaluateRules",
"(",
"final",
"StateObj",
"state",
")",
"{",
"MutableStateObj",
"dataState",
"=",
"States",
".",
"mutable",
"(",
")",
";",
"getRuleSet",
"(",
")",
".",
"stream",
"(",
")",
"//filter rules that apply given the state",
".",
"filter",
"(",
"i",
"->",
"i",
".",
"test",
"(",
"state",
")",
")",
"//evaluate the applicable rules",
".",
"map",
"(",
"input",
"->",
"Optional",
".",
"ofNullable",
"(",
"input",
".",
"evaluate",
"(",
"state",
")",
")",
")",
"//exclude empty results",
".",
"flatMap",
"(",
"o",
"->",
"o",
".",
"map",
"(",
"Stream",
"::",
"of",
")",
".",
"orElseGet",
"(",
"Stream",
"::",
"empty",
")",
")",
"//update the state with each result",
".",
"forEach",
"(",
"dataState",
"::",
"updateState",
")",
";",
"return",
"dataState",
";",
"}"
] |
Evaluate each rule, if it applies, accrue the new state changes
@param state input state
@return accrued state changes from matching rules
|
[
"Evaluate",
"each",
"rule",
"if",
"it",
"applies",
"accrue",
"the",
"new",
"state",
"changes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/BaseRuleEngine.java#L36-L49
|
15,864
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/org/rundeck/jaas/pam/AbstractPamLoginModule.java
|
AbstractPamLoginModule.authenticate
|
protected boolean authenticate(String name, char[] password) throws LoginException {
try {
if ((name == null) || (password == null)) {
debug("user or pass is null");
return false;
}
debug("PAM authentication trying (" + serviceName + ") for: " + name);
UnixUser authenticate = new PAM(serviceName).authenticate(name, new String(password));
debug("PAM authentication succeeded for: " + name);
this.unixUser = authenticate;
return true;
} catch (PAMException e) {
debug(e.getMessage());
if (isDebug()) {
e.printStackTrace();
}
return false;
}
}
|
java
|
protected boolean authenticate(String name, char[] password) throws LoginException {
try {
if ((name == null) || (password == null)) {
debug("user or pass is null");
return false;
}
debug("PAM authentication trying (" + serviceName + ") for: " + name);
UnixUser authenticate = new PAM(serviceName).authenticate(name, new String(password));
debug("PAM authentication succeeded for: " + name);
this.unixUser = authenticate;
return true;
} catch (PAMException e) {
debug(e.getMessage());
if (isDebug()) {
e.printStackTrace();
}
return false;
}
}
|
[
"protected",
"boolean",
"authenticate",
"(",
"String",
"name",
",",
"char",
"[",
"]",
"password",
")",
"throws",
"LoginException",
"{",
"try",
"{",
"if",
"(",
"(",
"name",
"==",
"null",
")",
"||",
"(",
"password",
"==",
"null",
")",
")",
"{",
"debug",
"(",
"\"user or pass is null\"",
")",
";",
"return",
"false",
";",
"}",
"debug",
"(",
"\"PAM authentication trying (\"",
"+",
"serviceName",
"+",
"\") for: \"",
"+",
"name",
")",
";",
"UnixUser",
"authenticate",
"=",
"new",
"PAM",
"(",
"serviceName",
")",
".",
"authenticate",
"(",
"name",
",",
"new",
"String",
"(",
"password",
")",
")",
";",
"debug",
"(",
"\"PAM authentication succeeded for: \"",
"+",
"name",
")",
";",
"this",
".",
"unixUser",
"=",
"authenticate",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"PAMException",
"e",
")",
"{",
"debug",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"if",
"(",
"isDebug",
"(",
")",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"false",
";",
"}",
"}"
] |
Authenticates using PAM
@param name
@param password
@return
@throws LoginException
|
[
"Authenticates",
"using",
"PAM"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/org/rundeck/jaas/pam/AbstractPamLoginModule.java#L78-L97
|
15,865
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/org/rundeck/jaas/pam/AbstractPamLoginModule.java
|
AbstractPamLoginModule.createRolePrincipals
|
protected List<Principal> createRolePrincipals(UnixUser username) {
ArrayList<Principal> principals = new ArrayList<Principal>();
if (null != supplementalRoles) {
for (String supplementalRole : supplementalRoles) {
Principal rolePrincipal = createRolePrincipal(supplementalRole);
if (null != rolePrincipal) {
principals.add(rolePrincipal);
}
}
}
if (useUnixGroups) {
for (String s : username.getGroups()) {
Principal rolePrincipal = createRolePrincipal(s);
if (null != rolePrincipal) {
principals.add(rolePrincipal);
}
}
}
return principals;
}
|
java
|
protected List<Principal> createRolePrincipals(UnixUser username) {
ArrayList<Principal> principals = new ArrayList<Principal>();
if (null != supplementalRoles) {
for (String supplementalRole : supplementalRoles) {
Principal rolePrincipal = createRolePrincipal(supplementalRole);
if (null != rolePrincipal) {
principals.add(rolePrincipal);
}
}
}
if (useUnixGroups) {
for (String s : username.getGroups()) {
Principal rolePrincipal = createRolePrincipal(s);
if (null != rolePrincipal) {
principals.add(rolePrincipal);
}
}
}
return principals;
}
|
[
"protected",
"List",
"<",
"Principal",
">",
"createRolePrincipals",
"(",
"UnixUser",
"username",
")",
"{",
"ArrayList",
"<",
"Principal",
">",
"principals",
"=",
"new",
"ArrayList",
"<",
"Principal",
">",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"supplementalRoles",
")",
"{",
"for",
"(",
"String",
"supplementalRole",
":",
"supplementalRoles",
")",
"{",
"Principal",
"rolePrincipal",
"=",
"createRolePrincipal",
"(",
"supplementalRole",
")",
";",
"if",
"(",
"null",
"!=",
"rolePrincipal",
")",
"{",
"principals",
".",
"add",
"(",
"rolePrincipal",
")",
";",
"}",
"}",
"}",
"if",
"(",
"useUnixGroups",
")",
"{",
"for",
"(",
"String",
"s",
":",
"username",
".",
"getGroups",
"(",
")",
")",
"{",
"Principal",
"rolePrincipal",
"=",
"createRolePrincipal",
"(",
"s",
")",
";",
"if",
"(",
"null",
"!=",
"rolePrincipal",
")",
"{",
"principals",
".",
"add",
"(",
"rolePrincipal",
")",
";",
"}",
"}",
"}",
"return",
"principals",
";",
"}"
] |
Create Principals for any roles
@param username
@return
|
[
"Create",
"Principals",
"for",
"any",
"roles"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/org/rundeck/jaas/pam/AbstractPamLoginModule.java#L144-L163
|
15,866
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java
|
AuthRundeckStorageTree.authorizedPath
|
private boolean authorizedPath(AuthContext context, Path path, String action) {
Decision evaluate = context.evaluate(
resourceForPath(path),
action,
environmentForPath(path)
);
return evaluate.isAuthorized();
}
|
java
|
private boolean authorizedPath(AuthContext context, Path path, String action) {
Decision evaluate = context.evaluate(
resourceForPath(path),
action,
environmentForPath(path)
);
return evaluate.isAuthorized();
}
|
[
"private",
"boolean",
"authorizedPath",
"(",
"AuthContext",
"context",
",",
"Path",
"path",
",",
"String",
"action",
")",
"{",
"Decision",
"evaluate",
"=",
"context",
".",
"evaluate",
"(",
"resourceForPath",
"(",
"path",
")",
",",
"action",
",",
"environmentForPath",
"(",
"path",
")",
")",
";",
"return",
"evaluate",
".",
"isAuthorized",
"(",
")",
";",
"}"
] |
Evaluate access based on path
@param context auth context
@param path path
@param action action
@return true if authorized
|
[
"Evaluate",
"access",
"based",
"on",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java#L58-L65
|
15,867
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java
|
AuthRundeckStorageTree.resourceForPath
|
private Map<String, String> resourceForPath(Path path) {
return AuthorizationUtil.resource(STORAGE_PATH_AUTH_RES_TYPE, authResForPath(path));
}
|
java
|
private Map<String, String> resourceForPath(Path path) {
return AuthorizationUtil.resource(STORAGE_PATH_AUTH_RES_TYPE, authResForPath(path));
}
|
[
"private",
"Map",
"<",
"String",
",",
"String",
">",
"resourceForPath",
"(",
"Path",
"path",
")",
"{",
"return",
"AuthorizationUtil",
".",
"resource",
"(",
"STORAGE_PATH_AUTH_RES_TYPE",
",",
"authResForPath",
"(",
"path",
")",
")",
";",
"}"
] |
Return authorization resource map for a path
@param path path
@return map defining the authorization resource
|
[
"Return",
"authorization",
"resource",
"map",
"for",
"a",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java#L74-L76
|
15,868
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java
|
AuthRundeckStorageTree.authResForPath
|
private Map<String, String> authResForPath(Path path) {
HashMap<String, String> authResource = new HashMap<String, String>();
authResource.put(PATH_RES_KEY, path.getPath());
authResource.put(NAME_RES_KEY, path.getName());
return authResource;
}
|
java
|
private Map<String, String> authResForPath(Path path) {
HashMap<String, String> authResource = new HashMap<String, String>();
authResource.put(PATH_RES_KEY, path.getPath());
authResource.put(NAME_RES_KEY, path.getName());
return authResource;
}
|
[
"private",
"Map",
"<",
"String",
",",
"String",
">",
"authResForPath",
"(",
"Path",
"path",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"authResource",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"authResource",
".",
"put",
"(",
"PATH_RES_KEY",
",",
"path",
".",
"getPath",
"(",
")",
")",
";",
"authResource",
".",
"put",
"(",
"NAME_RES_KEY",
",",
"path",
".",
"getName",
"(",
")",
")",
";",
"return",
"authResource",
";",
"}"
] |
Map containing path and name given a path
@param path path
@return map
|
[
"Map",
"containing",
"path",
"and",
"name",
"given",
"a",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/storage/AuthRundeckStorageTree.java#L85-L90
|
15,869
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/cli/acl/AclTool.java
|
AclTool.go
|
protected void go() throws CLIToolOptionsException {
if (null == action) {
throw new CLIToolOptionsException("Command expected. Choose one of: " + Arrays.asList(Actions.values()));
}
try {
switch (action) {
case list:
listAction();
break;
case test:
testAction();
break;
case create:
createAction();
break;
case validate:
validateAction();
break;
default:
throw new CLIToolOptionsException("Unrecognized action: " + action);
}
} catch (IOException | PoliciesParseException e) {
throw new CLIToolOptionsException(e);
}
}
|
java
|
protected void go() throws CLIToolOptionsException {
if (null == action) {
throw new CLIToolOptionsException("Command expected. Choose one of: " + Arrays.asList(Actions.values()));
}
try {
switch (action) {
case list:
listAction();
break;
case test:
testAction();
break;
case create:
createAction();
break;
case validate:
validateAction();
break;
default:
throw new CLIToolOptionsException("Unrecognized action: " + action);
}
} catch (IOException | PoliciesParseException e) {
throw new CLIToolOptionsException(e);
}
}
|
[
"protected",
"void",
"go",
"(",
")",
"throws",
"CLIToolOptionsException",
"{",
"if",
"(",
"null",
"==",
"action",
")",
"{",
"throw",
"new",
"CLIToolOptionsException",
"(",
"\"Command expected. Choose one of: \"",
"+",
"Arrays",
".",
"asList",
"(",
"Actions",
".",
"values",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"switch",
"(",
"action",
")",
"{",
"case",
"list",
":",
"listAction",
"(",
")",
";",
"break",
";",
"case",
"test",
":",
"testAction",
"(",
")",
";",
"break",
";",
"case",
"create",
":",
"createAction",
"(",
")",
";",
"break",
";",
"case",
"validate",
":",
"validateAction",
"(",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"CLIToolOptionsException",
"(",
"\"Unrecognized action: \"",
"+",
"action",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"|",
"PoliciesParseException",
"e",
")",
"{",
"throw",
"new",
"CLIToolOptionsException",
"(",
"e",
")",
";",
"}",
"}"
] |
Call the action
@throws CLIToolOptionsException if an error occurs
|
[
"Call",
"the",
"action"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/cli/acl/AclTool.java#L578-L602
|
15,870
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/cli/acl/AclTool.java
|
AclTool.applyArgValidate
|
private boolean applyArgValidate() throws CLIToolOptionsException {
if(argValidate) {
Validation validation = validatePolicies();
if(argVerbose && !validation.isValid()) {
reportValidation(validation);
}
if(!validation.isValid()){
log("The validation " + (validation.isValid() ? "passed" : "failed"));
exit(2);
return true;
}
}
return false;
}
|
java
|
private boolean applyArgValidate() throws CLIToolOptionsException {
if(argValidate) {
Validation validation = validatePolicies();
if(argVerbose && !validation.isValid()) {
reportValidation(validation);
}
if(!validation.isValid()){
log("The validation " + (validation.isValid() ? "passed" : "failed"));
exit(2);
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"applyArgValidate",
"(",
")",
"throws",
"CLIToolOptionsException",
"{",
"if",
"(",
"argValidate",
")",
"{",
"Validation",
"validation",
"=",
"validatePolicies",
"(",
")",
";",
"if",
"(",
"argVerbose",
"&&",
"!",
"validation",
".",
"isValid",
"(",
")",
")",
"{",
"reportValidation",
"(",
"validation",
")",
";",
"}",
"if",
"(",
"!",
"validation",
".",
"isValid",
"(",
")",
")",
"{",
"log",
"(",
"\"The validation \"",
"+",
"(",
"validation",
".",
"isValid",
"(",
")",
"?",
"\"passed\"",
":",
"\"failed\"",
")",
")",
";",
"exit",
"(",
"2",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
If argValidate is specified, validate the input, exit 2 if invalid. Print validation report if argVerbose
@return true if validation check failed
@throws CLIToolOptionsException
|
[
"If",
"argValidate",
"is",
"specified",
"validate",
"the",
"input",
"exit",
"2",
"if",
"invalid",
".",
"Print",
"validation",
"report",
"if",
"argVerbose"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/cli/acl/AclTool.java#L765-L778
|
15,871
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/NodesXMLParser.java
|
NodesXMLParser.parse
|
public void parse() throws NodeFileParserException {
final ResourceXMLParser resourceXMLParser;
if(null!=file){
resourceXMLParser=new ResourceXMLParser(file);
}else{
resourceXMLParser = new ResourceXMLParser(input);
}
//parse both node and settings
resourceXMLParser.setReceiver(this);
// long start = System.currentTimeMillis();
try {
resourceXMLParser.parse();
} catch (ResourceXMLParserException e) {
throw new NodeFileParserException(e);
} catch (IOException e) {
throw new NodeFileParserException(e);
}
// System.err.println("parse: " + (System.currentTimeMillis() - start));
}
|
java
|
public void parse() throws NodeFileParserException {
final ResourceXMLParser resourceXMLParser;
if(null!=file){
resourceXMLParser=new ResourceXMLParser(file);
}else{
resourceXMLParser = new ResourceXMLParser(input);
}
//parse both node and settings
resourceXMLParser.setReceiver(this);
// long start = System.currentTimeMillis();
try {
resourceXMLParser.parse();
} catch (ResourceXMLParserException e) {
throw new NodeFileParserException(e);
} catch (IOException e) {
throw new NodeFileParserException(e);
}
// System.err.println("parse: " + (System.currentTimeMillis() - start));
}
|
[
"public",
"void",
"parse",
"(",
")",
"throws",
"NodeFileParserException",
"{",
"final",
"ResourceXMLParser",
"resourceXMLParser",
";",
"if",
"(",
"null",
"!=",
"file",
")",
"{",
"resourceXMLParser",
"=",
"new",
"ResourceXMLParser",
"(",
"file",
")",
";",
"}",
"else",
"{",
"resourceXMLParser",
"=",
"new",
"ResourceXMLParser",
"(",
"input",
")",
";",
"}",
"//parse both node and settings",
"resourceXMLParser",
".",
"setReceiver",
"(",
"this",
")",
";",
"// long start = System.currentTimeMillis();",
"try",
"{",
"resourceXMLParser",
".",
"parse",
"(",
")",
";",
"}",
"catch",
"(",
"ResourceXMLParserException",
"e",
")",
"{",
"throw",
"new",
"NodeFileParserException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"NodeFileParserException",
"(",
"e",
")",
";",
"}",
"// System.err.println(\"parse: \" + (System.currentTimeMillis() - start));",
"}"
] |
Parse the project.xml formatted file and fill in the nodes found
|
[
"Parse",
"the",
"project",
".",
"xml",
"formatted",
"file",
"and",
"fill",
"in",
"the",
"nodes",
"found"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/NodesXMLParser.java#L90-L108
|
15,872
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/common/NodesXMLParser.java
|
NodesXMLParser.fillNode
|
private void fillNode(final ResourceXMLParser.Entity entity, final NodeEntryImpl node) {
node.setUsername(entity.getProperty(NODE_USERNAME));
node.setHostname(entity.getProperty(NODE_HOSTNAME));
node.setOsArch(entity.getProperty(NODE_OS_ARCH));
node.setOsFamily(entity.getProperty(NODE_OS_FAMILY));
node.setOsName(entity.getProperty(NODE_OS_NAME));
node.setOsVersion(entity.getProperty(NODE_OS_VERSION));
node.setDescription(entity.getProperty(COMMON_DESCRIPTION));
final String tags = entity.getProperty(COMMON_TAGS);
final HashSet<String> tags1;
if (null != tags && !"".equals(tags)) {
tags1 = new HashSet<String>();
for (final String s : tags.split(",")) {
tags1.add(s.trim());
}
} else {
tags1 = new HashSet<String>();
}
node.setTags(tags1);
if (null == node.getAttributes()) {
node.setAttributes(new HashMap<String, String>());
}
if (null != entity.getProperties()) {
for (String key : entity.getProperties().stringPropertyNames()) {
if (!ResourceXMLConstants.allPropSet.contains(key)) {
node.getAttributes().put(key, entity.getProperty(key));
}
}
}
//parse embedded attribute elements
}
|
java
|
private void fillNode(final ResourceXMLParser.Entity entity, final NodeEntryImpl node) {
node.setUsername(entity.getProperty(NODE_USERNAME));
node.setHostname(entity.getProperty(NODE_HOSTNAME));
node.setOsArch(entity.getProperty(NODE_OS_ARCH));
node.setOsFamily(entity.getProperty(NODE_OS_FAMILY));
node.setOsName(entity.getProperty(NODE_OS_NAME));
node.setOsVersion(entity.getProperty(NODE_OS_VERSION));
node.setDescription(entity.getProperty(COMMON_DESCRIPTION));
final String tags = entity.getProperty(COMMON_TAGS);
final HashSet<String> tags1;
if (null != tags && !"".equals(tags)) {
tags1 = new HashSet<String>();
for (final String s : tags.split(",")) {
tags1.add(s.trim());
}
} else {
tags1 = new HashSet<String>();
}
node.setTags(tags1);
if (null == node.getAttributes()) {
node.setAttributes(new HashMap<String, String>());
}
if (null != entity.getProperties()) {
for (String key : entity.getProperties().stringPropertyNames()) {
if (!ResourceXMLConstants.allPropSet.contains(key)) {
node.getAttributes().put(key, entity.getProperty(key));
}
}
}
//parse embedded attribute elements
}
|
[
"private",
"void",
"fillNode",
"(",
"final",
"ResourceXMLParser",
".",
"Entity",
"entity",
",",
"final",
"NodeEntryImpl",
"node",
")",
"{",
"node",
".",
"setUsername",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_USERNAME",
")",
")",
";",
"node",
".",
"setHostname",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_HOSTNAME",
")",
")",
";",
"node",
".",
"setOsArch",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_OS_ARCH",
")",
")",
";",
"node",
".",
"setOsFamily",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_OS_FAMILY",
")",
")",
";",
"node",
".",
"setOsName",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_OS_NAME",
")",
")",
";",
"node",
".",
"setOsVersion",
"(",
"entity",
".",
"getProperty",
"(",
"NODE_OS_VERSION",
")",
")",
";",
"node",
".",
"setDescription",
"(",
"entity",
".",
"getProperty",
"(",
"COMMON_DESCRIPTION",
")",
")",
";",
"final",
"String",
"tags",
"=",
"entity",
".",
"getProperty",
"(",
"COMMON_TAGS",
")",
";",
"final",
"HashSet",
"<",
"String",
">",
"tags1",
";",
"if",
"(",
"null",
"!=",
"tags",
"&&",
"!",
"\"\"",
".",
"equals",
"(",
"tags",
")",
")",
"{",
"tags1",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"tags",
".",
"split",
"(",
"\",\"",
")",
")",
"{",
"tags1",
".",
"add",
"(",
"s",
".",
"trim",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"tags1",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"}",
"node",
".",
"setTags",
"(",
"tags1",
")",
";",
"if",
"(",
"null",
"==",
"node",
".",
"getAttributes",
"(",
")",
")",
"{",
"node",
".",
"setAttributes",
"(",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"entity",
".",
"getProperties",
"(",
")",
")",
"{",
"for",
"(",
"String",
"key",
":",
"entity",
".",
"getProperties",
"(",
")",
".",
"stringPropertyNames",
"(",
")",
")",
"{",
"if",
"(",
"!",
"ResourceXMLConstants",
".",
"allPropSet",
".",
"contains",
"(",
"key",
")",
")",
"{",
"node",
".",
"getAttributes",
"(",
")",
".",
"put",
"(",
"key",
",",
"entity",
".",
"getProperty",
"(",
"key",
")",
")",
";",
"}",
"}",
"}",
"//parse embedded attribute elements",
"}"
] |
Fill the NodeEntryImpl based on the Entity's parsed attributes
@param entity entity
@param node node
|
[
"Fill",
"the",
"NodeEntryImpl",
"based",
"on",
"the",
"Entity",
"s",
"parsed",
"attributes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/common/NodesXMLParser.java#L121-L153
|
15,873
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java
|
ZipResourceLoader.getResourceNames
|
public String[] getResourceNames() {
if (null != resourcesList) {
return resourcesList.toArray(new String[resourcesList.size()]);
}
if (null != basedirListing) {
return basedirListing.toArray(new String[basedirListing.size()]);
}
String[] list = listZipPath(zipFile, resourcesBasedir);
if (null != list) {
basedirListing = Arrays.asList(list);
return list;
}
return new String[0];
}
|
java
|
public String[] getResourceNames() {
if (null != resourcesList) {
return resourcesList.toArray(new String[resourcesList.size()]);
}
if (null != basedirListing) {
return basedirListing.toArray(new String[basedirListing.size()]);
}
String[] list = listZipPath(zipFile, resourcesBasedir);
if (null != list) {
basedirListing = Arrays.asList(list);
return list;
}
return new String[0];
}
|
[
"public",
"String",
"[",
"]",
"getResourceNames",
"(",
")",
"{",
"if",
"(",
"null",
"!=",
"resourcesList",
")",
"{",
"return",
"resourcesList",
".",
"toArray",
"(",
"new",
"String",
"[",
"resourcesList",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"basedirListing",
")",
"{",
"return",
"basedirListing",
".",
"toArray",
"(",
"new",
"String",
"[",
"basedirListing",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"String",
"[",
"]",
"list",
"=",
"listZipPath",
"(",
"zipFile",
",",
"resourcesBasedir",
")",
";",
"if",
"(",
"null",
"!=",
"list",
")",
"{",
"basedirListing",
"=",
"Arrays",
".",
"asList",
"(",
"list",
")",
";",
"return",
"list",
";",
"}",
"return",
"new",
"String",
"[",
"0",
"]",
";",
"}"
] |
Get the list of resources in the jar
|
[
"Get",
"the",
"list",
"of",
"resources",
"in",
"the",
"jar"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java#L59-L72
|
15,874
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java
|
ZipResourceLoader.extractResources
|
public void extractResources() throws IOException {
if (!cacheDir.isDirectory()) {
if (!cacheDir.mkdirs()) {
//debug("Failed to create cachedJar dir for dependent resources: " + cachedir);
}
}
if (null != resourcesList) {
//debug("jar manifest lists resources: " + resourcesList + " for file: " + pluginJar);
extractJarContents(resourcesList, cacheDir);
for (final String s : resourcesList) {
File libFile = new File(cacheDir, s);
libFile.deleteOnExit();
}
} else {
//debug("using resources dir: " + resDir + " for file: " + pluginJar);
ZipUtil.extractZip(zipFile.getAbsolutePath(), cacheDir, resourcesBasedir, resourcesBasedir);
}
}
|
java
|
public void extractResources() throws IOException {
if (!cacheDir.isDirectory()) {
if (!cacheDir.mkdirs()) {
//debug("Failed to create cachedJar dir for dependent resources: " + cachedir);
}
}
if (null != resourcesList) {
//debug("jar manifest lists resources: " + resourcesList + " for file: " + pluginJar);
extractJarContents(resourcesList, cacheDir);
for (final String s : resourcesList) {
File libFile = new File(cacheDir, s);
libFile.deleteOnExit();
}
} else {
//debug("using resources dir: " + resDir + " for file: " + pluginJar);
ZipUtil.extractZip(zipFile.getAbsolutePath(), cacheDir, resourcesBasedir, resourcesBasedir);
}
}
|
[
"public",
"void",
"extractResources",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"cacheDir",
".",
"isDirectory",
"(",
")",
")",
"{",
"if",
"(",
"!",
"cacheDir",
".",
"mkdirs",
"(",
")",
")",
"{",
"//debug(\"Failed to create cachedJar dir for dependent resources: \" + cachedir);",
"}",
"}",
"if",
"(",
"null",
"!=",
"resourcesList",
")",
"{",
"//debug(\"jar manifest lists resources: \" + resourcesList + \" for file: \" + pluginJar);",
"extractJarContents",
"(",
"resourcesList",
",",
"cacheDir",
")",
";",
"for",
"(",
"final",
"String",
"s",
":",
"resourcesList",
")",
"{",
"File",
"libFile",
"=",
"new",
"File",
"(",
"cacheDir",
",",
"s",
")",
";",
"libFile",
".",
"deleteOnExit",
"(",
")",
";",
"}",
"}",
"else",
"{",
"//debug(\"using resources dir: \" + resDir + \" for file: \" + pluginJar);",
"ZipUtil",
".",
"extractZip",
"(",
"zipFile",
".",
"getAbsolutePath",
"(",
")",
",",
"cacheDir",
",",
"resourcesBasedir",
",",
"resourcesBasedir",
")",
";",
"}",
"}"
] |
Extract resources return the extracted files
@return the collection of extracted files
|
[
"Extract",
"resources",
"return",
"the",
"extracted",
"files"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/ZipResourceLoader.java#L123-L141
|
15,875
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.continueProcessing
|
private void continueProcessing() {
try {
while (!Thread.currentThread().isInterrupted()) {
HashMap<String, String> changes = new HashMap<>();
//load all changes already in the queue
getAvailableChanges(changes);
if (changes.isEmpty()) {
if (inProcess.isEmpty()) {
//no pending operations, signalling no new state changes will occur
workflowEngine.event(
WorkflowSystemEventType.EndOfChanges,
"No more state changes expected, finishing workflow."
);
return;
}
if (Thread.currentThread().isInterrupted()) {
break;
}
waitForChanges(changes);
}
if (changes.isEmpty()) {
//no changes within sleep time, try again
continue;
}
getContextGlobalData(changes);
//handle state changes
processStateChanges(changes);
if (workflowEngine.isWorkflowEndState(workflowEngine.getState())) {
workflowEngine.event(WorkflowSystemEventType.WorkflowEndState, "Workflow end state reached.");
return;
}
processOperations(results::add);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
if (Thread.currentThread().isInterrupted()) {
workflowEngine.event(WorkflowSystemEventType.Interrupted, "Engine interrupted, stopping engine...");
cancelFutures();
interrupted = Thread.interrupted();
}
awaitFutures();
}
|
java
|
private void continueProcessing() {
try {
while (!Thread.currentThread().isInterrupted()) {
HashMap<String, String> changes = new HashMap<>();
//load all changes already in the queue
getAvailableChanges(changes);
if (changes.isEmpty()) {
if (inProcess.isEmpty()) {
//no pending operations, signalling no new state changes will occur
workflowEngine.event(
WorkflowSystemEventType.EndOfChanges,
"No more state changes expected, finishing workflow."
);
return;
}
if (Thread.currentThread().isInterrupted()) {
break;
}
waitForChanges(changes);
}
if (changes.isEmpty()) {
//no changes within sleep time, try again
continue;
}
getContextGlobalData(changes);
//handle state changes
processStateChanges(changes);
if (workflowEngine.isWorkflowEndState(workflowEngine.getState())) {
workflowEngine.event(WorkflowSystemEventType.WorkflowEndState, "Workflow end state reached.");
return;
}
processOperations(results::add);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
if (Thread.currentThread().isInterrupted()) {
workflowEngine.event(WorkflowSystemEventType.Interrupted, "Engine interrupted, stopping engine...");
cancelFutures();
interrupted = Thread.interrupted();
}
awaitFutures();
}
|
[
"private",
"void",
"continueProcessing",
"(",
")",
"{",
"try",
"{",
"while",
"(",
"!",
"Thread",
".",
"currentThread",
"(",
")",
".",
"isInterrupted",
"(",
")",
")",
"{",
"HashMap",
"<",
"String",
",",
"String",
">",
"changes",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"//load all changes already in the queue",
"getAvailableChanges",
"(",
"changes",
")",
";",
"if",
"(",
"changes",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"inProcess",
".",
"isEmpty",
"(",
")",
")",
"{",
"//no pending operations, signalling no new state changes will occur",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"EndOfChanges",
",",
"\"No more state changes expected, finishing workflow.\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"isInterrupted",
"(",
")",
")",
"{",
"break",
";",
"}",
"waitForChanges",
"(",
"changes",
")",
";",
"}",
"if",
"(",
"changes",
".",
"isEmpty",
"(",
")",
")",
"{",
"//no changes within sleep time, try again",
"continue",
";",
"}",
"getContextGlobalData",
"(",
"changes",
")",
";",
"//handle state changes",
"processStateChanges",
"(",
"changes",
")",
";",
"if",
"(",
"workflowEngine",
".",
"isWorkflowEndState",
"(",
"workflowEngine",
".",
"getState",
"(",
")",
")",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"WorkflowEndState",
",",
"\"Workflow end state reached.\"",
")",
";",
"return",
";",
"}",
"processOperations",
"(",
"results",
"::",
"add",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"if",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"isInterrupted",
"(",
")",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"Interrupted",
",",
"\"Engine interrupted, stopping engine...\"",
")",
";",
"cancelFutures",
"(",
")",
";",
"interrupted",
"=",
"Thread",
".",
"interrupted",
"(",
")",
";",
"}",
"awaitFutures",
"(",
")",
";",
"}"
] |
Continue processing from current state
|
[
"Continue",
"processing",
"from",
"current",
"state"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L89-L137
|
15,876
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.getAvailableChanges
|
private void getAvailableChanges( final Map<String, String> changes) {
WorkflowSystem.OperationCompleted<DAT> task = stateChangeQueue.poll();
while (task != null && task.getNewState() != null) {
changes.putAll(task.getNewState().getState());
DAT result = task.getResult();
if (null != sharedData && null != result) {
sharedData.addData(result);
}
task = stateChangeQueue.poll();
}
}
|
java
|
private void getAvailableChanges( final Map<String, String> changes) {
WorkflowSystem.OperationCompleted<DAT> task = stateChangeQueue.poll();
while (task != null && task.getNewState() != null) {
changes.putAll(task.getNewState().getState());
DAT result = task.getResult();
if (null != sharedData && null != result) {
sharedData.addData(result);
}
task = stateChangeQueue.poll();
}
}
|
[
"private",
"void",
"getAvailableChanges",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"changes",
")",
"{",
"WorkflowSystem",
".",
"OperationCompleted",
"<",
"DAT",
">",
"task",
"=",
"stateChangeQueue",
".",
"poll",
"(",
")",
";",
"while",
"(",
"task",
"!=",
"null",
"&&",
"task",
".",
"getNewState",
"(",
")",
"!=",
"null",
")",
"{",
"changes",
".",
"putAll",
"(",
"task",
".",
"getNewState",
"(",
")",
".",
"getState",
"(",
")",
")",
";",
"DAT",
"result",
"=",
"task",
".",
"getResult",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"sharedData",
"&&",
"null",
"!=",
"result",
")",
"{",
"sharedData",
".",
"addData",
"(",
"result",
")",
";",
"}",
"task",
"=",
"stateChangeQueue",
".",
"poll",
"(",
")",
";",
"}",
"}"
] |
Poll for changes from the queue, and process all changes that are immediately available without waiting
@param changes changes map
|
[
"Poll",
"for",
"changes",
"from",
"the",
"queue",
"and",
"process",
"all",
"changes",
"that",
"are",
"immediately",
"available",
"without",
"waiting"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L143-L153
|
15,877
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.processRunnableOperations
|
private void processRunnableOperations(
final Consumer<WorkflowSystem.OperationResult<DAT, RES, OP>> resultConsumer,
final List<OP> shouldrun,
final List<OP> shouldskip,
final DAT inputData
)
{
for (final OP operation : shouldrun) {
if (shouldskip.contains(operation)) {
continue;
}
pending.remove(operation);
workflowEngine.event(
WorkflowSystemEventType.WillRunOperation,
String.format("operation starting: %s", operation),
operation
);
final ListenableFuture<RES> submit = executorService.submit(() -> operation.apply(inputData));
inProcess.add(operation);
futures.add(submit);
FutureCallback<RES> callback = new FutureCallback<RES>() {
@Override
public void onSuccess(final RES successResult) {
workflowEngine.event(
WorkflowSystemEventType.OperationSuccess,
String.format("operation succeeded: %s", successResult),
successResult
);
assert successResult != null;
WorkflowSystem.OperationResult<DAT, RES, OP> result = result(successResult, operation);
resultConsumer.accept(result);
stateChangeQueue.add(successResult);
inProcess.remove(operation);
}
@Override
public void onFailure(final Throwable t) {
workflowEngine.event(
WorkflowSystemEventType.OperationFailed,
String.format("operation failed: %s", t),
t
);
WorkflowSystem.OperationResult<DAT, RES, OP> result = result(t, operation);
resultConsumer.accept(result);
StateObj newFailureState = operation.getFailureState(t);
if (null != newFailureState && newFailureState.getState().size() > 0) {
WorkflowSystem.OperationCompleted<DAT> objectOperationCompleted = WorkflowEngine.dummyResult(
newFailureState);
stateChangeQueue.add(objectOperationCompleted);
}
inProcess.remove(operation);
}
};
Futures.addCallback(submit, callback, manager);
}
}
|
java
|
private void processRunnableOperations(
final Consumer<WorkflowSystem.OperationResult<DAT, RES, OP>> resultConsumer,
final List<OP> shouldrun,
final List<OP> shouldskip,
final DAT inputData
)
{
for (final OP operation : shouldrun) {
if (shouldskip.contains(operation)) {
continue;
}
pending.remove(operation);
workflowEngine.event(
WorkflowSystemEventType.WillRunOperation,
String.format("operation starting: %s", operation),
operation
);
final ListenableFuture<RES> submit = executorService.submit(() -> operation.apply(inputData));
inProcess.add(operation);
futures.add(submit);
FutureCallback<RES> callback = new FutureCallback<RES>() {
@Override
public void onSuccess(final RES successResult) {
workflowEngine.event(
WorkflowSystemEventType.OperationSuccess,
String.format("operation succeeded: %s", successResult),
successResult
);
assert successResult != null;
WorkflowSystem.OperationResult<DAT, RES, OP> result = result(successResult, operation);
resultConsumer.accept(result);
stateChangeQueue.add(successResult);
inProcess.remove(operation);
}
@Override
public void onFailure(final Throwable t) {
workflowEngine.event(
WorkflowSystemEventType.OperationFailed,
String.format("operation failed: %s", t),
t
);
WorkflowSystem.OperationResult<DAT, RES, OP> result = result(t, operation);
resultConsumer.accept(result);
StateObj newFailureState = operation.getFailureState(t);
if (null != newFailureState && newFailureState.getState().size() > 0) {
WorkflowSystem.OperationCompleted<DAT> objectOperationCompleted = WorkflowEngine.dummyResult(
newFailureState);
stateChangeQueue.add(objectOperationCompleted);
}
inProcess.remove(operation);
}
};
Futures.addCallback(submit, callback, manager);
}
}
|
[
"private",
"void",
"processRunnableOperations",
"(",
"final",
"Consumer",
"<",
"WorkflowSystem",
".",
"OperationResult",
"<",
"DAT",
",",
"RES",
",",
"OP",
">",
">",
"resultConsumer",
",",
"final",
"List",
"<",
"OP",
">",
"shouldrun",
",",
"final",
"List",
"<",
"OP",
">",
"shouldskip",
",",
"final",
"DAT",
"inputData",
")",
"{",
"for",
"(",
"final",
"OP",
"operation",
":",
"shouldrun",
")",
"{",
"if",
"(",
"shouldskip",
".",
"contains",
"(",
"operation",
")",
")",
"{",
"continue",
";",
"}",
"pending",
".",
"remove",
"(",
"operation",
")",
";",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"WillRunOperation",
",",
"String",
".",
"format",
"(",
"\"operation starting: %s\"",
",",
"operation",
")",
",",
"operation",
")",
";",
"final",
"ListenableFuture",
"<",
"RES",
">",
"submit",
"=",
"executorService",
".",
"submit",
"(",
"(",
")",
"->",
"operation",
".",
"apply",
"(",
"inputData",
")",
")",
";",
"inProcess",
".",
"add",
"(",
"operation",
")",
";",
"futures",
".",
"add",
"(",
"submit",
")",
";",
"FutureCallback",
"<",
"RES",
">",
"callback",
"=",
"new",
"FutureCallback",
"<",
"RES",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onSuccess",
"(",
"final",
"RES",
"successResult",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"OperationSuccess",
",",
"String",
".",
"format",
"(",
"\"operation succeeded: %s\"",
",",
"successResult",
")",
",",
"successResult",
")",
";",
"assert",
"successResult",
"!=",
"null",
";",
"WorkflowSystem",
".",
"OperationResult",
"<",
"DAT",
",",
"RES",
",",
"OP",
">",
"result",
"=",
"result",
"(",
"successResult",
",",
"operation",
")",
";",
"resultConsumer",
".",
"accept",
"(",
"result",
")",
";",
"stateChangeQueue",
".",
"add",
"(",
"successResult",
")",
";",
"inProcess",
".",
"remove",
"(",
"operation",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onFailure",
"(",
"final",
"Throwable",
"t",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"OperationFailed",
",",
"String",
".",
"format",
"(",
"\"operation failed: %s\"",
",",
"t",
")",
",",
"t",
")",
";",
"WorkflowSystem",
".",
"OperationResult",
"<",
"DAT",
",",
"RES",
",",
"OP",
">",
"result",
"=",
"result",
"(",
"t",
",",
"operation",
")",
";",
"resultConsumer",
".",
"accept",
"(",
"result",
")",
";",
"StateObj",
"newFailureState",
"=",
"operation",
".",
"getFailureState",
"(",
"t",
")",
";",
"if",
"(",
"null",
"!=",
"newFailureState",
"&&",
"newFailureState",
".",
"getState",
"(",
")",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"WorkflowSystem",
".",
"OperationCompleted",
"<",
"DAT",
">",
"objectOperationCompleted",
"=",
"WorkflowEngine",
".",
"dummyResult",
"(",
"newFailureState",
")",
";",
"stateChangeQueue",
".",
"add",
"(",
"objectOperationCompleted",
")",
";",
"}",
"inProcess",
".",
"remove",
"(",
"operation",
")",
";",
"}",
"}",
";",
"Futures",
".",
"addCallback",
"(",
"submit",
",",
"callback",
",",
"manager",
")",
";",
"}",
"}"
] |
Process the runnable operations
@param shouldrun operations to run
@param shouldskip operations to skip
@param inputData input data for the currently runnable operations
|
[
"Process",
"the",
"runnable",
"operations"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L204-L261
|
15,878
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.waitForChanges
|
private void waitForChanges(final Map<String, String> changes) throws InterruptedException {
WorkflowSystem.OperationCompleted<DAT> take = stateChangeQueue.poll(sleeper.time(), sleeper.unit());
if (null == take || take.getNewState().getState().isEmpty()) {
sleeper.backoff();
return;
}
sleeper.reset();
changes.putAll(take.getNewState().getState());
if (null != sharedData) {
sharedData.addData(take.getResult());
}
getAvailableChanges(changes);
}
|
java
|
private void waitForChanges(final Map<String, String> changes) throws InterruptedException {
WorkflowSystem.OperationCompleted<DAT> take = stateChangeQueue.poll(sleeper.time(), sleeper.unit());
if (null == take || take.getNewState().getState().isEmpty()) {
sleeper.backoff();
return;
}
sleeper.reset();
changes.putAll(take.getNewState().getState());
if (null != sharedData) {
sharedData.addData(take.getResult());
}
getAvailableChanges(changes);
}
|
[
"private",
"void",
"waitForChanges",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"changes",
")",
"throws",
"InterruptedException",
"{",
"WorkflowSystem",
".",
"OperationCompleted",
"<",
"DAT",
">",
"take",
"=",
"stateChangeQueue",
".",
"poll",
"(",
"sleeper",
".",
"time",
"(",
")",
",",
"sleeper",
".",
"unit",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"take",
"||",
"take",
".",
"getNewState",
"(",
")",
".",
"getState",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"sleeper",
".",
"backoff",
"(",
")",
";",
"return",
";",
"}",
"sleeper",
".",
"reset",
"(",
")",
";",
"changes",
".",
"putAll",
"(",
"take",
".",
"getNewState",
"(",
")",
".",
"getState",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"sharedData",
")",
"{",
"sharedData",
".",
"addData",
"(",
"take",
".",
"getResult",
"(",
")",
")",
";",
"}",
"getAvailableChanges",
"(",
"changes",
")",
";",
"}"
] |
Sleep until changes are available on the queue, if any are found then consume remaining and
return false, otherwise return true
@param changes
@return true if no changes found in the sleep time.
@throws InterruptedException
|
[
"Sleep",
"until",
"changes",
"are",
"available",
"on",
"the",
"queue",
"if",
"any",
"are",
"found",
"then",
"consume",
"remaining",
"and",
"return",
"false",
"otherwise",
"return",
"true"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L289-L305
|
15,879
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.processStateChanges
|
private void processStateChanges(final Map<String, String> changes) {
workflowEngine.event(WorkflowSystemEventType.WillProcessStateChange,
String.format("saw state changes: %s", changes), changes
);
workflowEngine.getState().updateState(changes);
boolean update = Rules.update(workflowEngine.getRuleEngine(), workflowEngine.getState());
workflowEngine.event(
WorkflowSystemEventType.DidProcessStateChange,
String.format(
"applied state changes and rules (changed? %s): %s",
update,
workflowEngine.getState()
),
workflowEngine.getState()
);
}
|
java
|
private void processStateChanges(final Map<String, String> changes) {
workflowEngine.event(WorkflowSystemEventType.WillProcessStateChange,
String.format("saw state changes: %s", changes), changes
);
workflowEngine.getState().updateState(changes);
boolean update = Rules.update(workflowEngine.getRuleEngine(), workflowEngine.getState());
workflowEngine.event(
WorkflowSystemEventType.DidProcessStateChange,
String.format(
"applied state changes and rules (changed? %s): %s",
update,
workflowEngine.getState()
),
workflowEngine.getState()
);
}
|
[
"private",
"void",
"processStateChanges",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"changes",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"WillProcessStateChange",
",",
"String",
".",
"format",
"(",
"\"saw state changes: %s\"",
",",
"changes",
")",
",",
"changes",
")",
";",
"workflowEngine",
".",
"getState",
"(",
")",
".",
"updateState",
"(",
"changes",
")",
";",
"boolean",
"update",
"=",
"Rules",
".",
"update",
"(",
"workflowEngine",
".",
"getRuleEngine",
"(",
")",
",",
"workflowEngine",
".",
"getState",
"(",
")",
")",
";",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"DidProcessStateChange",
",",
"String",
".",
"format",
"(",
"\"applied state changes and rules (changed? %s): %s\"",
",",
"update",
",",
"workflowEngine",
".",
"getState",
"(",
")",
")",
",",
"workflowEngine",
".",
"getState",
"(",
")",
")",
";",
"}"
] |
Handle the state changes for the rule engine
@param changes
|
[
"Handle",
"the",
"state",
"changes",
"for",
"the",
"rule",
"engine"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L312-L329
|
15,880
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.processOperations
|
private void processOperations(
final Consumer<WorkflowSystem.OperationResult<DAT, RES, OP>> resultConsumer
)
{
int origPendingCount = pending.size();
//operations which match runnable conditions
List<OP> shouldrun = pending.stream()
.filter(input -> input.shouldRun(workflowEngine.getState()))
.collect(Collectors.toList());
//runnable that should be skipped
List<OP> shouldskip = shouldrun.stream()
.filter(input -> input.shouldSkip(workflowEngine.getState()))
.collect(Collectors.toList());
//shared data
DAT inputData = null != sharedData ? sharedData.produceNext() : null;
processRunnableOperations(resultConsumer, shouldrun, shouldskip, inputData);
processSkippedOperations(shouldskip);
pending.removeAll(shouldskip);
skipped.addAll(shouldskip);
workflowEngine.eventLoopProgress(origPendingCount, shouldskip.size(), shouldrun.size(), pending.size());
}
|
java
|
private void processOperations(
final Consumer<WorkflowSystem.OperationResult<DAT, RES, OP>> resultConsumer
)
{
int origPendingCount = pending.size();
//operations which match runnable conditions
List<OP> shouldrun = pending.stream()
.filter(input -> input.shouldRun(workflowEngine.getState()))
.collect(Collectors.toList());
//runnable that should be skipped
List<OP> shouldskip = shouldrun.stream()
.filter(input -> input.shouldSkip(workflowEngine.getState()))
.collect(Collectors.toList());
//shared data
DAT inputData = null != sharedData ? sharedData.produceNext() : null;
processRunnableOperations(resultConsumer, shouldrun, shouldskip, inputData);
processSkippedOperations(shouldskip);
pending.removeAll(shouldskip);
skipped.addAll(shouldskip);
workflowEngine.eventLoopProgress(origPendingCount, shouldskip.size(), shouldrun.size(), pending.size());
}
|
[
"private",
"void",
"processOperations",
"(",
"final",
"Consumer",
"<",
"WorkflowSystem",
".",
"OperationResult",
"<",
"DAT",
",",
"RES",
",",
"OP",
">",
">",
"resultConsumer",
")",
"{",
"int",
"origPendingCount",
"=",
"pending",
".",
"size",
"(",
")",
";",
"//operations which match runnable conditions",
"List",
"<",
"OP",
">",
"shouldrun",
"=",
"pending",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"input",
"->",
"input",
".",
"shouldRun",
"(",
"workflowEngine",
".",
"getState",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"//runnable that should be skipped",
"List",
"<",
"OP",
">",
"shouldskip",
"=",
"shouldrun",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"input",
"->",
"input",
".",
"shouldSkip",
"(",
"workflowEngine",
".",
"getState",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"//shared data",
"DAT",
"inputData",
"=",
"null",
"!=",
"sharedData",
"?",
"sharedData",
".",
"produceNext",
"(",
")",
":",
"null",
";",
"processRunnableOperations",
"(",
"resultConsumer",
",",
"shouldrun",
",",
"shouldskip",
",",
"inputData",
")",
";",
"processSkippedOperations",
"(",
"shouldskip",
")",
";",
"pending",
".",
"removeAll",
"(",
"shouldskip",
")",
";",
"skipped",
".",
"addAll",
"(",
"shouldskip",
")",
";",
"workflowEngine",
".",
"eventLoopProgress",
"(",
"origPendingCount",
",",
"shouldskip",
".",
"size",
"(",
")",
",",
"shouldrun",
".",
"size",
"(",
")",
",",
"pending",
".",
"size",
"(",
")",
")",
";",
"}"
] |
Run and skip pending operations
@param resultConsumer consumer for result of operations
|
[
"Run",
"and",
"skip",
"pending",
"operations"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L336-L364
|
15,881
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java
|
WorkflowEngineOperationsProcessor.processSkippedOperations
|
private void processSkippedOperations(final List<OP> shouldskip) {
for (final OP operation : shouldskip) {
workflowEngine.event(
WorkflowSystemEventType.WillSkipOperation,
String.format("Skip condition statisfied for operation: %s, skipping", operation),
operation
);
StateObj newstate = operation.getSkipState(workflowEngine.getState());
WorkflowSystem.OperationCompleted<DAT> objectOperationCompleted = WorkflowEngine.dummyResult(newstate);
stateChangeQueue.add(objectOperationCompleted);
}
}
|
java
|
private void processSkippedOperations(final List<OP> shouldskip) {
for (final OP operation : shouldskip) {
workflowEngine.event(
WorkflowSystemEventType.WillSkipOperation,
String.format("Skip condition statisfied for operation: %s, skipping", operation),
operation
);
StateObj newstate = operation.getSkipState(workflowEngine.getState());
WorkflowSystem.OperationCompleted<DAT> objectOperationCompleted = WorkflowEngine.dummyResult(newstate);
stateChangeQueue.add(objectOperationCompleted);
}
}
|
[
"private",
"void",
"processSkippedOperations",
"(",
"final",
"List",
"<",
"OP",
">",
"shouldskip",
")",
"{",
"for",
"(",
"final",
"OP",
"operation",
":",
"shouldskip",
")",
"{",
"workflowEngine",
".",
"event",
"(",
"WorkflowSystemEventType",
".",
"WillSkipOperation",
",",
"String",
".",
"format",
"(",
"\"Skip condition statisfied for operation: %s, skipping\"",
",",
"operation",
")",
",",
"operation",
")",
";",
"StateObj",
"newstate",
"=",
"operation",
".",
"getSkipState",
"(",
"workflowEngine",
".",
"getState",
"(",
")",
")",
";",
"WorkflowSystem",
".",
"OperationCompleted",
"<",
"DAT",
">",
"objectOperationCompleted",
"=",
"WorkflowEngine",
".",
"dummyResult",
"(",
"newstate",
")",
";",
"stateChangeQueue",
".",
"add",
"(",
"objectOperationCompleted",
")",
";",
"}",
"}"
] |
Process skipped operations
@param shouldskip list of operations to skip
|
[
"Process",
"skipped",
"operations"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/rules/WorkflowEngineOperationsProcessor.java#L371-L382
|
15,882
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java
|
JettyCombinedLdapLoginModule.getUserRoles
|
@Override
protected List getUserRoles(final DirContext dirContext, final String username)
throws LoginException, NamingException
{
if (_ignoreRoles) {
ArrayList<String> strings = new ArrayList<>();
addSupplementalRoles(strings);
return strings;
} else {
return super.getUserRoles(dirContext, username);
}
}
|
java
|
@Override
protected List getUserRoles(final DirContext dirContext, final String username)
throws LoginException, NamingException
{
if (_ignoreRoles) {
ArrayList<String> strings = new ArrayList<>();
addSupplementalRoles(strings);
return strings;
} else {
return super.getUserRoles(dirContext, username);
}
}
|
[
"@",
"Override",
"protected",
"List",
"getUserRoles",
"(",
"final",
"DirContext",
"dirContext",
",",
"final",
"String",
"username",
")",
"throws",
"LoginException",
",",
"NamingException",
"{",
"if",
"(",
"_ignoreRoles",
")",
"{",
"ArrayList",
"<",
"String",
">",
"strings",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"addSupplementalRoles",
"(",
"strings",
")",
";",
"return",
"strings",
";",
"}",
"else",
"{",
"return",
"super",
".",
"getUserRoles",
"(",
"dirContext",
",",
"username",
")",
";",
"}",
"}"
] |
Override to perform behavior of "ignoreRoles" option
@param dirContext context
@param username username
@return empty or supplemental roles list only if "ignoreRoles" is true, otherwise performs normal LDAP lookup
@throws LoginException
@throws NamingException
|
[
"Override",
"to",
"perform",
"behavior",
"of",
"ignoreRoles",
"option"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java#L89-L100
|
15,883
|
rundeck/rundeck
|
rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java
|
JettyCombinedLdapLoginModule.login
|
@Override
public boolean login() throws LoginException {
if ((getShared().isUseFirstPass() || getShared().isTryFirstPass()) && getShared().isHasSharedAuth()) {
debug(
String.format(
"JettyCombinedLdapLoginModule: login with shared auth, " +
"try? %s, use? %s",
getShared().isTryFirstPass(),
getShared().isUseFirstPass()
)
);
setAuthenticated(
authenticate(
getShared().getSharedUserName(),
getShared().getSharedUserPass()
)
);
}
if (getShared().isUseFirstPass() && getShared().isHasSharedAuth()) {
//finish with shared password auth attempt
debug(String.format("AbstractSharedLoginModule: using login result: %s", isAuthenticated()));
if (isAuthenticated()) {
wasAuthenticated(getShared().getSharedUserName(), getShared().getSharedUserPass());
}
return isAuthenticated();
}
if (getShared().isHasSharedAuth()) {
if (isAuthenticated()) {
return isAuthenticated();
}
debug(String.format("AbstractSharedLoginModule: shared auth failed, now trying callback auth."));
}
Object[] userPass = new Object[0];
try {
userPass = getCallBackAuth();
} catch (IOException e) {
if (isDebug()) {
e.printStackTrace();
}
throw new LoginException(e.toString());
} catch (UnsupportedCallbackException e) {
if (isDebug()) {
e.printStackTrace();
}
throw new LoginException(e.toString());
}
if (null == userPass || userPass.length < 2) {
setAuthenticated(false);
} else {
String name = (String) userPass[0];
Object pass = userPass[1];
setAuthenticated(authenticate(name, pass));
if (isAuthenticated()) {
wasAuthenticated(name, pass);
}
}
return isAuthenticated();
}
|
java
|
@Override
public boolean login() throws LoginException {
if ((getShared().isUseFirstPass() || getShared().isTryFirstPass()) && getShared().isHasSharedAuth()) {
debug(
String.format(
"JettyCombinedLdapLoginModule: login with shared auth, " +
"try? %s, use? %s",
getShared().isTryFirstPass(),
getShared().isUseFirstPass()
)
);
setAuthenticated(
authenticate(
getShared().getSharedUserName(),
getShared().getSharedUserPass()
)
);
}
if (getShared().isUseFirstPass() && getShared().isHasSharedAuth()) {
//finish with shared password auth attempt
debug(String.format("AbstractSharedLoginModule: using login result: %s", isAuthenticated()));
if (isAuthenticated()) {
wasAuthenticated(getShared().getSharedUserName(), getShared().getSharedUserPass());
}
return isAuthenticated();
}
if (getShared().isHasSharedAuth()) {
if (isAuthenticated()) {
return isAuthenticated();
}
debug(String.format("AbstractSharedLoginModule: shared auth failed, now trying callback auth."));
}
Object[] userPass = new Object[0];
try {
userPass = getCallBackAuth();
} catch (IOException e) {
if (isDebug()) {
e.printStackTrace();
}
throw new LoginException(e.toString());
} catch (UnsupportedCallbackException e) {
if (isDebug()) {
e.printStackTrace();
}
throw new LoginException(e.toString());
}
if (null == userPass || userPass.length < 2) {
setAuthenticated(false);
} else {
String name = (String) userPass[0];
Object pass = userPass[1];
setAuthenticated(authenticate(name, pass));
if (isAuthenticated()) {
wasAuthenticated(name, pass);
}
}
return isAuthenticated();
}
|
[
"@",
"Override",
"public",
"boolean",
"login",
"(",
")",
"throws",
"LoginException",
"{",
"if",
"(",
"(",
"getShared",
"(",
")",
".",
"isUseFirstPass",
"(",
")",
"||",
"getShared",
"(",
")",
".",
"isTryFirstPass",
"(",
")",
")",
"&&",
"getShared",
"(",
")",
".",
"isHasSharedAuth",
"(",
")",
")",
"{",
"debug",
"(",
"String",
".",
"format",
"(",
"\"JettyCombinedLdapLoginModule: login with shared auth, \"",
"+",
"\"try? %s, use? %s\"",
",",
"getShared",
"(",
")",
".",
"isTryFirstPass",
"(",
")",
",",
"getShared",
"(",
")",
".",
"isUseFirstPass",
"(",
")",
")",
")",
";",
"setAuthenticated",
"(",
"authenticate",
"(",
"getShared",
"(",
")",
".",
"getSharedUserName",
"(",
")",
",",
"getShared",
"(",
")",
".",
"getSharedUserPass",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"getShared",
"(",
")",
".",
"isUseFirstPass",
"(",
")",
"&&",
"getShared",
"(",
")",
".",
"isHasSharedAuth",
"(",
")",
")",
"{",
"//finish with shared password auth attempt",
"debug",
"(",
"String",
".",
"format",
"(",
"\"AbstractSharedLoginModule: using login result: %s\"",
",",
"isAuthenticated",
"(",
")",
")",
")",
";",
"if",
"(",
"isAuthenticated",
"(",
")",
")",
"{",
"wasAuthenticated",
"(",
"getShared",
"(",
")",
".",
"getSharedUserName",
"(",
")",
",",
"getShared",
"(",
")",
".",
"getSharedUserPass",
"(",
")",
")",
";",
"}",
"return",
"isAuthenticated",
"(",
")",
";",
"}",
"if",
"(",
"getShared",
"(",
")",
".",
"isHasSharedAuth",
"(",
")",
")",
"{",
"if",
"(",
"isAuthenticated",
"(",
")",
")",
"{",
"return",
"isAuthenticated",
"(",
")",
";",
"}",
"debug",
"(",
"String",
".",
"format",
"(",
"\"AbstractSharedLoginModule: shared auth failed, now trying callback auth.\"",
")",
")",
";",
"}",
"Object",
"[",
"]",
"userPass",
"=",
"new",
"Object",
"[",
"0",
"]",
";",
"try",
"{",
"userPass",
"=",
"getCallBackAuth",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"isDebug",
"(",
")",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"throw",
"new",
"LoginException",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"UnsupportedCallbackException",
"e",
")",
"{",
"if",
"(",
"isDebug",
"(",
")",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"throw",
"new",
"LoginException",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"userPass",
"||",
"userPass",
".",
"length",
"<",
"2",
")",
"{",
"setAuthenticated",
"(",
"false",
")",
";",
"}",
"else",
"{",
"String",
"name",
"=",
"(",
"String",
")",
"userPass",
"[",
"0",
"]",
";",
"Object",
"pass",
"=",
"userPass",
"[",
"1",
"]",
";",
"setAuthenticated",
"(",
"authenticate",
"(",
"name",
",",
"pass",
")",
")",
";",
"if",
"(",
"isAuthenticated",
"(",
")",
")",
"{",
"wasAuthenticated",
"(",
"name",
",",
"pass",
")",
";",
"}",
"}",
"return",
"isAuthenticated",
"(",
")",
";",
"}"
] |
Override default login logic, to use shared login credentials if available
@return true if authenticated
@throws LoginException
|
[
"Override",
"default",
"login",
"logic",
"to",
"use",
"shared",
"login",
"credentials",
"if",
"available"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/rundeckapp/src/main/groovy/com/dtolabs/rundeck/jetty/jaas/JettyCombinedLdapLoginModule.java#L109-L168
|
15,884
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.fileCopy
|
public static void fileCopy(final File src, final File dest, final boolean overwrite) throws IOException {
if (!dest.exists() || (dest.exists() && overwrite)) {
// Create parent directory structure if necessary
FileUtils.mkParentDirs(dest);
if (overwrite) {
Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else {
Files.copy(src.toPath(), dest.toPath());
}
}
}
|
java
|
public static void fileCopy(final File src, final File dest, final boolean overwrite) throws IOException {
if (!dest.exists() || (dest.exists() && overwrite)) {
// Create parent directory structure if necessary
FileUtils.mkParentDirs(dest);
if (overwrite) {
Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else {
Files.copy(src.toPath(), dest.toPath());
}
}
}
|
[
"public",
"static",
"void",
"fileCopy",
"(",
"final",
"File",
"src",
",",
"final",
"File",
"dest",
",",
"final",
"boolean",
"overwrite",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"dest",
".",
"exists",
"(",
")",
"||",
"(",
"dest",
".",
"exists",
"(",
")",
"&&",
"overwrite",
")",
")",
"{",
"// Create parent directory structure if necessary",
"FileUtils",
".",
"mkParentDirs",
"(",
"dest",
")",
";",
"if",
"(",
"overwrite",
")",
"{",
"Files",
".",
"copy",
"(",
"src",
".",
"toPath",
"(",
")",
",",
"dest",
".",
"toPath",
"(",
")",
",",
"StandardCopyOption",
".",
"REPLACE_EXISTING",
")",
";",
"}",
"else",
"{",
"Files",
".",
"copy",
"(",
"src",
".",
"toPath",
"(",
")",
",",
"dest",
".",
"toPath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Copies file src to dest using nio.
@param src source file
@param dest destination file
@param overwrite true to overwrite if it already exists
@throws IOException on io error
|
[
"Copies",
"file",
"src",
"to",
"dest",
"using",
"nio",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L43-L54
|
15,885
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.deleteDirOnExit
|
public static void deleteDirOnExit(final File dir) {
if (dir.isDirectory()) {
final String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
deleteDirOnExit(new File(dir, children[i]));
}
}
// The directory is now empty so delete it
dir.deleteOnExit();
}
|
java
|
public static void deleteDirOnExit(final File dir) {
if (dir.isDirectory()) {
final String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
deleteDirOnExit(new File(dir, children[i]));
}
}
// The directory is now empty so delete it
dir.deleteOnExit();
}
|
[
"public",
"static",
"void",
"deleteDirOnExit",
"(",
"final",
"File",
"dir",
")",
"{",
"if",
"(",
"dir",
".",
"isDirectory",
"(",
")",
")",
"{",
"final",
"String",
"[",
"]",
"children",
"=",
"dir",
".",
"list",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"deleteDirOnExit",
"(",
"new",
"File",
"(",
"dir",
",",
"children",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"// The directory is now empty so delete it",
"dir",
".",
"deleteOnExit",
"(",
")",
";",
"}"
] |
Delete a directory recursively. This method will delete all files and subdirectories.
@param dir Directory to delete
@return If no error occurs, true is returned. false otherwise.
|
[
"Delete",
"a",
"directory",
"recursively",
".",
"This",
"method",
"will",
"delete",
"all",
"files",
"and",
"subdirectories",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L100-L110
|
15,886
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.fileRename
|
public static void fileRename(final File file, final String newPath, final Class clazz) {
File newDestFile = new File(newPath);
File lockFile = new File(newDestFile.getAbsolutePath() + ".lock");
try {
synchronized (clazz) {
FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();
FileLock lock = channel.lock();
try {
try {
// Create parent directory structure if necessary
FileUtils.mkParentDirs(newDestFile);
Files.move(file.toPath(), newDestFile.toPath(),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ioe) {
throw new CoreException("Unable to move file " + file +
" to destination " + newDestFile + ": " + ioe.getMessage());
}
} finally {
lock.release();
channel.close();
}
}
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace(System.err);
throw new CoreException("Unable to rename file: " + e.getMessage(), e);
}
}
|
java
|
public static void fileRename(final File file, final String newPath, final Class clazz) {
File newDestFile = new File(newPath);
File lockFile = new File(newDestFile.getAbsolutePath() + ".lock");
try {
synchronized (clazz) {
FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel();
FileLock lock = channel.lock();
try {
try {
// Create parent directory structure if necessary
FileUtils.mkParentDirs(newDestFile);
Files.move(file.toPath(), newDestFile.toPath(),
StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ioe) {
throw new CoreException("Unable to move file " + file +
" to destination " + newDestFile + ": " + ioe.getMessage());
}
} finally {
lock.release();
channel.close();
}
}
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace(System.err);
throw new CoreException("Unable to rename file: " + e.getMessage(), e);
}
}
|
[
"public",
"static",
"void",
"fileRename",
"(",
"final",
"File",
"file",
",",
"final",
"String",
"newPath",
",",
"final",
"Class",
"clazz",
")",
"{",
"File",
"newDestFile",
"=",
"new",
"File",
"(",
"newPath",
")",
";",
"File",
"lockFile",
"=",
"new",
"File",
"(",
"newDestFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\".lock\"",
")",
";",
"try",
"{",
"synchronized",
"(",
"clazz",
")",
"{",
"FileChannel",
"channel",
"=",
"new",
"RandomAccessFile",
"(",
"lockFile",
",",
"\"rw\"",
")",
".",
"getChannel",
"(",
")",
";",
"FileLock",
"lock",
"=",
"channel",
".",
"lock",
"(",
")",
";",
"try",
"{",
"try",
"{",
"// Create parent directory structure if necessary",
"FileUtils",
".",
"mkParentDirs",
"(",
"newDestFile",
")",
";",
"Files",
".",
"move",
"(",
"file",
".",
"toPath",
"(",
")",
",",
"newDestFile",
".",
"toPath",
"(",
")",
",",
"StandardCopyOption",
".",
"REPLACE_EXISTING",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"CoreException",
"(",
"\"Unable to move file \"",
"+",
"file",
"+",
"\" to destination \"",
"+",
"newDestFile",
"+",
"\": \"",
"+",
"ioe",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"lock",
".",
"release",
"(",
")",
";",
"channel",
".",
"close",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"IOException: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"e",
".",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"throw",
"new",
"CoreException",
"(",
"\"Unable to rename file: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Rename a file.
Uses Java's nio library to use a lock.
@param file File to rename
@param newPath Path for new file name
@param clazz Class associated with lock
@throws com.dtolabs.rundeck.core.CoreException A CoreException is raised if any underlying I/O
operation fails.
|
[
"Rename",
"a",
"file",
".",
"Uses",
"Java",
"s",
"nio",
"library",
"to",
"use",
"a",
"lock",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L121-L148
|
15,887
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.mkParentDirs
|
public static void mkParentDirs(final File file) throws IOException {
// Create parent directory structure if necessary
File parentFile = file.getParentFile();
if (parentFile == null) {
// File was created with a relative path
parentFile = file.getAbsoluteFile().getParentFile();
}
if (parentFile != null && !parentFile.exists()) {
if (!parentFile.mkdirs()) {
throw new IOException("Unable to create parent directory " +
"structure for file " + file.getAbsolutePath());
}
}
}
|
java
|
public static void mkParentDirs(final File file) throws IOException {
// Create parent directory structure if necessary
File parentFile = file.getParentFile();
if (parentFile == null) {
// File was created with a relative path
parentFile = file.getAbsoluteFile().getParentFile();
}
if (parentFile != null && !parentFile.exists()) {
if (!parentFile.mkdirs()) {
throw new IOException("Unable to create parent directory " +
"structure for file " + file.getAbsolutePath());
}
}
}
|
[
"public",
"static",
"void",
"mkParentDirs",
"(",
"final",
"File",
"file",
")",
"throws",
"IOException",
"{",
"// Create parent directory structure if necessary",
"File",
"parentFile",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"parentFile",
"==",
"null",
")",
"{",
"// File was created with a relative path",
"parentFile",
"=",
"file",
".",
"getAbsoluteFile",
"(",
")",
".",
"getParentFile",
"(",
")",
";",
"}",
"if",
"(",
"parentFile",
"!=",
"null",
"&&",
"!",
"parentFile",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"parentFile",
".",
"mkdirs",
"(",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Unable to create parent directory \"",
"+",
"\"structure for file \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Create parent directory structure of a given file, if it doesn't already
exist.
@param file File to create directories for
@throws IOException if an I/O error occurs
|
[
"Create",
"parent",
"directory",
"structure",
"of",
"a",
"given",
"file",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L167-L180
|
15,888
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.getBaseDir
|
public static File getBaseDir(final List<File> files) {
String common = getCommonPrefix(files.stream().map(new Function<File, String>() {
@Override
public String apply(final File file) {
return file.getAbsolutePath();
}
}).collect(Collectors.toList()));
if (null != common) {
return new File(common);
}
return null;
}
|
java
|
public static File getBaseDir(final List<File> files) {
String common = getCommonPrefix(files.stream().map(new Function<File, String>() {
@Override
public String apply(final File file) {
return file.getAbsolutePath();
}
}).collect(Collectors.toList()));
if (null != common) {
return new File(common);
}
return null;
}
|
[
"public",
"static",
"File",
"getBaseDir",
"(",
"final",
"List",
"<",
"File",
">",
"files",
")",
"{",
"String",
"common",
"=",
"getCommonPrefix",
"(",
"files",
".",
"stream",
"(",
")",
".",
"map",
"(",
"new",
"Function",
"<",
"File",
",",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"apply",
"(",
"final",
"File",
"file",
")",
"{",
"return",
"file",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"}",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"if",
"(",
"null",
"!=",
"common",
")",
"{",
"return",
"new",
"File",
"(",
"common",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Return common base directory of the given files
@param files
@return common base directory
|
[
"Return",
"common",
"base",
"directory",
"of",
"the",
"given",
"files"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L189-L200
|
15,889
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java
|
FileUtils.relativePath
|
public static String relativePath(File parent, File child) {
Path superPath = parent.toPath();
Path subPath = child.toPath();
if (!subPath.startsWith(superPath)) {
throw new IllegalArgumentException("Not a subpath: " + child);
}
return superPath.relativize(subPath).toString();
}
|
java
|
public static String relativePath(File parent, File child) {
Path superPath = parent.toPath();
Path subPath = child.toPath();
if (!subPath.startsWith(superPath)) {
throw new IllegalArgumentException("Not a subpath: " + child);
}
return superPath.relativize(subPath).toString();
}
|
[
"public",
"static",
"String",
"relativePath",
"(",
"File",
"parent",
",",
"File",
"child",
")",
"{",
"Path",
"superPath",
"=",
"parent",
".",
"toPath",
"(",
")",
";",
"Path",
"subPath",
"=",
"child",
".",
"toPath",
"(",
")",
";",
"if",
"(",
"!",
"subPath",
".",
"startsWith",
"(",
"superPath",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not a subpath: \"",
"+",
"child",
")",
";",
"}",
"return",
"superPath",
".",
"relativize",
"(",
"subPath",
")",
".",
"toString",
"(",
")",
";",
"}"
] |
Return the relative path between a parent directory and some child path
@param parent
@param child
@return the relative path for the child
@throws IllegalArgumentException if child is not a subpath
|
[
"Return",
"the",
"relative",
"path",
"between",
"a",
"parent",
"directory",
"and",
"some",
"child",
"path"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/utils/FileUtils.java#L212-L219
|
15,890
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/NodeFirstWorkflowExecutor.java
|
NodeFirstWorkflowExecutor.executeWFSectionNodeDispatch
|
private WorkflowStatusDataResult executeWFSectionNodeDispatch(
StepExecutionContext executionContext,
int stepCount,
List<StepExecutionResult> results,
Map<String, Collection<StepExecutionResult>> failures,
final Map<Integer, StepExecutionResult> stepFailures,
IWorkflow flowsection,
WFSharedContext sharedContext
)
throws ExecutionServiceException, DispatcherException
{
logger.debug("Node dispatch for " + flowsection.getCommands().size() + " steps");
final DispatcherResult dispatch;
final WorkflowExecutionItem innerLoopItem = createInnerLoopItem(flowsection);
final Dispatchable dispatchedWorkflow = new DispatchedWorkflow(
getFramework().getWorkflowExecutionService(),
innerLoopItem,
stepCount,
executionContext.getStepContext()
);
WFSharedContext dispatchSharedContext = new WFSharedContext(sharedContext);
//dispatch the sequence of dispatched items to each node
dispatch = getFramework().getExecutionService().dispatchToNodes(
ExecutionContextImpl.builder(executionContext)
.sharedDataContext(dispatchSharedContext)
.stepNumber(stepCount)
.build(),
dispatchedWorkflow
);
logger.debug("Node dispatch result: " + dispatch);
WFSharedContext resultData = extractWFDispatcherResult(
dispatch,
results,
failures,
stepFailures,
flowsection.getCommands().size(),
stepCount
);
return workflowResult(dispatch.isSuccess(), null, ControlBehavior.Continue, resultData);
}
|
java
|
private WorkflowStatusDataResult executeWFSectionNodeDispatch(
StepExecutionContext executionContext,
int stepCount,
List<StepExecutionResult> results,
Map<String, Collection<StepExecutionResult>> failures,
final Map<Integer, StepExecutionResult> stepFailures,
IWorkflow flowsection,
WFSharedContext sharedContext
)
throws ExecutionServiceException, DispatcherException
{
logger.debug("Node dispatch for " + flowsection.getCommands().size() + " steps");
final DispatcherResult dispatch;
final WorkflowExecutionItem innerLoopItem = createInnerLoopItem(flowsection);
final Dispatchable dispatchedWorkflow = new DispatchedWorkflow(
getFramework().getWorkflowExecutionService(),
innerLoopItem,
stepCount,
executionContext.getStepContext()
);
WFSharedContext dispatchSharedContext = new WFSharedContext(sharedContext);
//dispatch the sequence of dispatched items to each node
dispatch = getFramework().getExecutionService().dispatchToNodes(
ExecutionContextImpl.builder(executionContext)
.sharedDataContext(dispatchSharedContext)
.stepNumber(stepCount)
.build(),
dispatchedWorkflow
);
logger.debug("Node dispatch result: " + dispatch);
WFSharedContext resultData = extractWFDispatcherResult(
dispatch,
results,
failures,
stepFailures,
flowsection.getCommands().size(),
stepCount
);
return workflowResult(dispatch.isSuccess(), null, ControlBehavior.Continue, resultData);
}
|
[
"private",
"WorkflowStatusDataResult",
"executeWFSectionNodeDispatch",
"(",
"StepExecutionContext",
"executionContext",
",",
"int",
"stepCount",
",",
"List",
"<",
"StepExecutionResult",
">",
"results",
",",
"Map",
"<",
"String",
",",
"Collection",
"<",
"StepExecutionResult",
">",
">",
"failures",
",",
"final",
"Map",
"<",
"Integer",
",",
"StepExecutionResult",
">",
"stepFailures",
",",
"IWorkflow",
"flowsection",
",",
"WFSharedContext",
"sharedContext",
")",
"throws",
"ExecutionServiceException",
",",
"DispatcherException",
"{",
"logger",
".",
"debug",
"(",
"\"Node dispatch for \"",
"+",
"flowsection",
".",
"getCommands",
"(",
")",
".",
"size",
"(",
")",
"+",
"\" steps\"",
")",
";",
"final",
"DispatcherResult",
"dispatch",
";",
"final",
"WorkflowExecutionItem",
"innerLoopItem",
"=",
"createInnerLoopItem",
"(",
"flowsection",
")",
";",
"final",
"Dispatchable",
"dispatchedWorkflow",
"=",
"new",
"DispatchedWorkflow",
"(",
"getFramework",
"(",
")",
".",
"getWorkflowExecutionService",
"(",
")",
",",
"innerLoopItem",
",",
"stepCount",
",",
"executionContext",
".",
"getStepContext",
"(",
")",
")",
";",
"WFSharedContext",
"dispatchSharedContext",
"=",
"new",
"WFSharedContext",
"(",
"sharedContext",
")",
";",
"//dispatch the sequence of dispatched items to each node",
"dispatch",
"=",
"getFramework",
"(",
")",
".",
"getExecutionService",
"(",
")",
".",
"dispatchToNodes",
"(",
"ExecutionContextImpl",
".",
"builder",
"(",
"executionContext",
")",
".",
"sharedDataContext",
"(",
"dispatchSharedContext",
")",
".",
"stepNumber",
"(",
"stepCount",
")",
".",
"build",
"(",
")",
",",
"dispatchedWorkflow",
")",
";",
"logger",
".",
"debug",
"(",
"\"Node dispatch result: \"",
"+",
"dispatch",
")",
";",
"WFSharedContext",
"resultData",
"=",
"extractWFDispatcherResult",
"(",
"dispatch",
",",
"results",
",",
"failures",
",",
"stepFailures",
",",
"flowsection",
".",
"getCommands",
"(",
")",
".",
"size",
"(",
")",
",",
"stepCount",
")",
";",
"return",
"workflowResult",
"(",
"dispatch",
".",
"isSuccess",
"(",
")",
",",
"null",
",",
"ControlBehavior",
".",
"Continue",
",",
"resultData",
")",
";",
"}"
] |
Execute a workflow section that should be dispatched across nodes
@return true if the section was succesful
|
[
"Execute",
"a",
"workflow",
"section",
"that",
"should",
"be",
"dispatched",
"across",
"nodes"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/NodeFirstWorkflowExecutor.java#L214-L256
|
15,891
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/NodeFirstWorkflowExecutor.java
|
NodeFirstWorkflowExecutor.splitWorkflowDispatchedSections
|
private List<IWorkflow> splitWorkflowDispatchedSections(IWorkflow workflow) throws ExecutionServiceException {
ArrayList<StepExecutionItem> dispatchItems = new ArrayList<>();
ArrayList<IWorkflow> sections = new ArrayList<>();
for (final StepExecutionItem item : workflow.getCommands()) {
StepExecutor executor = getFramework().getStepExecutionService().getExecutorForItem(item);
if (executor.isNodeDispatchStep(item)) {
dispatchItems.add(item);
} else {
if (dispatchItems.size() > 0) {
//add workflow section
sections.add(new WorkflowImpl(dispatchItems,
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
dispatchItems = new ArrayList<>();
}
sections.add(new WorkflowImpl(Collections.singletonList(item),
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
}
}
if (null != dispatchItems && dispatchItems.size() > 0) {
//add workflow section
sections.add(new WorkflowImpl(dispatchItems,
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
}
return sections;
}
|
java
|
private List<IWorkflow> splitWorkflowDispatchedSections(IWorkflow workflow) throws ExecutionServiceException {
ArrayList<StepExecutionItem> dispatchItems = new ArrayList<>();
ArrayList<IWorkflow> sections = new ArrayList<>();
for (final StepExecutionItem item : workflow.getCommands()) {
StepExecutor executor = getFramework().getStepExecutionService().getExecutorForItem(item);
if (executor.isNodeDispatchStep(item)) {
dispatchItems.add(item);
} else {
if (dispatchItems.size() > 0) {
//add workflow section
sections.add(new WorkflowImpl(dispatchItems,
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
dispatchItems = new ArrayList<>();
}
sections.add(new WorkflowImpl(Collections.singletonList(item),
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
}
}
if (null != dispatchItems && dispatchItems.size() > 0) {
//add workflow section
sections.add(new WorkflowImpl(dispatchItems,
workflow.getThreadcount(),
workflow.isKeepgoing(),
workflow.getStrategy()));
}
return sections;
}
|
[
"private",
"List",
"<",
"IWorkflow",
">",
"splitWorkflowDispatchedSections",
"(",
"IWorkflow",
"workflow",
")",
"throws",
"ExecutionServiceException",
"{",
"ArrayList",
"<",
"StepExecutionItem",
">",
"dispatchItems",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"ArrayList",
"<",
"IWorkflow",
">",
"sections",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"StepExecutionItem",
"item",
":",
"workflow",
".",
"getCommands",
"(",
")",
")",
"{",
"StepExecutor",
"executor",
"=",
"getFramework",
"(",
")",
".",
"getStepExecutionService",
"(",
")",
".",
"getExecutorForItem",
"(",
"item",
")",
";",
"if",
"(",
"executor",
".",
"isNodeDispatchStep",
"(",
"item",
")",
")",
"{",
"dispatchItems",
".",
"add",
"(",
"item",
")",
";",
"}",
"else",
"{",
"if",
"(",
"dispatchItems",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"//add workflow section",
"sections",
".",
"add",
"(",
"new",
"WorkflowImpl",
"(",
"dispatchItems",
",",
"workflow",
".",
"getThreadcount",
"(",
")",
",",
"workflow",
".",
"isKeepgoing",
"(",
")",
",",
"workflow",
".",
"getStrategy",
"(",
")",
")",
")",
";",
"dispatchItems",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"sections",
".",
"add",
"(",
"new",
"WorkflowImpl",
"(",
"Collections",
".",
"singletonList",
"(",
"item",
")",
",",
"workflow",
".",
"getThreadcount",
"(",
")",
",",
"workflow",
".",
"isKeepgoing",
"(",
")",
",",
"workflow",
".",
"getStrategy",
"(",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"dispatchItems",
"&&",
"dispatchItems",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"//add workflow section",
"sections",
".",
"add",
"(",
"new",
"WorkflowImpl",
"(",
"dispatchItems",
",",
"workflow",
".",
"getThreadcount",
"(",
")",
",",
"workflow",
".",
"isKeepgoing",
"(",
")",
",",
"workflow",
".",
"getStrategy",
"(",
")",
")",
")",
";",
"}",
"return",
"sections",
";",
"}"
] |
Splits a workflow into a sequence of sub-workflows, separated along boundaries of node-dispatch sets.
|
[
"Splits",
"a",
"workflow",
"into",
"a",
"sequence",
"of",
"sub",
"-",
"workflows",
"separated",
"along",
"boundaries",
"of",
"node",
"-",
"dispatch",
"sets",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/execution/workflow/NodeFirstWorkflowExecutor.java#L507-L538
|
15,892
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/tasks/net/SSHTaskBuilder.java
|
SSHTaskBuilder.build
|
public static ExtSSHExec build(final INodeEntry nodeentry, final String[] args,
final Project project,
final Map<String, Map<String, String>> dataContext,
final SSHConnectionInfo sshConnectionInfo, final int loglevel, final PluginLogger logger) throws
BuilderException {
final ExtSSHExec extSSHExec = new ExtSSHExec();
build(extSSHExec, nodeentry, args, project, dataContext, sshConnectionInfo,
loglevel, logger);
extSSHExec.setAntLogLevel(loglevel);
return extSSHExec;
}
|
java
|
public static ExtSSHExec build(final INodeEntry nodeentry, final String[] args,
final Project project,
final Map<String, Map<String, String>> dataContext,
final SSHConnectionInfo sshConnectionInfo, final int loglevel, final PluginLogger logger) throws
BuilderException {
final ExtSSHExec extSSHExec = new ExtSSHExec();
build(extSSHExec, nodeentry, args, project, dataContext, sshConnectionInfo,
loglevel, logger);
extSSHExec.setAntLogLevel(loglevel);
return extSSHExec;
}
|
[
"public",
"static",
"ExtSSHExec",
"build",
"(",
"final",
"INodeEntry",
"nodeentry",
",",
"final",
"String",
"[",
"]",
"args",
",",
"final",
"Project",
"project",
",",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"dataContext",
",",
"final",
"SSHConnectionInfo",
"sshConnectionInfo",
",",
"final",
"int",
"loglevel",
",",
"final",
"PluginLogger",
"logger",
")",
"throws",
"BuilderException",
"{",
"final",
"ExtSSHExec",
"extSSHExec",
"=",
"new",
"ExtSSHExec",
"(",
")",
";",
"build",
"(",
"extSSHExec",
",",
"nodeentry",
",",
"args",
",",
"project",
",",
"dataContext",
",",
"sshConnectionInfo",
",",
"loglevel",
",",
"logger",
")",
";",
"extSSHExec",
".",
"setAntLogLevel",
"(",
"loglevel",
")",
";",
"return",
"extSSHExec",
";",
"}"
] |
Build a Task that performs SSH command
@param loglevel level
@param nodeentry target node
@param args arguments
@param project ant project
@param dataContext data
@param logger logger
@param sshConnectionInfo connection info
@return task
@throws BuilderException on error
|
[
"Build",
"a",
"Task",
"that",
"performs",
"SSH",
"command"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/tasks/net/SSHTaskBuilder.java#L549-L563
|
15,893
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java
|
FilePluginCache.remove
|
private void remove(final ProviderIdent ident) {
final cacheItem cacheItem = cache.get(ident);
if (null != cacheItem) {
filecache.remove(cacheItem.getFirst());
}
cache.remove(ident);
}
|
java
|
private void remove(final ProviderIdent ident) {
final cacheItem cacheItem = cache.get(ident);
if (null != cacheItem) {
filecache.remove(cacheItem.getFirst());
}
cache.remove(ident);
}
|
[
"private",
"void",
"remove",
"(",
"final",
"ProviderIdent",
"ident",
")",
"{",
"final",
"cacheItem",
"cacheItem",
"=",
"cache",
".",
"get",
"(",
"ident",
")",
";",
"if",
"(",
"null",
"!=",
"cacheItem",
")",
"{",
"filecache",
".",
"remove",
"(",
"cacheItem",
".",
"getFirst",
"(",
")",
")",
";",
"}",
"cache",
".",
"remove",
"(",
"ident",
")",
";",
"}"
] |
Remove the association with ident, and remove any filecache association as well.
|
[
"Remove",
"the",
"association",
"with",
"ident",
"and",
"remove",
"any",
"filecache",
"association",
"as",
"well",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java#L91-L97
|
15,894
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java
|
FilePluginCache.getLoaderForIdent
|
public synchronized ProviderLoader getLoaderForIdent(final ProviderIdent ident) throws ProviderLoaderException {
final cacheItem cacheItem = cache.get(ident);
if (null == cacheItem) {
return rescanForItem(ident);
}
final File file = cacheItem.getFirst();
if (cacheItem.getSecond().isExpired(ident, file)) {
remove(ident);
return rescanForItem(ident);
} else {
return loadFileProvider(cacheItem);
}
}
|
java
|
public synchronized ProviderLoader getLoaderForIdent(final ProviderIdent ident) throws ProviderLoaderException {
final cacheItem cacheItem = cache.get(ident);
if (null == cacheItem) {
return rescanForItem(ident);
}
final File file = cacheItem.getFirst();
if (cacheItem.getSecond().isExpired(ident, file)) {
remove(ident);
return rescanForItem(ident);
} else {
return loadFileProvider(cacheItem);
}
}
|
[
"public",
"synchronized",
"ProviderLoader",
"getLoaderForIdent",
"(",
"final",
"ProviderIdent",
"ident",
")",
"throws",
"ProviderLoaderException",
"{",
"final",
"cacheItem",
"cacheItem",
"=",
"cache",
".",
"get",
"(",
"ident",
")",
";",
"if",
"(",
"null",
"==",
"cacheItem",
")",
"{",
"return",
"rescanForItem",
"(",
"ident",
")",
";",
"}",
"final",
"File",
"file",
"=",
"cacheItem",
".",
"getFirst",
"(",
")",
";",
"if",
"(",
"cacheItem",
".",
"getSecond",
"(",
")",
".",
"isExpired",
"(",
"ident",
",",
"file",
")",
")",
"{",
"remove",
"(",
"ident",
")",
";",
"return",
"rescanForItem",
"(",
"ident",
")",
";",
"}",
"else",
"{",
"return",
"loadFileProvider",
"(",
"cacheItem",
")",
";",
"}",
"}"
] |
Get the loader for the provider
@param ident provider ident
@return loader for the provider
|
[
"Get",
"the",
"loader",
"for",
"the",
"provider"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java#L106-L119
|
15,895
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java
|
FilePluginCache.loadFileProvider
|
private ProviderLoader loadFileProvider(final cacheItem cached) {
final File file = cached.getFirst();
final PluginScanner second = cached.getSecond();
return filecache.get(file, second);
}
|
java
|
private ProviderLoader loadFileProvider(final cacheItem cached) {
final File file = cached.getFirst();
final PluginScanner second = cached.getSecond();
return filecache.get(file, second);
}
|
[
"private",
"ProviderLoader",
"loadFileProvider",
"(",
"final",
"cacheItem",
"cached",
")",
"{",
"final",
"File",
"file",
"=",
"cached",
".",
"getFirst",
"(",
")",
";",
"final",
"PluginScanner",
"second",
"=",
"cached",
".",
"getSecond",
"(",
")",
";",
"return",
"filecache",
".",
"get",
"(",
"file",
",",
"second",
")",
";",
"}"
] |
return the loader stored in filecache for the file and scanner
|
[
"return",
"the",
"loader",
"stored",
"in",
"filecache",
"for",
"the",
"file",
"and",
"scanner"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java#L133-L137
|
15,896
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java
|
FilePluginCache.rescanForItem
|
private synchronized ProviderLoader rescanForItem(final ProviderIdent ident) throws ProviderLoaderException {
File candidate = null;
PluginScanner cscanner = null;
for (final PluginScanner scanner : getScanners()) {
final File file = scanner.scanForFile(ident);
if (null != file) {
if (null != candidate) {
throw new ProviderLoaderException(
"More than one plugin file matched: " + file + ", and " + candidate,
ident.getService(), ident.getProviderName()
);
}
candidate = file;
cscanner = scanner;
}
}
if (null != candidate) {
final cacheItem cacheItem = new cacheItem(candidate, cscanner);
cache.put(ident, cacheItem);
return loadFileProvider(cacheItem);
}
return null;
}
|
java
|
private synchronized ProviderLoader rescanForItem(final ProviderIdent ident) throws ProviderLoaderException {
File candidate = null;
PluginScanner cscanner = null;
for (final PluginScanner scanner : getScanners()) {
final File file = scanner.scanForFile(ident);
if (null != file) {
if (null != candidate) {
throw new ProviderLoaderException(
"More than one plugin file matched: " + file + ", and " + candidate,
ident.getService(), ident.getProviderName()
);
}
candidate = file;
cscanner = scanner;
}
}
if (null != candidate) {
final cacheItem cacheItem = new cacheItem(candidate, cscanner);
cache.put(ident, cacheItem);
return loadFileProvider(cacheItem);
}
return null;
}
|
[
"private",
"synchronized",
"ProviderLoader",
"rescanForItem",
"(",
"final",
"ProviderIdent",
"ident",
")",
"throws",
"ProviderLoaderException",
"{",
"File",
"candidate",
"=",
"null",
";",
"PluginScanner",
"cscanner",
"=",
"null",
";",
"for",
"(",
"final",
"PluginScanner",
"scanner",
":",
"getScanners",
"(",
")",
")",
"{",
"final",
"File",
"file",
"=",
"scanner",
".",
"scanForFile",
"(",
"ident",
")",
";",
"if",
"(",
"null",
"!=",
"file",
")",
"{",
"if",
"(",
"null",
"!=",
"candidate",
")",
"{",
"throw",
"new",
"ProviderLoaderException",
"(",
"\"More than one plugin file matched: \"",
"+",
"file",
"+",
"\", and \"",
"+",
"candidate",
",",
"ident",
".",
"getService",
"(",
")",
",",
"ident",
".",
"getProviderName",
"(",
")",
")",
";",
"}",
"candidate",
"=",
"file",
";",
"cscanner",
"=",
"scanner",
";",
"}",
"}",
"if",
"(",
"null",
"!=",
"candidate",
")",
"{",
"final",
"cacheItem",
"cacheItem",
"=",
"new",
"cacheItem",
"(",
"candidate",
",",
"cscanner",
")",
";",
"cache",
".",
"put",
"(",
"ident",
",",
"cacheItem",
")",
";",
"return",
"loadFileProvider",
"(",
"cacheItem",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Rescan for the ident and cache and return the loader
|
[
"Rescan",
"for",
"the",
"ident",
"and",
"cache",
"and",
"return",
"the",
"loader"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/plugins/FilePluginCache.java#L142-L164
|
15,897
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java
|
ExtSSHExec.addEnv
|
public void addEnv(final Environment.Variable env){
if(null==envVars) {
envVars = new ArrayList<Environment.Variable>();
}
envVars.add(env);
}
|
java
|
public void addEnv(final Environment.Variable env){
if(null==envVars) {
envVars = new ArrayList<Environment.Variable>();
}
envVars.add(env);
}
|
[
"public",
"void",
"addEnv",
"(",
"final",
"Environment",
".",
"Variable",
"env",
")",
"{",
"if",
"(",
"null",
"==",
"envVars",
")",
"{",
"envVars",
"=",
"new",
"ArrayList",
"<",
"Environment",
".",
"Variable",
">",
"(",
")",
";",
"}",
"envVars",
".",
"add",
"(",
"env",
")",
";",
"}"
] |
Add an Env element
@param env element
|
[
"Add",
"an",
"Env",
"element"
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java#L222-L227
|
15,898
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java
|
ExtSSHExec.execute
|
public void execute() throws BuildException {
if (getHost() == null) {
throw new BuildException("Host is required.");
}
if (getUserInfo().getName() == null) {
throw new BuildException("Username is required.");
}
if (getUserInfo().getKeyfile() == null
&& getUserInfo().getPassword() == null
&& getSshKeyData() == null) {
throw new BuildException("Password or Keyfile is required.");
}
if (command == null && commandResource == null) {
throw new BuildException("Command or commandResource is required.");
}
if (inputFile != null && inputProperty != null) {
throw new BuildException("You can't specify both inputFile and"
+ " inputProperty.");
}
if (inputFile != null && !inputFile.exists()) {
throw new BuildException("The input file "
+ inputFile.getAbsolutePath()
+ " does not exist.");
}
Session session = null;
StringBuffer output = new StringBuffer();
try {
session = openSession();
if(null!=getDisconnectHolder()){
final Session sub=session;
getDisconnectHolder().setDisconnectable(new Disconnectable() {
public void disconnect() {
sub.disconnect();
}
});
}
/* called once */
if (command != null) {
executeCommand(session, command, output);
} else { // read command resource and execute for each command
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(commandResource.getInputStream()));
String cmd;
while ((cmd = br.readLine()) != null) {
executeCommand(session, cmd, output);
output.append("\n");
}
FileUtils.close(br);
} catch (IOException e) {
if (getFailonerror()) {
throw new BuildException(e);
} else {
log("Caught exception: " + e.getMessage(),
Project.MSG_ERR);
}
}
}
} catch (JSchException e) {
if (getFailonerror()) {
throw new BuildException(e);
} else {
log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
} finally {
try {
if (null != this.sshAgentProcess) {
this.sshAgentProcess.stopAgent();
}
} catch (IOException e) {
log( "Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
if (outputProperty != null) {
getProject().setNewProperty(outputProperty, output.toString());
}
if (session != null && session.isConnected()) {
session.disconnect();
}
}
}
|
java
|
public void execute() throws BuildException {
if (getHost() == null) {
throw new BuildException("Host is required.");
}
if (getUserInfo().getName() == null) {
throw new BuildException("Username is required.");
}
if (getUserInfo().getKeyfile() == null
&& getUserInfo().getPassword() == null
&& getSshKeyData() == null) {
throw new BuildException("Password or Keyfile is required.");
}
if (command == null && commandResource == null) {
throw new BuildException("Command or commandResource is required.");
}
if (inputFile != null && inputProperty != null) {
throw new BuildException("You can't specify both inputFile and"
+ " inputProperty.");
}
if (inputFile != null && !inputFile.exists()) {
throw new BuildException("The input file "
+ inputFile.getAbsolutePath()
+ " does not exist.");
}
Session session = null;
StringBuffer output = new StringBuffer();
try {
session = openSession();
if(null!=getDisconnectHolder()){
final Session sub=session;
getDisconnectHolder().setDisconnectable(new Disconnectable() {
public void disconnect() {
sub.disconnect();
}
});
}
/* called once */
if (command != null) {
executeCommand(session, command, output);
} else { // read command resource and execute for each command
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(commandResource.getInputStream()));
String cmd;
while ((cmd = br.readLine()) != null) {
executeCommand(session, cmd, output);
output.append("\n");
}
FileUtils.close(br);
} catch (IOException e) {
if (getFailonerror()) {
throw new BuildException(e);
} else {
log("Caught exception: " + e.getMessage(),
Project.MSG_ERR);
}
}
}
} catch (JSchException e) {
if (getFailonerror()) {
throw new BuildException(e);
} else {
log("Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
} finally {
try {
if (null != this.sshAgentProcess) {
this.sshAgentProcess.stopAgent();
}
} catch (IOException e) {
log( "Caught exception: " + e.getMessage(), Project.MSG_ERR);
}
if (outputProperty != null) {
getProject().setNewProperty(outputProperty, output.toString());
}
if (session != null && session.isConnected()) {
session.disconnect();
}
}
}
|
[
"public",
"void",
"execute",
"(",
")",
"throws",
"BuildException",
"{",
"if",
"(",
"getHost",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Host is required.\"",
")",
";",
"}",
"if",
"(",
"getUserInfo",
"(",
")",
".",
"getName",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Username is required.\"",
")",
";",
"}",
"if",
"(",
"getUserInfo",
"(",
")",
".",
"getKeyfile",
"(",
")",
"==",
"null",
"&&",
"getUserInfo",
"(",
")",
".",
"getPassword",
"(",
")",
"==",
"null",
"&&",
"getSshKeyData",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Password or Keyfile is required.\"",
")",
";",
"}",
"if",
"(",
"command",
"==",
"null",
"&&",
"commandResource",
"==",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"Command or commandResource is required.\"",
")",
";",
"}",
"if",
"(",
"inputFile",
"!=",
"null",
"&&",
"inputProperty",
"!=",
"null",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"You can't specify both inputFile and\"",
"+",
"\" inputProperty.\"",
")",
";",
"}",
"if",
"(",
"inputFile",
"!=",
"null",
"&&",
"!",
"inputFile",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"\"The input file \"",
"+",
"inputFile",
".",
"getAbsolutePath",
"(",
")",
"+",
"\" does not exist.\"",
")",
";",
"}",
"Session",
"session",
"=",
"null",
";",
"StringBuffer",
"output",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"try",
"{",
"session",
"=",
"openSession",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"getDisconnectHolder",
"(",
")",
")",
"{",
"final",
"Session",
"sub",
"=",
"session",
";",
"getDisconnectHolder",
"(",
")",
".",
"setDisconnectable",
"(",
"new",
"Disconnectable",
"(",
")",
"{",
"public",
"void",
"disconnect",
"(",
")",
"{",
"sub",
".",
"disconnect",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"/* called once */",
"if",
"(",
"command",
"!=",
"null",
")",
"{",
"executeCommand",
"(",
"session",
",",
"command",
",",
"output",
")",
";",
"}",
"else",
"{",
"// read command resource and execute for each command",
"try",
"{",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"commandResource",
".",
"getInputStream",
"(",
")",
")",
")",
";",
"String",
"cmd",
";",
"while",
"(",
"(",
"cmd",
"=",
"br",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"executeCommand",
"(",
"session",
",",
"cmd",
",",
"output",
")",
";",
"output",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"}",
"FileUtils",
".",
"close",
"(",
"br",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"if",
"(",
"getFailonerror",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"e",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"Caught exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"JSchException",
"e",
")",
"{",
"if",
"(",
"getFailonerror",
"(",
")",
")",
"{",
"throw",
"new",
"BuildException",
"(",
"e",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"Caught exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"null",
"!=",
"this",
".",
"sshAgentProcess",
")",
"{",
"this",
".",
"sshAgentProcess",
".",
"stopAgent",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"log",
"(",
"\"Caught exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"Project",
".",
"MSG_ERR",
")",
";",
"}",
"if",
"(",
"outputProperty",
"!=",
"null",
")",
"{",
"getProject",
"(",
")",
".",
"setNewProperty",
"(",
"outputProperty",
",",
"output",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"session",
"!=",
"null",
"&&",
"session",
".",
"isConnected",
"(",
")",
")",
"{",
"session",
".",
"disconnect",
"(",
")",
";",
"}",
"}",
"}"
] |
Execute the command on the remote host.
@exception BuildException Most likely a network error or bad parameter.
|
[
"Execute",
"the",
"command",
"on",
"the",
"remote",
"host",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java#L302-L385
|
15,899
|
rundeck/rundeck
|
core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java
|
ExtSSHExec.writeToFile
|
private void writeToFile(String from, boolean append, File to)
throws IOException {
FileWriter out = null;
try {
out = new FileWriter(to.getAbsolutePath(), append);
StringReader in = new StringReader(from);
char[] buffer = new char[BUFFER_SIZE];
int bytesRead;
while (true) {
bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
out.write(buffer, 0, bytesRead);
}
out.flush();
} finally {
if (out != null) {
out.close();
}
}
}
|
java
|
private void writeToFile(String from, boolean append, File to)
throws IOException {
FileWriter out = null;
try {
out = new FileWriter(to.getAbsolutePath(), append);
StringReader in = new StringReader(from);
char[] buffer = new char[BUFFER_SIZE];
int bytesRead;
while (true) {
bytesRead = in.read(buffer);
if (bytesRead == -1) {
break;
}
out.write(buffer, 0, bytesRead);
}
out.flush();
} finally {
if (out != null) {
out.close();
}
}
}
|
[
"private",
"void",
"writeToFile",
"(",
"String",
"from",
",",
"boolean",
"append",
",",
"File",
"to",
")",
"throws",
"IOException",
"{",
"FileWriter",
"out",
"=",
"null",
";",
"try",
"{",
"out",
"=",
"new",
"FileWriter",
"(",
"to",
".",
"getAbsolutePath",
"(",
")",
",",
"append",
")",
";",
"StringReader",
"in",
"=",
"new",
"StringReader",
"(",
"from",
")",
";",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"BUFFER_SIZE",
"]",
";",
"int",
"bytesRead",
";",
"while",
"(",
"true",
")",
"{",
"bytesRead",
"=",
"in",
".",
"read",
"(",
"buffer",
")",
";",
"if",
"(",
"bytesRead",
"==",
"-",
"1",
")",
"{",
"break",
";",
"}",
"out",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"bytesRead",
")",
";",
"}",
"out",
".",
"flush",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Writes a string to a file. If destination file exists, it may be
overwritten depending on the "append" value.
@param from string to write
@param to file to write to
@param append if true, append to existing file, else overwrite
@exception IOException on io error
|
[
"Writes",
"a",
"string",
"to",
"a",
"file",
".",
"If",
"destination",
"file",
"exists",
"it",
"may",
"be",
"overwritten",
"depending",
"on",
"the",
"append",
"value",
"."
] |
8070f774f55bffaa1118ff0c03aea319d40a9668
|
https://github.com/rundeck/rundeck/blob/8070f774f55bffaa1118ff0c03aea319d40a9668/core/src/main/java/com/dtolabs/rundeck/core/tasks/net/ExtSSHExec.java#L547-L568
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.