anchor.diff:      Src = occi_uri:to_binary(occi_link:get_source(Link)),
       Target = occi_uri:to_binary(occi_link:get_target(Link)),
       Attrs = [ { occi_attribute:get_id(A), occi_attribute:get_value(A)} 
  -	      || A <- occi_link:get_attributes(Link) ],
  +              || A <- occi_link:get_attributes(Link) ],
       Owner = io_lib:format("~p", [occi_node:owner(Node)]),
       case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"SaveLink">>, 
  -			 [Kind, Mixins, Src, Target, Attrs, Owner]) of
  -	ok -> 
  -	    {ok, State};
  -	{ok, _Ret} ->
  -	    ?error("Backend invalid answer: ~p", [_Ret]),
  -	    {{error, backend_error}, State};
  -	{error, Err} -> 
  -	    {{error, Err}, State}
  +                         [Kind, Mixins, Src, Target, Attrs, Owner]) of
  +        ok -> 
  +            {ok, State};
  +        {ok, _Ret} ->
  +            ?error("Backend invalid answer: ~p", [_Ret]),
  +            {{error, backend_error}, State};
  +        {error, Err} -> 
  +            {{error, Err}, State}
       end;
   
   save(#state{proxy=Backend}=State, #occi_node{type=occi_collection, data=Coll}=Node) ->
  
positive.code:     Id = occi_cid:to_binary(occi_collection:id(Coll)),
      Entities = [ occi_uri:to_binary(E) || E <- occi_collection:entities(Coll) ],
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"SaveMixin">>, [Id, Entities]) of
  	ok -> 
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} -> 
  	    {{error, Err}, State}
      end.
  
  
  delete(#state{i_mixin=false}=State, #occi_node{type=capabilities}) ->
      % TODO: handle this in occi_store: do not query backend in case it does not support and return sthig like 403
      {ok, State};
  
  delete(#state{proxy=Backend}=State, #occi_node{type=capabilities, data=Mixin}=Node) ->
      ?info("[~p] delete(~p)~n", [?MODULE, Node]),
      Id = occi_cid:to_binary(occi_mixin:id(Mixin)),
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"DelMixin">>, [Id]) of
  	ok ->
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} ->
  	    {{error, Err}, State}
      end;
  
  delete(#state{proxy=Backend}=State, #occi_node{id=Uri}=Node) ->
      ?info("[~p] delete(~p)~n", [?MODULE, Node]),
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"Delete">>, [occi_uri:to_binary(Uri)]) of
  	ok ->
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} ->
  	    {{error, Err}, State}
      end.
  
  
  update(#state{i_mixin=false}=State, #occi_node{type=capabilities}) ->
      % TODO: handle this in occi_store: do not query backend in case it does not support and return sthig like 403
      {ok, State};
      
  update(#state{proxy=Backend}=State, #occi_node{type=capabilities, data=Mixin}=Node) ->
      ?info("[~p] update(~p)~n", [?MODULE, Node]),
      Id = occi_cid:to_binary(occi_mixin:id(Mixin)),
      Location = occi_uri:to_binary(occi_node:id(Node)),
      Owner = io_lib:format("~p", [occi_node:owner(Node)]),
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"AddMixin">>, [Id, Location, Owner]) of
  	ok ->
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} ->
  	    {{error, Err}, State}
      end;    
  update(#state{proxy=Backend}=State, #occi_node{type=occi_collection, data=Coll}=Node) ->
      ?info("[~p] update(~p)~n", [?MODULE, Node]),
      Id = occi_cid:to_binary(occi_collection:id(Coll)),
      Entities = [ occi_uri:to_binary(E) || E <- occi_collection:entities(Coll) ],
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"UpdateMixin">>, [Id, Entities]) of
  	ok ->
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} ->
  	    {{error, Err}, State}
      end;    
  
  update(#state{proxy=Backend}=State, #occi_node{data=Entity}=Node) ->
      ?info("[~p] update(~p)~n", [?MODULE, Node]),
      Id = occi_node:id(Node),
      Attrs = [ { occi_attribute:get_id(A), occi_attribute:get_value(A)} 
  	      || A <- 
  		     case Entity of
  			 #occi_resource{} -> occi_resource:get_attributes(Entity);
  			 #occi_link{} -> occi_link:get_attributes(Entity)
  		     end ],
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"Update">>, [Id, Attrs]) of
  	ok ->
  	    {ok, State};
  	{ok, _Ret} ->
  	    ?error("Backend invalid answer: ~p", [_Ret]),
  	    {{error, backend_error}, State};
  	{error, Err} ->
  	    {{error, Err}, State}
      end.
  
  
  find(#state{proxy=Backend}=State, Node) ->
      ?info("[~p] find(~p)~n", [?MODULE, Node]),
      case occi_node:type(Node) of
  	capabilities ->
  	    Schema = dbus_properties_proxy:get(Backend, ?IFACE_BACKEND, 'schema'),
  	    Ext = occi_parser_xml:parse_extension(Schema),
  	    Kinds = occi_extension:kinds(Ext),
  	    Mixins = occi_extension:mixins(Ext),
  	    {{ok, [#occi_node{data={Kinds, Mixins, []}}]}, State};
  	occi_collection ->
  	    find_bounded(State, Node);
  	_ ->
  	    Id = occi_node:id(Node),
  	    case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"Find">>, [occi_uri:to_binary(Id)]) of
  		{ok, []} ->
  		    {{ok, []}, State};
  		{ok, [?N_ENTITY, OpaqueId, Owner, Serial]} ->
  		    Res = #occi_node{id=Id, objid=OpaqueId, owner=Owner, etag=Serial, type=occi_entity},
  		    {{ok, [Res]}, State};
  		{ok, [?N_UNBOUNDED, _, _, _]} ->
  		    find_unbounded(State, Node);
  		{ok, _Res} ->
  		    ?error("Backend invalid answer: ~p", [_Res]),
  		    {{error, backend_error}, State};
  		{error, Err} ->
  		    {{error, Err}, State}
  	    end
      end.
  
  
  
negative.code: 
  %% occi_backend callbacks
  -export([init/1,
           terminate/1]).
  -export([update/2,
           save/2,
           delete/2,
           find/2,
           load/3,
           action/3]).
  
  -record(state, {conn      :: dbus_connection(),
                  proxy     :: dbus_proxy(),
                  i_mixin   :: boolean(),
                  i_action  :: boolean()}).
  
  %%%===================================================================
  %%% occi_backend callbacks
  %%%===================================================================
  init(#occi_backend{opts=Props}) ->
      try parse_opts(Props) of
          {Service, Opts} -> connect_backend(Service, Opts)
      catch throw:Err -> {error, Err}
      end.
  
  
  terminate(#state{proxy=Backend}) ->
      case dbus_proxy:call(Backend, ?IFACE_BACKEND, <<"Terminate">>, []) of
          _ -> ok
      end.
  
  
  