Dekoh platform API

com.pramati.bfly.das.contacts.helper
Class ShareService

java.lang.Object
  extended by com.pramati.bfly.das.contacts.helper.ShareService

public class ShareService
extends Object

ShareService exposes methods to Share and Unshare applications from a Dekoh Desktop to other Dekoh users. Only shared applications can be accessed.

ShareService for a Dekoh user can be obtained by invoking ShareService.getShareServiceForUser(DesktopUser).

One way to obtain the DesktopUser is by invoking SessionUtil.getLoggedInDesktopUser(request) with a request Object. This request should be part of the Session, in which user has logged into this Dekoh Desktop.

Since:
15 Jun, 2007

Nested Class Summary
static class ShareService.ShareScope
          Defines the Application Share Scope.
 
Method Summary
 void addContactsForApp(String appName, String[] contactKeys)
          Shares this application to more contacts.
 Set getSharedContactsForApp(String appName)
          Gets the contacts for which the given application appName is shared by this Dekoh User from this Dekoh Desktop.
 ShareService.ShareScope getShareScope(String appName)
          Gets ShareScope for the given application.
static ShareService getShareServiceForUser(DesktopUser desktopUser)
          Gets the ShareService of given DekohUser.
 ShareInfo getSharesFromContacts()
          Invoking this Api is same as invoking getSharesFromContacts(false)
 ShareInfo getSharesFromContacts(boolean synchronously)
          Gets the list of applications shared to this Desktop User from all its contacts.
 ShareInfo getSharesFromNonContacts()
          Invoking this Api is same as invoking getSharesFromNonContacts(false)
 ShareInfo getSharesFromNonContacts(boolean synchronously)
          Gets the list of applications shared to this desktopUser from all its Non-contacts.
 void removeContactsForApp(String appName, String[] contactKeys)
          Unshares this application from given contacts.
 void setAppToAll(String appName)
          Shares the application to Public.
 void setAppToAllContacts(String appName)
          Shares the application to All Contacts.
 void setAppToDekohNetwork(String appName)
          Shares the application to Dekoh Network.
 void setContactsForApp(String appName, String[] contactKeys)
          Shares the application to given contacts.
 void shareCollectionToContacts(String appName, String[] contactKeys)
          To share a collection (Application content data), application needs to be shared.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getShareServiceForUser

public static ShareService getShareServiceForUser(DesktopUser desktopUser)
Gets the ShareService of given DekohUser. Instance of DesktopUser who is currently logged in can be obtained by invoking SessionUtil.getLoggedInDesktopUser(request) method.

Parameters:
desktopUser - DekohUser for whom the ShareService is needed. Cannot be null. This needs to be a valid DekohUser, i.e should be a registered DekohUser with a valid dekohId.
Returns:
ShareService instance for sharing/unsharing applications.

getSharesFromContacts

public ShareInfo getSharesFromContacts()
                                throws ShareException,
                                       CASNotReachableException,
                                       UserOfflineException,
                                       ForbiddenException
Invoking this Api is same as invoking getSharesFromContacts(false)

Throws:
ShareException
CASNotReachableException
UserOfflineException
ForbiddenException
See Also:
ShareService.getSharesFromContacts(boolean)

getSharesFromContacts

public ShareInfo getSharesFromContacts(boolean synchronously)
                                throws ShareException,
                                       CASNotReachableException,
                                       UserOfflineException,
                                       ForbiddenException
Gets the list of applications shared to this Desktop User from all its contacts. use getSharesFromNonContacts(synchronously) for getting shared applications to this desktopUser from its Non Contacts.

Parameters:
synchronously - whether to fetch the shared application information from central server synchronously. if true, will fetch this information from central server and returns. otherwise, this will returned the cached information, which is updated periodically.
Returns:
ShareInfo instance having information on shared application.
Throws:
ShareException - If unable to refresh the ShareInformation from central server.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
See Also:
ShareService.getSharesFromNonContacts(boolean)

