Вопрос

I have a FileNet p8 server which contains 2 CMIS repositories: RepoA and RepoB.

I would like to select one or the other using the RepositoryId session parameter, but I always end up with the 2 repositories:

var cmisParameters = new Dictionary<string, string>();
cmisParameters[SessionParameter.BindingType] = BindingType.AtomPub;
cmisParameters[SessionParameter.AtomPubUrl] = "myurl";
cmisParameters[SessionParameter.User] = "myuser";
cmisParameters[SessionParameter.Password] = "mypassword";
cmisParameters[SessionParameter.RepositoryId] = "RepoB";

SessionFactory factory = SessionFactory.NewInstance();
IList<IRepository> repositories = factory.GetRepositories(cmisParameters);
foreach (var repository in repositories)
{
    Console.WriteLine(repository.Id);
}

The output is:

RepoA
RepoB

I specified the RepositoryId so I think the output should only be RepoB.

Is it a known FileNet bug? Or am I missing something?

Это было полезно?

Решение

The GetRepositories() method of the SessionFactory ignores the repository ID of the parameter map and returns all available repositories. This is useful, if you have no information about the existing repositories at the given endpoint.

So, if you know the ID of your target repository, you don't need to get them all. In this case you can simply use the CreateSession() method.

factory.CreateSession(cmisParameters);

Другие советы

For now I just use the workaround below.

Any better solution is very welcome!

IList<IRepository> repositories = factory.GetRepositories(cmisParameters);
IRepository repository = null;
// Get the repository.
if (repositories.Count == 1)
{
    // Normal case
    repository = factory.GetRepositories(cmisParameters)[0];
}
else
{
    // Workaround for FileNet
    Console.WriteLine("Sync", "Unexpected nb of repos: " + repositories.Count);
    string repositoryId = cmisParameters[SessionParameter.RepositoryId];
    foreach (IRepository potentialRepository in repositories)
    {
        if(potentialRepository.Id.Equals(repositoryId))
        {
            repository = potentialRepository;
        }
    }
}

That there are multiple repositories is actually the normal case. Endpoints that only expose one repository are the exception. FileNet follows the CMIS spec here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top