Dekoh platform API

com.pramati.bfly.das.contacts.persistence
Class ApplicationShareManager

java.lang.Object
  extended by com.pramati.bfly.das.contacts.persistence.ApplicationShareManager

public class ApplicationShareManager
extends Object

Manager class for sharing/unsharing applications in various modes. ApplicationShareManager.getShareManager() returns an singleton instance of this class.

Since:
23 Mar, 2007

Method Summary
 Set getApplicationsSharedToAllContacts(String accountId)
          To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to all its contacts.
 Set getApplicationsSharedToDekohNetwork(String accountId)
          To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to entire DekohNetwork
 Set getApplicationsSharedToPublic(String accountId)
          To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to public.
 Set getSharedBuddiesForApp(String accountId, String appName)
          API to get the contacts for which the given application 'appName' is shared by user with account Id 'accountId' from this Dekoh Desktop.
 ShareInfo getShareIn(String accountId)
           
static ApplicationShareManager getShareManager()
           
 ShareInfo getSharesFromNonContacts(String accountId)
           
 void intialize()
           
 void intializeShareOut()
           
 boolean isSharedToAll(String accountId, String appName)
          API to know whether application 'appName' is shared globally to everyone by user with account Id 'accountId' from this Dekoh desktop.
 boolean isSharedToAllContacts(String accountId, String appName)
          API to know whether application 'appName' is shared to all user contacts by user with account Id 'accountId' from this Dekoh Desktop.
 boolean isSharedToDekohNetwork(String accountId, String appName)
          API to know whether application 'appName' is shared to every user on DekohNetwork by user with account Id 'accountId' from this Dekoh Desktop.
 void refreshShareIn(String authenticatedCookie, String accountId)
          To refresh the list of applications shared to this logged in user from its contacts and non contacts.
 void refreshShareOut(String authenticatedCookie, String accountId)
          Api to refresh the shared Application information by logged in users.
 boolean registerShareListener(ShareListener shareListener)
          For registering a ShareListener, for giving callbacks when Sharing/Unsharing event occurs.
 void shareAppToAll(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          API to share an application to Everyone.
 void shareAppToAllContacts(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          Api to share an application to all user contacts.
 void shareAppToContacts(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName, String[] contactKeys)
          Api to explicitly share an application to some contacts.
 void shareAppToDekohNetwork(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          Api to share an application to everyone on DekohNetwork.
 boolean unregisterShareListener(ShareListener shareListener)
          For unregistering a ShareListener.
 void unshareAppFromAll(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          To unshare an application, which is already shared to All.
 void unshareAppFromAllContacts(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          To unshare an application, which is already shared to All contacts of the Logged in user.
 void unshareAppFromContacts(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName, String[] contactKeys)
          To unshare an application, which is already shared to some Contacts.
 void unshareAppFromDekohNetwork(String accountId, String loggedInUserDekohId, String authenticatedCookie, String appName)
          To unshare an application, which is already shared to Dekoh Network.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

intialize

public void intialize()

intializeShareOut

public void intializeShareOut()

getShareManager

public static ApplicationShareManager getShareManager()

registerShareListener

public boolean registerShareListener(ShareListener shareListener)
For registering a ShareListener, for giving callbacks when Sharing/Unsharing event occurs.

Parameters:
shareListener - ShareListener instance which gets callbacks when a share/unshare event occurs.
Returns:
true if shareListener is successfully registered.

unregisterShareListener

public boolean unregisterShareListener(ShareListener shareListener)
For unregistering a ShareListener.

Parameters:
shareListener - ShareListener instance for which no more callbacks are needed while sharing/unsharing event occurs.
Returns:
true if shareListener is successfully registered. would return false, if user tries to deregister a non registered listener.

getShareIn

public ShareInfo getShareIn(String accountId)
Parameters:
accountId -
Returns:

getSharesFromNonContacts

public ShareInfo getSharesFromNonContacts(String accountId)
Parameters:
accountId -
Returns:

refreshShareIn

public void refreshShareIn(String authenticatedCookie,
                           String accountId)
                    throws ShareException,
                           CASNotReachableException,
                           UserOfflineException,
                           ForbiddenException
To refresh the list of applications shared to this logged in user from its contacts and non contacts. use getShareIn for getting shared applications to the logged in user from its Contacts and @link #getShareInFromNonContacts(String) getShareInFromNonContacts} for getting shared applications to the logged in user from its NonContacts.

Parameters:
authenticatedCookie - Authenticated cookie of the logged in user. This is needed for authenticating and authorizing the logged in user on the central server, before returning the requested information.
accountId - AccountId of the logged in user.
Throws:
ShareException - If unable to get the ShareInformation from central server.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.
See Also:
ApplicationShareManager.getShareIn(String)

refreshShareOut

public void refreshShareOut(String authenticatedCookie,
                            String accountId)
                     throws ShareException,
                            CASNotReachableException,
                            UserOfflineException,
                            ForbiddenException
Api to refresh the shared Application information by logged in users. This api will update the Dekoh Desktop with application shared information by the logged in user from this DekohDesktop (Identified by its Dekoh Desktop Id) to all its contacts. After refreshing, invoke these api to know how an application is shared to its contacts.
 
 

Parameters:
authenticatedCookie - Authenticated cookie of the logged in user. This is needed for authenticating and authorizing the logged in user on the central server, before returning the requested information.
accountId - AccountId of the logged in user.
Throws:
ShareException - If unable to refresh the ShareInformation from central server.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.

getApplicationsSharedToPublic

public Set getApplicationsSharedToPublic(String accountId)
To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to public.

Parameters:
accountId - DesktopUsers accountId for whom above information is requested
Returns:
contextroot of the application's which are shared as public. Will return emptyset if no application has been shared.

getApplicationsSharedToAllContacts

public Set getApplicationsSharedToAllContacts(String accountId)
To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to all its contacts.

Parameters:
accountId - DesktopUsers accountId for whom above information is requested
Returns:
contextroot of the application's which are shared to all contacts. Will return emptyset if no application has been shared.

getApplicationsSharedToDekohNetwork

public Set getApplicationsSharedToDekohNetwork(String accountId)
To get the list of application shared by the DesktopUser with given accountId from this DekohDesktop to entire DekohNetwork

Parameters:
accountId - DesktopUsers accountId for whom above information is requested
Returns:
contextroot of the application's which are shared to entire DekohNetwork. Will return emptyset if no application has been shared.

isSharedToAll

public boolean isSharedToAll(String accountId,
                             String appName)
API to know whether application 'appName' is shared globally to everyone by user with account Id 'accountId' from this Dekoh desktop. It is important to note that refresh needs to be invoked atleast once before invoking this api.

Parameters:
accountId - LoggedIn user's accountId.
appName - Application, for which it is checked whether it is globally shared.
Returns:
true, if globally shared. else will return false.

isSharedToDekohNetwork

public boolean isSharedToDekohNetwork(String accountId,
                                      String appName)
API to know whether application 'appName' is shared to every user on DekohNetwork by user with account Id 'accountId' from this Dekoh Desktop. It is important to note that refresh needs to be invoked atleast once before invoking this api.

Parameters:
accountId - LoggedIn user's accountId.
appName - Application, for which it is checked whether it is shared to entire Dekoh network.
Returns:
true, if shared to entire Dekoh Network. else will return false.

isSharedToAllContacts

public boolean isSharedToAllContacts(String accountId,
                                     String appName)
API to know whether application 'appName' is shared to all user contacts by user with account Id 'accountId' from this Dekoh Desktop. It is important to note that refresh needs to be invoked atleast once before invoking this api.

Parameters:
accountId - LoggedIn user's accountId.
appName - Application, for which it is checked whether it is shared to all user contacts.
Returns:
true, if shared to all user Contacts. else will return false.

getSharedBuddiesForApp

public Set getSharedBuddiesForApp(String accountId,
                                  String appName)
API to get the contacts for which the given application 'appName' is shared by user with account Id 'accountId' from this Dekoh Desktop. It is important to note that refresh needs to be invoked atleast once before invoking this api.

Parameters:
accountId - LoggedIn user's accountId.
appName - AppName for which the sharedContacts details 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.

shareAppToAll

public void shareAppToAll(String accountId,
                          String loggedInUserDekohId,
                          String authenticatedCookie,
                          String appName)
                   throws ShareException,
                          CASNotReachableException,
                          UserOfflineException,
                          ForbiddenException
API to share an application to Everyone. By invoking this api, application 'appName' on your Dekoh Desktop can be accessed any anyone, who are not even part of DekohNetwork. This api also assumes that Application is deployed and started on this Dekoh Desktop, and no check is made to validate the same. After successfully sharing the application ShareListener.sharedAppToAll listener callbacks are triggered.

If This application is already shared by using Other share modes i.e DekohNetwork or AllContacts or ExplicitShare, invoking this api will upgrade the Application share, so that this application can be accessed by everyone globally.

Also to be noted is that the old Sharing information is not lost. i.e, after invoking this Api, invoking unshareAppFromAll, will result in falling back to the earliest sharing mode.

For Example:

Suppose an Application 'app1' is shared to some Contacts and then this Api is invoked. Now unsharing from all, will make the application still available to old Contacts for which this application is explicitly shared, unless unshare is invoked explicitly for those contacts.

Use this api with caution.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - Authenticated cookie of the logged in user. This is needed for authenticating and authorizing the logged in user on the central server, before returning the requested information.
appName - Application Name which needs to be shared globally to everyone.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.

shareAppToDekohNetwork

public void shareAppToDekohNetwork(String accountId,
                                   String loggedInUserDekohId,
                                   String authenticatedCookie,
                                   String appName)
                            throws ShareException,
                                   CASNotReachableException,
                                   UserOfflineException,
                                   ForbiddenException
Api to share an application to everyone on DekohNetwork. By invoking this api, application 'appName' on your DekohDesktop can be accessed any anyone who is part of DekohNetwork. This api also assumes that Application is deployed and started on this Dekoh Desktop, and no check is made to validate the same. After successfully sharing the application ShareListener.sharedAppToDekohNetwork listener callbacks are triggered.

If this Api is invoked on an Application, which is already shared To All, would result in a ShareException.

If This application is already shared by using modes AllContacts or ExplicitShare, invoking this api will upgrade the Application share, so that this application can be accessed by everyone on Dekoh Network.

Also to be noted is that the old Sharing information is not lost. i.e, after invoking this Api, invoking unshareAppFromDekohNetwork, will result in falling back to the earliest sharing mode.

For Example:

Suppose an Application 'app1' is shared to some Contacts and then this Api is invoked. Now unsharing from Dekoh Network, will make the application still available to old Contacts for which this application is explicitly shared, unless unshare is invoked explicitly for those contacts.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - Authenticated cookie of the logged in user. This is needed for authenticating and authorizing the logged in user on the central server, before returning the requested information.
appName - Application which needs to be shared to everyone on DekohNetwork.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id, or is Already shared to All. i.e invoking isSharedToAll should return true.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.

shareAppToAllContacts

public void shareAppToAllContacts(String accountId,
                                  String loggedInUserDekohId,
                                  String authenticatedCookie,
                                  String appName)
                           throws ShareException,
                                  CASNotReachableException,
                                  UserOfflineException,
                                  ForbiddenException
Api to share an application to all user contacts. By invoking this api, application 'appName' on your DekohDesktop can be accessed any user who is in LoggedIn user contact's list. This api also assumes that Application is deployed and started on this Dekoh Desktop, and no check is made to validate the same. After successfully sharing the application ShareListener.sharedAppToAllContacts listener callbacks are triggered.

If this Api is invoked on an Application, which is already shared To All or To DekohNetwork, would result in a ShareException.

If This application is already shared by using modes ExplicitShare, invoking this api will upgrade the Application share, so that this application can be accessed by everyone on users Contacts list.

Also to be noted is that the old Sharing information is not lost. i.e, after invoking this Api, invoking unshareAppFromDekohNetwork, will result in falling back to the earliest sharing mode.

For Example:

Suppose an Application 'app1' is shared to some Contacts and then this Api is invoked. Now unsharing from All Contacts, will make the application still available to old Contacts for which this application is explicitly shared, unless unshare is invoked explicitly for those contacts.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - Authenticated cookie of the logged in user. This is needed for authenticating and authorizing the logged in user on the central server, before returning the requested information.
appName - Application which needs to be shared to everyone on logged in user contact's list.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id or is already shared to All or DekohNetwork i.e invoking isSharedToAll or isSharedToDekohNetwork would return true.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.

shareAppToContacts

public void shareAppToContacts(String accountId,
                               String loggedInUserDekohId,
                               String authenticatedCookie,
                               String appName,
                               String[] contactKeys)
                        throws ShareException,
                               CASNotReachableException,
                               UserOfflineException,
                               ForbiddenException,
                               HeuristicShareException
Api to explicitly share an application to some contacts. By invoking this api, application 'appName' on your DekohDesktop can be accessed any only user to whom its explictly shared (as specified by contactKeys). This api also assumes that Application is deployed and started on this Dekoh Desktop, and no check is made to validate the same. After successfully sharing the application ShareListener.sharedAppToContacts listener callbacks are triggered.

If this Api is invoked on an Application, which is already shared To All or To DekohNetwork or To All Contacts, would result in a ShareException.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - LoggedIn user's Authenticated Cookie. This cookie is needed to authenticate oneself to cas, before sharing the application.
appName - Application which needs to be shared to given contacts.
contactKeys - Contact key of the LoggedIn user's contacts. can be obtained by invoking Contact.getContactKey()
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id or is already shared to All or to DekohNetwork or to All Contact i.e invoking isSharedToAll or isSharedToDekohNetwork or ApplicationShareManager.isSharedToAllContacts(String,String) would return true.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.
HeuristicShareException - If sharing the application fails for some contacts. This exception has list of contacts for whom the sharing has failed.

unshareAppFromAll

public void unshareAppFromAll(String accountId,
                              String loggedInUserDekohId,
                              String authenticatedCookie,
                              String appName)
                       throws ShareException,
                              CASNotReachableException,
                              UserOfflineException,
                              ForbiddenException
To unshare an application, which is already shared to All. Invoking this api on an Application for which isSharedToAll returns false, would trigger a ShareException. After successfully unsharing the application ShareListener.unsharedAppFromAll listener callbacks are triggered.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - LoggedIn user's Authenticated Cookie. This cookie is needed to authenticate oneself to cas, before sharing the application.
appName - Application which needs to be unshared globally from everyone.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id or if this application is not already shared to All i.e invoking isSharedToAll would return false.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.

unshareAppFromDekohNetwork

public void unshareAppFromDekohNetwork(String accountId,
                                       String loggedInUserDekohId,
                                       String authenticatedCookie,
                                       String appName)
                                throws ShareException,
                                       CASNotReachableException,
                                       UserOfflineException,
                                       ForbiddenException
To unshare an application, which is already shared to Dekoh Network. Invoking this api on an Application for which isSharedToDekohNetwork returns false, would trigger a ShareException. After successfully unsharing the application ShareListener.unsharedAppFromDekohNetwork listener callbacks are triggered.

one point to note here is, if an Application is first shared using shareAppToDekohNetwork, and then upgraded using shareAppToAll, invoking this Api will result in removing old share Information, though the application is still available to all.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - LoggedIn user's Authenticated Cookie. This cookie is needed to authenticate oneself to cas, before sharing the application.
appName - Application which needs to be unshared from everyone on DekohNetwork.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id or if this application is not already shared to Dekoh Network i.e invoking ApplicationShareManager.isSharedToDekohNetwork(String,String) isSharedToDekohNetwork} would return false.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.
See Also:
ApplicationShareManager.shareAppToAll(String,String,String,String)

unshareAppFromAllContacts

public void unshareAppFromAllContacts(String accountId,
                                      String loggedInUserDekohId,
                                      String authenticatedCookie,
                                      String appName)
                               throws ShareException,
                                      CASNotReachableException,
                                      UserOfflineException,
                                      ForbiddenException
To unshare an application, which is already shared to All contacts of the Logged in user. Invoking this api on an Application for which isSharedToAllContacts returns false, would trigger a ShareException. After successfully unsharing the application ShareListener.unsharedAppFromAllContacts listener callbacks are triggered.

one point to note here is, if an Application is first shared using shareAppToAllContacts, and then upgraded using shareAppToAll or shareAppToDekohNetwork, invoking this Api will result in removing old share Information, though the application is still available to all or DekohNetwork.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - LoggedIn user's Authenticated Cookie. This cookie is needed to authenticate oneself to cas, before sharing the application.
appName - Application which needs to be unshared from All Contacts.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id or if this application is not already shared to All Contacts i.e invoking isSharedToAllContacts would return false.
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.
See Also:
ApplicationShareManager.shareAppToAll(String,String,String,String), ApplicationShareManager.shareAppToDekohNetwork(String,String,String,String)

unshareAppFromContacts

public void unshareAppFromContacts(String accountId,
                                   String loggedInUserDekohId,
                                   String authenticatedCookie,
                                   String appName,
                                   String[] contactKeys)
                            throws ShareException,
                                   CASNotReachableException,
                                   UserOfflineException,
                                   ForbiddenException,
                                   HeuristicShareException
To unshare an application, which is already shared to some Contacts. After successfully unsharing the application ShareListener.unsharedAppFromContacts listener callbacks are triggered.

one point to note here is, if an Application is first shared using shareAppToContacts, and then upgraded using shareAppToAll or shareAppToDekohNetwork or shareAppToAllContacts, invoking this Api will result in removing old share Information, though the application is still available to 'all' or 'DekohNetwork' or 'All Contacts'.

Parameters:
accountId - LoggedIn user's AccountId.
loggedInUserDekohId - LoggedIn user's Dekoh Id.
authenticatedCookie - LoggedIn user's Authenticated Cookie. This cookie is needed to authenticate oneself to cas, before sharing the application.
appName - Application which needs to be unshared from given contacts.
contactKeys - ContactKeys of the contacts for which the sharing needs to be removed.
Throws:
ShareException - If, Sharing fails. One of the Possible reasons could be Invalid Dekoh Desktop Id
UserOfflineException - If authenticatedCookie is null. When user is logged in locally because of no internet connectivity, authenticatedCookie would be set to null. so it is assumed in this api that, if authenticatedCookie is passed as null, user should have logged in locally. so cant do any share operations.
CASNotReachableException - If for any reason, Central server is not reachable.
ForbiddenException - If the authenticatedCookie is not a valid cookie.
HeuristicShareException - If unsharing the application fails for some contacts. This exception has list of contacts for whom the unsharing has failed.

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers