# Personal Repository

The personal repository is an area of the DAV server reserved for personal use. Although the exact path to the personal repository is configurable, it is likely to be something like `http://host:port/base/$uid/PR`, where `$uid` is the current user id. A connected DAV server is required to use the Personal Repository and this can be achieved in a number of ways. See Using DAV Repositories for ways of connecting to a DAV Repository.

The personal repository is anchored off the Global profile for any user. This means that the Global profile should be configured, otherwise the personal repository will not be available. The User Service documentation explains how profile are managed, in particular how to set up the global profile. The definition for the global profile is required to indicate the backend repository for the profile, which might be something like a SAS Metadata Server or an LDAP server.

In many cases only one DAV repository will be connected, but in the case where more than one is connected, use an attribute in the global profile to specify which to use for the personal repository. The attribute `PersonalRepositoryHome` should be set to the name of the repository. eg. `PersonalRepositoryHome="Test"`. Setting this attribute on the group profile will cause all users in the group to use the same DAV server for their personal repositories. It is also possible to set this attribute for an individual person (either because they are not part of a group, or as a special case for this person).

To obtain a reference to the personal repository and the three predefined applications in the personal repository, MyInbox, MyDocuments and MyResults, one would use the following code:

    PersonalRepository pr;
    MyInbox myInbox;
    MyDocuments myDocuments;

    // Get a new user context
    userMe = _userService.newUser( username, password, domain );

    // Get the global profile (profile called “global”)
    ProfileInterface po = userMe.getProfile();
    PersonalRepositoryInterface pr = null;
    if ( po instanceof GlobalProfileInterface ) {

        // Get the personal repository from the global profile
        pr = ((GlobalProfileInterface)po).getPersonalRepository();
        if (pr != null) {
            myInbox     = pr.getApplicationManager( PersonalRepository.INBOX );
            myDocuments = pr.getApplicationManager( PersonalRepository.DOCUMENTS );
            myResults   = pr.getApplicationManager( PersonalRepository.RESULTS );
        }
    }

The predefined application folders, MyInbox, MyDocuments and MyResults, are just Information Service folders and so one can manipulate the folders and their contents using this interface. The personal repository is also a Folder, but the preferred mechanism of using the Personal Repository would be to add Application folders for specific applications, if the Inbox, Documents and Results predefined sections are found insufficient. To define new application folders for the personal repository, use the following example:

    pr.registerApplication( applName, applClass );

where applClass is the name of a class that implements the FolderInterface interface. Additional functionality (eg. restricting creation to certain types etc.) can be added to this class.

#### Security

Access to the personal repository is protected by default. The credentials used are obtained from the user context in which the request is being run.