GE Orion Context Broker: when we make an update of the entity, does not allow us to update the attribute of type "coords" - fiware-orion

Regards,
Our problem is ‘a priori’ related to the GE implementation Orion Context Broker. Our version Orion Context Broker: 0.14.0.
We have a Web Service which we have implemented, sending data collected by a number of dispositives, to a machine that we have deployed in our account Fi-ware Platform. The problem that has been presented to us is that one of the attributes we are setting is a type attribute “coords” and when we are trying to make an update of the entity, does not allow us to update that attribute, and gives the following error (see below, a part of the response). We also want to update this field.
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type />
<contextValue />
</contextAttribute>
<contextAttribute>
<name>date</name>
<type />
<contextValue />
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue />
<metada>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metada>
</contextAttribute>
</contextAttributeList>
</contextElement>
<statusCode>
<code>472</code>
<reasonPhrase>request parameter is invalid/not allowed</reasonPhrase>
<details>action:UPDATE - entity: (300000000000008, dispositivo) - offending attribute: position - location attribute has to be defined at creation time, with APPEND</details>
</statusCode>
</contextElementResponse>
The REST request that we are setting to the ContextBroker and which is giving us problems is:
public static String payloadUpdateTemplate =
#"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
<contextAttribute>
<name>latitude</name>
<type>φ</type>
<contextValue>{2}</contextValue>
</contextAttribute>
<contextAttribute>
<name>longitude</name>
<type>λ</type>
<contextValue>{3}</contextValue>
</contextAttribute>
<contextAttribute>
<name>altitude</name>
<type>m</type>
<contextValue>{4}</contextValue>
</contextAttribute>
<contextAttribute>
<name>acceleration</name>
<type>m/s²</type>
<contextValue>{5}</contextValue>
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type></type>
<contextValue>{6}</contextValue>
</contextAttribute>
<contextAttribute>
<name>date</name>
<type></type>
<contextValue>{7}</contextValue>
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>UPDATE</updateAction>
</updateContextRequest>";
Yes, we have previously created the entity that we are trying to update, using updateContext operation with APPEND action type. The payload that we are using to do entity creation is:
public static String payloadInsertTemplate =
#"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
<contextAttribute>
<name>latitude</name>
<type>φ</type>
<contextValue>{2}</contextValue>
</contextAttribute>
<contextAttribute>
<name>longitude</name>
<type>λ</type>
<contextValue>{3}</contextValue>
</contextAttribute>
<contextAttribute>
<name>altitude</name>
<type>m</type>
<contextValue>{4}</contextValue>
</contextAttribute>
<contextAttribute>
<name>acceleration</name>
<type>m/s²</type>
<contextValue>{5}</contextValue>
</contextAttribute>
<contextAttribute>
<name>android_version</name>
<type></type>
<contextValue>{6}</contextValue>
</contextAttribute>
<contextAttribute>
<name>date</name>
<type></type>
<contextValue>{7}</contextValue>
</contextAttribute>
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>APPEND</updateAction>
</updateContextRequest>";
We are using a REST Web Service. The literal {0} in the payload identifies each entity of the context. For example, if the ID of a dispositivo is 1111, the literal {0} will be 1111. In the other side, if the code of a sensor is 2222, the literal {0} will be 2222. The literal {0} is an identification key (unique and not null).
More information,
1) First of all, we insert a new entity with the following payload. The literal {0} is the ID of the entity, for example, id(entity) = 30000000000002. The literal {1} is the current value of the temperature of the entity Id, for example, temperature(entity) = 30,0.
public static String payloadInsertTemplate =
#"<updateContextRequest>
<contextElementList>
<contextElement>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>{1}</contextValue>
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>{2}, {3}</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
</contextElementList>
<updateAction>APPEND</updateAction>
</updateContextRequest>";
2) The result of the insertion operation is as follows.
<updateContextResponse>
<contextResponseList>
<contextElementResponse>
<contextElement>
<entityId type="dispositivo" isPattern="false">
<id>30000000000002</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue />
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue />
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contexAttributeList>
</contextElement>
<statusCode>
<code>200</code>
<reasonPhrase>OK</reasonPhrase>
</statusCode>
</contextElementResponse>
</contextResponseList>
</updateContextResponse>
3) We make the query and we can check the new values created with the payload.
<queryContextRequest>
<entityIdList>
<entityId type='dispositivo' isPattern='false'>
<id>{0}</id>
</entityId>
</entityIdList>
<attributeList/>
</queryContextRequest>
4) Then we are getting the value that we have introduced.
<queryContextResponse>
<contextResponseList>
<contextElementResponse>
<contextElement>
<entityId type="dispositivo" isPattern="false">
<id>30000000000002</id>
</entityId>
<contextAttributeList>
<contextAttribute>
<name>temperature</name>
<type>Cº</type>
<contextValue>30,0</contextValue>
</contextAttribute>
.
.
.
.
<contextAttribute>
<name>position</name>
<type>coords</type>
<contextValue>36.723804, -4.417518</contextValue>
<metadata>
<contextMetadata>
<name>location</name>
<type>string</type>
<value>WSG84</value>
</contextMetadata>
</metadata>
</contextAttribute>
</contextAttributeList>
</contextElement>
<statusCode>
<code>200</code>
<reasonPhrase>OK</reasonPhrase>
</statusCode>
</contextElementResponse>
</contextResponseList>
5) Now we try to do the update of this data which we have introduced correctly (how you can check) and it gives the error.

This block means that you can't update a value of an attribute that not defined at creation time.
action:UPDATE - entity: (300000000000008, dispositivo) -
offending attribute: position - location attribute has to be defined
at creation time, with APPEND
If the location attribute was not defined at creation time you should use APPEND action to create that new attribute in your entity, also if this entity already created before.
Using APPEND instead of UPDATE you will be able to append new attributes to a previously created Entity.
After that be sure that you're replacing all curly braces to properly values.

This seems to be an issue in 0.14.0 (and before). Fortunatelly, there are two easy workarounds to this problem:
Use APPEND instead of UPDATE (note that APPEND on existing context elements has the same semantic than UPDATE).
Remove the <metadata>...</metadata> for location given that once you have defined an attribute as location it is stored as such and you don't need to "repeat" the metadata in further updateCoxtext requests (you can check that with queryContext).
We will implement a fix in the next release (0.14.1). Thanks for the feedback!

Related

How to deal with nested xml-collections in ETL of OrientDB?

I followed the samples at OrientDBs manual to extract data from a xml collection (2nd sample) and load it into a OrientDB graph database: it worked.
But now i stuck and don't know, how to describe the oetl-configuration (json-File), if I change the samples source data that it looks like (and meets my requirements) - nest a <ADD>-Section:
<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<ADD>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</ADD>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<ADD>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</ADD>
</CD>
</CATALOG>
Does anybody know, how to write the configuration. The following doesn't work, and the ADD field in my graph database is an empty string:
...
"extractor" :
{ "xml":
{
"rootNode": "CATALOG.CD",
"tagsAsAttribute": ["CATALOG.CD"]
}
},
...
Thanks for your help!
Best

How to Fix "There has been an error processing your request :: Specified invalid parent id (Magento_Backend::mgs)" in Admin Panel..?

I'm using Magento2,when i login on my website i got this message.
There has been an error processing your request Specified invalid
parent id (Magento_Backend::mgs) Error log record number:
1307308720759
This website was working fine but last day i run a query and recompile and then this issue start coming up....
Below Error Log Detail
{"0":"Specified invalid parent id (Magento_Backend::mgs)","1":"#0
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
Magento\Backend\Model\Menu\Builder->getResult(Object(Magento\Backend\Model\Menu))\n#1
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Backend\Model\Menu\Builder\Interceptor->___callParent('getResult',
Array)\n#2
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Backend\Model\Menu\Builder\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Backend\Model\Menu))\n#3
/home/gervetus/public_html/generated/code/Magento/Backend/Model/Menu/Builder/Interceptor.php(26):
Magento\Backend\Model\Menu\Builder\Interceptor->___callPlugins('getResult',
Array, Array)\n#4
/home/gervetus/public_html/vendor/magento/module-backend/Model/Menu/Config.php(148):
Magento\Backend\Model\Menu\Builder\Interceptor->getResult(Object(Magento\Backend\Model\Menu))\n#5
/home/gervetus/public_html/vendor/magento/module-backend/Model/Menu/Config.php(111):
Magento\Backend\Model\Menu\Config->_initMenu()\n#6
/home/gervetus/public_html/vendor/magento/module-backend/Model/Url.php(361):
Magento\Backend\Model\Menu\Config->getMenu()\n#7
/home/gervetus/public_html/vendor/magento/module-backend/Model/Url.php(321):
Magento\Backend\Model\Url->_getMenu()\n#8
/home/gervetus/public_html/generated/code/Magento/Backend/Model/Url/Interceptor.php(102):
Magento\Backend\Model\Url->getStartupPageUrl()\n#9
/home/gervetus/public_html/vendor/magento/module-backend/App/AbstractAction.php(276):
Magento\Backend\Model\Url\Interceptor->getStartupPageUrl()\n#10
/home/gervetus/public_html/vendor/magento/module-backend/App/AbstractAction.php(208):
Magento\Backend\App\AbstractAction->_processUrlKeys()\n#11
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))\n#12
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callParent('dispatch',
Array)\n#13
/home/gervetus/public_html/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143):
Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#14
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor),
Object(Closure), Object(Magento\Framework\App\Request\Http))\n#15
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#16
/home/gervetus/public_html/generated/code/Magento/Backend/Controller/Adminhtml/Index/Index/Interceptor.php(26):
Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->___callPlugins('dispatch',
Array, NULL)\n#17
/home/gervetus/public_html/vendor/magento/framework/App/FrontController.php(55):
Magento\Backend\Controller\Adminhtml\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#18
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))\n#19
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch',
Array)\n#20
/home/gervetus/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))\n#21
/home/gervetus/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26):
Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch',
Array, Array)\n#22
/home/gervetus/public_html/vendor/magento/framework/App/Http.php(135):
Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#23
/home/gervetus/public_html/vendor/magento/framework/App/Bootstrap.php(256):
Magento\Framework\App\Http->launch()\n#24
/home/gervetus/public_html/index.php(40):
Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))\n#25
{main}","url":"/admin/admin/index/index/key/6570ae1e6f609b1c1c0433e9e2307b5d7250e1e160091871b57a4326817cae2e/","script_name":"/index.php"}
Just modify the menu file located under /vendor/magento/module-cms/etc/adminthml/menu.xml
<add id="Magento_Backend::mgs" title="Blocks" translate="title" module="Magento_Cms" sortOrder="30" parent="Magento_Backend::mgs" action="cms/block" resource="Magento_Cms::block"/>
Here's how it'll look
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Magento_Cms::cms_page" title="Pages" translate="title" module="Magento_Cms" sortOrder="0" parent="Magento_Backend::content_elements" action="cms/page" resource="Magento_Cms::page"/>
<add id="Magento_Cms::cms_block" title="Blocks" translate="title" module="Magento_Cms" sortOrder="30" parent="Magento_Backend::content_elements" action="cms/block" resource="Magento_Cms::block"/>
<add id="Magento_Backend::mgs" title="Blocks" translate="title" module="Magento_Cms" sortOrder="30" parent="Magento_Backend::mgs" action="cms/block" resource="Magento_Cms::block"/>
</menu>
</config>
As per error there is no any parent id name with mgs so it will throw error.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Magento_Cms::cms_page" title="Pages" module="Magento_Cms" sortOrder="0" parent="Magento_Backend::content_elements" action="cms/page" resource="Magento_Cms::page"/>
<add id="Magento_Cms::cms_block" title="Blocks" module="Magento_Cms" sortOrder="30" parent="Magento_Backend::content_elements" action="cms/block" resource="Magento_Cms::block"/>
</menu>
In the code above parent="Magento_Backend::content_elements" will display in content menu so give valid id to your menu then it will work.
For reference see this link

Mulesoft Insertion into Mongo DB database

