use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class UserControllerUtils method getUserDataApprovalWorkflows.
/**
* Gets the data approval workflows a user can see, including the workflow
* levels accessible to the user and the actions (if any) they can take at
* those levels to approve (and accept if configured) data.
*
* @param user the user
* @throws Exception if an error occurs
*/
public RootNode getUserDataApprovalWorkflows(User user) throws Exception {
CollectionNode collectionNode = new CollectionNode("dataApprovalWorkflows", true);
for (DataApprovalWorkflow workflow : dataApprovalService.getAllWorkflows()) {
if (!aclService.canRead(user, workflow)) {
continue;
}
ComplexNode workflowNode = new ComplexNode("dataApprovalWorkflow");
workflowNode.addChild(new SimpleNode("name", workflow.getName()));
workflowNode.addChild(new SimpleNode("id", workflow.getUid()));
workflowNode.addChild(getWorkflowLevelNodes(user, workflow));
collectionNode.addChild(workflowNode);
}
collectionNode.getUnorderedChildren().sort(Comparator.comparing(c -> (String) ((SimpleNode) c.getUnorderedChildren().get(0)).getValue()));
RootNode rootNode = NodeUtils.createRootNode("dataApprovalWorkflows");
rootNode.addChild(collectionNode);
return rootNode;
}
use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class MeController method verifyPasswordInternal.
// ------------------------------------------------------------------------------------------------
// Supportive methods
// ------------------------------------------------------------------------------------------------
private RootNode verifyPasswordInternal(String password, User currentUser) throws WebMessageException {
if (password == null) {
throw new WebMessageException(conflict("Required attribute 'password' missing or null."));
}
boolean valid = passwordManager.matches(password, currentUser.getPassword());
RootNode rootNode = NodeUtils.createRootNode("response");
rootNode.addChild(new SimpleNode("isCorrectPassword", valid));
return rootNode;
}
Aggregations