use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ModifyProfileHandler method newProfileEditor.
private void newProfileEditor(final EditableUser edit) {
final PropertyTree profile = edit.source.getProfile();
final PropertyTreeMapper mapper = createPropertyTreeMapper(profile, true);
final ScriptValue scriptValue = this.editor.call(mapper);
updateUser(edit, scriptValue);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ModifyNodeHandler method execute.
@Override
public Object execute() {
final Node node = getExistingNode();
final ScriptValue updatedNodeScriptValue = applyEditor(node);
final BinaryAttachments binaryAttachments = getBinaryAttachments(updatedNodeScriptValue);
final UpdateNodeParams updateNodeParams = UpdateNodeParams.create().id(node.id()).editor(createEditor(updatedNodeScriptValue)).setBinaryAttachments(binaryAttachments).build();
final Node updatedNode = this.nodeService.update(updateNodeParams);
return new NodeMapper(updatedNode, false);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ErrorHandlerScriptImpl method doExecute.
private PortalResponse doExecute(final PortalError portalError, final String handlerMethod) {
Tracer.withCurrent(this::addTraceInfo);
final PortalErrorMapper portalErrorMapper = new PortalErrorMapper(portalError);
final ScriptValue result = this.scriptExports.executeMethod(handlerMethod, portalErrorMapper);
if ((result == null) || !result.isObject()) {
return null;
} else {
return new PortalResponseSerializer(result, portalError.getStatus()).defaultPostProcess(false).applyFilters(false).serialize();
}
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueTranslatorTest method getCreateNodeHandlerParams.
private ScriptValueTranslatorResult getCreateNodeHandlerParams(final String name) {
final ScriptExports exports = runScript("/com/enonic/xp/lib/value/script-values.js");
final ScriptValue value = exports.executeMethod(name);
return new ScriptValueTranslator().create(value);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ControllerScriptImpl method doExecute.
private PortalResponse doExecute(final PortalRequest portalRequest) {
Tracer.withCurrent(this::addTraceInfo);
final HttpMethod method = portalRequest.getMethod();
final boolean isHead = method == HttpMethod.HEAD;
String runMethod = isHead ? "get" : method.toString().toLowerCase();
final boolean exists = this.scriptExports.hasMethod(runMethod);
if (!exists) {
if (this.scriptExports.hasMethod(ALL_SCRIPT_METHOD_NAME)) {
runMethod = ALL_SCRIPT_METHOD_NAME;
} else {
return new PortalResponseSerializer(null, HttpStatus.METHOD_NOT_ALLOWED).serialize();
}
}
final PortalRequestMapper requestMapper = new PortalRequestMapper(portalRequest);
final ScriptValue result = this.scriptExports.executeMethod(runMethod, requestMapper);
return new PortalResponseSerializer(result).serialize();
}
Aggregations