in taverna-external-tool-activity-ui/src/main/java/org/apache/taverna/activities/externaltool/views/ExternalToolConfigView.java [607:816]
public boolean checkValues() {
if (isFromRepository()) {
return true;
}
boolean result = true;
String text = "";
Set<String> stringReplacementPortNames = new HashSet<String>();
Set<String> stringReplacementTags = new HashSet<String>();
for (ExternalToolStringReplacementViewer v : stringReplacementViewList) {
String name = v.getName();
if (name.equalsIgnoreCase("stdin") || name.equalsIgnoreCase("stdout") || name.equalsIgnoreCase("stderr")) {
text += "A string replacement port has a reserved name \"" + name + "\"\n";
result = false;
}
else if (stringReplacementPortNames.contains(name)) {
text += "Two string replacement ports have the name \"" + name
+ "\"\n";
result = false;
} else if (!name.matches(VALID_NAME_REGEX)) {
text += "String replacement port name \"" + name
+ "\" is invalid\n";
result = false;
} else {
stringReplacementPortNames.add(name);
}
String tag = v.getValue();
if (stringReplacementTags.contains(tag)) {
text += "Two string replacement ports replace \"%%" + tag
+ "%%\"\n";
result = false;
} else if (!tag.matches(VALID_NAME_REGEX)) {
text += "String replacement tag \"%%" + tag
+ "%%\" is invalid\n";
result = false;
} else {
stringReplacementTags.add(tag);
}
}
Matcher m = tagPattern.matcher(scriptTextArea.getText());
Set<String> tags = new HashSet<String>();
while (m.find()) {
String tag = m.group(1);
if (tag != null) {
if (tag.isEmpty()) {
text += "The command contains an empty tag i.e. %%%%\n";
result = false;
} else {
if (!tag.matches(VALID_NAME_REGEX)) {
text += "The command contains an invalid tag \"%%"
+ tag + "\"%%\n";
result = false;
}
if (!stringReplacementTags.contains(tag)) {
text += "There is no string replacement for %%" + tag
+ "%%\n";
result = false;
} else {
tags.add(tag);
}
}
}
}
for (String tag : stringReplacementTags) {
if (!tags.contains(tag)) {
text += "String replacement for %%" + tag
+ "%% is not used in the command\n";
result = false;
}
}
Set<String> inputFilePortNames = new HashSet<String>();
Set<String> inputFileNames = new HashSet<String>();
for (ExternalToolFileViewer v : inputFileViewList) {
String name = v.getName();
if (name.equalsIgnoreCase("stdin") || name.equalsIgnoreCase("stdout") || name.equalsIgnoreCase("stderr")) {
text += "An input file port has a reserved name \"" + name + "\"\n";
result = false;
}
else if (stringReplacementPortNames.contains(name)) {
text += "A string replacement port and an input file port have the name \""
+ name + "\"\n";
result = false;
} else if (inputFilePortNames.contains(name)) {
text += "Two file input ports have the name \"" + name + "\"\n";
result = false;
} else if (!name.matches(VALID_NAME_REGEX)) {
text += "File input port name \"" + name + "\" is invalid\n";
result = false;
} else {
inputFilePortNames.add(name);
}
String fileName = v.getValue();
if (inputFileNames.contains(fileName)) {
text += "Two file inputs ports write to the same file \""
+ fileName + "\"\n";
result = false;
} else {
inputFileNames.add(fileName);
}
}
Set<String> fileListPortNames = new HashSet<String>();
Set<String> fileListFileNames = new HashSet<String>();
for (ExternalToolFileViewer v : fileListViewList) {
String name = v.getName();
if (name.equalsIgnoreCase("stdin") || name.equalsIgnoreCase("stdout") || name.equalsIgnoreCase("stderr")) {
text += "A file list port has a reserved name \"" + name + "\"\n";
result = false;
} else if (stringReplacementPortNames.contains(name)) {
text += "A string replacement port and a file list port have the name \""
+ name + "\"\n";
result = false;
} else if (inputFilePortNames.contains(name)) {
text += "A file input port and a file list port have the name \""
+ name + "\"\n";
result = false;
} else if (fileListPortNames.contains(name)) {
text += "Two file list ports have the name \"" + name + "\"\n";
result = false;
} else if (!name.matches(VALID_NAME_REGEX)) {
text += "File list port name \"" + name + "\" is invalid\n";
result = false;
} else {
fileListPortNames.add(name);
}
String fileName = v.getValue();
if (fileListFileNames.contains(fileName)) {
text += "Two file list ports write to the same file \""
+ fileName + "\"\n";
result = false;
} else if (inputFileNames.contains(fileName)) {
text += "A file input port and a file list port write to the same file \""
+ fileName + "\"\n";
result = false;
} else {
fileListFileNames.add(fileName);
}
}
Set<String> staticStringFileNames = new HashSet<String>();
for (ExternalToolStaticStringViewer v : staticStringViewList) {
String fileName = v.getValue();
if (staticStringFileNames.contains(fileName)) {
text += "Two static strings write to the same file \""
+ fileName + "\"\n";
result = false;
} else if (inputFileNames.contains(fileName)) {
text += "A file input port and a static string write to the same file \""
+ fileName + "\"\n";
result = false;
} else if (fileListFileNames.contains(fileName)) {
text += "A file list port and a static string write to the same file \""
+ fileName + "\"\n";
result = false;
} else {
staticStringFileNames.add(fileName);
}
}
Set<String> staticUrlFileNames = new HashSet<String>();
for (ExternalToolStaticUrlViewer v : staticUrlViewList) {
String fileName = v.getValue();
if (staticUrlFileNames.contains(fileName)) {
text += "Two static URLss write to the same file \"" + fileName
+ "\"\n";
result = false;
} else if (inputFileNames.contains(fileName)) {
text += "A file input port and a static URL write to the same file \""
+ fileName + "\"\n";
result = false;
} else if (fileListFileNames.contains(fileName)) {
text += "A file list port and a static URL write to the same file \""
+ fileName + "\"\n";
result = false;
} else if (staticStringFileNames.contains(fileName)) {
text += "A static string and a static URL write to the same file \""
+ fileName + "\"\n";
result = false;
} else {
staticUrlFileNames.add(fileName);
}
}
Set<String> outputPortNames = new HashSet<String>();
for (ExternalToolFileViewer v : outputViewList) {
String name = v.getName();
if (name.equalsIgnoreCase("stdin") || name.equalsIgnoreCase("stdout") || name.equalsIgnoreCase("stderr")) {
text += "An output port has a reserved name \"" + name + "\"\n";
result = false;
} else if (outputPortNames.contains(name)) {
text += "Two output file ports have the name \"" + name
+ "\"\n";
result = false;
} else if (!name.matches(VALID_NAME_REGEX)) {
text += "Output file port name \"" + name + "\" is invalid\n";
result = false;
} else {
outputPortNames.add(name);
}
}
if (!result) {
JOptionPane.showMessageDialog(this, text, "Problems",
JOptionPane.ERROR_MESSAGE);
}
return result;
}