Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/766 only metadata update #1009

Merged
merged 5 commits into from
Jul 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Fix: Add multiservice flag for the default configuration in the RPM. (Issue #964
Add: New operation "GET /v2/entities" (Issue #947)
Add: New operation "GET /v2" (Issue #956)
Fix: ONCHANGE subscription sends notification when value under condition it is not updated with updateContext-APPEND in some cases (Issue #943)
Fix: updating attribute metadata without updating attribute value at the same time is now supported (Issue #766)
Add: Reuse curl context for outgoing notifications, so now connections are persistent if the HTTP server doesn't close them
Fix: remove unconditional tracing on xmlTreat()/jsonTreat() which was impacting on performance (specially in high-load scenarios)
Fix: use NOSIGNAL as libcurl option to avoid crashes in that library. (Issue #1016)
Add: CLI paramter -cprForwardLimit to cap the number of forwarding request for a single client request. (Issue #1016).
Add: New operation "GET /v2/entities/{entityId}" (Issue #950)
Add: New operation "GET /v2/entities/{entityId}/attrs/{attrName}" (Issue #989)

29 changes: 25 additions & 4 deletions src/lib/mongoBackend/MongoCommonUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,31 @@ static bool mergeAttrInfo(BSONObj& attr, ContextAttribute* caP, BSONObj* mergedA
{
BSONObjBuilder ab;

/* 1. Add value */
valueBson(caP, ab);
/* 1. Add value, if present in the request (it could be omitted in the case of updating only metadata).
* When the value of the attribute is empty (no update needed/wanted), then the value of the attribute is
* 'copied' from DB to the variable 'ab' and sent back to mongo, to not destroy the value */
if (caP->value != "" || caP->compoundValueP != NULL)
{
valueBson(caP, ab);
}
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, when the value of the attribute is empty (no update needed/wanted), then the value of the attribute is 'copied' from DB to the variable 'ab' and sent back to mongo, to not destroy the value ?

An explaining comment would be good :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5dc4402

{
/* Slightly different treatment, depending on whether the attribute value in DB is compound or not */
if (attr.getField(ENT_ATTRS_VALUE).type() == Object)
{
ab.append(ENT_ATTRS_VALUE, attr.getField(ENT_ATTRS_VALUE).embeddedObject());
}
else if (attr.getField(ENT_ATTRS_VALUE).type() == Array)
{
ab.appendArray(ENT_ATTRS_VALUE, attr.getField(ENT_ATTRS_VALUE).embeddedObject());
}
else
{
ab.append(ENT_ATTRS_VALUE, STR_FIELD(attr, ENT_ATTRS_VALUE));
}
}

/* Add type, if present in request. If not, just use the one that is already present in the database. */
/* 2. Add type, if present in request. If not, just use the one that is already present in the database. */
if (caP->type != "")
{
ab.append(ENT_ATTRS_TYPE, caP->type);
Expand Down Expand Up @@ -1824,7 +1845,7 @@ void processContextElement
{
ContextAttribute* aP = ceP->contextAttributeVector[ix];

if ((aP->value.size() == 0) && (aP->compoundValueP == NULL))
if ((aP->value.size() == 0) && (aP->compoundValueP == NULL) && (aP->metadataVector.size() == 0))
{
ContextAttribute* ca = new ContextAttribute(aP);

Expand Down
Loading