diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 1c79163c7..150a40ebe 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -288,7 +288,7 @@ init_nodes(Host, ServerHost, _NodeTree, Plugins) -> case lists:member("hometree", Plugins) of true -> create_node(Host, ServerHost, string_to_node("/home"), service_jid(Host), "hometree"), - create_node(Host, ServerHost, string_to_node("/home" ++ ServerHost), service_jid(Host), "hometree"); + create_node(Host, ServerHost, string_to_node("/home/" ++ ServerHost), service_jid(Host), "hometree"); false -> ok end. diff --git a/src/mod_pubsub/node_flat.erl b/src/mod_pubsub/node_flat.erl index fb517adb1..e044015b2 100644 --- a/src/mod_pubsub/node_flat.erl +++ b/src/mod_pubsub/node_flat.erl @@ -60,8 +60,8 @@ get_item/2, set_item/1, get_item_name/3, - node_to_path/1, - path_to_node/1 + node_to_path/1, + path_to_node/1 ]). @@ -185,12 +185,12 @@ get_item_name(Host, Node, Id) -> node_hometree:get_item_name(Host, Node, Id). node_to_path(Node) -> - [binary_to_list(Node)]. + [Node]. path_to_node(Path) -> case Path of % default slot - [Node] -> list_to_binary(Node); + [Node] -> Node; % handle old possible entries, used when migrating database content to new format [Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/")); % default case (used by PEP for example) diff --git a/src/mod_pubsub/node_flat_odbc.erl b/src/mod_pubsub/node_flat_odbc.erl index cc9bb9e84..1230fe29a 100644 --- a/src/mod_pubsub/node_flat_odbc.erl +++ b/src/mod_pubsub/node_flat_odbc.erl @@ -61,8 +61,8 @@ set_item/1, get_item_name/3, get_last_items/3, - node_to_path/1, - path_to_node/1 + node_to_path/1, + path_to_node/1 ]). @@ -191,14 +191,7 @@ get_last_items(NodeId, From, Count) -> node_hometree_odbc:get_last_items(NodeId, From, Count). node_to_path(Node) -> - [binary_to_list(Node)]. + node_flat:node_to_path(Node). path_to_node(Path) -> - case Path of - % default slot - [Node] -> list_to_binary(Node); - % handle old possible entries, used when migrating database content to new format - [Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/")); - % default case (used by PEP for example) - _ -> list_to_binary(Path) - end. + node_flat:path_to_node(Path). diff --git a/src/mod_pubsub/node_hometree.erl b/src/mod_pubsub/node_hometree.erl index 7c62d645e..3c47c5a64 100644 --- a/src/mod_pubsub/node_hometree.erl +++ b/src/mod_pubsub/node_hometree.erl @@ -76,8 +76,8 @@ get_item/2, set_item/1, get_item_name/3, - node_to_path/1, - path_to_node/1 + node_to_path/1, + path_to_node/1 ]). %% ================ @@ -208,7 +208,7 @@ create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) -> case acl:match_rule(ServerHost, Access, exmpp_jid:make(LU, LS, LR)) of allow -> case node_to_path(Node) of - ["home", Server, User | _] -> true; + [<<"home">>, Server, User | _] -> true; _ -> false end; _ -> @@ -986,12 +986,12 @@ get_item_name(_Host, _Node, Id) -> Id. node_to_path(Node) -> - string:tokens(binary_to_list(Node), "/"). - + [list_to_binary(Item) || Item <- string:tokens(binary_to_list(Node), "/")]. + path_to_node([]) -> <<>>; path_to_node(Path) -> - list_to_binary(string:join([""|Path], "/")). + list_to_binary(string:join([""|[binary_to_list(Item) || Item <- Path]], "/")). %% @spec (Affiliation, Subscription) -> true | false %% Affiliation = owner | member | publisher | outcast | none diff --git a/src/mod_pubsub/node_hometree_odbc.erl b/src/mod_pubsub/node_hometree_odbc.erl index 7d7aa7caf..e3f729680 100644 --- a/src/mod_pubsub/node_hometree_odbc.erl +++ b/src/mod_pubsub/node_hometree_odbc.erl @@ -239,7 +239,7 @@ create_node(NodeId, Owner) -> %% Removed = [mod_pubsub:pubsubNode()] %% @doc
purge items of deleted nodes after effective deletion.
delete_node(Removed) -> -%% pablo: TODO, this is present on trunk/node_home_tree but not on trunk/node_home_tree_odbc. +%% pablo: TODO, this is present on trunk/node_hometree but not on trunk/node_hometree_odbc. %% check what is the desired behaviour %% Tr = fun(#pubsub_state{stateid = {J, _}, subscriptions = Ss}) -> %% lists:map(fun(S) -> @@ -1382,9 +1382,7 @@ i2l(L, N) when is_list(L) -> end. node_to_path(Node) -> - string:tokens(binary_to_list(Node), "/"). + node_hometree:node_to_path(Node). -path_to_node([]) -> - <<>>; path_to_node(Path) -> - list_to_binary(string:join([""|Path], "/")). + node_hometree:path_to_node(Path). diff --git a/src/mod_pubsub/node_pep.erl b/src/mod_pubsub/node_pep.erl index 8bfd5428d..6a1ba2c45 100644 --- a/src/mod_pubsub/node_pep.erl +++ b/src/mod_pubsub/node_pep.erl @@ -66,8 +66,8 @@ get_item/2, set_item/1, get_item_name/3, - node_to_path/1, - path_to_node/1 + node_to_path/1, + path_to_node/1 ]). init(Host, ServerHost, Opts) -> diff --git a/src/mod_pubsub/node_pep_odbc.erl b/src/mod_pubsub/node_pep_odbc.erl index af309c9b2..ca1ce0127 100644 --- a/src/mod_pubsub/node_pep_odbc.erl +++ b/src/mod_pubsub/node_pep_odbc.erl @@ -70,9 +70,9 @@ get_item/2, set_item/1, get_item_name/3, - get_last_items/3, - node_to_path/1, - path_to_node/1 + get_last_items/3, + node_to_path/1, + path_to_node/1 ]). init(Host, ServerHost, Opts) -> diff --git a/src/mod_pubsub/nodetree_tree.erl b/src/mod_pubsub/nodetree_tree.erl index 84ecfb906..6bdf81d3c 100644 --- a/src/mod_pubsub/nodetree_tree.erl +++ b/src/mod_pubsub/nodetree_tree.erl @@ -212,15 +212,15 @@ create_node(Host, Node, Type, Owner, Options, Parents) -> true; _ -> case Parents of - [] -> true; - [Parent | _] -> - case mnesia:read({pubsub_node, {Host, Parent}}) of - [#pubsub_node{owners = [{[], Host, []}]}] -> true; - [#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners); - _ -> false - end; - _ -> - false + [] -> true; + [Parent | _] -> + case mnesia:read({pubsub_node, {Host, Parent}}) of + [#pubsub_node{owners = [{undefined, Host, undefined}]}] -> true; + [#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners); + _ -> false + end; + _ -> + false end end, case ParentExists of