use of com.enonic.xp.node.UpdateNodeParams in project xp by enonic.
the class GetActiveNodeVersionsCommandTest method updateNode.
private void updateNode(final Node node, Context context) {
UpdateNodeParams updateNodeParams = UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> toBeEdited.data.setString("myString", "edit")).build();
context.runWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).binaryService(this.binaryService).storageService(this.storageService).searchService(this.searchService).build().execute());
}
use of com.enonic.xp.node.UpdateNodeParams in project xp by enonic.
the class SecurityServiceImpl method updateGroup.
@Override
public Group updateGroup(final UpdateGroupParams updateGroupParams) {
return callWithContext(() -> {
final Node node = this.nodeService.getByPath(updateGroupParams.getKey().toPath());
if (node == null) {
throw new PrincipalNotFoundException(updateGroupParams.getKey());
}
final Group existingGroup = PrincipalNodeTranslator.groupFromNode(node);
final Group groupToUpdate = updateGroupParams.update(existingGroup);
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.toUpdateNodeParams(groupToUpdate);
final Node updatedNode = nodeService.update(updateNodeParams);
this.nodeService.refresh(RefreshMode.SEARCH);
return PrincipalNodeTranslator.groupFromNode(updatedNode);
});
}
use of com.enonic.xp.node.UpdateNodeParams in project xp by enonic.
the class SecurityServiceImpl method doRemoveRelationships.
private void doRemoveRelationships(final PrincipalKey from) {
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.removeAllRelationshipsToUpdateNodeParams(from);
nodeService.update(updateNodeParams);
}
use of com.enonic.xp.node.UpdateNodeParams in project xp by enonic.
the class SecurityServiceImpl method updateIdProvider.
@Override
public IdProvider updateIdProvider(final UpdateIdProviderParams updateIdProviderParams) {
return callWithContext(() -> {
final NodePath idProviderNodePath = IdProviderNodeTranslator.toIdProviderNodePath(updateIdProviderParams.getKey());
final Node node = this.nodeService.getByPath(idProviderNodePath);
if (node == null) {
return null;
}
final IdProvider existingIdProvider = IdProviderNodeTranslator.fromNode(node);
final IdProvider idProviderToUpdate = updateIdProviderParams.update(existingIdProvider);
final UpdateNodeParams updateNodeParams = IdProviderNodeTranslator.toUpdateNodeParams(idProviderToUpdate, node.id());
final Node idProviderNode = nodeService.update(updateNodeParams);
if (updateIdProviderParams.getIdProviderPermissions() != null) {
final Node usersNode = nodeService.getByPath(IdProviderNodeTranslator.toIdProviderUsersNodePath(updateIdProviderParams.getKey()));
final Node groupsNode = nodeService.getByPath(IdProviderNodeTranslator.toIdProviderGroupsNodePath(updateIdProviderParams.getKey()));
final IdProviderAccessControlList permissions = updateIdProviderParams.getIdProviderPermissions();
AccessControlList idProviderNodePermissions = IdProviderNodeTranslator.idProviderPermissionsToIdProviderNodePermissions(permissions);
AccessControlList usersNodePermissions = IdProviderNodeTranslator.idProviderPermissionsToUsersNodePermissions(permissions);
AccessControlList groupsNodePermissions = IdProviderNodeTranslator.idProviderPermissionsToGroupsNodePermissions(permissions);
final Node rootNode = nodeService.getRoot();
idProviderNodePermissions = mergeWithRootPermissions(idProviderNodePermissions, rootNode.getPermissions());
usersNodePermissions = mergeWithRootPermissions(usersNodePermissions, rootNode.getPermissions());
groupsNodePermissions = mergeWithRootPermissions(groupsNodePermissions, rootNode.getPermissions());
setNodePermissions(idProviderNode.id(), idProviderNodePermissions);
setNodePermissions(usersNode.id(), usersNodePermissions);
setNodePermissions(groupsNode.id(), groupsNodePermissions);
final ApplyNodePermissionsParams applyPermissions = ApplyNodePermissionsParams.create().nodeId(idProviderNode.id()).overwriteChildPermissions(false).build();
nodeService.applyPermissions(applyPermissions);
}
this.nodeService.refresh(RefreshMode.SEARCH);
return IdProviderNodeTranslator.fromNode(idProviderNode);
});
}
use of com.enonic.xp.node.UpdateNodeParams in project xp by enonic.
the class SecurityServiceImpl method doRemoveMemberships.
private void doRemoveMemberships(final PrincipalKey member) {
final PrincipalKeys memberships = queryDirectMemberships(member);
if (memberships.isEmpty()) {
return;
}
for (PrincipalKey from : memberships) {
final PrincipalRelationship relationship = PrincipalRelationship.from(from).to(member);
final UpdateNodeParams updateNodeParams = PrincipalNodeTranslator.removeRelationshipToUpdateNodeParams(relationship);
nodeService.update(updateNodeParams);
}
}
Aggregations