Blue Mind
Release 1.0

net.bluemind.core.client.book
Class BookClient

java.lang.Object
  extended by net.bluemind.core.client.impl.AbstractClientImpl
      extended by net.bluemind.core.client.book.BookClient
All Implemented Interfaces:
IAddressBook, ISyncClient

public class BookClient
extends AbstractClientImpl
implements IAddressBook


Field Summary
 
Fields inherited from class net.bluemind.core.client.impl.AbstractClientImpl
logger
 
Constructor Summary
BookClient(java.lang.String syncServicesUrl)
           
 
Method Summary
 ResultList<Contact> advancedSearchContact(AccessToken token, ContactQuery cq)
          Solr based contact search
 Contact create(AccessToken token, Contact contact)
          Creates a new Contact.
 Folder createFolder(AccessToken token, Folder f)
          Creates a new contact Folder
 Contact createWithoutDuplicate(AccessToken token, Contact contact)
          Creates a Contact after checking if a similar one exists.
 Contact deleteContact(AccessToken token, java.lang.String uid)
          Delete contact
 void deleteFolder(AccessToken token, int id)
           
 FolderChanges doFolderSync(AccessToken token, ClientFolderChanges clientChanges, java.util.Date lastSync, java.lang.Boolean addDefaults)
          This method is a one-shot transactional synchronization API for Folder objects.
 ContactChanges doSync(AccessToken token, ClientContactChanges clientChanges, SyncScope scope, java.util.Date lastSync)
          This method is a one-shot transactional synchronization API for Contact objects.
 java.lang.String exportAllVCards(AccessToken token, java.lang.String query)
          Returns a vcard for all the contacts matching a given solr query
 java.lang.String exportFolderVcards(AccessToken token, int folderId)
          Creates a vcard for all the Contact in a Folder with the provided id
 java.lang.String exportVCard(AccessToken token, int id)
          Returns a vcard for a given Contact id
 java.util.List<Folder> findFolders(AccessToken token)
           
 java.util.List<Folder> findFolders(AccessToken token, FolderQuery fq)
           
 ResultList<Folder> findFoldersFromPattern(AccessToken token, java.lang.String pattern)
           
 Contact getContactFromId(AccessToken token, java.lang.String id)
          Fetch a Contact from its unique id
 Folder getFolderFromId(AccessToken token, int id)
          Fetch a Folder with its unique id
 FolderChanges getFolderSync(AccessToken token, java.util.Date lastSync, java.lang.Boolean addDefaults)
           
 Contact getPublicCollectedFromEmail(AccessToken token, java.lang.String email)
          Returns a non-null Contact if a contact with the given email exists in the public_collected folder from the token's domain.
 java.util.List<Folder> getSubscribedFolders(AccessToken token, int userId)
           
 java.util.List<Contact> importAllVCards(AccessToken token, Folder f, java.lang.String vCard)
           
 Contact importVCard(AccessToken token, Folder f, java.lang.String vCard)
          Imports a vcard containing exactly one contact in the given folder.
 AccessToken login(java.lang.String login, java.lang.String password, java.lang.String origin)
           
 void logout(AccessToken at)
           
 ResultList<Contact> searchContact(AccessToken token, ContactQuery cq, int limit)
          SQL based contact search, suitable ONLY for autocomplete as this method also returns groups & shared mailboxes as "fake" contacts.
 void setFolderSubscription(AccessToken token, int userId, java.util.List<java.lang.Integer> folders)
           
 void setFolderSync(AccessToken token, Folder f, boolean value)
          Marks a folder for synchronization for the token user.
 void subscribreMassUserFromAFolder(AccessToken token, int folderId, java.util.List<java.lang.Integer> users)
          Subscribes a bunch of users to a given folder id
 void unsetFolderSubscription(AccessToken token, int userId, java.util.List<java.lang.Integer> folders)
           
 void unsubscribreMassUserFromAFolder(AccessToken token, int folderId, java.util.List<java.lang.Integer> users)
          Un-subscribes a bunch of users from a given folder id
 Contact update(AccessToken token, Contact contact)
          Modifies an existing Contact.
 Folder updateFolder(AccessToken token, Folder f)
          Modifies an existing Folder (its name, etc)
 void waitForIndexing(AccessToken token)
          This is for unit testing only.
 
