0

こんにちは、リポジトリのプログラムによる構成を行うにはどうすればよいですか。リポジトリ内の構成のパラメータのほとんどは、実行時にしか決定できないためです。

セッションを印刷しようとすると、匿名のクレデンシャルを使用できないようです。以下のNPEコードがスローされます。

   config.repositorySource("store")
          .usingClass(DiskSource.class)
          .setProperty("repositoryRootPath", "c:/x/repo1")
          .setProperty("defaultWorkspaceName","default");

          config.repository("content")
          .setOption(JcrRepository.Option.USE_ANONYMOUS_ACCESS_ON_FAILED_LOGIN, "true")
          .setSource("store");

    Session session  =  engine.getRepository("content").login("default");

カスタムオーセンティケーターをJcrConfigurationに追加できますか?

4

1 に答える 1

0

ModeShape エンジンを構成する正しい方法は、こちらで説明されているように、JcrConfiguration オブジェクトを使用することです。これはあなたがしていることのように見えるので、その部分は正しいです。

構成を作成したら、問題がないかどうかを確認できます。

if ( !configuration.getProblems().isEmpty() ) {
    for ( Problem problem : configuration.getProblems() ) {
         // Report these problems!
    }
}

問題がなければ、構成を使用して新しい JcrEngine インスタンスを作成できます (ドキュメントを参照)。

JcrConfiguration config = ...
JcrEngine engine = config.build();
engine.start();

次に、名前でリポジトリを検索し、JCR API を使用してログインします。

javax.jcr.Repository repository = engine.getRepository("Name of repository");

Credentials credentials = ...; // JCR credentials
String workspaceName = ...;  // Name of repository workspace
Session session = repository.login(credentials,workspaceName);
于 2012-10-01T12:04:22.083 に答える