Java Code Examples for com.tinkerpop.blueprints.impls.orient.OrientGraph#getVertexByKey()

The following examples show how to use com.tinkerpop.blueprints.impls.orient.OrientGraph#getVertexByKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCommentRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void updComment(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try{
        graph.begin();
        String commentId = (String)data.get("commentId");
        OrientVertex comment = (OrientVertex)graph.getVertexByKey("Comment.commentId", commentId);
        if(comment != null) {
            comment.setProperty("content", data.get("content"));
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 2
Source File: AbstractUserRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void delUser(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex user = graph.getVertexByKey("User.userId", data.get("userId"));
        if(user != null) {
            graph.removeVertex(user.getProperty("credential"));
            graph.removeVertex(user);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 3
Source File: AbstractPostRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void upVotePost(Map<String, Object> data) {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        OrientVertex updateUser = (OrientVertex) graph.getVertexByKey("User.userId", data.remove("updateUserId"));
        OrientVertex post = (OrientVertex) graph.getVertexByKey("Post.entityId", data.get("entityId"));
        if (post != null && updateUser != null) {
            // remove DownVote edge if there is.
            for (Edge edge : updateUser.getEdges(post, Direction.OUT, "DownVote")) {
                if (edge.getVertex(Direction.IN).equals(post)) graph.removeEdge(edge);
            }
            updateUser.addEdge("UpVote", post);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 4
Source File: AbstractPageRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void delPage(String pageId) {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex page = graph.getVertexByKey("Page.pageId", pageId);
        if(page != null) {
            graph.removeVertex(page);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
    Map<String, Object> pageMap = ServiceLocator.getInstance().getMemoryImage("pageMap");
    ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)pageMap.get("cache");
    if(cache != null) {
        cache.remove(pageId);
    }
}
 
Example 5
Source File: AbstractOrderRule.java    From light with Apache License 2.0 6 votes vote down vote up
/**
 * To save the order right before routing to payment gateway
 *
 * @param data
 * @throws Exception
 */
protected void addOrder(Map<String, Object> data) throws Exception {
    logger.entry(data);
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex user = graph.getVertexByKey("User.userId", data.remove("createUserId"));
        OrientVertex order = graph.addVertex("class:Order", data);
        user.addEdge("Create", order);
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 6
Source File: AbstractMenuRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void addMenuItem(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex user = graph.getVertexByKey("User.userId", data.remove("createUserId"));
        List<String> addMenuItems = (List<String>)data.remove("addMenuItems");
        OrientVertex menuItem = graph.addVertex("class:MenuItem", data);
        if(addMenuItems != null && addMenuItems.size() > 0) {
            // find vertex for each menuItem id and create edge to it.
            for(String menuItemId: addMenuItems) {
                Vertex childMenuItem = graph.getVertexByKey("MenuItem.menuItemId", menuItemId);
                menuItem.addEdge("Own", childMenuItem);
            }
        }
        user.addEdge("Create", menuItem);
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 7
Source File: AbstractPageRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void addPage(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId"));
        OrientVertex page = graph.addVertex("class:Page", data);
        createUser.addEdge("Create", page);
        graph.commit();
        String json = page.getRecord().toJSON();
        Map<String, Object> pageMap = ServiceLocator.getInstance().getMemoryImage("pageMap");
        ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)pageMap.get("cache");
        if(cache == null) {
            cache = new ConcurrentLinkedHashMap.Builder<Object, Object>()
                    .maximumWeightedCapacity(1000)
                    .build();
            pageMap.put("cache", cache);
        }
        cache.put(data.get("pageId"), new CacheObject(page.getProperty("@version").toString(), json));
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 8
Source File: AbstractUserRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void upVoteUser(Map<String, Object> data) {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        OrientVertex user = (OrientVertex)graph.getVertexByKey("User.userId", data.get("userId"));
        OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", data.get("voteUserId"));
        if(user != null && voteUser != null) {
            for (Edge edge : voteUser.getEdges(user, Direction.OUT, "DownVote")) {
                if(edge.getVertex(Direction.IN).equals(user)) graph.removeEdge(edge);
            }
            voteUser.addEdge("UpVote", user);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 9
Source File: BranchRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void downBranchDb(String branchType, Map<String, Object> data) throws Exception {
    String className = branchType.substring(0, 1).toUpperCase() + branchType.substring(1);
    String index = className + ".categoryId";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try{
        graph.begin();
        OrientVertex updateUser = (OrientVertex)graph.getVertexByKey("User.userId", data.remove("updateUserId"));
        OrientVertex branch = (OrientVertex)graph.getVertexByKey(index, data.get("categoryId"));
        if(branch != null && updateUser != null) {
            // remove UpVote edge if there is.
            for (Edge edge : updateUser.getEdges(branch, Direction.OUT, "UpVote")) {
                if(edge.getVertex(Direction.IN).equals(branch)) graph.removeEdge(edge);
            }
            updateUser.addEdge("DownVote", branch);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 10
Source File: AbstractBfnRule.java    From light with Apache License 2.0 6 votes vote down vote up
protected void delPostDb(String bfnType, Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try{
        graph.begin();
        OrientVertex post = (OrientVertex)graph.getVertexByKey("Post.entityId", data.get("entityId"));
        if(post != null) {
            // TODO cascade deleting all comments belong to the post.
            // Need to come up a query on that to get the entire tree.
            /*
            // https://github.com/orientechnologies/orientdb/issues/1108
            delete graph...
            */
            // TODO remove tags edge. Do I need to?
            graph.removeVertex(post);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 11
Source File: AbstractConfigRule.java    From light with Apache License 2.0 5 votes vote down vote up
protected void updHostConfigDb(Map<String, Object> data) throws Exception {
    String host = (String)data.get("host");
    String configId = (String)data.get("configId");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try{
        graph.begin();
        Vertex updateUser = graph.getVertexByKey("User.userId", data.remove("updateUserId"));
        OrientVertex config = getConfigByHostId(graph, host, configId);
        if(config != null) {
            if(data.get("description") != null) {
                config.setProperty("description", data.get("description"));
            } else {
                config.removeProperty("description");
            }
            if(data.get("properties") != null) {
                config.setProperty("properties", data.get("properties"));
            } else {
                config.removeProperty("properties");
            }
            config.setProperty("updateDate", data.get("updateDate"));
            // updateUser
            updateUser.addEdge("Update", config);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 12
Source File: AbstractRoleRule.java    From light with Apache License 2.0 5 votes vote down vote up
protected void updRole(Map<String, Object> data) throws Exception {
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        graph.begin();
        Vertex updateUser = graph.getVertexByKey("User.userId", data.remove("updateUserId"));
        Vertex role = graph.getVertexByKey("Role.roleId", data.get("roleId"));
        if(role != null) {
            String host = (String)data.get("host");
            if(host != null && host.length() > 0) {
                if(!host.equals(role.getProperty("host"))) role.setProperty("host", host);
            } else {
                role.removeProperty("host");
            }
            String description = (String)data.get("description");
            if(description != null && !description.equals(role.getProperty("description"))) {
                role.setProperty("description", description);
            }
            role.setProperty("updateDate", data.get("updateDate"));
            updateUser.addEdge("Update", role);
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
        throw e;
    } finally {
        graph.shutdown();
    }
}
 
Example 13
Source File: AbstractRule.java    From light with Apache License 2.0 5 votes vote down vote up
public static Map<String, Object> getRuleByRuleClass(String ruleClass) throws Exception {
    Map<String, Object> map = null;
    Map<String, Object> ruleMap = ServiceLocator.getInstance().getMemoryImage("ruleMap");
    ConcurrentMap<String, Map<String, Object>> cache = (ConcurrentMap<String, Map<String, Object>>)ruleMap.get("cache");
    if(cache == null) {
        cache = new ConcurrentLinkedHashMap.Builder<String, Map<String, Object>>()
                .maximumWeightedCapacity(1000)
                .build();
        ruleMap.put("cache", cache);
    } else {
        map = cache.get(ruleClass);
    }
    if(map == null) {
        OrientGraph graph = ServiceLocator.getInstance().getGraph();
        try {
            OrientVertex rule = (OrientVertex)graph.getVertexByKey("Rule.ruleClass", ruleClass);
            if(rule != null) {
                map = rule.getRecord().toMap();
                // remove sourceCode as we don't need it and it is big
                map.remove("sourceCode");

                // convert schema to JsonSchema in order to speed up validation.
                if(map.get("schema") != null) {
                    JsonNode schemaNode = ServiceLocator.getInstance().getMapper().valueToTree(map.get("schema"));
                    JsonSchema schema = schemaFactory.getJsonSchema(schemaNode);
                    map.put("schema", schema);
                }

                logger.debug("map = " + map);
                cache.put(ruleClass, map);
            }
        } catch (Exception e) {
            logger.error("Exception:", e);
            throw e;
        } finally {
            graph.shutdown();
        }
    }
    return map;
}
 
Example 14
Source File: UpdPasswordRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String error = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String userId = (String)user.get("userId");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        Vertex updateUser = graph.getVertexByKey("User.userId", userId);
        if(updateUser != null) {
            String password = (String) data.get("password");
            String newPassword = (String)data.get("newPassword");
            String passwordConfirm = (String)data.get("passwordConfirm");

            // check if the password match
            boolean match = checkPassword(graph, updateUser, password);
            if(match) {
                if(newPassword.equals(passwordConfirm)) {
                    newPassword = HashUtil.generateStrongPasswordHash(newPassword);
                    Map eventMap = getEventMap(inputMap);
                    Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                    inputMap.put("eventMap", eventMap);
                    eventData.put("userId", updateUser.getProperty("userId"));
                    eventData.put("password", newPassword);
                    eventData.put("updateDate", new java.util.Date());
                } else {
                    error = "New password and password confirm are not the same.";
                    inputMap.put("responseCode", 400);
                }
            } else {
                error = "The old password is incorrect.";
                inputMap.put("responseCode", 400);
            }
        } else {
            error = "User with userId " + userId + " cannot be found.";
            inputMap.put("responseCode", 404);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 15
Source File: AbstractUserRule.java    From light with Apache License 2.0 4 votes vote down vote up
protected Vertex getUserByUserId(OrientGraph graph, String userId) throws Exception {
    return graph.getVertexByKey("User.userId", userId);
}
 
Example 16
Source File: UpdShippingAddressRule.java    From light with Apache License 2.0 4 votes vote down vote up
@Override
public boolean execute(Object... objects) throws Exception {
    logger.entry(objects);
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String error = null;
    Map<String, Object> resultMap = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String userId = (String)user.get("userId");
    String host = (String)data.get("host");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OrientVertex updateUser = (OrientVertex)graph.getVertexByKey("User.userId", userId);
        if(updateUser != null) {
            Map eventMap = getEventMap(inputMap);
            Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
            inputMap.put("eventMap", eventMap);
            eventData.putAll(data);
            eventData.put("userId", userId);
            eventData.put("updateDate", new java.util.Date());

            // now return the shipping cost and tax according to the address if cartTotal exists
            Object total = data.get("cartTotal");
            if(total != null) {
                BigDecimal cartTotal = new BigDecimal(data.get("cartTotal").toString());
                List<Map<String, Object>> items = (List)data.get("cartItems");
                resultMap = new HashMap<String, Object>();
                Map<String, Object> shippingAddress = (Map<String, Object>)data.get("shippingAddress");
                BigDecimal shipping = calculateShipping(host, shippingAddress, items, cartTotal);
                resultMap.put("shipping", shipping);
                // calculate taxes
                Map<String, BigDecimal> taxes = calculateTax(host, shippingAddress, items, cartTotal.add(shipping));
                resultMap.put("taxes", taxes);
            }
        } else {
            error = "User with userId " + userId + " cannot be found.";
            inputMap.put("responseCode", 404);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }

    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        if(resultMap != null) inputMap.put("result", mapper.writeValueAsString(resultMap));
        return true;
    }
}
 
Example 17
Source File: AbstractBfnRule.java    From light with Apache License 2.0 4 votes vote down vote up
protected void addPostDb(String bfnType, Map<String, Object> data) throws Exception {
    String className = bfnType.substring(0, 1).toUpperCase() + bfnType.substring(1);
    String host = (String)data.get("host");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try{
        graph.begin();
        Vertex createUser = graph.getVertexByKey("User.userId", data.remove("createUserId"));
        List<String> tags = (List<String>)data.remove("tags");
        
        OrientVertex post = graph.addVertex("class:Post", data);
        createUser.addEdge("Create", post);
        // parent
        OrientVertex parent = getBranchByHostId(graph, bfnType, host, (String) data.get("parentId"));
        if(parent != null) {
            parent.addEdge("HasPost", post);
        }
        // tag
        if(tags != null && tags.size() > 0) {
            for(String tagId: tags) {
                Vertex tag = null;
                // get the tag is it exists
                OIndex<?> tagHostIdIdx = graph.getRawGraph().getMetadata().getIndexManager().getIndex("tagHostIdIdx");
                OCompositeKey tagKey = new OCompositeKey(host, tagId);
                OIdentifiable tagOid = (OIdentifiable) tagHostIdIdx.get(tagKey);
                if (tagOid != null) {
                    tag = graph.getVertex(tagOid.getRecord());
                    post.addEdge("HasTag", tag);
                } else {
                    tag = graph.addVertex("class:Tag", "host", host, "tagId", tagId, "createDate", data.get("createDate"));
                    createUser.addEdge("Create", tag);
                    post.addEdge("HasTag", tag);
                }
            }
        }
        graph.commit();
    } catch (Exception e) {
        logger.error("Exception:", e);
        graph.rollback();
    } finally {
        graph.shutdown();
    }
}
 
Example 18
Source File: BranchRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean downBranch (String branchType, Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String rid = (String) data.get("@rid");
    String host = (String) data.get("host");
    String error = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OrientVertex branch = (OrientVertex)DbService.getVertexByRid(graph, rid);
        OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", user.get("userId"));
        if(branch == null) {
            error = "@rid " + rid + " cannot be found";
            inputMap.put("responseCode", 404);
        } else {
            // TODO check if the current user has down voted the branch before.
            boolean voted = false;
            for (Edge edge : voteUser.getEdges(branch, Direction.OUT, "DownVote")) {
                if(edge.getVertex(Direction.IN).equals(branch)) voted = true;
            }
            if(voted) {
                error = "You have down voted the " + branchType + " already";
                inputMap.put("responseCode", 400);
            } else {
                Map eventMap = getEventMap(inputMap);
                Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                inputMap.put("eventMap", eventMap);
                eventData.put("host", host);
                eventData.put("categoryId", branch.getProperty("categoryId"));
                eventData.put("updateUserId", user.get("userId"));
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        // update the branch tree as one of branch has changed.
        Map<String, Object> branchMap = ServiceLocator.getInstance().getMemoryImage("branchMap");
        ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)branchMap.get("treeCache");
        if(cache != null) {
            cache.remove(host + branchType);
        }
        return true;
    }
}
 
Example 19
Source File: UpProductRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean execute (Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>)objects[0];
    Map<String, Object> data = (Map<String, Object>)inputMap.get("data");
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    String rid = (String)data.get("@rid");
    String error = null;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OrientVertex product = (OrientVertex) DbService.getVertexByRid(graph, rid);
        OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", user.get("userId"));
        if(product == null) {
            error = "@rid " + rid + " cannot be found";
            inputMap.put("responseCode", 404);
        } else {
            // TODO check if the current user has up voted the product before.
            boolean voted = false;
            for (Edge edge : voteUser.getEdges(product, Direction.OUT, "UpVote")) {
                if(edge.getVertex(Direction.IN).equals(product)) voted = true;
            }
            if(voted) {
                error = "You have up voted the product already";
                inputMap.put("responseCode", 400);
            } else {
                Map eventMap = getEventMap(inputMap);
                Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                inputMap.put("eventMap", eventMap);
                eventData.put("entityId", product.getProperty("entityId"));
                eventData.put("updateUserId", user.get("userId"));
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        return true;
    }
}
 
Example 20
Source File: BranchRule.java    From light with Apache License 2.0 4 votes vote down vote up
public boolean upBranch (String branchType, Object ...objects) throws Exception {
    Map<String, Object> inputMap = (Map<String, Object>) objects[0];
    Map<String, Object> data = (Map<String, Object>) inputMap.get("data");
    String rid = (String) data.get("@rid");
    String host = (String) data.get("host");
    String error = null;
    Map<String, Object> user = (Map<String, Object>) inputMap.get("user");
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OrientVertex branch = (OrientVertex)DbService.getVertexByRid(graph, rid);
        OrientVertex voteUser = (OrientVertex)graph.getVertexByKey("User.userId", user.get("userId"));
        if(branch == null) {
            error = "@rid " + rid + " cannot be found";
            inputMap.put("responseCode", 404);
        } else {
            // TODO check if the current user has up voted the branch before.
            boolean voted = false;
            for (Edge edge : voteUser.getEdges(branch, Direction.OUT, "UpVote")) {
                if(edge.getVertex(Direction.IN).equals(branch)) voted = true;
            }
            if(voted) {
                error = "You have up voted the " + branchType + " already";
                inputMap.put("responseCode", 400);
            } else {
                Map eventMap = getEventMap(inputMap);
                Map<String, Object> eventData = (Map<String, Object>)eventMap.get("data");
                inputMap.put("eventMap", eventMap);
                eventData.put("host", host);
                eventData.put("categoryId", branch.getProperty("categoryId"));
                eventData.put("updateUserId", user.get("userId"));
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    if(error != null) {
        inputMap.put("result", error);
        return false;
    } else {
        // update the branch tree as one of branch has changed.
        Map<String, Object> branchMap = ServiceLocator.getInstance().getMemoryImage("branchMap");
        ConcurrentMap<Object, Object> cache = (ConcurrentMap<Object, Object>)branchMap.get("treeCache");
        if(cache != null) {
            cache.remove(host + branchType);
        }
        return true;
    }
}