"Cannot load class for procedure: %s",
className), cause);
}
}
ProcedureDescriptor descriptor = m_compiler.new ProcedureDescriptor(
new ArrayList<String>(), Language.JAVA, null, clazz);
// Add roles if specified.
if (statementMatcher.group(1) != null) {
for (String roleName : StringUtils.split(statementMatcher.group(1), ',')) {
// Don't put the same role in the list more than once.
String roleNameFixed = roleName.trim().toLowerCase();
if (!descriptor.m_authGroups.contains(roleNameFixed)) {
descriptor.m_authGroups.add(roleNameFixed);
}
}
}
// track the defined procedure
m_tracker.add(descriptor);
return true;
}
// matches if it is CREATE PROCEDURE <proc-name> [ALLOW <role> ...] AS <select-or-dml-statement>
statementMatcher = procedureSingleStatementPattern.matcher(statement);
if (statementMatcher.matches()) {
String clazz = checkIdentifierStart(statementMatcher.group(1), statement);
String sqlStatement = statementMatcher.group(3) + ";";
ProcedureDescriptor descriptor = m_compiler.new ProcedureDescriptor(
new ArrayList<String>(), clazz, sqlStatement, null, null, false, null, null, null);
// Add roles if specified.
if (statementMatcher.group(2) != null) {
for (String roleName : StringUtils.split(statementMatcher.group(2), ',')) {
descriptor.m_authGroups.add(roleName.trim().toLowerCase());
}
}
m_tracker.add(descriptor);
return true;
}
// matches if it is CREATE PROCEDURE <proc-name> [ALLOW <role> ...] AS
// ### <code-block> ### LANGUAGE <language-name>
statementMatcher = procedureWithScriptPattern.matcher(statement);
if (statementMatcher.matches()) {
String className = checkIdentifierStart(statementMatcher.group(1), statement);
String codeBlock = statementMatcher.group(3);
Language language = Language.valueOf(statementMatcher.group(4).toUpperCase());
Class<?> scriptClass = null;
if (language == Language.GROOVY) {
try {
scriptClass = GroovyCodeBlockCompiler.instance().parseCodeBlock(codeBlock, className);
} catch (CodeBlockCompilerException ex) {
throw m_compiler.new VoltCompilerException(String.format(
"Procedure \"%s\" code block has syntax errors:\n%s",
className, ex.getMessage()));
} catch (Exception ex) {
throw m_compiler.new VoltCompilerException(ex);
}
} else {
throw m_compiler.new VoltCompilerException(String.format(
"Language \"%s\" is not a supported", language.name()));
}
ProcedureDescriptor descriptor = m_compiler.new ProcedureDescriptor(
new ArrayList<String>(), language, codeBlock, scriptClass);
// Add roles if specified.
if (statementMatcher.group(2) != null) {
for (String roleName : StringUtils.split(statementMatcher.group(2), ',')) {