use of com.twinsoft.convertigo.beans.core.Sequence.OutputFilter in project convertigo by convertigo.
the class WriteFileStep method stepExecute.
@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
filePath = null;
try {
StepSource stepSource = getSource();
if (!stepSource.inError()) {
filePath = evaluateDataFileName(javascriptContext, scope);
// Retrieve a view based on context nodes (prevent to modify context nodes, output usefull nodes only)
OutputFilter outputFilter = sequence.new OutputFilter(writeOutputFalse ? OutputOption.UsefullOnly : OutputOption.VisibleOnly);
NodeList nl = Sequence.ouputDomView(stepSource.getContextOutputNodes(), outputFilter);
writeFile(filePath, nl);
filePath = getAbsoluteFilePath(filePath);
}
} catch (Exception e) {
setErrorStatus(true);
Engine.logBeans.error("An error occured while writing to file", e);
}
return super.stepExecute(javascriptContext, scope);
}
return false;
}
use of com.twinsoft.convertigo.beans.core.Sequence.OutputFilter in project convertigo by convertigo.
the class SessionSetObjectStep method createStepNodeValue.
@Override
protected void createStepNodeValue(Document doc, Element stepNode) throws EngineException {
stepNode.setAttribute("key", key.isEmpty() ? "empty_key" : StringUtils.normalize(key));
if (!key.isEmpty()) {
Object object = value.getObject(this);
if (object != null) {
if ((object instanceof NodeList) && value.isUseSource()) {
OutputFilter outputFilter = sequence.new OutputFilter(OutputOption.UsefullOnly);
object = Sequence.ouputDomView((NodeList) object, outputFilter);
}
getSequence().context.httpSession.setAttribute(key, object);
// Simple objects
if ((object instanceof Boolean) || (object instanceof Integer) || (object instanceof Double) || (object instanceof Float) || (object instanceof Character) || (object instanceof Long) || (object instanceof Short) || (object instanceof Byte) || (object instanceof String)) {
stepNode.setTextContent(ParameterUtils.toString(object));
} else // Complex objects
{
CDATASection cDATASection = doc.createCDATASection(ParameterUtils.toString(object));
stepNode.appendChild(cDATASection);
}
}
}
}
Aggregations