Methods inherited from class net.bluemind.core.client.impl.AbstractClientImpl
checkServerError, execute, executeStream, executeVoid, initParams, setToken, sudo, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BookClient

public BookClient(java.lang.String syncServicesUrl)
Method Detail

create

public Contact create(AccessToken token,
                      Contact contact)
               throws AuthFault,
                      ServerFault
Description copied from interface: IAddressBook
Creates a new Contact. The returned contact returns a positive id from Entity.getId().

Specified by:
create in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

createWithoutDuplicate

public Contact createWithoutDuplicate(AccessToken token,
                                      Contact contact)
                               throws AuthFault,
                                      ServerFault
Description copied from interface: IAddressBook
Creates a Contact after checking if a similar one exists. Returns the existing contact if a similar one is found. Search for similar contact is performed in one Folder if a folderId is set on the contact. Similar contacts are detected using lastname, email and mobile phone number.

Specified by:
createWithoutDuplicate in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

getContactFromId

public Contact getContactFromId(AccessToken token,
                                java.lang.String id)
                         throws AuthFault,
                                ServerFault
Description copied from interface: IAddressBook
Fetch a Contact from its unique id

Specified by:
getContactFromId in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

update

public Contact update(AccessToken token,
                      Contact contact)
               throws AuthFault,
                      ServerFault
Description copied from interface: IAddressBook
Modifies an existing Contact. Entity.getId() on the given contact must return a positive integer for the update to succeed.

Specified by:
update in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

deleteContact

public Contact deleteContact(AccessToken token,
                             java.lang.String uid)
                      throws AuthFault,
                             ServerFault
Description copied from interface: IAddressBook
Delete contact

Specified by:
deleteContact in interface IAddressBook
uid - contact ID
Returns:
Throws:
AuthFault
ServerFault

searchContact

public ResultList<Contact> searchContact(AccessToken token,
                                         ContactQuery cq,
                                         int limit)
                                  throws AuthFault,
                                         ServerFault
Description copied from interface: IAddressBook
SQL based contact search, suitable ONLY for autocomplete as this method also returns groups & shared mailboxes as "fake" contacts. The id in the returned contacts are entity ids, not real contact ids.

Specified by:
searchContact in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

getFolderSync

public FolderChanges getFolderSync(AccessToken token,
                                   java.util.Date lastSync,
                                   java.lang.Boolean addDefaults)
                            throws AuthFault,
                                   ServerFault
Specified by:
getFolderSync in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

getFolderFromId

public Folder getFolderFromId(AccessToken token,
                              int id)
                       throws AuthFault,
                              ServerFault
Description copied from interface: IAddressBook
Fetch a Folder with its unique id

Specified by:
getFolderFromId in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

createFolder

public Folder createFolder(AccessToken token,
                           Folder f)
                    throws AuthFault,
                           ServerFault
Description copied from interface: IAddressBook
Creates a new contact Folder

Specified by:
createFolder in interface IAddressBook
f - the folder to create
Returns:
Throws:
AuthFault
ServerFault

updateFolder

public Folder updateFolder(AccessToken token,
                           Folder f)
                    throws AuthFault,
                           ServerFault
Description copied from interface: IAddressBook
Modifies an existing Folder (its name, etc)

Specified by:
updateFolder in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

deleteFolder

public void deleteFolder(AccessToken token,
                         int id)
                  throws AuthFault,
                         ServerFault
Specified by:
deleteFolder in interface IAddressBook
Throws:
AuthFault
ServerFault

waitForIndexing

public void waitForIndexing(AccessToken token)
                     throws AuthFault,
                            ServerFault
Description copied from interface: IAddressBook
This is for unit testing only. Real code MUST not depend on solr indexing completion.

Specified by:
waitForIndexing in interface IAddressBook
Throws:
AuthFault
ServerFault

setFolderSync

public void setFolderSync(AccessToken token,
                          Folder f,
                          boolean value)
                   throws AuthFault,
                          ServerFault
Description copied from interface: IAddressBook
Marks a folder for synchronization for the token user. Look at IAddressBook.setFolderSubscription(AccessToken, int, List) for multiple subscriptions.

Specified by:
setFolderSync in interface IAddressBook
Throws:
AuthFault
ServerFault

login

public AccessToken login(java.lang.String login,
                         java.lang.String password,
                         java.lang.String origin)
Specified by:
login in interface ISyncClient
Overrides:
login in class AbstractClientImpl

logout

public void logout(AccessToken at)
Specified by:
logout in interface ISyncClient
Overrides:
logout in class AbstractClientImpl

exportVCard

public java.lang.String exportVCard(AccessToken token,
                                    int id)
                             throws ServerFault,
                                    AuthFault
Description copied from interface: IAddressBook
Returns a vcard for a given Contact id

Specified by:
exportVCard in interface IAddressBook
Returns:
Throws:
ServerFault
AuthFault

exportAllVCards

public java.lang.String exportAllVCards(AccessToken token,
                                        java.lang.String query)
                                 throws ServerFault,
                                        AuthFault
Description copied from interface: IAddressBook
Returns a vcard for all the contacts matching a given solr query

Specified by:
exportAllVCards in interface IAddressBook
query - the solr query
Returns:
Throws:
ServerFault
AuthFault

exportFolderVcards

public java.lang.String exportFolderVcards(AccessToken token,
                                           int folderId)
                                    throws ServerFault,
                                           AuthFault
Description copied from interface: IAddressBook
Creates a vcard for all the Contact in a Folder with the provided id

Specified by:
exportFolderVcards in interface IAddressBook
Returns:
Throws:
ServerFault
AuthFault

importVCard

public Contact importVCard(AccessToken token,
                           Folder f,
                           java.lang.String vCard)
                    throws ServerFault,
                           AuthFault
Description copied from interface: IAddressBook
Imports a vcard containing exactly one contact in the given folder.

Specified by:
importVCard in interface IAddressBook
Returns:
Throws:
ServerFault
AuthFault

importAllVCards

public java.util.List<Contact> importAllVCards(AccessToken token,
                                               Folder f,
                                               java.lang.String vCard)
                                        throws ServerFault,
                                               AuthFault
Specified by:
importAllVCards in interface IAddressBook
Throws:
ServerFault
AuthFault

findFolders

public java.util.List<Folder> findFolders(AccessToken token)
                                   throws ServerFault,
                                          AuthFault
Specified by:
findFolders in interface IAddressBook
Returns:
Throws:
ServerFault
AuthFault

advancedSearchContact

public ResultList<Contact> advancedSearchContact(AccessToken token,
                                                 ContactQuery cq)
                                          throws AuthFault,
                                                 ServerFault
Description copied from interface: IAddressBook
Solr based contact search

Specified by:
advancedSearchContact in interface IAddressBook
Returns:
The list of Contact matching the query.
Throws:
AuthFault
ServerFault

doSync

public ContactChanges doSync(AccessToken token,
                             ClientContactChanges clientChanges,
                             SyncScope scope,
                             java.util.Date lastSync)
                      throws AuthFault,
                             ServerFault
Description copied from interface: IAddressBook
This method is a one-shot transactional synchronization API for Contact objects. The caller submits all the changes (clientChanges ) that happened on his side since the pit point in time. The method checks what happened on the server side since the point in time. Using the changes wanted by the caller and what happened on the server sides, client changes are applied. When conflicts are detected, this method will resolve them. A list of changes ContactChanges that the caller MUST apply is returned, marking a new point in time for the next doSync call.

