Search in sources :

Example 36 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class PrincipalNodeTranslator method createUserProfileFromNode.

private static void createUserProfileFromNode(final PropertyTree nodeAsTree, final User.Builder user) {
    final PropertySet nodeProfile = nodeAsTree.getSet(PrincipalPropertyNames.PROFILE_KEY);
    final PropertyTree profile = nodeProfile == null ? new PropertyTree() : nodeProfile.toTree();
    user.profile(profile);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 37 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class PrincipalNodeTranslator method createRoleFromNode.

private static Role createRoleFromNode(final Node node) {
    Preconditions.checkNotNull(node);
    final PropertyTree nodeAsTree = node.data();
    return Role.create().key(PrincipalKeyNodeTranslator.toKey(node)).displayName(nodeAsTree.getString(PrincipalPropertyNames.DISPLAY_NAME_KEY)).description(nodeAsTree.getString(PrincipalPropertyNames.DESCRIPTION_KEY)).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree)

Example 38 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class PrincipalNodeTranslator method relationshipsFromNode.

static PrincipalRelationships relationshipsFromNode(final Node node) {
    final PropertyTree rootDataSet = node.data();
    final List<Property> members = rootDataSet.getProperties(PrincipalPropertyNames.MEMBER_KEY);
    if (members == null || members.isEmpty()) {
        return PrincipalRelationships.empty();
    }
    final ImmutableList.Builder<PrincipalRelationship> relationships = ImmutableList.builder();
    final PrincipalKey relationshipFrom = PrincipalKeyNodeTranslator.toKey(node);
    for (Property member : members) {
        final String memberKey = member.getValue().asString();
        final PrincipalKey relationshipTo = PrincipalKey.from(memberKey);
        final PrincipalRelationship relationship = PrincipalRelationship.from(relationshipFrom).to(relationshipTo);
        relationships.add(relationship);
    }
    return PrincipalRelationships.from(relationships.build());
}
Also used : PrincipalRelationship(com.enonic.xp.security.PrincipalRelationship) ImmutableList(com.google.common.collect.ImmutableList) PropertyTree(com.enonic.xp.data.PropertyTree) Property(com.enonic.xp.data.Property) PrincipalKey(com.enonic.xp.security.PrincipalKey)

Example 39 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class SecurityAuditLogSupportImpl method createUser.

@Override
public void createUser(final CreateUserParams params) {
    if (isEnabledAuditLogs) {
        PropertyTree data = new PropertyTree();
        PropertySet paramsSet = data.addSet("params");
        paramsSet.setString("key", params.getKey().toString());
        paramsSet.setString("email", params.getEmail());
        paramsSet.setString("login", params.getLogin());
        paramsSet.setString("displayName", params.getDisplayName());
        log("system.security.principal.create", data, AuditLogUris.from(params.getKey().toString()));
    }
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 40 with PropertyTree

use of com.enonic.xp.data.PropertyTree in project xp by enonic.

the class SecurityAuditLogSupportImpl method createGroup.

@Override
public void createGroup(final CreateGroupParams params) {
    if (isEnabledAuditLogs) {
        PropertyTree data = new PropertyTree();
        PropertySet paramsSet = data.addSet("params");
        paramsSet.setString("key", params.getKey().toString());
        paramsSet.setString("displayName", params.getDisplayName());
        paramsSet.setString("description", params.getDescription());
        log("system.security.principal.create", data, AuditLogUris.from(params.getKey().toString()));
    }
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)660 Test (org.junit.jupiter.api.Test)405 PropertySet (com.enonic.xp.data.PropertySet)150 Content (com.enonic.xp.content.Content)126 Node (com.enonic.xp.node.Node)112 CreateContentParams (com.enonic.xp.content.CreateContentParams)64 Form (com.enonic.xp.form.Form)37 Page (com.enonic.xp.page.Page)32 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)31 DescriptorKey (com.enonic.xp.page.DescriptorKey)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)30 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)28 PrincipalKey (com.enonic.xp.security.PrincipalKey)28 BinaryReference (com.enonic.xp.util.BinaryReference)28 Property (com.enonic.xp.data.Property)26 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)24 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)23 ByteSource (com.google.common.io.ByteSource)22 ExtraData (com.enonic.xp.content.ExtraData)21 Instant (java.time.Instant)21