Search in sources :

Example 1 with ScriptValueTranslatorResult

use of com.enonic.xp.lib.value.ScriptValueTranslatorResult in project xp by enonic.

the class ModifyProfileHandler method updateUser.

private void updateUser(final EditableUser target, final ScriptValue value) {
    if (value == null) {
        if (scope != null) {
            target.profile.removeProperty(scope);
        }
        return;
    }
    final ScriptValueTranslatorResult scriptValueTranslatorResult = new ScriptValueTranslator(false).create(value);
    final PropertyTree propertyTree = scriptValueTranslatorResult.getPropertyTree();
    if (this.scope == null) {
        target.profile = propertyTree;
    } else {
        target.profile.setSet(scope, propertyTree.getRoot());
    }
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree) ScriptValueTranslator(com.enonic.xp.lib.value.ScriptValueTranslator)

Example 2 with ScriptValueTranslatorResult

use of com.enonic.xp.lib.value.ScriptValueTranslatorResult in project xp by enonic.

the class CreateNodeParamsFactoryTest method createWithStringProperty.

private CreateNodeParams createWithStringProperty(final String nodeName, final String myNode) {
    final PropertyTree properties = new PropertyTree();
    properties.setString(nodeName, myNode);
    return new CreateNodeParamsFactory().create(new ScriptValueTranslatorResult(properties, BinaryAttachments.empty()));
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree)

Example 3 with ScriptValueTranslatorResult

use of com.enonic.xp.lib.value.ScriptValueTranslatorResult in project xp by enonic.

the class ModifyRepositoryHandler method updateRepositoryData.

private void updateRepositoryData(final EditableRepository target, final ScriptValue value) {
    if (value == null) {
        if (scope != null) {
            target.data.removeProperty(scope);
        }
    } else {
        final ScriptValueTranslatorResult scriptValueTranslatorResult = new ScriptValueTranslator().create(value);
        target.binaryAttachments = ImmutableList.copyOf(scriptValueTranslatorResult.getBinaryAttachments());
        final PropertyTree propertyTree = scriptValueTranslatorResult.getPropertyTree();
        if (scope == null) {
            target.data = propertyTree;
        } else {
            target.data.setSet(scope, propertyTree.getRoot());
        }
    }
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree) ScriptValueTranslator(com.enonic.xp.lib.value.ScriptValueTranslator)

Example 4 with ScriptValueTranslatorResult

use of com.enonic.xp.lib.value.ScriptValueTranslatorResult in project xp by enonic.

the class NodeHandler method setRootPermissions.

@SuppressWarnings("unused")
public Object setRootPermissions(final ScriptValue value) {
    final ScriptValueTranslatorResult translatorResult = new ScriptValueTranslator(false).create(value);
    final PropertyTree asPropertyTree = translatorResult.getPropertyTree();
    final Iterable<PropertySet> asPropertySets = asPropertyTree.getSets("_permissions");
    final boolean inheritPermissions = asPropertyTree.getBoolean("_inheritsPermissions") != null ? asPropertyTree.getBoolean("_inheritsPermissions") : true;
    if (asPropertySets == null) {
        throw new IllegalArgumentException("Did not find parameter [_permissions]");
    }
    final AccessControlList permissions = new PermissionsFactory(asPropertySets).create();
    return execute(SetRootPermissionsHandler.create().permissions(permissions).inheritPermissions(inheritPermissions).nodeService(this.nodeService).build());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) ScriptValueTranslator(com.enonic.xp.lib.value.ScriptValueTranslator)

Example 5 with ScriptValueTranslatorResult

use of com.enonic.xp.lib.value.ScriptValueTranslatorResult in project xp by enonic.

the class CreateNodeHandler method execute.

@Override
public Object execute() {
    final ScriptValueTranslatorResult params = getParams(this.params);
    final CreateNodeParams createNodeParams = new CreateNodeParamsFactory().create(params);
    final Node node = this.nodeService.create(createNodeParams);
    return new NodeMapper(node);
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) Node(com.enonic.xp.node.Node) NodeMapper(com.enonic.xp.lib.node.mapper.NodeMapper) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Aggregations

ScriptValueTranslatorResult (com.enonic.xp.lib.value.ScriptValueTranslatorResult)6 PropertyTree (com.enonic.xp.data.PropertyTree)5 ScriptValueTranslator (com.enonic.xp.lib.value.ScriptValueTranslator)4 PropertySet (com.enonic.xp.data.PropertySet)1 NodeMapper (com.enonic.xp.lib.node.mapper.NodeMapper)1 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)1 Node (com.enonic.xp.node.Node)1 AccessControlList (com.enonic.xp.security.acl.AccessControlList)1