Commit eaa89c05 authored by Hugo Roenick's avatar Hugo Roenick
Browse files

Commit final dos itens:

[OPENBUS-2087] - Registro de Ofertas lança UnauthorizedFacets incorretamente durante a tentativa de registro de entidades legadas
[OPENBUS-2088] - Find na faceta legada (IRegistryService) não implementa a semântica correta.
[OPENBUS-2089] - Relaxar o critério das propriedades reservadas

- correção dos bugs registrados nos itens acima
- simplificação do código do validador de teste

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/trunk@135128 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 1a790280
......@@ -99,51 +99,65 @@ function IRegistryService:findByCriteria(facets, criteria)
end
end
end
local offers = newfacets.OfferRegistry:findServices(props)
local offers
if #props == 0 then
offers = newfacets.OfferRegistry:getAllServices()
else
offers = newfacets.OfferRegistry:findServices(props)
end
local results = {}
for index, offer in ipairs(offers) do
for _, facet in ipairs(offer.facets) do
-- only add as result the offers that either offer a facet with a name or
-- interface name specified in the 'facets' parameter of this opertion
if facets[facet.name] ~= nil or facets[facet.interface_name] ~= nil then
local compId = {}
local name2index = {}
local props = {}
for _, prop in ipairs(offer.properties) do
local name = prop.name
if name == "openbus.component.name" then
compId.name = prop.value
elseif name == "openbus.component.version.major" then
compId.major = prop.value
elseif name == "openbus.component.version.minor" then
compId.minor = prop.value
elseif name == "openbus.component.version.patch" then
compId.patch = prop.value
else
if name == "openbus.offer.entity" then
name = "registered_by"
end
local index = name2index[name]
if index == nil then
index = #props+1
name2index[name] = index
props[index] = { name = name, value = {} }
end
local value = props[index].value
value[#value+1] = prop.value
end
local include = true
for _, facetspec in ipairs(facets) do
local found = false
for _, facetinfo in ipairs(offer.facets) do
if facetinfo.name == facetspec or facetinfo.interface_name == facetspec then
found = true
break
end
props[#props+1] = {
name = "component_id",
value = { "name", ("$name:$major.$minor.$patch"):tag(compId) }
}
results[#results+1] = {
member = offer.service_ref,
properties = props,
}
end
if not found then
include = false
break
end
end
if include then
local compId = {}
local name2index = {}
local props = {}
for _, prop in ipairs(offer.properties) do
local name = prop.name
if name == "openbus.component.name" then
compId.name = prop.value
elseif name == "openbus.component.version.major" then
compId.major = prop.value
elseif name == "openbus.component.version.minor" then
compId.minor = prop.value
elseif name == "openbus.component.version.patch" then
compId.patch = prop.value
else
if name == "openbus.offer.entity" then
name = "registered_by"
end
local index = name2index[name]
if index == nil then
index = #props+1
name2index[name] = index
props[index] = { name = name, value = {} }
end
local value = props[index].value
value[#value+1] = prop.value
end
end
props[#props+1] = {
name = "component_id",
value = { "name", ("$name:$major.$minor.$patch"):tag(compId) }
}
results[#results+1] = {
member = offer.service_ref,
properties = props,
}
end
end
return results
end
......
......@@ -112,7 +112,7 @@ function BusInterceptor:unmarshalCredential(...)
local credential = Interceptor.unmarshalCredential(self, ...)
if credential ~= nil then
local chain = credential.chain
if chain == nil then
if chain == nil then -- unjoined non-legacy call
chain = {
signature = false,
originators = {},
......@@ -120,7 +120,7 @@ function BusInterceptor:unmarshalCredential(...)
target = self.login.id,
}
credential.chain = chain
else
elseif chain.signature ~= nil then -- joined non-legacy call
local originators = chain.originators
originators[#originators+1] = chain.caller -- add last originator
chain.caller = getLoginInfoFor(self, chain.target)
......
......@@ -80,6 +80,23 @@ local function updateAuthorization(db, id, set, spec, value)
end
end
local ReservedProperties = {
["openbus.offer.id"] = true,
["openbus.offer.login"] = true,
["openbus.offer.entity"] = true,
["openbus.offer.timestamp"] = true,
["openbus.offer.year"] = true,
["openbus.offer.month"] = true,
["openbus.offer.day"] = true,
["openbus.offer.hour"] = true,
["openbus.offer.minute"] = true,
["openbus.offer.second"] = true,
["openbus.component.name"] = true,
["openbus.component.version.major"] = true,
["openbus.component.version.minor"] = true,
["openbus.component.version.patch"] = true,
}
local function makePropertyList(entry, service_props)
local props = {
{ name = "openbus.offer.id", value = entry.id },
......@@ -107,10 +124,10 @@ local function makePropertyList(entry, service_props)
end
local illegal = {}
for _, prop in ipairs(service_props) do
if prop.name:find("openbus", 1, true) == 1 then
illegal[#illegal+1] = prop
else
if ReservedProperties[prop.name] == nil then
props[#props+1] = prop
else
illegal[#illegal+1] = prop
end
end
if #illegal > 0 then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment