code: private ManageableRepository getRepository(RepositoryService rs) throws ResourceException
     {
        ManageableRepository mRepository = null;
        try
        {
           mRepository = repository == null ? rs.getCurrentRepository() : rs.getRepository(repository);
        }
        catch (Exception e)
        {
           throw new ResourceException("Could not get the "
              + (repository == null ? "current repository." : "repository '" + repository + "'"), e);
        }
        if (mRepository == null)
        {
           throw new ResourceException("Could not find the "
              + (repository == null ? "current repository." : "repository '" + repository + "'"));
        }
        if (LOG.isDebugEnabled())
        {
           LOG.debug("getRepository: repository = " + (repository == null ? "current." : repository));
        }
  
        return mRepository;
     }
docs: Gets the repository corresponding to the given context, if a repository name
  has been defined in the configuration of the {@link ManagedSessionFactory}
  it will try to get it otherwise it will get the current repository