anchor.diff:  -module(erli_generic_resource).
   
   %% Webmachine Callbacks
  --export([init/1,
  -	 allowed_methods/2,
  -	 options/2,
  -	 malformed_request/2,
  -	 resource_exists/2,
  -	 previously_existed/2,
  -	 generate_etag/2,
  -	 content_types_provided/2,
  -	 delete_resource/2,
  -	 delete_completed/2,
  -	 as_json/2,
  -	 process_post/2]).
  +-export([allowed_methods/2, as_json/2,
  +	 content_types_provided/2, delete_completed/2,
  +	 delete_resource/2, generate_etag/2, init/1,
  +	 malformed_request/2, options/2, previously_existed/2,
  +	 process_post/2, resource_exists/2]).
   
   -include("models.hrl").
  +
   -include_lib("webmachine/include/webmachine.hrl").
   
   %%-----------------------------------------------------------
  
positive.code: 	    {{halt, 422}, NRD, Ctx}
      end.
  
  
  -spec build_record(object_type(), proplist()) -> object().
  build_record(path, Form) ->
      TargetId = proplists:get_value(<<"target_id">>, Form),
      case proplists:get_value(<<"custom_id">>, Form) of
  	undefined ->
  	    #path{target_id=TargetId};
  	Id ->
  	    #path{target_id=TargetId, id=Id}
      end.
  
  
  -spec maybe_store(collection_type(), object(), #wm_reqdata{}, term()) ->
  			 {true | {halt, 409 | 422}, #wm_reqdata{}, term()}.
  maybe_store(CollectionType, Record, RD, Ctx) ->
      case erli_storage:create(Record) of
  	{error, {conflict, {SubmittedRecord, ExistingRecord}}} ->
  	    Body = jsx:encode([{<<"conflictingEntity">>,
  				erli_utils:to_proplist(ExistingRecord)},
  			       {<<"submittedEntity">>,
  
negative.code: 	    NRD = erli_utils:add_json_response(RD, Body),
  	    {{halt, 422}, NRD, Ctx};
  	SavedTarget ->
  	    Body = jsx:encode([{atom_to_binary(CollectionType,
  					       latin1),
  				erli_utils:to_proplist(SavedTarget)}]),
  	    NRD = erli_utils:add_json_response(RD, Body),
  	    {true, NRD, Ctx}
      end.
  
  -spec root_elem_exists(object_type(), id()) ->
  			      false | {boolean(), object()}.
  root_elem_exists(ObjType, Id) ->
      case erli_storage:read(ObjType, Id) of
  	{error, _Error} -> false;
  	Obj when is_record(Obj, target) ->
  	    {not Obj#target.is_banned, Obj};
  	Obj when is_record(Obj, path) ->
  