Search in sources :

Example 1 with ScriptValueTranslator

use of com.enonic.xp.lib.value.ScriptValueTranslator 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 ScriptValueTranslator

use of com.enonic.xp.lib.value.ScriptValueTranslator 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 3 with ScriptValueTranslator

use of com.enonic.xp.lib.value.ScriptValueTranslator 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 4 with ScriptValueTranslator

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

the class ModifyNodeHandler method updateNode.

private void updateNode(final EditableNode target, final ScriptValue scriptValue) {
    final ScriptValueTranslatorResult scriptValueTranslatorResult = new ScriptValueTranslator(false).create(scriptValue);
    final PropertyTree nodeAsPropertyTree = scriptValueTranslatorResult.getPropertyTree();
    ModifyNodeExecutor.create().editableNode(target).propertyTree(nodeAsPropertyTree).build().execute();
}
Also used : ScriptValueTranslatorResult(com.enonic.xp.lib.value.ScriptValueTranslatorResult) PropertyTree(com.enonic.xp.data.PropertyTree) ScriptValueTranslator(com.enonic.xp.lib.value.ScriptValueTranslator)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)4 ScriptValueTranslator (com.enonic.xp.lib.value.ScriptValueTranslator)4 ScriptValueTranslatorResult (com.enonic.xp.lib.value.ScriptValueTranslatorResult)4 PropertySet (com.enonic.xp.data.PropertySet)1 AccessControlList (com.enonic.xp.security.acl.AccessControlList)1