+ protected void help(String[] rawArgs, StringBuilder buf) {
+ String[] args = Arrays.copyOfRange(rawArgs, 1, rawArgs.length);
+ List<URI> uris = asURIs(args);
+ uris: for (URI uri : uris) {
+ String[] path = uri.getPath().split("/");
+ if (path.length < 2) {
+ for (ExecutionModuleDescriptor emd : agent
+ .listExecutionModuleDescriptors()) {
+ buf.append(
+ "# Execution Module " + emd.getName() + " v"
+ + emd.getVersion()).append('\n');
+ if (emd.getDescription() != null
+ && !emd.getDescription().trim().equals(""))
+ buf.append(emd.getDescription()).append('\n');
+ }
+ continue uris;
+ }
+
+ String moduleName = path[1];
+ // TODO process version
+ String moduleVersion = null;
+
+ ExecutionModuleDescriptor emd = agent.getExecutionModuleDescriptor(
+ moduleName, moduleVersion);
+
+ if (path.length >= 2) {
+ StringBuilder flow = new StringBuilder();
+ for (int i = 2; i < path.length; i++)
+ flow.append('/').append(path[i]);
+ String flowPath = flow.toString();
+ ExecutionFlowDescriptor flowDescriptor = null;
+ for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
+ if (efd.getName().equals(flowPath)) {
+ flowDescriptor = efd;
+ break;
+ }
+ }
+ if (flowDescriptor == null)
+ throw new SlcException("Flow " + uri + " not found");
+
+ buf.append(
+ "# Execution Module " + emd.getName() + " v"
+ + emd.getVersion()).append('\n');
+ buf.append(" Flow ").append(flowDescriptor.getName());
+ if (flowDescriptor.getDescription() != null
+ && !flowDescriptor.getDescription().trim().equals(""))
+ buf.append(" ").append(flowDescriptor.getDescription());
+ buf.append('\n');
+ ExecutionSpec spec = flowDescriptor.getExecutionSpec();
+ for (String attrKey : spec.getAttributes().keySet()) {
+ ExecutionSpecAttribute esa = spec.getAttributes().get(
+ attrKey);
+ buf.append(" --").append(attrKey);
+ // TODO check values in query part
+ if (esa.getValue() != null)
+ buf.append(" ").append(esa.getValue());
+ buf.append('\n');
+ }
+ } else {
+ // module only
+ buf.append(
+ "# Execution Module " + emd.getName() + " v"
+ + emd.getVersion()).append('\n');
+ if (emd.getDescription() != null
+ && !emd.getDescription().trim().equals(""))
+ buf.append(emd.getDescription()).append('\n');
+ for (ExecutionFlowDescriptor efd : emd.getExecutionFlows()) {
+ buf.append(" ").append(efd.getName());
+ if (efd.getDescription() != null
+ && !efd.getDescription().trim().equals(""))
+ buf.append(" ").append(efd.getDescription());
+ }
+ buf.append('\n');
+ }
+ }
+ }
+