Specified by:
doSync in interface IAddressBook
clientChanges - The changes that happened on the caller side.
lastSync - The point in time for changes.
Returns:
The conflict-resolved list of changes that the caller must apply.
Throws:
AuthFault
ServerFault

doFolderSync

public FolderChanges doFolderSync(AccessToken token,
                                  ClientFolderChanges clientChanges,
                                  java.util.Date lastSync,
                                  java.lang.Boolean addDefaults)
                           throws AuthFault,
                                  ServerFault
Description copied from interface: IAddressBook
This method is a one-shot transactional synchronization API for Folder objects. The caller submits all the changes (clientChanges ) that happened on his side since the lastSync point in time. The method checks what happened on the server side since the point in time. Using the changes wanted by the caller and what happened on the server sides, client changes are applied. When conflicts are detected, this method will resolve them. A list of changes ContactChanges that the caller MUST apply is returned, marking a new point in time for the next doSync call.

Specified by:
doFolderSync in interface IAddressBook
clientChanges - The changes that happened on the caller side.
lastSync - The point in time for changes.
Returns:
Throws:
AuthFault
ServerFault

findFolders

public java.util.List<Folder> findFolders(AccessToken token,
                                          FolderQuery fq)
                                   throws AuthFault,
                                          ServerFault
Specified by:
findFolders in interface IAddressBook
Throws:
AuthFault
ServerFault

findFoldersFromPattern

public ResultList<Folder> findFoldersFromPattern(AccessToken token,
                                                 java.lang.String pattern)
                                          throws AuthFault,
                                                 ServerFault
Specified by:
findFoldersFromPattern in interface IAddressBook
Throws:
AuthFault
ServerFault

setFolderSubscription

public void setFolderSubscription(AccessToken token,
                                  int userId,
                                  java.util.List<java.lang.Integer> folders)
                           throws AuthFault,
                                  ServerFault
Specified by:
setFolderSubscription in interface IAddressBook
Throws:
AuthFault
ServerFault

getSubscribedFolders

public java.util.List<Folder> getSubscribedFolders(AccessToken token,
                                                   int userId)
                                            throws AuthFault,
                                                   ServerFault
Specified by:
getSubscribedFolders in interface IAddressBook
Throws:
AuthFault
ServerFault

unsetFolderSubscription

public void unsetFolderSubscription(AccessToken token,
                                    int userId,
                                    java.util.List<java.lang.Integer> folders)
                             throws AuthFault,
                                    ServerFault
Specified by:
unsetFolderSubscription in interface IAddressBook
Throws:
AuthFault
ServerFault

subscribreMassUserFromAFolder

public void subscribreMassUserFromAFolder(AccessToken token,
                                          int folderId,
                                          java.util.List<java.lang.Integer> users)
                                   throws AuthFault,
                                          ServerFault
Description copied from interface: IAddressBook
Subscribes a bunch of users to a given folder id

Specified by:
subscribreMassUserFromAFolder in interface IAddressBook
Throws:
AuthFault
ServerFault

unsubscribreMassUserFromAFolder

public void unsubscribreMassUserFromAFolder(AccessToken token,
                                            int folderId,
                                            java.util.List<java.lang.Integer> users)
                                     throws AuthFault,
                                            ServerFault
Description copied from interface: IAddressBook
Un-subscribes a bunch of users from a given folder id

Specified by:
unsubscribreMassUserFromAFolder in interface IAddressBook
Throws:
AuthFault
ServerFault

getPublicCollectedFromEmail

public Contact getPublicCollectedFromEmail(AccessToken token,
                                           java.lang.String email)
                                    throws AuthFault,
                                           ServerFault
Description copied from interface: IAddressBook
Returns a non-null Contact if a contact with the given email exists in the public_collected folder from the token's domain.

Specified by:
getPublicCollectedFromEmail in interface IAddressBook
Returns:
Throws:
AuthFault
ServerFault

Blue Mind
Release 1.0