in taverna-rest-activity-ui/src/main/java/org/apache/taverna/activities/rest/ui/config/RESTActivityConfigurationPanel.java [160:219]
public boolean checkValues() {
// HTTP method is a fixed selection combo-box - no validation required
// URL signature must be present and be valid
String candidateURLSignature = tfURLSignature.getText().trim();
if (candidateURLSignature == null
|| candidateURLSignature.length() == 0) {
JOptionPane.showMessageDialog(MainWindow.getMainWindow(),
"URL signature must not be empty",
"REST Activity Configuration - Warning",
JOptionPane.WARNING_MESSAGE);
return (false);
} else {
try {
// Test if any exceptions will be thrown - if not, proceed to
// other validations
URISignatureHandler.validate(candidateURLSignature);
} catch (URISignatureParsingException e) {
JOptionPane.showMessageDialog(MainWindow.getMainWindow(), e
.getMessage(), "REST Activity Configuration - Warning",
JOptionPane.WARNING_MESSAGE);
return (false);
}
// Test if the URL string contains "unsafe" characters, i.e. characters
// that need URL-encoding.
// From RFC 1738: "...Only alphanumerics [0-9a-zA-Z], the special
// characters "$-_.+!*'()," (not including the quotes) and reserved
// characters used for their reserved purposes may be
// used unencoded within a URL."
// Reserved characters are: ";/?:@&=" ..." (excluding quotes) and "%" used
// for escaping.
// We do not warn the user if they have not properly enclosed parameter
// names in curly braces as this check is already being done elsewhere in the code.
// We do not check the characters in parameter names either.
try {
// Test if any exceptions will be thrown - if not, proceed to
// other validations
URISignatureHandler.checkForUnsafeCharacters(candidateURLSignature);
} catch (URISignatureParsingException e) {
JOptionPane.showMessageDialog(MainWindow.getMainWindow(), e
.getMessage(), "REST Activity Configuration - Warning",
JOptionPane.WARNING_MESSAGE);
return (false);
}
// Other HTTP headers configured must not have empty names
ArrayList<String> otherHTTPHeaderNames = httpHeadersTableModel.getHTTPHeaderNames();
for (String headerName : otherHTTPHeaderNames){
if (headerName.equals("")){
JOptionPane.showMessageDialog(MainWindow.getMainWindow(), "One of the HTTP header names is empty", "REST Activity Configuration - Warning",
JOptionPane.WARNING_MESSAGE);
return false;
}
}
}
// All valid, return true
return true;
}