FolderServerGroup findGroupByName(String groupName) {
   String cypher = CypherQueryBuilder.getGroupByName();
   Map<String, Object> params = CypherParamBuilder.getGroupByName(groupName);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode groupNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(groupNode);
 }
 FolderServerGroup updateGroupById(
     String groupId, Map<String, String> updateFields, String updatedBy) {
   String cypher = CypherQueryBuilder.updateGroupById(updateFields);
   Map<String, Object> params =
       CypherParamBuilder.updateGroupById(groupId, updateFields, updatedBy);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode updatedNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(updatedNode);
 }
예제 #3
0
 /**
  * Method for locating node specified by given JSON pointer instances. Method will never return
  * null; if no matching node exists, will return a node for which {@link #isMissingNode()} returns
  * true.
  *
  * @return Node that matches given JSON Pointer: if no match exists, will return a node for which
  *     {@link #isMissingNode()} returns true.
  * @since 2.3
  */
 @Override
 public final JsonNode at(JsonPointer ptr) {
   // Basically: value nodes only match if we have "empty" path left
   if (ptr.matches()) {
     return this;
   }
   JsonNode n = _at(ptr);
   if (n == null) {
     return MissingNode.getInstance();
   }
   return n.at(ptr.tail());
 }
 boolean deleteGroupById(String groupURL) {
   String cypher = CypherQueryBuilder.deleteGroupById();
   Map<String, Object> params = CypherParamBuilder.deleteGroupById(groupURL);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode errorsNode = jsonNode.at("/errors");
   if (errorsNode.size() != 0) {
     JsonNode error = errorsNode.path(0);
     log.warn("Error while deleting group:", error);
   }
   return errorsNode.size() == 0;
 }
 boolean removeRelation(FolderServerUser user, FolderServerGroup group, RelationLabel relation) {
   String cypher = CypherQueryBuilder.removeRelation(NodeLabel.USER, NodeLabel.GROUP, relation);
   Map<String, Object> params =
       CypherParamBuilder.matchFromNodeToNode(user.getId(), group.getId());
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode errorsNode = jsonNode.at("/errors");
   if (errorsNode.size() != 0) {
     JsonNode error = errorsNode.path(0);
     log.warn("Error while removing relation:", error);
   }
   return errorsNode.size() == 0;
 }
 FolderServerGroup createGroup(
     String groupURL,
     String name,
     String displayName,
     String description,
     String ownerURL,
     Map<String, Object> extraProperties) {
   String cypher = CypherQueryBuilder.createGroup(extraProperties);
   Map<String, Object> params =
       CypherParamBuilder.createGroup(
           groupURL, name, displayName, description, ownerURL, extraProperties);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode groupNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(groupNode);
 }
 List<FolderServerGroup> findGroups() {
   List<FolderServerGroup> groupList = new ArrayList<>();
   String cypher = CypherQueryBuilder.findGroups();
   CypherQuery q = new CypherQueryLiteral(cypher);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode userListJsonNode = jsonNode.at("/results/0/data");
   if (userListJsonNode != null && !userListJsonNode.isMissingNode()) {
     userListJsonNode.forEach(
         f -> {
           JsonNode groupNode = f.at("/row/0");
           if (groupNode != null && !groupNode.isMissingNode()) {
             FolderServerGroup cg = buildGroup(groupNode);
             groupList.add(cg);
           }
         });
   }
   return groupList;
 }
 List<FolderServerUser> findGroupMembers(String groupURL) {
   List<FolderServerUser> memberList = new ArrayList<>();
   String cypher = CypherQueryBuilder.getGroupUsersWithRelation(RelationLabel.MEMBEROF);
   Map<String, Object> params = CypherParamBuilder.matchGroupId(groupURL);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode userListJsonNode = jsonNode.at("/results/0/data");
   if (userListJsonNode != null && !userListJsonNode.isMissingNode()) {
     userListJsonNode.forEach(
         f -> {
           JsonNode userNode = f.at("/row/0");
           if (userNode != null && !userNode.isMissingNode()) {
             FolderServerUser u = buildUser(userNode);
             memberList.add(u);
           }
         });
   }
   return memberList;
 }