def check_rec_resources(res,path='')
messages = []
res.each do |tres|
tpath = if path == ''
'/'
else
tres.attributes['relative'].nil? ? path + '{}/' : path + tres.attributes['relative'] + '/'
end
h_ifield = {}; h_pfield = {}
h_ofield = {}; h_tfield = {}
h_cfield = {}
tres.find("des:get|des:put|des:patch|des:delete|des:post|des:request").each do |mt|
mn = (mt.attributes['type'].nil? ? mt.qname.to_s : mt.attributes['type'])
h_ifield[mn] ||= {}; h_pfield[mn] ||= {}
h_ofield[mn] ||= []; h_tfield[mn] ||= []
h_cfield[mn] ||= 0
a = mt.attributes
if !a['in'].nil? && a['in'] != '*'
h_ifield[mn][a['in']] ||= 0
h_ifield[mn][a['in']] += 1
end
if !a['pass'].nil? && a['pass'] != '*'
h_pfield[mn][a['pass']] ||= 0
h_pfield[mn][a['pass']] += 1
end
h_ofield[mn] << a['out'] unless a['out'].nil?
h_tfield[mn] << a['transformation'] unless a['transformation'].nil?
h_cfield[mn] += 1 if !a['transformation'].nil? || a['in'] == '*' || a['pass'] == '*'
end
h_ifield.each do |mn,ifield|
messages += check_multi_fields(ifield,"#{tpath} -> #{mn}","in")
end
h_pfield.each do |mn,pfield|
messages += check_multi_fields(pfield,"#{tpath} -> #{mn}","pass")
end
h_ofield.each do |mn,ofield|
messages += check_fields(ofield,"#{tpath} -> #{mn}","out","message")
end
h_tfield.each do |mn,tfield|
messages += check_fields(tfield,"#{tpath} -> #{mn}","transformation","transformation")
end
h_cfield.each do |mn,cfield|
messages << "#{tpath} -> #{mn}: more than one catchall (*) operation is not allowed." if cfield > 1
end
messages += check_rec_resources(tres.find("des:resource"),tpath)
end
messages
end