I am using a Mongo DB connector to insert data into Mongo Instance located in mLab.
I am sure I am using the correct credentials since these credentials are working when I am using them through a Java code.
But here using the Mongo DB connector constantly throws me an error as can be seen below.
org.mule.api.ConnectionException: Couldn't connect with the given
credentials org.mule.api.ConnectionException: Couldn't connect with
the given credentials at
org.mule.module.mongo.MongoCloudConnector.getDatabase(MongoCloudConnector.java:1304)
at
org.mule.module.mongo.MongoCloudConnector.connect(MongoCloudConnector.java:1173)
at
org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionFactory.makeObject(MongoCloudConnectorConnectionFactory.java:56)
at
org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220)
at
org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.acquireConnection(MongoCloudConnectorConnectionManager.java:361)
at
org.mule.module.mongo.connectivity.MongoCloudConnectorConnectionManager.test(MongoCloudConnectorConnectionManager.java:444)
at
org.mule.tooling.metadata.api.utils.ConnectionTester.internalTestConnection(ConnectionTester.java:88)
at
org.mule.tooling.metadata.api.utils.ConnectionTester.testConnectionFor(ConnectionTester.java:113)
at
Is there something that I am missing here?
Below is the XML :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mongo="http://www.mulesoft.org/schema/mule/mongo" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/mongo http://www.mulesoft.org/schema/mule/mongo/current/mule-mongo.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Configuration" host="developers.zomato.com" port="80" doc:name="HTTP Request Configuration"/>
<http:request-config name="HTTP_Request_Configuration1" host="api.mlab.com" port="80" doc:name="HTTP Request Configuration"/>
<mongo:config name="Mongo_DB" password="XXXXX" database="restaurant_data" host="ds241039.mlab.com" port="41039" doc:name="Mongo DB" username="XxXx"/>
<flow name="rest-webservice-applicationFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/rest" allowedMethods="GET" doc:name="HTTP"/>
<http:request config-ref="HTTP_Request_Configuration" path="api/v2.1/search" method="GET" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="entity_id" value="1"/>
<http:query-param paramName="entity_type" value="city"/>
<http:header headerName="user-key" value="XXXXXXXXX"/>
</http:request-builder>
</http:request>
<dw:transform-message doc:name="Transform Message" metadata:id="13f7b603-ac1e-45b4-9950-32c39a20ee36">
<dw:input-payload mimeType="application/json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
{
results_found: payload.results_found,
results_start: payload.results_start,
results_shown: payload.results_shown,
restaurants: payload.restaurants map ((restaurant , indexOfRestaurant) -> {
restaurant: {
R: restaurant.restaurant.R,
id: restaurant.restaurant.id,
name: restaurant.restaurant.name,
url: restaurant.restaurant.url,
location: restaurant.restaurant.location,
switch_to_order_menu: restaurant.restaurant.switch_to_order_menu,
cuisines: restaurant.restaurant.cuisines,
average_cost_for_two: restaurant.restaurant.average_cost_for_two,
price_range: restaurant.restaurant.price_range,
currency: restaurant.restaurant.currency,
offers: restaurant.restaurant.offers map ((offer , indexOfOffer) -> offer),
thumb: restaurant.restaurant.thumb,
user_rating: restaurant.restaurant.user_rating,
photos_url: restaurant.restaurant.photos_url,
menu_url: restaurant.restaurant.menu_url,
featured_image: restaurant.restaurant.featured_image,
has_online_delivery: restaurant.restaurant.has_online_delivery,
is_delivering_now: restaurant.restaurant.is_delivering_now,
deeplink: restaurant.restaurant.deeplink,
has_table_booking: restaurant.restaurant.has_table_booking,
events_url: restaurant.restaurant.events_url
}
})
}]]></dw:set-payload>
</dw:transform-message>
<mongo:json-to-dbobject doc:name="Mongo DB"/>
<mongo:insert-object config-ref="Mongo_DB" doc:name="Mongo DB" collection="restaurant"/>
</flow>
</mule>
The MongoDB connector uses the deprecated MONGODB-CR authentication mechanism, MLab is expecting the SCRAM-SHA-1 mechanism.
The SCRAM-SHA-1 mechanism is available in the enterprise version of Mulesoft ESB.
The connection URI configuration is available on version 4.2.0 and above. This is how you configure it:
Add the connector to pom.xml:
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-mongo-connector</artifactId>
<version>4.2.0</version>
</dependency>
Configure a connection in your flow:
<mongo:config-connection-string name="MongoDB_Config"
connectionString="mongodb://jdoe:myPass#localhost:27017?authMechanism=SCRAM-SHA-1"/>

howto use the logback discriminator value to filter mongodb inserts

