The SiteManager is the first object required in the Cartella API. It represents a session-specific connection to the Cartella library.

In the Cartella web application, each browser session uses a SiteManager object to issue commands such as select, create, update, or delete a content object in the Cartella content repository. The SiteManager object instance is user specific. All commands issued will have the user's context. (If no user is logged in to the SiteManager instance, the context is viewed as an anonymous user.)

Here are the steps to construct a SiteManager object instance:

  1. Retrieve an instance of the CartellaGlobalManager
  2. Create the SiteManager instance
  3. Authenticate the SiteManager

Note that only the ISiteManager is used.

Retrieve an instance of the CartellaGlobalManager

The CartellaGlobalManager is a singleton object covering the entire Cartella Application Domain. Use this method to create an instance of the SiteManager:
CopyC#
ICartellaGlobalManager globalManager = CartellaGlobalManager.Get();

Create a SiteManager Instance

Create a new SiteManager instance. Once created, the CartellaGlobalManager will maintain a reference to it. After twenty minutes inactivity (default session timeout), it is automatically released.

Note that all created SiteManager objects have a unique Guid. Use this ID to retrieve an existing instance from the CartellaGlobalManager's indexer.

CopyC#
//Create a new SiteManager instance from CartellaGlobalManager.
ISiteManager siteManager = globalManager.CreateInstance();
Guid instanceGuid = (siteManager as SiteManager).UniqueID;

//Retrieve an existing SiteManager instance via CartellaGlobalManager's indexer
ISiteManager existingSiteManager = globalManager[instanceGuid];

Authenticate SiteManager

A newly-created SiteManager instance can only be used to select objects. To be able to Create, Update, or Delete an object, the SiteManager needs to be authenticated.

The Authenticate method in the SiteManager will return a boolean: True if the authentication succeeded, False otherwise.

It will throw an exception if it encounters an error during authentication (e.g. Licensing problem). It is good practice to put a "try-catch" block around it.

CopyC#
bool authenticated;
try
{
    authenticated = siteManager.Authenticate("username", "password");
}
catch (Exception e)
{
    authenticated = false;
    //do something with the exception here...
}

See Also

Reference

CreateInstance()()()()