getSharesFromNonContacts

public ShareInfo getSharesFromNonContacts()
                                   throws ShareException,
                                          CASNotReachableException,
                                          UserOfflineException,
                                          ForbiddenException
Invoking this Api is same as invoking getSharesFromNonContacts(false)

Throws:
ShareException
CASNotReachableException
UserOfflineException
ForbiddenException
See Also:
ShareService.getSharesFromNonContacts(boolean)

getSharesFromNonContacts

public ShareInfo getSharesFromNonContacts(boolean synchronously)
                                   throws ShareException,
                                          CASNotReachableException,
                                          UserOfflineException,
                                          ForbiddenException
Gets the list of applications shared to this desktopUser from all its Non-contacts. use getSharesFromContacts(synchronously) for getting shared applications to this desktopUser from its Contacts.

Parameters:
synchronously - Whether to fetch the shared application information from central server synchronously. if true, will fetch this information from central server and returns. otherwise, this will returned the cached information, which is updated periodically.
Returns:
ShareInfo instance having information on shared application from non-Contacts.
Throws:
ShareException - If unable to refresh the ShareInformation from central server.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
See Also:
ShareService.getSharesFromContacts(boolean)

getShareScope

public ShareService.ShareScope getShareScope(String appName)
Gets ShareScope for the given application. ShareScope is
 
 

Parameters:
appName - Application for which ShareScope is information is needed.
Returns:
ShareScope for this application. possible values are ShareService.ShareScope.SHARED_TO_ALL, ShareService.ShareScope.SHARED_TO_DEKOH, ShareService.ShareScope.SHARED_TO_ALL_CONTACTS, ShareService.ShareScope.PRIVATE_SHARE, ShareService.ShareScope.NOT_SHARED

getSharedContactsForApp

public Set getSharedContactsForApp(String appName)
Gets the contacts for which the given application appName is shared by this Dekoh User from this Dekoh Desktop.

Parameters:
appName - application name for which the shared contacts information is requested.
Returns:
Set Of contacts for which application appName is shared by account 'accountId'. Will return an empty list, if the app is neither explicitly shared to some contacts nor installed on this Dekoh Desktop.

shareCollectionToContacts

public void shareCollectionToContacts(String appName,
                                      String[] contactKeys)
                               throws ShareException,
                                      CASNotReachableException,
                                      UserOfflineException,
                                      ForbiddenException,
                                      HeuristicShareException
To share a collection (Application content data), application needs to be shared. This method shares the application.

While sharing the application following rules are applied.

 
  • If the application, is never shared earlier, application would be shared to all Contacts of this Desktop user.
  • If the application is already shared to Public/DekohNetwork/AllContacts, nothing would be done by this api
  • If the Application is explicitly to some other contacts, the passed in contacts (referred by contactKeys) are added to the list of contacts to whom this application is explicitly shared.

If for some reason sharing to some contacts fail, this api throws a ShareException. But even after getting this exception, the application is stil shared to other contacts.

Parameters:
appName - Application which needs to be shared to given contacts.
contactKeys - Contacts for whom this application is getting shared.
Throws:
ShareException - If failed to share given application to all the passed contacts. possible reasons could be
  • invalid contactKeys
  • loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share applications
.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
HeuristicShareException - If sharing the application fails for some contacts. This exception has list of contacts for whom the sharing has failed.
See Also:
ShareService.ShareScope

addContactsForApp

public void addContactsForApp(String appName,
                              String[] contactKeys)
                       throws ShareException,
                              CASNotReachableException,
                              UserOfflineException,
                              ForbiddenException,
                              HeuristicShareException
Shares this application to more contacts. Invoking this method on an application, which was earlier shared to Public or to Dekoh Network or to All Contacts would throw a ShareException.