I have multiple threads generating log entries and I use the logback SiftingAppender to know who did what. Everything works fine and now im trying to save the log to mongodb.
In the mongodb the log needs to be saved into an embedded document array. Every user document have one embedded document that has an array of embedded documents containing log lines
Since im just started to learn logback this has to be some trial and error now.
In the below test logback.xml i have the file, consol and a custom appender.
My idea was that i could catch the SiftingAppender discriminator value in the custom appender append() method. Then the getMDCPropertyMap(); in the ILoggingEventgives me the MDC values but the question is if this is an efficient technic for what i want to do
I cannot see that logback has any native MDC-mongodb-appender or maybe i have missed something.
<configuration>
<appender name="SIFT-FILE" class="ch.qos.logback.classic.sift.SiftingAppender">
<!-- in the absence of the class attribute, it is assumed that the
desired discriminator type is
ch.qos.logback.classic.sift.MDCBasedDiscriminator -->
<discriminator>
<key>userid</key>
<defaultValue>unknown</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${userid}" class="ch.qos.logback.core.FileAppender">
<file>${userid}.log</file>
<append>true</append>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %level %mdc %logger{35} - %msg%n</pattern>
</layout>
</appender>
</sift>
</appender>
<appender name="SIFT-STDOUT" class="ch.qos.logback.classic.sift.SiftingAppender">
<!-- in the absence of the class attribute, it is assumed that the
desired discriminator type is
ch.qos.logback.classic.sift.MDCBasedDiscriminator -->
<discriminator>
<key>userid</key>
<defaultValue>unknown</defaultValue>
</discriminator>
<sift>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} ${userid}- %msg %n</pattern>
</encoder>
</appender>
</sift>
</appender>
<appender name="SIFT-MONGO" class="ch.qos.logback.classic.sift.SiftingAppender">
<!-- in the absence of the class attribute, it is assumed that the
desired discriminator type is
ch.qos.logback.classic.sift.MDCBasedDiscriminator -->
<discriminator>
<key>userid</key>
<defaultValue>unknown</defaultValue>
</discriminator>
<sift>
<appender name="MONGO" class="com.carlsberg.MongoAppender">
</appender>
</sift>
</appender>
<root level="DEBUG">
<appender-ref ref="SIFT-FILE" />
<appender-ref ref="SIFT-STDOUT" />
<appender-ref ref="SIFT-MONGO" />
</root>
</configuration>
I used the SiftingAppender discriminator value in the my custom appender like this.
public void append(ILoggingEvent event) {
Map<String, String> m = event.getMDCPropertyMap();
String id = (String) m.get("userid");
if(id != null){
Query<UserLog> query1 = mongo.createQuery(UserLog.class);
query1.field("lowerCaseUserName").equal(id.toLowerCase());
UpdateOperations<UserLog> up2 = mongo.createUpdateOperations
(UserLog.class).add("log", event.getLevel().levelStr +" "+ ft.format(event.getTimeStamp()) +" "+ event.getFormattedMessage(), true);
UpdateResults<UserLog> udr1 = mongo.update(query1, up2);
if(udr1.getError() != null){
System.out.print("ERROR CANNOT SAVE to UserLog ip adress for " + id);
}
}
}

syncml status 415 for devinf

