use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class EmailActionExecutor method validateAndMail.
@SuppressWarnings("unchecked")
protected void validateAndMail(Context context, Element element) throws ActionExecutorException {
// The XSD does the min/max occurrence validation for us.
Namespace ns = element.getNamespace();
String[] tos = new String[0];
String[] ccs = new String[0];
String[] bccs;
String subject = "";
String body = "";
String[] attachments = new String[0];
String contentType;
Element child = null;
// <to> - One ought to exist.
String text = element.getChildTextTrim(TO, ns);
if (text.isEmpty()) {
throw new ActionExecutorException(ErrorType.ERROR, "EM001", "No recipients were specified in the to-address field.");
}
tos = text.split(COMMA);
// <cc> - Optional, but only one ought to exist.
try {
ccs = element.getChildTextTrim(CC, ns).split(COMMA);
} catch (Exception e) {
// It is alright for cc to be given empty or not be present.
ccs = new String[0];
}
// <bcc> - Optional, but only one ought to exist.
try {
bccs = element.getChildTextTrim(BCC, ns).split(COMMA);
} catch (Exception e) {
// It is alright for bcc to be given empty or not be present.
bccs = new String[0];
}
// <subject> - One ought to exist.
subject = element.getChildTextTrim(SUB, ns);
// <body> - One ought to exist.
body = element.getChildTextTrim(BOD, ns);
// <attachment> - Optional
String attachment = element.getChildTextTrim(ATTACHMENT, ns);
if (attachment != null) {
attachments = attachment.split(COMMA);
}
contentType = element.getChildTextTrim(CONTENT_TYPE, ns);
if (contentType == null || contentType.isEmpty()) {
contentType = DEFAULT_CONTENT_TYPE;
}
// All good - lets try to mail!
email(tos, ccs, bccs, subject, body, attachments, contentType, context.getWorkflow().getUser());
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class EmailActionExecutor method start.
@Override
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
LOG.info("Starting action");
try {
context.setStartData("-", "-", "-");
Element actionXml = XmlUtils.parseXml(action.getConf());
validateAndMail(context, actionXml);
context.setExecutionData("OK", null);
} catch (Exception ex) {
throw convertException(ex);
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class FsActionExecutor method chmod.
void chmod(Context context, XConfiguration fsConf, Path nameNodePath, Path path, String permissions, boolean dirFiles, boolean recursive) throws ActionExecutorException {
LOG.info("Setting permissions [{0}] on [{1}]. Recursive mode: [{2}]", permissions, path, recursive);
HashMap<String, String> argsMap = new HashMap<String, String>();
argsMap.put("permissions", permissions);
try {
FileSystem fs = getFileSystemFor(path, context, fsConf);
path = resolveToFullPath(nameNodePath, path, true);
Path[] pathArr = FileUtil.stat2Paths(fs.globStatus(path));
if (pathArr == null || pathArr.length == 0) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS009", "chmod" + ", path(s) that matches [{0}] does not exist", path);
}
checkGlobMax(pathArr);
for (Path p : pathArr) {
recursiveFsOperation("chmod", fs, nameNodePath, p, argsMap, dirFiles, recursive, true);
}
} catch (Exception ex) {
throw convertException(ex);
}
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class FsActionExecutor method resolveToFullPath.
Path resolveToFullPath(Path nameNode, Path path, boolean withScheme) throws ActionExecutorException {
Path fullPath;
// If no nameNode is given, validate the path as-is and return it as-is
if (nameNode == null) {
validatePath(path, withScheme);
fullPath = path;
} else {
// If the path doesn't have a scheme or authority, use the nameNode which should have already been verified earlier
String pathScheme = path.toUri().getScheme();
String pathAuthority = path.toUri().getAuthority();
if (pathScheme == null || pathAuthority == null) {
if (path.isAbsolute()) {
String nameNodeSchemeAuthority = nameNode.toUri().getScheme() + "://" + nameNode.toUri().getAuthority();
fullPath = new Path(nameNodeSchemeAuthority + path.toString());
} else {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FS011", "Path [{0}] cannot be relative", path);
}
} else {
// If it is the nameNode, then it should have already been verified earlier so return it as-is
if (!nameNode.toUri().getScheme().equals(pathScheme) || !nameNode.toUri().getAuthority().equals(pathAuthority)) {
validatePath(path, withScheme);
}
fullPath = path;
}
}
return fullPath;
}
use of org.apache.oozie.action.ActionExecutorException in project oozie by apache.
the class FsActionExecutor method start.
@Override
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
LOG.info("Starting action");
try {
context.setStartData("-", "-", "-");
Element actionXml = XmlUtils.parseXml(action.getConf());
doOperations(context, actionXml);
context.setExecutionData("OK", null);
} catch (Exception ex) {
throw convertException(ex);
}
}
Aggregations