use of com.enonic.xp.node.Nodes in project xp by enonic.
the class SecurityServiceImpl method duplicateEmailValidation.
private void duplicateEmailValidation(final PrincipalKey key, final String email) {
if (email == null) {
return;
}
final CompareExpr idProviderExpr = CompareExpr.create(FieldExpr.from(PrincipalIndexPath.ID_PROVIDER_KEY), CompareExpr.Operator.EQ, ValueExpr.string(key.getIdProviderKey().toString()));
final CompareExpr emailExpr = CompareExpr.create(FieldExpr.from(PrincipalIndexPath.EMAIL_KEY), CompareExpr.Operator.EQ, ValueExpr.string(email));
final QueryExpr query = QueryExpr.from(LogicalExpr.and(idProviderExpr, emailExpr));
final Nodes nodes = callWithContext(() -> {
final FindNodesByQueryResult result = nodeService.findByQuery(NodeQuery.create().query(query).build());
return this.nodeService.getByIds(result.getNodeIds());
});
final User user = nodes.isEmpty() ? null : PrincipalNodeTranslator.userFromNode(nodes.first());
if (nodes.getSize() > 1 || (user != null && !user.getKey().equals(key))) {
throw new IllegalArgumentException("A user with email '" + email + "' already exists in id provider '" + key.getIdProviderKey() + "'");
}
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class ApplicationServiceImpl method doInstallStoredApplications.
private void doInstallStoredApplications(final ApplicationInstallationParams params) {
LOG.info("Searching for installed applications");
final Nodes applicationNodes = repoService.getApplications();
LOG.info("Found [" + applicationNodes.getSize() + "] installed applications");
for (final Node applicationNode : applicationNodes) {
try {
final Application application = doInstallStoredApplication(applicationNode.id());
if (application == null) {
continue;
}
final ApplicationKey applicationKey = application.getKey();
LOG.info("Stored application [{}] installed successfully", applicationKey);
if (params.isTriggerEvent()) {
doPublishInstalledEvent(applicationNode);
}
if (params.isStart() && storedApplicationIsStarted(applicationNode)) {
doStartApplication(applicationKey, params.isTriggerEvent(), false);
}
} catch (Exception e) {
LOG.error("Cannot install application [{}]", applicationNode.name(), e);
}
}
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class GetContentByPathsCommand method doExecute.
private Contents doExecute() {
final NodePaths paths = ContentNodeHelper.translateContentPathsToNodePaths(contentPaths);
final Nodes nodes = nodeService.getByPaths(paths);
return this.translator.fromNodes(nodes, true);
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class FindIssueCommentsCommand method execute.
public FindIssueCommentsResult execute() {
validateBlockingChecks();
final Node issue = nodeService.getById(NodeId.from(this.query.getIssue()));
final NodeQuery nodeQuery = IssueCommentQueryNodeQueryTranslator.translate(this.query, issue.name());
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
final Nodes foundNodes = this.nodeService.getByIds(result.getNodeIds());
final List<IssueComment> issues = IssueCommentNodeTranslator.fromNodes(foundNodes);
return FindIssueCommentsResult.create().comments(issues).hits(result.getHits()).totalHits(result.getTotalHits()).build();
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class FindIssuesCommand method execute.
public FindIssuesResult execute() {
final NodeQuery nodeQuery = IssueQueryNodeQueryTranslator.translate(this.query);
final FindNodesByQueryResult result = nodeService.findByQuery(nodeQuery);
final Nodes foundNodes = this.nodeService.getByIds(result.getNodeIds());
final List<Issue> issues = IssueNodeTranslator.fromNodes(foundNodes);
return FindIssuesResult.create().issues(issues).hits(result.getHits()).totalHits(result.getTotalHits()).build();
}
Aggregations