Reputation: 60213
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?
Upvotes: 0
Views: 645
Reputation: 3235
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.
Upvotes: 0
Reputation: 1786
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);
Upvotes: 4
Reputation: 60213
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;
}
}
}
Upvotes: 0