I'm getting 415 status from N95 client for sending server devinf.
I tried many things but no success.
Here is server response (generated by me, I'm writing my own implementation of syncml server.):
<?xml version="1.0"?>
<!DOCTYPE SyncML PUBLIC "-//SYNCML//DTD SyncML 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/OMA-TS-SyncML_RepPro_DTD-V1_2.dtd">
<SyncML>
<SyncHdr>
<VerDTD>1.2</VerDTD>
<VerProto>SyncML/1.2</VerProto>
<SessionID>14</SessionID>
<MsgID>1</MsgID>
<Target>
<LocURI>IMEI:356406027185460</LocURI>
</Target>
<Source>
<LocURI>http://localhost:8880</LocURI>
</Source>
<Meta>
<MaxMsgSize xmlns="syncml:metinf">10000</MaxMsgSize>
</Meta>
</SyncHdr>
<SyncBody>
<Status>
<MsgRef>1</MsgRef>
<Data>200</Data>
<Cmd>Alert</Cmd>
<CmdRef>1</CmdRef>
<CmdID>1</CmdID>
</Status>
<Status>
<MsgRef>1</MsgRef>
<Data>200</Data>
<Cmd>Put</Cmd>
<CmdRef>2</CmdRef>
<CmdID>2</CmdID>
</Status>
<Status>
<MsgRef>1</MsgRef>
<Data>200</Data>
<Cmd>Get</Cmd>
<CmdRef>3</CmdRef>
<CmdID>3</CmdID>
<TargetRef>./devinf12</TargetRef>
</Status>
<Results>
<MsgRef>1</MsgRef>
<Item>
<Meta>
<Type xmlns="syncml:metinf">application/vnd.syncml-devinf+xml</Type>
</Meta>
<Source>
<LocURI>./devinf12</LocURI>
</Source>
<Data>
<DevInf xmlns="syncml:devinf">
<VerDTD>1.2</VerDTD>
<Man>my company ltd.</Man>
<Mod>syncml mod</Mod>
<SwV>0.01</SwV>
<FwV>1.01</FwV>
<HwV>0.1a</HwV>
<DevID>syncmlserv</DevID>
<DevTyp>server</DevTyp>
<DataStore>
<SourceRef>./contacts</SourceRef>
<Rx-Pref>
<CTType>text/vcard</CTType>
<VerCT>3.0</VerCT>
</Rx-Pref>
<Rx>
<CTType>text/vcard</CTType>
<VerCT>2.1</VerCT>
</Rx>
<Tx-Pref>
<CTType>text/vcard</CTType>
<VerCT>3.0</VerCT>
</Tx-Pref>
<Tx>
<CTType>text/vcard</CTType>
<VerCT>2.1</VerCT>
</Tx>
<CTCap>
<CTType>text/x-vcard</CTType>
<PropName>BEGIN</PropName>
<ValEnum>VCARD</ValEnum>
<PropName>END</PropName>
<ValEnum>VCARD</ValEnum>
<PropName>VERSION</PropName>
<ValEnum>2.1</ValEnum>
<PropName>N</PropName>
<PropName>TEL</PropName>
<ParamName>VOICE</ParamName>
<ParamName>FAX</ParamName>
<ParamName>CELL</ParamName>
</CTCap>
<CTCap>
<CTType>text/x-vcard</CTType>
<PropName>BEGIN</PropName>
<ValEnum>VCARD</ValEnum>
<PropName>END</PropName>
<ValEnum>VCARD</ValEnum>
<PropName>VERSION</PropName>
<ValEnum>3.0</ValEnum>
<PropName>N</PropName>
<PropName>TEL</PropName>
<ParamName>VOICE</ParamName>
<ParamName>FAX</ParamName>
<ParamName>CELL</ParamName>
</CTCap>
<SyncCap>
<SyncType>1</SyncType>
<SyncType>2</SyncType>
<SyncType>3</SyncType>
<SyncType>4</SyncType>
<SyncType>5</SyncType>
<SyncType>6</SyncType>
</SyncCap>
</DataStore>
</DevInf>
</Data>
</Item>
<CmdRef>3</CmdRef>
<CmdID>4</CmdID>
<Meta>
<Type xmlns="syncml:metinf">application/vnd.syncml-devinf+xml</Type>
</Meta>
<TargetRef>./devinf12</TargetRef>
</Results>
</SyncBody>
</SyncML>
And Here is what client sends:
<?xml version="1.0"?>
<!DOCTYPE SyncML PUBLIC "-//SYNCML//DTD SyncML 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/OMA-TS-SyncML_RepPro_DTD-V1_2.dtd">
<SyncML xmlns="SYNCML:SYNCML1.2">
<SyncHdr>
<VerDTD>1.2</VerDTD>
<VerProto>SyncML/1.2</VerProto>
<SessionID>14</SessionID>
<MsgID>2</MsgID>
<Target>
<LocURI>http://localhost:8880</LocURI>
</Target>
<Source>
<LocURI>IMEI:356406027185460</LocURI>
</Source>
<Meta>
<MaxMsgSize xmlns="syncml:metinf">10000</MaxMsgSize>
</Meta>
</SyncHdr>
<SyncBody>
<Status>
<CmdID>1</CmdID>
<MsgRef>1</MsgRef>
<CmdRef>0</CmdRef>
<Cmd>SyncHdr</Cmd>
<TargetRef>IMEI:356406027185460</TargetRef>
<SourceRef>http://localhost:8880</SourceRef>
<Data>200</Data>
</Status>
<Status>
<CmdID>2</CmdID>
<MsgRef>1</MsgRef>
<CmdRef>4</CmdRef>
<Cmd>Results</Cmd>
<Data>415</Data>
</Status>
</SyncBody>
</SyncML>
Just one note putting meta in/out of Item does not change a thing.
I'm basically lost at that stage..
the response code is a SyncML response..
probabaly you have a Unsupported media type or format. The unsupported content
type or format SHOULD also be identified in the Item
element type in the Status.
check on that...