SOAP response structure for GetContactsRequest

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

SOAP response structure for GetContactsRequest

Postby parin » Thu Nov 28, 2013 7:55 am

@liverpoolfcfan
I got it for parsing Emails.we can do same in Java like above code.. but how will you parse addresses..to make the case more worsen enter random single values in multiple address like in adress 1 with type home enter only City. in address 2 with type Other enter only Street. and in address 3 with type Home again enter State or Country. now this is my ultimate and most dangerous parsing case ever.


liverpoolfcfan
Outstanding Member
Outstanding Member
Posts: 944
Joined: Sat Sep 13, 2014 12:47 am

SOAP response structure for GetContactsRequest

Postby liverpoolfcfan » Thu Nov 28, 2013 8:16 am

Same principle applies.
All are stored in sets.

homeStreet,homeCity,homePostalCode,homeCountry make up the first set.

homeStreet2,homeCity2,homePostalCode2,homeCountry2 make up the second set.

etc.
Same goes for work... and other...
You just need to adjust your isset checks to look for the existence of any one of the 4 pieces of information for any given address set
NOTE: The zimbra web UI does a bad job of SAVING these if you do as you said - just enter random single pieces of information in for each address.
liverpoolfcfan
Outstanding Member
Outstanding Member
Posts: 944
Joined: Sat Sep 13, 2014 12:47 am

SOAP response structure for GetContactsRequest

Postby liverpoolfcfan » Thu Nov 28, 2013 8:55 am

By the way, I have opened a bug on the behaviour of the Web Client saving these partially entered addresses

Bug 85145 ? Addresses muddled if not all fields filled in for Contact
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

SOAP response structure for GetContactsRequest

Postby parin » Fri Nov 29, 2013 12:06 am

Actually we can not say it is a bug of the web ui.. that is the only problem i am talking about.. user can enter anything of any type inside address.like you tried to enter 5 addresses of same type HOME. now what happens is when we try to fetch that contact from SOAP request,the resulting response has muddled attributes. this is the default behavior and we can not say it is a bug.so that is why i am suggesting to have some arragement of attribute data. now imagine a worst case having 5 addresses and each having only City field. now when we will fetch that contact, the response will contain something like this.
Jhon

XYZ

smith

test@test.com

XYZ

test@test.com

test@test.com

XYZ

..

.

.

.

.

XYZ


Now this is the usual response we get through SOAP request. so once we get this data,arrays of A tag is prepared.now think how you will parse addresses. because you dont know the arrangement ! also to parse simple data like firstName or lastName, we must travers entire array. and according to me this is not efficient. so i suggest they must have some proper ordering. so it is a severe problem of arrangement and not a bug.
gren
Zimbra Employee
Zimbra Employee
Posts: 39
Joined: Sat Sep 13, 2014 1:23 am

SOAP response structure for GetContactsRequest

Postby gren » Sat Nov 30, 2013 4:12 pm

[quote user="parin"]@liverpoolfcfan
exactly correct.. we see a response part only. but my question is how it is going to store in underlying database. take an example of emails just as above and we have table relationship like Contact Table for contact details and Email table for contactEmail details. now Contact and ContactEmail have O2M relationship.means one contact can have 0 or more emails. so now the problem arises. json response will simply return _attr element with list of contact attribute. so my question is how we will find multiple emails from that Map. also the problem becomes more complecated when user enters multiple addresses. and in that case it becomes more worsen when users like me adds single value like city in one address,street in second address and state in another address for testing.so now finding out how many addresses user have entered is very tough. can you help me in this case. ???[/QUOTE]
I think the other replies to this are probably more useful than what I'm saying here but one of your questions was about how this is stored in the server. The contact fields are actually stored encoded in the metadata column in the database. A command like:

# zmmetadump -m user2@coco.local -i 257


will decode the contents of the metadata column (along with other database columns) to produce output like:

[Database Columns]

mailbox_id: 2

id: 257

type: 6

parent_id:

folder_id: 7

index_id: 0

imap_id: 257

date: 1385847060 (Sat 2013/11/30 21:31:00 GMT)

size: 0

locator:

blob_digest:

unread:

flags: 0

tags: 0

tag_names:

sender: Goose, Gray

recipients:

subject:

name:

mod_metadata: 2

change_date: 1385847060 (Sat 2013/11/30 21:31:00 GMT)

mod_content: 2

uuid:
[Metadata]

{

fld = {

email = gg@example.com

email2 = ggoose@eg.com

email3 = gray.goose@example.com

firstName = Gray

lastName = Goose

}

}


If you download the Zimbra source, the file responsible for encoding/decoding this field is ZimbraServer/src/java/com/zimbra/cs/mailbox/Metadata.java.

The zmmetadata source is in ZimbraServer/src/java/com/zimbra/cs/mailbox/util/MetadataDump.java
parin
Posts: 28
Joined: Sat Sep 13, 2014 3:06 am

SOAP response structure for GetContactsRequest

Postby parin » Mon Dec 02, 2013 12:51 am

@gren,@liverpoolfcfan
Thank you both of you for giving responses. but still i am unable to express what problem i am facing. you will think this as a counter argument. but the fact is i am unable to make you understand what my problem is. i request you to read my actual problem in the post below.
[QUOTE]
Same principle applies.
All are stored in sets.

homeStreet,homeCity,homePostalCode,homeCountry make up the first set.

homeStreet2,homeCity2,homePostalCode2,homeCountry2 make up the second set.

etc.
Same goes for work... and other...
You just need to adjust your isset checks to look for the existence of any one of the 4 pieces of information for any given address set
NOTE: The zimbra web UI does a bad job of SAVING these if you do as you said - just enter random single pieces of information in for each address.
[/QUOTE]
and what i replyed to this response..
[QUOTE]Actually we can not say it is a bug of the web ui.. that is the only problem i am talking about.. user can enter anything of any type inside address.like you tried to enter 5 addresses of same type HOME. now what happens is when we try to fetch that contact from SOAP request,the resulting response has muddled attributes. this is the default behavior and we can not say it is a bug.so that is why i am suggesting to have some arragement of attribute data. now imagine a worst case having 5 addresses and each having only City field. now when we will fetch that contact, the response will contain something like this.
Jhon

XYZ

smith

test@test.com

XYZ

test@test.com

test@test.com

XYZ

..

.

.

.

.

XYZ


Now this is the usual response we get through SOAP request. so once we get this data,arrays of A tag is prepared.now think how you will parse addresses. because you dont know the arrangement ! also to parse simple data like firstName or lastName, we must travers entire array. and according to me this is not efficient. so i suggest they must have some proper ordering. so it is a severe problem of arrangement and not a bug. [/QUOTE]


so actually this post asks multiple questions about the algorithm and both database structure. so according to my problem,user can enter anything any number of times in address fields. the resulting soap request will contatin whataver non-null values in form of .. so this is not at all a problem for me. it is just a soap request structure. my problem starts when we actually try to fetch those data back in order to store into my local database.when we try to fetch that contact containing multiple addresses, it is mearly impossible to construct a whole address out of that list of attributes. because the resulting response contains list of in no order. so we have no clue whether user has enter address or if so wht fields user has entered. in order to answer those questions,we must loop through that list. so my actual question is something like this. how the web client displays muddled addresses field into correct address type.
for database structure i am using one main Contact table with number of other tables like Phone,Address,Email for multiple values. so another question is that ,is my db structure is correct?? if not what modification should be done in order to store contact details.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 5 guests