Parameters:
appName - Application which needs to be shared to given contacts.
contactKeys - Contacts for whom this Application is getting shared.
Throws:
ShareException - If failed to share given application to all the passed contacts. possible reasons could be
  • invalid contactKeys
  • this application was earlier shared to Public/DekohNetwork/AllContacts
  • loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share applications
.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
HeuristicShareException - If sharing the application fails for some contacts. This exception has list of contacts for whom the sharing has failed.

removeContactsForApp

public void removeContactsForApp(String appName,
                                 String[] contactKeys)
                          throws ShareException,
                                 CASNotReachableException,
                                 UserOfflineException,
                                 HeuristicShareException
Unshares this application from given contacts. Invoking this method on an application, which was earlier shared to Public or to Dekoh Network or to All Contacts would throw a ShareException.

Parameters:
appName - Application which needs to be unshared from given contacts.
contactKeys - Contacts for whom this Application is getting unshared.
Throws:
ShareException - If failed to unshare given application to all the passed contacts. possible reasons could be
  • invalid contactKeys
  • this application was earlier shared to Public/DekohNetwork/AllContacts
  • loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can unshare applications
.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
HeuristicShareException - If unsharing the application fails for some contacts. This exception has list of contacts for whom the unsharing has failed.

setContactsForApp

public void setContactsForApp(String appName,
                              String[] contactKeys)
                       throws ShareException,
                              CASNotReachableException,
                              UserOfflineException,
                              ForbiddenException,
                              HeuristicShareException
Shares the application to given contacts. If the application was previously shared, unshare the application and share it explcitly to passed contacts. i.e If given application is,
 
  • Not shared, share to passed contacts.
  • shared to Public/DekohNetwork/AllContacts, unshare the application and share only to passed contacts.
  • Already shared explicitly to some contacts (private share) then unshare from earlier contacts, and share to passed contacts.

Parameters:
appName - Application which needs to be shared to given contacts.
contactKeys - Contacts to whom this Application needs to be shared.
Throws:
ShareException - If failed to share given application to all the passed contacts. possible reasons could be
  • invalid contactKeys or
  • loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share application to All Contacts.
    UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
    CASNotReachableException - If for any reason, Central server is not reachable.
    ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.
    HeuristicShareException - If unsharing the application fails for some contacts. This exception has list of contacts for whom the unsharing has failed.

setAppToAllContacts

public void setAppToAllContacts(String appName)
                         throws ShareException,
                                CASNotReachableException,
                                UserOfflineException,
                                ForbiddenException
Shares the application to All Contacts. If the application was previously shared, unshare the application and share it to all contacts. i.e If given application is,
 
 

Parameters:
appName - Application which needs to be shared to All contacts.
Throws:
ShareException - If failed to share given application to All Contacts. One of the possible reason could be that loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share application to All Contacts.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.

setAppToDekohNetwork

public void setAppToDekohNetwork(String appName)
                          throws ShareException,
                                 CASNotReachableException,
                                 UserOfflineException
Shares the application to Dekoh Network. If the application was previously shared, unshare the application and share it to Dekoh Network. i.e If given application is,
 
 

Parameters:
appName - Application which needs to be shared to Dekoh Network.
Throws:
ShareException - If failed to share given application to Dekoh Network. One of the possible reason could be that loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share application to Dekoh Network.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.

setAppToAll

public void setAppToAll(String appName)
                 throws ShareException,
                        CASNotReachableException,
                        UserOfflineException
Shares the application to Public. If the application was previously shared, unshare the application and share it to Public. i.e If given application is,
 
 

Parameters:
appName - Application which needs to be shared to Public.
Throws:
ShareException - If failed to share given application to Public. One of the possible reason could be that loggedin user is not a valid registered DekohUser. Only DekohUsers who have registered and got a valid dekohid can share application to Public.
UserOfflineException - If User is logged into Dekoh Desktop in offline mode.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticated Session from central server on this DekohDesktop has expired. Desktop user should logoff and login again, before trying any other sharing operation.

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers