ヘッダーをスキップ
Oracle® Fusion Middleware Oracle Enterprise Repository開発者ガイド
12cリリース1 (12.1.3)
E59445-03
  目次へ移動
目次
索引へ移動
索引

前
 
次
 

4 リポジトリ拡張性フレームワークの使用

この章では、リポジトリ拡張性フレームワーク(REX)アーキテクチャについて説明し、OpenAPIを有効にしてWSDLを使用する方法について解説します。

この章では、次の項目について説明します。

4.1 REXの概要

REXは、プログラムでOracle Enterprise Repositoryに統合するWebサービスAPIです。これは、業界で認められた標準に基づいており、相互運用性とプラットフォームの独立性に重点を置いて設計されています。REXでは、Web Services Description Language (WSDL v1.1)で記述された、リモート・プロシージャ・コール(RPC)Webサービスを使用します。これにより、クライアントで、任意のプラットフォームやWebサービスをサポートする任意の実装言語を使用して、Oracle Enterprise Repositoryと相互に動作できます。たとえば、Oracle Enterprise RepositoryはJ2EEアプリケーションですが、REXを使用して.NETクライアントとプログラムで相互に動作できます。


注意:

flashlineおよびregistryというインスタンスが、特にJavaパッケージ構造およびREXクラス名としてこのドキュメントで使用されています。

Oracle Enterprise RepositoryがSiteminderで保護されるように構成されているか、今後構成される場合、次のURLを無視するか、または保護しないようにポリシー・サーバーを構成して、OpenAPI統合が正しく機能できるようにする必要があります。

http://appserver.example.com/oer/services/


注意:

このドキュメントで使用している例は説明用であり、Oracle Enterprise Repository WSDLのバージョン間のパッケージ構造の違いのためにコンパイルされません。使用しているバージョンのOracle Enterprise Repositoryに合うように、パッケージ構造を変更する必要があります。

REXの詳細は、Oracle Fusion Middleware Oracle Enterprise Repository拡張性フレームワーク(REX)のREX Javadocを参照してください。

4.2 REXのアーキテクチャ

図4-1に、REXのアーキテクチャを示します。

図4-1 REXのアーキテクチャ

図4-1の説明が続きます
「図4-1 REXのアーキテクチャ」の説明

Oracle Enterprise RepositoryおよびREXの高度なアーキテクチャは、次の高度な目標を考慮して設計されています。

  • 柔軟性

    SOAP、WSDLおよびHTTPなどの業界で認められた標準に準拠しているクライアント・プラットフォームは、REXインタフェースを介してOracle Enterprise Repositoryと相互に動作できます。一般的なクライアント・プラットフォームとAPIが適切に連携することが検証されています。

  • 拡張性

    新機能がOracle Enterprise Repositoryに追加された際に、その機能にアクセスするためのサブシステムの追加プロセスが、Oracle Enterprise Repositoryの階層化アーキテクチャにより単純化されます。詳細は、4.2.4項「Oracle Enterprise Repository REXのバージョンの考慮事項」を参照してください。

  • 簡潔性

    エンドユーザーは、REXで使用可能な拡張機能を簡単に利用できます。

4.2.1 サブシステムの概要

Oracle Enterprise RepositoryのREXを使用すると、様々なサブシステムにアクセスできます。これらのサブシステムは、システムの機能を論理的なカテゴリ(動作するエンティティのタイプとほぼ同様)に大まかにグループ化しています。このドキュメントの大部分は、これらのサブシステムに基づいた項で構成されています。

REXメソッドは、様々なサブシステムに基づいたスキームを使用して、名前が付けられています。このプロセスで使用されるアルゴリズムの詳細は、4.2.2項「CRUD-Qネーミング規則」を参照してください。REXで定義されているサブシステムは、次のとおりです。

  • 許容値

  • アセット

  • アセット・タイプ

  • 認証トークン

  • カテゴリ分け

  • カテゴリ分けタイプ

  • 部門

  • 抽出

  • インポート/エクスポート

  • プロジェクト

  • リレーションシップ

  • ロール

  • ユーザー

  • ベンダー

4.2.2 CRUD-Qネーミング規則

オープンAPIメソッドのネーミングで使用されているスキームは、CRUD-Qニーモニックに基づいています。CRUD-Qは、次の5つの操作を表しています。

  • C: 作成(Create)

  • R: 読取り(Read)

  • U: 更新(Update)

  • D: 削除(Delete)

  • Q: 問合せ(Query)

各メソッドは、次の例のように、そのメソッドが属するサブシステムの名前で始まり、次にそのサブシステム内で実行される操作の説明が続きます。

<サブシステム><操作>

たとえば、アセット・サブシステムで作成の操作を実行するメソッド名は、次のようになります。

assetCreate(...)

このネーミング規則を使用すると、次のような名前も考えられます。

assetRead(...)
assetUpdate(...)
assetDelete(...)
assetQuery(...)

サブシステムにはCRUD-Qセット以外の操作が含まれていることがあります。また、CRUD-Qの操作をすべて含んでいるわけではありません。たとえば、ユーザーを削除できないので、userDeleteメソッドはありませんが、userDeactivateメソッドはあります。表4-1に、サブシステムがCRUD-Q操作以外に含めることのできる操作の詳細なリストを示します。

表4-1 サブシステムとCRUD-Q規則の関係


作成 読取り 更新 削除 問合せ その他の機能

許容値リスト

はい

はい

はい

はい

はい

許可、アクティブ化、割当て、非アクティブ化、登録、リタイア、発行、未許可、割当て解除、登録解除、未発行、カスタム・アクセス設定の変更

アセット

はい

はい

はい

はい

はい


アセット・タイプ

はい

はい

はい

はい

はい


カテゴリ分けタイプ

はい

はい

はい

はい

はい


部門

はい

はい

はい

いいえ

はい


抽出

はい

はい

はい

いいえ

はい


プロジェクト

はい

はい

はい

はい

はい

閉じる、開く、再割当て、抽出、ユーザーの削除

リレーションシップ

はい

はい

はい

いいえ

はい


ロール

はい

はい

はい

はい

はい


ユーザー

はい

はい

はい

いいえ

はい

アクティブ化、非アクティブ化、ロックアウト、未承認

ベンダー

はい

はい

はい

はい

はい


連絡先

はい

はい

はい

はい

はい



4.2.2.1 メソッド呼出しの原子性

特に断りがなければ、REXの呼出しはすべて原子的です。すなわち、すべての呼出しは、完全に成功するか、完全に失敗するかのいずれかです。

たとえば、あるバージョンのcategorizationUpdateメソッドは、引数としてカテゴリ分けの更新の配列を取ります。この場合、カテゴリ分けの更新が1回失敗すると、カテゴリ分けの更新はすべて失敗します。

4.2.2.2 呼出し間のトランザクションの未サポート

現在、REXでは、呼出し間のトランザクションをサポートしていません。たとえば、エラーの場合、一連のREXの呼出しに関連付けれられた操作にロールバックできません。

4.2.3 基本的なWSDLのデータ型

REXでは、次の基本的なWSDLデータ型およびWSDLで定義された複合の型が使用されています。

次の型の配列が返されます。

  • xsd:int

  • xsd:long

  • xsd:string

  • xsd:boolean

  • xsd:dateTime

次のURLのIDEまたはWebサービス・ツールキットを指して、REX WSDLを使用することにより、APIスタブを動的に生成できます。

http://appserver/oer/services/FlashlineRegistry?WSDL

OERとのカスタム統合をOracle BPM 11gから作成する場合は、かわりに次のURLを使用します。

http://appserver/oer/services/RexAPI?wsdl

Oracle Enterprise Repository REX WSDLのJavaスタブは、AXIS WSDL2javaユーティリティを使用して作成できます。

java -cp .;axis.jar; xerces.jar; commons-discovery.jar; commons-logging.jar; jaxen-full.jar; jaxrpc.jar; saaj.jar;wsdl4j.jar; xalan.jar org.apache.axis.wsdl.WSDL2Java

この変換プロセスの完了に必要なJARファイルは、次のとおりです。

  • axis.jar

  • xerces.jar

  • commons-discovery.jar

  • commons-logging.jar

  • jaxen-full.jar

  • jaxrpc.jar

  • saaj.jar

  • wsdl4j.jar

  • xalan.jar


注意:

URL内のappserverは、Oracle Enterprise Repositoryがインストールされているサーバーの名前で置き換えてください。

4.2.4 Oracle Enterprise Repository REXのバージョンの考慮事項

Oracle Enterprise Repository REXはOracle Enterprise Repositoryと同様に発展します。このプロセスの結果として、REXの新旧バージョン間で非互換が起こることがあります。すべてのバージョン間の互換性の実現を目標としていますが、下位互換性が実現されるかどうかは予測できない場合もあります。したがって、制限が避けられない可能性があります。Oracle Enterprise Repository REXには、次の下位互換性拡張が含まれます。

  • Oracle Enterprise Repository Weサービスへの新しいメソッドの追加

  • WSDLでの新しい複合型の定義

これらの下位互換性への変更に関して、新機能を利用する必要がある場合にかぎり、クライアント・プロキシの再生成が必要になります。

非互換の変更を回避できない場合にかぎり、サービスのネームスペースが変更されます。このような変更の例には、既存の複合型の変更や、サービスのメソッドの署名における変更があります。この場合、最低限のコード変更があるので、クライアント・プロキシの再生成が必要です。以前のバージョンのREXから生成されたクライアント・プロキシでは、新しいサービスに接続できません。

複合型のネームスペースは変更されません。

4.3 基本的な概念

この項では、オープンAPIの有効化およびWSDLの使用の開始方法などのREXの基本的な概念について説明します。

4.3.1 Oracle Enterprise RepositoryでのオープンAPIの有効化

この手順は、Oracle Enterprise Repositoryの「管理」画面で実行します。

  1. 「システム設定」をクリックします。

  2. 新しいシステム設定の有効化テキスト・ボックスにプロパティcmee.extframework.enabledを入力します。

  3. 「有効化」をクリックします。オープンAPIセクションが表示されます。

  4. cmee.extframework.enabledプロパティにTrueが設定されていることを確認します。

  5. 「保存」をクリックします。これで、REXがOracle Enterprise Repositoryインスタンス内で有効になっています。

4.3.2 WSDLの使用

REXを使用するための最初の手順は、Oracle Enterprise Repositoryサーバーとの通信に必要なクライアント側スタブの生成です。これは、通常、特定のWebサービス・ツールキットで提供されている自動ツールを使用して実行されます。この項では、様々な統合開発環境およびツールキットを使用して、クライアント・スタブを生成する方法について説明します。

認証と認可

REXを使用するための最初の手順は、サーバーでの認証です。authTokenCreateメソッドを使用して認証が実行されます。このメソッドは、Oracle Enterprise Repositoryでの認証で使用する際に、ユーザーIDとパスワードを引数として取ります。IDとパスワードの認証が成功すると、認証トークンが返されます。このトークンは、後続のすべてのREXの呼出しで使用する必要があります。

有効なAuthTokenがすべてのREXメソッドに含まれていない場合、OpenAPIExceptionがスローされます。これは、authTokenCreateおよびauthTokenDelete以外のすべてのメソッドに適用されます。

次の例は、AuthTokenを取得してこれを後続のREX呼出しで使用する方法を示しています。

例4-1 AuthTokenを取得してREX呼出しで使用する方法

package com.example.flashlineclient;
//The imports below are assumed for any of the included examples
import javax.xml.rpc.ServiceException;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Asset;
public class FlexTest {
public FlexTest () {
}
public static void main(String[] pArgs)throws OpenAPIException, RemoteException, ServiceException {
try {
FlashlineRegistry lRegistry = null;
AuthToken lAuthToken = null;
URL lURL = null;
lURL = new URL("http://www.example.com/appname/services/FlashlineRegistry");
//"www.example.com" should be your server address
//"appname" is the application name of the location that the Registry is running
 on
//These two things must be changed to the proper values in every example
lRegistry = new FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
lAuthToken = lRegistry.authTokenCreate("username", "password");
System.out.println(lAuthToken.getToken());
//displaying the authtoken as a string to the screen
Asset lAsset = lRegistry.assetRead(lAuthToken, 559);
//reading asset number 559
System.out.println(lAsset.getName());
//displaying the name of asset 559 to the screen
} catch(OpenAPIException lEx) {
System.out.println("ServerCode = "+ lEx.getServerErrorCode());
System.out.println("Message = "+ lEx.getMessage());
System.out.println("StackTrace:");
lEx.printStackTrace();
} catch (RemoteException lEx) {
lEx.printStackTrace();
} catch (ServiceException lEx) {
lEx.printStackTrace();
} catch (MalformedURLException lEx) {
lEx.printStackTrace();
}
System.out.println("execution completed");
System.exit(0);
}
}

認可

REXでは、Oracle Enterprise Repositoryアプリケーションと同じ認可ルールが実行されます。認可に使用するユーザーIDとパスワードでは、REXでユーザーに使用できる権限が判定されます。たとえば、プロジェクトに割り当てられた編集権限を持たない認証済のユーザーがprojectCreate REXメソッドを使用してプロジェクトを作成しようとした場合、OpenAPIExceptionがスローされます。

例外処理

オープンAPIはSOAPフォルトでサーバー・エラーをクライアントに通知します。SOAPフォルトが処理される方法は、使用している言語とSOAPツールキットによって異なります。

この項では、一般的なプラットフォームとツールキットの組合せを使用して、クライアント・コード内でオープンAPIが生成した例外を検出して処理する方法を示します。

JavaとAXIS

オープンAPIがスローした例外は、SOAPフォルトとして転送されてから、AXISクライアント・ツールキットでJava例外としてデシリアライズされます。つまり、AXISは、SOAPフォルトを対応するクライアント側OpenAPIExceptionクラスにマップしようとします。サーバー側エラーは、com.flashline.registry.openapi.OpenAPIExceptionインスタンスとしてクライアントに示されます。したがって、クライアント・コードは、前述のコードから、次に示したコードで例外を取得できます。

try {
lAsset = lRegistry.assetCreate(..);
} catch(OpenAPIException lEx) {
System.out.println("ServerCode = "+ lEx.getServerErrorCode());
System.out.println("Message = "+ lEx.getMessage());
System.out.println("StackTrace:");
lEx.printStackTrace();
} catch (RemoteException lEx) {
lEx.printStackTrace();
} catch (ServiceException lEx) {
lEx.printStackTrace();
} catch (MalformedURLException lEx) {
lEx.printStackTrace();
}

検証

エンティティをOracle Enterprise Repositoryに保存しようとする際に、入力内容の検証が試行されます。欠落しているデータや無効なデータがあると、サーバーは、フィールドのリストとそれぞれのエラーが含まれるOpenAPIExceptionをスローします。

詳細は、「例外処理」を参照してください。

REXにおける問合せの考慮事項

基準オブジェクトは、現在、用語とグループ化のさらに柔軟性の高い表現に移行しています。このオブジェクトが発生すると、これらの変更は、基準オブジェクトを使用して問合せを実行する場合に、特定のAPI機能を使用できるかどうかに影響します。サブシステムでは、対応する基準オブジェクトのみ直接評価されます。このドキュメントで説明しないかぎり、基礎となるSearchTermGroupの拡張機能は使用されません。

バイナリ・データの送信(添付ファイル)

様々なREXメソッドでは、クライアントとサーバー間で大量のバイナリ・データの送受信を必要とする場合があります。たとえば、インポート/エクスポート・サブシステムでは、インポート元からペイロードを送信するメソッドやエクスポート済アセットを表すペイロードを受信するメソッドが提供されています。

通常、バイナリ・データは、WebサービスのRPC起動によって、Dynamic Internet Message Exchange(DIME)、SOAP with Attachments (SwA)またはBase-64エンコーディングを介して、転送されます。それぞれに長所と短所がありますが、3つすべてを直接サポートしているクライアントは少数です。

Oracle Enterprise RepositoryのオープンAPIは、バイナリ・データの転送に3つのメカニズムすべてをサポートしています。詳細は、次の項を参照してください。バイナリ・データの転送に提供されているメソッドには3つのバージョンがあり、それぞれが異なる転送メカニズムをサポートしています。たとえば、エクスポート結果を取得するには、ユーザーは次のメソッドのいずれかを選択できます。

  • importGetResultsB64

    base-64エンコーディング形式でエクスポート結果を取得します。これは、あまり一般的ではありませんが、クライアントがbase-64データをエンコードまたはデコードできる場合は、どのプラットフォームでも使用できます。

  • importGetResultsDIME

    DIMEプロトコルを使用して、エクスポート結果を添付ファイルとして取得します。これは、ほとんどの.NETクライアントに優先される選択肢です。

  • importGetResultsSwA

    SOAP with Attachments (SwA)プロトコルを使用して、エクスポート結果を添付ファイルとして取得します(MIMEベース)。

.NETとMicrosoft Web Services Enhancement(WSE)キットでのDIME添付ファイルの使用

Microsoftでは、標準の.Net Webサービス・ツールキットの拡張を提供しています。Microsoft Web Services Enhancement(WSE)キットでは、Dynamic Internet Messaging Exchange(DIME)プロトコルを使用して、Webサービスを介した添付ファイルの送受信などの拡張機能を提供しています。

次のコード・スニペットは、DIME添付ファイルによるデータ送信の例を示しています。

例4-2 DIME添付ファイルによるデータ送信の例

// relax the requirement for the server to understand ALL headers. This MUST be
// done, or the call with the attachment fails. After the call, if you wish,
// you can set this back to "true"
registry.RequestSoapContext.Path.EncodedMustUnderstand= "false";
// clear the attachments queue
registry.RequestSoapContext.Attachments.Clear();
registry.RequestSoapContext.Attachments.Add(
new Microsoft.Web.Services.Dime.DimeAttachment("0", "application/zip",
Microsoft.Web.Services.Dime.TypeFormatEnum.MediaType, "c:\\tmp\\import.zip"));
// start an import running on the server
registry.importExecute(lAuthToken, "flashline", null, "FEA Flashpack Import",
null);
// do some polling (calls to importStatus) to monitor the import progress,
// if you wish

次のコード・スニペットは、DIME添付ファイルによるデータ受信の例を示しています。

例4-3 DIME添付ファイルによるデータ受信の例

// relax the requirement for the server to understand ALL headers. This MUST be
// done, or the call with the attachment fails. After the call, if you wish,
// you can set this back to "true"
registry.RequestSoapContext.Path.EncodedMustUnderstand= "false";
// clear the attachments queue
registry.RequestSoapContext.Attachments.Clear();
// start an export
flashline.ImpExpJob lJob =
registry.exportExecute(lAuthToken, "flashline", null, "Complete Export",
 "flashline",
"<entitytypes>
<entitytype type=\"acceptableValueList\">
<entities>
<entity id=\"100\"/>
</entities>
</entitytype>
</entitytypes>");
// do some polling (calls to exportStatus) to watch the progress of the
// export, if you wish...
// this call blocks until either the method returns (or an exception is
 thrown),
// or the call times out.
registry.exportGetResultsDIME(lAuthToken, lJob);
// check to see if the call resulted in attachments being returned...
if(registry.ResponseSoapContext.Attachments.Count > 0)
{
Stream lStream = registry.ResponseSoapContext.Attachments[0].Stream;
// write the data out somewhere...
}

添付ファイルとJava AXISクライアントでのSOAPの使用

Axisクライアントでは、SOAP添付ファイルをJavaで処理する機能が提供されています。詳細は、http://www-106.ibm.com/developerworks/webservices/library/ws-soapatt/を参照してください。

次のコード・スニペットは、データ受信の例を示しています。

byte[] lResults = null;
ImpExpJob lExportJob =
mFlashlineRegistrySrc.exportExecute(mAuthTokenSrc,"flashline",null,
"Export Assets","default", createAssetQuery().toString());
lExportJob =
mFlashlineRegistrySrc.exportStatus(mAuthTokenSrc, lExportJob);
lResults =
mFlashlineRegistrySrc.exportGetResultsB64(mAuthTokenSrc, lExportJob);
// write the results out to disk in a temp file
File lFile = null;
String lTempDirectory =
System.getProperty("java.io.tmpdir");
lFile = new File(lTempDirectory + File.separator + "impexp.zip");
FileOutputStream lOS = new FileOutputStream(lFile);
BufferedOutputStream lBOS = new BufferedOutputStream(lOS);
lBOS.write(lResults);
lBOS.flush();
lBOS.close();
lOS.close();

次のコード・スニペットは、DIME添付ファイルによるデータ送信の例を示しています。

// open file and attach as data source
InputStream lIS = new FileInputStream(lFile);
((Stub)mFlashlineRegistryDest)._setProperty
(Call.ATTACHMENT_ENCAPSULATION_FORMAT, Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
ByteArrayDataSource lDataSource = new ByteArrayDataSource(lIS,
 "application/x-zip-compressed");
DataHandler lDH = new DataHandler(lDataSource);
// add the attachment
((Stub)mFlashlineRegistryDest).addAttachment(lDH);
ImpExpJob lJob =
mFlashlineRegistryDest.importExecute(mAuthTokenDest, "flashline", null, "Import
 Assets Test", null);

4.4 REX APIの説明とユースケース

この項では、REX APIについて説明し、ユースケースを示します。

4.4.1 アーティファクト・ストアAPI

この項では、アーティファクト・ストアAPIのユースケースについて説明します。このユースケースで、欠落しているアーティファクト・ストアをOracle Enterprise Repositoryに作成する方法について解説します。

4.4.1.1 概要

アーティファクト・ストア・サブシステムは、Oracle Enterprise Repositoryのアーティファクト・ストアに問い合せたり、これを作成したりする場合に使用する、Webサービス・ベースのメカニズムを提供します。

4.4.1.2 ユースケース: 欠落しているアーティファクト・ストアの作成

説明

このユースケースでは、欠落しているアーティファクト・ストアの作成方法について説明します。

サンプル・コード

例4-4 ユースケース: 欠落しているアーティファクト・ストアの作成

package com.flashline.sample.artifactstoreapi;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.ArtifactStoreBean;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.ArtifactStoreCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ArtifactStores {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
  ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------------
      // query for an artifact store
      ArtifactStoreCriteria lArtifactStoreCriteria = null;
      ArtifactStoreBean[] lArtifactStoreBeans = null;
      ArtifactStoreBean lArtifactStoreBean = null;
      lArtifactStoreCriteria = new ArtifactStoreCriteria();
      lArtifactStoreCriteria.setHostCriteria("existing-artifact-store.com");
      lArtifactStoreCriteria.setBasepathCriteria("/");
      lArtifactStoreBeans = repository.artifactStoreQuery(authToken,
 lArtifactStoreCriteria, false);
      // create a missing artifact store if missing and based on the criteria
      lArtifactStoreCriteria = new ArtifactStoreCriteria();
      lArtifactStoreCriteria.setHostCriteria("missing-artifact-store.com");
      lArtifactStoreCriteria.setBasepathCriteria("/");
      // a new artifact store is created
      lArtifactStoreBeans = repository.artifactStoreQuery(authToken,
 lArtifactStoreCriteria, true);
      lArtifactStoreBean = lArtifactStoreBeans[0];
    } catch(Exception e) {
      throw new RuntimeException(e.getMessage());
    }
  }
}

4.4.2 許容値リストAPI

この項では、許容値リストAPIのユースケースについて説明します。このユースケースで、新しい許容値リストを作成し、これをOracle Enterprise Repositoryに入力し、アセットの単一または複数の選択リストに許容値を移入する方法について解説します。

4.4.2.1 概要

許容値リストは、単一および複数の選択ドロップダウン・ボックスのメタデータ要素で使用します。

アセット・タイプを作成または編集する場合、許容値リストはメタデータ要素として使用します。これらのメタデータ要素は、アセット・タイプ/コンプライアンス・テンプレートのエディタおよびビューアXMLで、ID別に参照します。

アセットを作成または編集する場合、許容値リストに含まれる値は、特定のアセット・タイプ/コンプライアンス・テンプレート用に定義されたメタデータ要素のオプションとして使用します。許容値リストの許容値を使用するには、アセット(Asset.GetCustomData())のカスタム・データを変更して、許容値のIDを参照します。

4.4.2.2 ユースケース: 許容値リストの作成および編集

説明

新しい許容値リストを作成し、これをOracle Enterprise Repositoryに入力します。

サンプル・コード

例4-5 ユースケース: 許容値リストの作成および編集

package com.flashline.sample.acceptablevaluelists;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AcceptableValue;
import com.flashline.registry.openapi.entity.AcceptableValueList;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateAndEditAcceptableValueList {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Build an array of acceptable values for the list.
      // //////////////////////////////
      String newAcceptableValueListName = "My AcceptableValueList
 "+Calendar.getInstance().getTimeInMillis();
      AcceptableValue[] acceptableValues = new AcceptableValue[3];
      acceptableValues[0] = new AcceptableValue();
      acceptableValues[0].setValue("My Value");
      acceptableValues[1] = new AcceptableValue();
      acceptableValues[1].setValue("My Next Value");
      acceptableValues[2] = new AcceptableValue();
      acceptableValues[2].setValue("My Last Value");
      // //////////////////////////////
      // Create the AcceptableValueList in Repository
      // //////////////////////////////
      AcceptableValueList newAcceptableValueList = repository
          .acceptableValueListCreate(authToken, newAcceptableValueListName,
              acceptableValues);
      System.out.println("The new acceptableValueList id  =\""
          + newAcceptableValueList.getID() + "\"");
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.2.3 ユースケース: 許容値リストの検索およびアセットでの使用

説明

アセットの単一または複数の選択リストに許容値を移入します。

サンプル・コード

例4-6 ユースケース: リストへの許容値の移入

package com.flashline.sample.acceptablevaluelists;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AcceptableValue;
import com.flashline.registry.openapi.entity.AcceptableValueList;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AcceptableValueListCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindAcceptableValueListAndUseInAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Find the AcceptableValueList
      // //////////////////////////////
      AcceptableValueListCriteria criteria = new AcceptableValueListCriteria();
      criteria.setNameCriteria("My AcceptableValueList");
      AcceptableValueList[] acceptableValueLists = repository
          .acceptableValueListQuery(authToken, criteria);
      AcceptableValueList myAcceptableValueList = acceptableValueLists[0];
      AcceptableValue[] acceptableValues = myAcceptableValueList
          .getAcceptableValues();
      // //////////////////////////////
      // Find one value within the AcceptableValueList
      // //////////////////////////////
      AcceptableValue myAcceptableValue = null;
      for (int i = 0; i < acceptableValues.length; i++) {
        if (acceptableValues[i].getValue().equals("My Value")) {
          myAcceptableValue = acceptableValues[i];
          break;
        }
      }
      long myAcceptableValueID = myAcceptableValue.getID();
      Asset myAsset = repository.assetRead(authToken, 561);
      String customData = myAsset.getCustomData();
      // //////////////////////////////
      // Modify customData to use myAcceptableValueID.
      // //////////////////////////////
      String modifiedCustomData = customData;
      // ...
      // //////////////////////////////
      // save modified custom data
      // //////////////////////////////
      myAsset.setCustomData(modifiedCustomData);
      repository.assetUpdate(authToken, myAsset);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.3 アセットAPI

この項では、アセットAPIについて説明し、アセットAPIのユースケースを示します。このユースケースで、アセットの作成または変更、アセットの検索の作成、およびアセット・ステータスとアセット・タブの操作を行う方法について解説します。

4.4.3.1 概要

アセットは、Oracle Enterprise Repositoryのコア・エンティティです。このドキュメントには、アセット・サブシステムのアクションの作成、読込み、更新、削除および問合せについて記述されています。また、次の項目の更新についても記述されています。

  • アセットのアクティブ・ステータス:

    • アクティブ化

    • 非アクティブ化

    • リタイア

  • アセットの登録ステータス:

    • 発行

    • 承認

    • 登録

    • 未発行

    • 未承認

    • 登録解除

  • アセットの割当てステータス:

    • 割当て

    • 未割当て

REXを使用してOracle Enterprise Repositoryのアセットを操作する場合、いくつかの問題を考慮する必要があります。メモリー消費におけるトレードオフとパフォーマンスについて、よく検討する必要があります。

  • メモリーの消費

    アセットおよびそのメタデータは、REXサーバーとREXを使用するクライアント・ソフトウェアの両方で、かなりの量のメモリーを消費します。REXを使用してOracle Enterprise Repositoryを検索する場合、多数のアセットが返される可能性があります。サービス拒否によるシステムの中断を回避するために、管理者は、REXメソッドのassetQueryのコールで返される結果の最大数を制限します。システム設定のcmee.extframework.assets.maxでは、問合せの結果として返される検索結果の最大数を制御します。問合せに一致する結果の数が最大数を超えると、REXによって例外が生成されます。

    多数のアセットが問合せに一致する可能性がある場合、assetQuerySummaryメソッドをお薦めします。Oracle Enterprise Repositoryに問合せを実行する別の方法では、assetQueryへのコールとして同じアセットと完全一致させますが、完全なアセット・オブジェクトではなく、軽量アセット・サマリー・オブジェクトを返します。これらのサマリー・オブジェクトのメモリーの消費量は少ないので、問合せの結果としてリソースを使い果す可能性はほとんどありません。

    サマリー問合せが実行された後、assetReadまたはassetReadArrayFromSummaryのいずれかを使用して、完全なアセット・オブジェクトを対象アセットのために取得できます。複数のアセットが必要な場合、assetReadArrayFromSummaryメソッドを使用することをお薦めします。このメソッドの使用方法の詳細は、APIのドキュメントを参照してください。

  • パフォーマンス

    REXは、標準的なWebサービス・テクノロジに基づいており、柔軟性と移植性において多数の利点があります。ただし、あらゆるWebサービスに基づいたテクノロジと同様に、特にデータ量が多い状況(多数のアセットを操作する場合など)で、パフォーマンスがあまりよくないことがあります。REXでは、想定されるパフォーマンスの問題を開発者が回避できるオプションがあります。

    • 反復する読込み

      Webサービス・テクノロジの主なオーバーヘッドは、ネットワーク転送と組み合せた、XMLを使用するシリアライズとデシリアライズで起こります。このようなオーバーヘッドの多くは、多数のアセットが読み込まれる状況で回避できます。たとえば、REXを使用して、50個のアセットをOracle Enterprise Repositoryから取得する場合、assetReadが50回コールされます。よりよい方法として、必要なアセットのIDを単一の引数として渡す、assetReadArrayメソッドを使用する方法を採用するとします。これを使用すると、1回のコールですべての50個のアセットが取得されるので、パフォーマンスがかなり向上します。

    • リスト表示操作

      エンドユーザーにリスト表示するために、REXからデータを取得することがあります。この場合、アセットをよく検査して選択する必要があります。このような場合、完全なアセット・メタデータは、サマリー・リストの生成に必要ありません。前述のメモリーに関する項で説明したとおり、REXで提供されたサマリー・メソッドを使用することを検討してください。

  • アクセス制御

    • REXのユーザーに表示されるアセットおよびこれらのアセットの情報は、アクセス設定によって、ある程度制御されます。Web GUIを介してシステムにアクセスするユーザーのために存在する、同様のアクセス制限もREXアセット・サブシステムに適用されます。

    • 問合せの制限: assetQueryまたはassetReadをコールする場合、ユーザーが取得できるのは、表示権限のあるアセットのみです。

    • 更新の制限: ユーザーが更新できるのは、編集権限のあるアセットのみです。

    • ファイルの制限: ユーザーが表示できるのは、各ファイルに適用済のファイル・タイプのカスタム・アクセス設定で設定されているように、ダウンロード権限のあるファイルのみです。つまり、ユーザーはアセットを表示できますが、アセットのファイルの中には表示できないものもあるということです。各ファイルには、アセットの権限とは別に、そのファイル用の権限があります。特定のファイル・タイプの権限がファイルに適用されていない場合、これらの権限はそのファイルが属するアセットの権限から継承されます。

4.4.3.1.1 定義

この項では、次の項目の定義について説明します。

  • IDおよびUUID

    • IDは、単一のOracle Enterprise Repositoryインスタンス内でアセットを一意に特定するために内部で使用される一意の識別子(数値)です。

    • UUIDは、Oracle Enterprise Repositoryのインスタンスで一意にアセットを特定するためにユニバーサルに使用される識別子(16進数で表される128ビットの数値)です。各アセットのUUIDは、主に読込みと検索用に表示されます。REXを使用してこのフィールドを変更しないことを強くお薦めします。ただし、管理者がアセットのUUIDを変更することを選択した場合、フォーマットは一貫している必要があります(00000000-0000-0000-0000-000000000000)。また、UUIDは、ターゲットのOracle Enterprise Repositoryインスタンス内で一意である必要があります。これ以外の場合、変更操作は失敗します。

  • 名前およびバージョン

    アセットを一意に特定するために結合した文字列のフィールド。

  • カスタム・データ

    アセットのカスタマイズ可能なメタデータは、この文字列内にXML構造で保存されています。サンプル・コードでは、カスタム・データ・メソッドを記述しています。

4.4.3.1.2 サンプル・コード

例4-7 カスタム・データ・メソッドのサンプル・コード

package com.flashline.sample.assetapi;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.xml.rpc.ServiceException;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import org.jdom.xpath.XPath;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateCustomData {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
      .getFlashlineRegistry(lURL);
      ////////////////////////////////////////////////////////////
      // Login to OER
      ////////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      //////////////////////////////////////////
      // assetUpdateCustomDataString
      //////////////////////////////////////////
      // Find and Modify a custom data field value with a value supplied on the
 command line
      Long currentLicenses = new
 Long(repository.assetReadCustomDataString(authToken, 589, "/
_-total-licenses-owned"));
      currentLicenses = new Long(currentLicenses.intValue() + 1);
      //    save the modifications
      //  NOTICE: A leading slash is required to specify the appropriate path to
 the element being updated.
      repository.assetUpdateCustomDataString(authToken, 589, "/
_-total-licenses-owned", currentLicenses.toString());
      //////////////////////////////////////////
      // assetUpdateCustomDataStringArray
      //////////////////////////////////////////
      // Add a custom data field value with a value supplied on the command line
      Format formatter = new SimpleDateFormat("yyyyMMdd");
      String dateFormat = formatter.format(new Date());
      // NOTICE: for the following method, there is no leading slash for the
 elements being updated.
      String[] versionHistory = {"version-history/version-history/version-number",
 "version-history/version-history/production-date-yyyymmdd-",
 "version-history/version-history/comments"};
      String[] versionHistoryValues = {currentLicenses.toString(), dateFormat,
 "Updated version History: " + dateFormat};
      //    save the modifications
      repository.assetUpdateCustomDataStringArray(authToken, 589, versionHistory,
 versionHistoryValues);
      //////////////////////////////////////////
      // assetUpdateCustomDataNode
      //////////////////////////////////////////
      //The following updates a specific custom data element called
 "document-name" that is a child of "document",
      //which is a child of "documentation"
      XPath lXPath = null;
      List lElms = null;
      //First read the Node "documentation" of the specific asset
      String lXMLDocumentation = repository.assetReadCustomDataNode(authToken,
 589, "documentation");
      //Using DOM, convert the XML to a Document
      Document lDoc = null;
      SAXBuilder lBuilder = new SAXBuilder();
      StringReader lReader = null;
      lReader = new StringReader(lXMLDocumentation);
      lBuilder.setValidation(false);
      lBuilder.setIgnoringElementContentWhitespace(true);
      lDoc = lBuilder.build(lReader);
      lXPath = XPath.newInstance("documentation/document");
      lElms = lXPath.selectNodes(lDoc);
      //Cycle through the "document" elements until we find the one we want.  Then
 update it.
      for (int i=0;i<lElms.size();i++) {
        Element lElm = (Element)lElms.get(i);
        List lChildElms = lElm.getChildElements();
        for (int x=0;x<lChildElms.size();x++) {
          Element lChildElm = (Element)lChildElms.get(x);
          if (lChildElm.getName().equals("document-name") &&
 lChildElm.getValue().equals("API")) {
            lChildElm.setText("API KHAN");
          } else {
            lChildElm.setText(lChildElm.getValue());
          }
        }
      }
      //Convert the Document back to an XML string and update the asset's custom
 data.
      repository.assetUpdateCustomDataNode(authToken, 589, "documentation", new
 XMLOutputter().outputString(lDoc));
      //////////////////////////////////////////
      // assetUpdateCustomDataNodeArray
      //////////////////////////////////////////
      try {
        //The following updates multiple custom data elements.  One is called
 "document-name" that is a child of "document",
        //which is a child of "documentation"
        //The other is the element called "also-known-as"
        lXPath = null;
        lElms = null;
        //First read the Node "documentation" of the specific asset
        lXMLDocumentation = repository.assetReadCustomDataNode(authToken, 589,
 "documentation");
        //Using DOM, convert the XML to a Document
        lDoc = null;
        lBuilder = new SAXBuilder();
        lReader = null;
        lReader = new StringReader(lXMLDocumentation);
        lBuilder.setValidation(false);
        lBuilder.setIgnoringElementContentWhitespace(true);
        lDoc = lBuilder.build(lReader);
        lXPath = XPath.newInstance("documentation/document");
        lElms = lXPath.selectNodes(lDoc);
        //Cycle through the "document" elements until we find the one we want. 
 Then update it.
        for (int i=0;i<lElms.size();i++) {
          Element lElm = (Element)lElms.get(i);
          List lChildElms = lElm.getChildElements();
          for (int x=0;x<lChildElms.size();x++) {
            Element lChildElm = (Element)lChildElms.get(x);
            if (lChildElm.getName().equals("document-name") &&
 lChildElm.getValue().equals("API")) {
              lChildElm.setText("API KHAN");
            } else {
              lChildElm.setText(lChildElm.getValue());
            }
          }
        }
        String lDoc1 = new XMLOutputter().outputString(lDoc);
        //Get the next element
        lXMLDocumentation = repository.assetReadCustomDataNode(authToken, 589,
 "also-known-as");
        lDoc = null;
        lBuilder = new SAXBuilder();
        lReader = null;
        lReader = new StringReader(lXMLDocumentation);
        lBuilder.setValidation(false);
        lBuilder.setIgnoringElementContentWhitespace(true);
        lDoc = lBuilder.build(lReader);
        lXPath = XPath.newInstance("also-known-as");
        lElms = lXPath.selectNodes(lDoc);
        //Get the also-known-as element
        for (int i=0;i<lElms.size();i++) {
          Element lElm = (Element)lElms.get(i);
          lElm.setText("Modified Alias");
        }
        String lDoc2 = new XMLOutputter().outputString(lDoc);
        //Convert the Document back to an XML string and update the asset's custom
 data.
        repository.assetUpdateCustomDataNodeFromStringArray(authToken, 589, new
 String[] {"documentation", "also-known-as"}, new String[] {lDoc1, lDoc2});
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

4.4.3.1.3 関連するサブシステム

この項では、アセットAPIで使用される次の関連サブシステムについて説明します。

  • アセット・タイプ

    すべてのアセットには、アクティブで有効なアセット・タイプが必要です。このアセット・タイプは、アセット用のカスタム・データに保存できるメタデータを定義します。

  • ベンダー

    必要に応じて、アセットをベンダーにリンクできます。リンクはベンダーID別に行います。

  • 許容値

    アセットを作成または編集する場合、許容値リストに含まれる許容値は、アセット・タイプ用に定義されたメタデータ要素のオプションとして使用します。許容値リストの許容値を使用するには、アセット(Asset.GetCustomData())のカスタム・データを変更して、許容値のIDを参照します。

  • リレーションシップ・タイプ

    リレーションシップ・タイプは、アセット間に存在できるリレーションシップの種類を定義します。

  • カテゴリ分けタイプ

    カテゴリ分けタイプは、アセット・タイプに追加された最上位レベルのグループのカテゴリ分けです。カテゴリ分けは、アセットを記述します。

  • プロジェクト

    アセットは、プロジェクト別に作成できます。アセット用にプロジェクトを作成すると、IDの配列で格納されます。

  • ユーザー

    ユーザーはアセットに割り当てることができます。メタデータの操作の担当者です。

4.4.3.2 ユースケース

この項では、アセットAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.3.2.1 ユースケース: 新しいアセットの作成

説明

新しいアセットを作成し、これをOracle Enterprise Repositoryに入力します。

サンプル・コード

例4-8 ユースケース: 新しいアセットの作成

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // Create new asset
      ///////////////////////////////////
      Asset myAsset = repository.assetCreate(authToken,
          "My Asset Name108", "My Version
 "+Calendar.getInstance().getTimeInMillis(), 144);
      ////////////////////////////////////////////
      //The following demonstrates how to modify a custom data Date element on an
 asset.
      //This date must be in a specific format and the name of the element must by
 known.
      //In this example, the name of the element is "testdate".  This element must
 have been created in the
      //asset type as a Date element
      //Update the testdate field to January 1, 2007
      //Note: the format of the date should match the system setting for Short
 Date.
      repository.assetUpdateCustomDataString(authToken, myAsset.getID(),
 "testdate", "2007-1-1");
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.2 ユースケース: XMLからの新しいアセットの作成

説明

アセットのXML表現から新しいアセットを作成することもできます。スキーマを使用してアセットのXMLを検証してから、作成します。アセット・タイプのスキーマは、例4-9に示されているように、オープンAPIで使用できます。

個別に検証を実行する必要はありません。作成の前に、アセットのXMLが内部で検証されるためです。個別に検証を実行する場合、Xerces 2.0などの検証用のXMLパーサーを見つける必要があります。

サンプル・コード

例4-9 ユースケース: XMLからの新しいアセットの作成

package com.flashline.sample.assetapi;
import java.io.IOException;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.rpc.ServiceException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewAssetFromXML {
  public static void main(String pArgs[]) throws ServiceException,
      ParserConfigurationException, SAXException, IOException {
    String SCHEMA_LANGUAGE =
 "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
    String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
    String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
    SAXParserFactory lSaxParserFactory = null;
    SAXParser lSaxParser = null;
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      // Anonymous class to handle validation errors
      DefaultHandler lDefaultHandler = new DefaultHandler() {
        public void error(SAXParseException exception) throws SAXException {
          throw exception;
        }
        public void fatalError(SAXParseException exception) throws SAXException {
          throw exception;
        }
      };
      //////////////////////////////////////////////////////////////////////
      // Define the asset you want to create in XML
      //////////////////////////////////////////////////////////////////////
      // This is the XML of the asset we're creating. Typically it would
      // come from a GUI or other asset creation mechanism. It is hard
      // coded for this example.
      /////////////////////////////////////////////////////////////////////
      String assetXML = "<asset id=\"0\">"
          + "           <asset-type id=\"145\" icon=\"component.gif\"
 lastSavedDate=\"17 Jul 2007 12:00:00 AM\">Component</asset-type>"
          + "           <mandatory-data>"
          + "               <name>NewComponent</name>"
          + "              
 <version>"+Calendar.getInstance().getTimeInMillis()+"</version>"
          + "               <description><![CDATA[My Description]]></description>"
          + "               <keywords/>"
          + "               <notification-email/>"
          + "               <applied-policies/>"
          + "               <vendor id=\"0\"/>"
          + "               <file-informations/>"
          + "               <hash-informations/>"
          + "               <producing-projects/>"
          + "               <submission-files/>"
          + "               <applied-compliance-templates/>"
          + "               <contacts/>"
          + "               <relationships/>"
          + "               <categorization-types/>"
          + "           </mandatory-data>"
          + "           <admin-data>"
          + "           </admin-data>"
          + "       </asset>";
      //////////////////////////////////////////////////////////////////////
      // This returns the Schema for the asset type of the asset we're
      // creating
      //////////////////////////////////////////////////////////////////////
      String schema = repository.assetTypeSchemaRead(authToken, 144);
      //////////////////////////////////////////////////////////////////////
      // This block of code shows validating the asset XML against
      // the schema
      //////////////////////////////////////////////////////////////////////
      lSaxParserFactory = SAXParserFactory.newInstance();
      lSaxParserFactory.setNamespaceAware(true);
      lSaxParserFactory.setValidating(true);
      lSaxParser = lSaxParserFactory.newSAXParser();
      lSaxParser.setProperty(SCHEMA_LANGUAGE, XML_SCHEMA);
      lSaxParser.setProperty(SCHEMA_SOURCE, new InputSource(new StringReader(
          schema)));
      lSaxParser.parse(new InputSource(new StringReader(assetXML)),
          lDefaultHandler);
      //////////////////////////////////////////////////////////////////////
      // If no exception was thrown the asset XML validates and
      // the creation should not fail due to XML formatting errors.
      //////////////////////////////////////////////////////////////////////
      repository.assetCreateFromXML(authToken, assetXML);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.3 ユースケース: アセットの変更

説明

既存のアセットのメタデータを変更します。

サンプル・コード

例4-10 ユースケース: アセットの変更

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Categorization;
import com.flashline.registry.openapi.entity.CategorizationType;
import com.flashline.registry.openapi.query.CategorizationTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ModifyExistingAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ////////////////////////////////////////////////////////////
      // Login to OER
      ////////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ////////////////////////////////////////////////////////////
      // Read the asset you want to modify
      ////////////////////////////////////////////////////////////
      Asset myAsset = repository.assetRead(authToken, 559);
      // 559 is the example asset number
      ////////////////////////////////////////////////////////////
      // Modify the name, version, description, and notification
      // email
      ////////////////////////////////////////////////////////////
      myAsset.setName("New Name");
      myAsset.setVersion("New Version");
      myAsset.setDescription("New Description");
      myAsset.setNotificationEmail("user@example.com");
      ////////////////////////////////////////////////////////////
      // Modify Categorizations on the asset
      ////////////////////////////////////////////////////////////
      // Setup arrays used for assigning categorizations
      CategorizationType[] lAllCatTypes = null;
      Categorization[] lAllCats = null;
      CategorizationType[] lCatTypes = new CategorizationType[1];
      Categorization[] lCats = new Categorization[1];
      ////////////////////////////////////////////////////////////
      // Search for all categorizations that are asset assignable
      ////////////////////////////////////////////////////////////
      CategorizationTypeCriteria categorizationTypeCriteria = new
 CategorizationTypeCriteria();
      categorizationTypeCriteria.setNameCriteria("");
      lAllCatTypes = repository.categorizationTypeQuery(authToken,
          categorizationTypeCriteria);
      ////////////////////////////////////////////////////////////
      // Find all the categorizations to be assigned to the asset
      ////////////////////////////////////////////////////////////
      for (int i = 0; i < lAllCatTypes.length; i++) {
        CategorizationType lCatType = repository.categorizationTypeRead(
            authToken, lAllCatTypes[i].getID());
        lAllCats = repository.categorizationReadByType(authToken,
            lCatType, true, true);
        if (lAllCats.length > 0) {
          lCatTypes[0] = lCatType;
          // when we find the first one, use it
          break;
        }
      }
      lCats[0] = lAllCats[0];
      ////////////////////////////////////////////////////////////
      // Modify the asset to use the categorizations
      ////////////////////////////////////////////////////////////
      myAsset.setCategorizations(lCats);
      myAsset.setCategorizationTypes(lCatTypes);
      ////////////////////////////////////////////////////////////
      // Modify the custom access settings for the asset
      ////////////////////////////////////////////////////////////
      String[] lCasTypes = repository.customAccessSettingTypesGet(authToken);
      String[] lCustomAccessSettings = null;
      if (lCasTypes!=null && lCasTypes.length>0) {
        lCustomAccessSettings = repository.customAccessSettingNamesGet(authToken,
 lCasTypes[0]);
      }
      if (lCustomAccessSettings!=null && lCustomAccessSettings.length>0) {
        String[] myCustomAccessSettings = { lCustomAccessSettings[0] };
        myAsset.setCustomAccessSettings(myCustomAccessSettings);
      }
      ////////////////////////////////////////////////////////////
      // Add producing projects to the asset
      ////////////////////////////////////////////////////////////
      long[] producingProjectsIDs = new long[1];
      producingProjectsIDs[0] = 50000;
      myAsset.setProducingProjectsIDs(producingProjectsIDs);
      ////////////////////////////////////////////////////////////
      // save the modifications
      ////////////////////////////////////////////////////////////
      repository.assetUpdate(authToken, myAsset);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.4 ユースケース: アセットへのユーザーの割当て

説明

複数のユーザーを1つのアセットに割り当てることができます。

サンプル・コード

例4-11 ユースケース: アセットへのユーザーの割当て

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssignedUser;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.UserCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AssignUsers {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      //////////////////////////////////////////////////////////
      // Login to OER
      //////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      //////////////////////////////////////////////////////////
      // Retrieve desired asset
      //////////////////////////////////////////////////////////
      Asset myAsset = repository.assetRead(authToken, 559);
      // 559 is the example asset number
      //////////////////////////////////////////////////////////
      // Create array of AssignedUser objects
      //////////////////////////////////////////////////////////
      AssignedUser[] lUsers = new AssignedUser[3];
      //////////////////////////////////////////////////////////
      // NOTE:
      //
      // The AssignedUser object has two methods:
      // setUserID(long)
      // setAssignedDate(Calendar).
      // (Specifies the date the user was assigned to the
      // asset. If no date is specified, the current date
      // is used.)
      //////////////////////////////////////////////////////////
      //////////////////////////////////////////////////////////
      // Add AssignedUser objects to the array
      //////////////////////////////////////////////////////////
      AssignedUser lUser = new AssignedUser();
      lUser.setUserID(99); // 99 is the admin user id
      lUsers[0] = lUser;
      lUser = new AssignedUser();
      RegistryUser lRegistryUser1 = createRegistryUser(repository, authToken);
      lUser.setUserID(lRegistryUser1.getID());
      lUsers[1] = lUser;
      lUser = new AssignedUser();
      RegistryUser lRegistryUser2 = createRegistryUser(repository, authToken);
      lUser.setUserID(lRegistryUser2.getID());
      lUsers[2] = lUser;
      //////////////////////////////////////////////////////////
      // Add array to the asset that is being updated
      //////////////////////////////////////////////////////////
      myAsset.setAssignedUsers(lUsers);
      //////////////////////////////////////////////////////////
      // save the modifications
      //////////////////////////////////////////////////////////
      repository.assetUpdate(authToken, myAsset);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static RegistryUser createRegistryUser(FlashlineRegistry repository,
 AuthToken authToken) throws OpenAPIException, RemoteException {
    RegistryUser lRet = null;
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    lRet = repository.userCreate(authToken, lUserName, "", lUserName,
 lUserName+"@example.com", lUserName, false, false, false);
    return lRet;
  }
}
4.4.3.2.5 ユースケース: アセットの検索の作成

説明

特定の条件を満たすアセットをすべて検索します。

サンプル・コード

例4-12 ユースケース: アセットの検索の作成

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetSummary;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.DateRangeSearchTerm;
import com.flashline.registry.openapi.query.SearchTerm;
import com.flashline.registry.openapi.query.TabStatusSearchTerm;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindAssets {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ////////////////////////////////////////////////////////////
      // Login to OER
      ////////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ////////////////////////////////////////////////////////////
      // Search for all assets
      ////////////////////////////////////////////////////////////
      AssetCriteria criteria = new AssetCriteria();
      AssetSummary[] assets = repository.assetQuerySummary(authToken, criteria);
      ////////////////////////////////////////////////////////////
      // try a general search which includes Name, version,
      // description, and keywords
      ////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      criteria.setGeneralCriteria("My Asset");
      assets = repository.assetQuerySummary(authToken, criteria);
      ////////////////////////////////////////////////////////////
      // Search for assets that contain a specific search string
      // in one particular field.
      ////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      criteria.setNameCriteria("My Name");
      criteria.setVersionCriteria("My version");
      criteria.setDescriptionCriteria("My Description");
      assets = repository.assetQuerySummary(authToken, criteria);
      ////////////////////////////////////////////////////////////
      // Implementing a Search through the AssetCriteria Object
      // --------------------------------------------------
      // If no operator is specified when implementing a search
      // using the setSearchTerms method in the AssetCriteria
      // object, the system defaults to the operator EQUALS.
      // The operator LIKE must be specified if required for the
      // search.
      ////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      SearchTerm lSearchTerm = new SearchTerm();
      lSearchTerm.setKey("name");
      lSearchTerm.setOperator("LIKE");
      lSearchTerm.setValue("Test");
      SearchTerm[] lTerms = new SearchTerm[1];
      lTerms[0] = lSearchTerm;
      criteria.setSearchTerms(lTerms);
      assets = repository.assetQuerySummary(authToken, criteria);
      //Search for assets where a specific DATETIME field is a given age
      //////////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      //Not specifying an operator defaults to 'equals'.
      DateRangeSearchTerm lTerm = new DateRangeSearchTerm();
      /////////////////////////
      //date-range is the query key.  registereddate is the date field we are
 searching on
      //Allowable fields to search on:
      //submitteddate
      //registereddate
      //accepteddate
      //createddate
      //updateddate
      //To do a search for all assets that were registered more than 5 days ago
      lTerm.setKey("date-range");
      //Set the value to a day 5 days older than the current date.  Assume today's
 date is 1/10/2007
      //The format defaults to OER's system setting for Short Date Format.
      //The format can be set to any valid date format using setDateFormat() and
 passing the date format.
      lTerm.setDateFormat("yyyy-MM-dd");
      lTerm.setBeginDate("2007-1-5");
      lTerm.setBeginOperator("lt");
      lTerm.setDateField("registereddate");
      lTerms = new SearchTerm[1];
      lTerms[0] = lTerm;
      criteria.setSearchTerms(lTerms);
      assets = repository.assetQuerySummary(authToken, criteria);
      //Search for assets where a given date field is within a date range
      //////////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      lTerm = new DateRangeSearchTerm();
      /////////////////////////
      //date-range is the query key.  registereddate is the date field we are
 searching on
      //Allowable fields to search on:
      //submitteddate
      //registereddate
      //accepteddate
      //createddate
      //updateddate
      //The following SearchTerm translates to "Assets where the registereddate is
 greater than or equal to Jan. 1, 2007
      lTerm.setKey("date-range");
      //The format defaults to OER's system setting for Short Date Format.
      //The format can be set to any valid date format using setDateFormat() and
 passing the date format.
      lTerm.setDateField("registereddate");
      lTerm.setDateFormat("yyyy-MM-yy");
      lTerm.setBeginDate("2007-01-01");
      lTerm.setBeginOperator("gte");
      lTerm.setEndDate("2007-01-10");
      lTerm.setEndOperator("lte");
      //The following SearchTerm translates to "Assets where the registereddate is
 less than or equal to Jan. 10, 2007
      criteria.setSearchTerms(new SearchTerm[] {lTerm});
      //This query returns all assets that were registered between January 1 and
 January 10, including those days.
      assets = repository.assetQuerySummary(authToken, criteria);
      //Search for assets where a given tab has been approved or unapproved
      //////////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      TabStatusSearchTerm lTabTerm = new TabStatusSearchTerm();
      //tabstatus is the type of search we want to do.  overview is the name of
 the tab we want to search on
      lTabTerm.setKey("tabstatus");
      lTabTerm.setTabNames(new String[] {"overview"});
      lTabTerm.setApproved(true);
      criteria.setSearchTerms(new SearchTerm[] {lTabTerm});
      //This query returns all assets with the Overview tab being approved
      assets = repository.assetQuerySummary(authToken, criteria);
      //You may also search by a date range.
      lTabTerm.setKey("tabstatus");
      lTabTerm.setTabNames(new String[] {"overview"});
      lTabTerm.setApproved(false);
      lTabTerm.setBeginDate("2007-1-01");
      lTabTerm.setBeginOperator("lte");
      criteria.setSearchTerms(new SearchTerm[] {lTabTerm});
      //The following returns all assets that have the Overview tab unapproved
 since or before January 1, 2007
      assets = repository.assetQuerySummary(authToken, criteria);
      //Search for assets where a custom field date has a specific value.
      //This test returns all assets that have a testdate of January 1, 2007.
      //The testdate field is a custom data date element.
      //////////////////////////////////////////////////////////////////
      criteria = new AssetCriteria();
      DateRangeSearchTerm lDateRangeTerm = new DateRangeSearchTerm();
      //Test Equals
      lDateRangeTerm.setKey("/asset/custom-data/testdate");
      lDateRangeTerm.setBeginDate("2007-01-1");
      lDateRangeTerm.setBeginOperator("eq");
      criteria.setSearchTerms(new SearchTerm[] {lDateRangeTerm});
      assets = repository.assetQuerySummary(authToken, criteria);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.6 ユースケース: アセット・ステータスのアップグレード

説明

アセットのステータス・レベルを未発行から、発行済、承認済、登録済に変更します。

サンプル・コード

例4-13 ユースケース: アセット・ステータスのアップグレード

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class PromoteAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      long lAssetID = 559;
      // -------------------------------------------------------
      // asset with id 559 would have to be unsubmitted for this to work
      AssetCriteria lAssetCriteria = new AssetCriteria();
      lAssetCriteria.setIDCriteria(lAssetID);
      KeyValuePair lKeyValuePair = repository.assetEvaluate(authToken,
 lAssetCriteria, "Registration Status");
      if (!lKeyValuePair.getValue().equalsIgnoreCase("unsubmitted")) {
        unregisterAsset(repository, authToken, lAssetID);
      }
      ///////////////////////////////////////////////////////////
      // promote the asset from unsubmitted to submitted
      ///////////////////////////////////////////////////////////
      repository.assetSubmit(authToken, lAssetID);
      // asset 559 would have to be unsubmitted for this to work
      ///////////////////////////////////////////////////////////
      // promote the asset from submitted to accepted
      ///////////////////////////////////////////////////////////
      repository.assetAccept(authToken, lAssetID);
      // asset 561 would have to be submitted for this to work
      ///////////////////////////////////////////////////////////
      // promote the asset from accepted to registered
      ///////////////////////////////////////////////////////////
      repository.assetRegister(authToken, lAssetID);
      // asset 563 would have to be accepted for this to work
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static void unregisterAsset(FlashlineRegistry repository, AuthToken
 authToken, long pAssetID) {
    try {
      repository.assetUnRegister(authToken, pAssetID);
    } catch (Exception e) {
    }
    try {
      repository.assetUnAccept(authToken, pAssetID);
    } catch (Exception e) {
    }
    try {
      repository.assetUnSubmit(authToken, pAssetID);
    } catch (Exception e) {
    }
  }
}
4.4.3.2.7 ユースケース: アセット・ステータスのダウングレード

説明

前述のユースケースとは反対に、アセットのステータス・レベルを登録済から、承認済、発行済、未発行に変更します。

サンプル・コード

例4-14 ユースケース: アセット・ステータスのダウングレード

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class DemoteAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      long lAssetID = 559;
      // -------------------------------------------------------
      // asset with id 559 would have to be registered for this to work
      AssetCriteria lAssetCriteria = new AssetCriteria();
      lAssetCriteria.setIDCriteria(lAssetID);
      KeyValuePair lKeyValuePair = repository.assetEvaluate(authToken,
 lAssetCriteria, "Registration Status");
      if (!lKeyValuePair.getValue().equalsIgnoreCase("registered")) {
        registerAsset(repository, authToken, lAssetID);
      }
      ///////////////////////////////////////////////////////////
      // demote the asset from registered to accepted
      ///////////////////////////////////////////////////////////
      repository.assetUnRegister(authToken, lAssetID);
      ///////////////////////////////////////////////////////////
      // demote the asset from accepted to submitted
      ///////////////////////////////////////////////////////////
      repository.assetUnAccept(authToken, lAssetID);
      ///////////////////////////////////////////////////////////
      // demote the asset from submitted to unsubmitted
      ///////////////////////////////////////////////////////////
      repository.assetUnSubmit(authToken, lAssetID);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static void registerAsset(FlashlineRegistry repository, AuthToken
 authToken, long pAssetID) {
    try {
      repository.assetSubmit(authToken, pAssetID);
    } catch (Exception e) {
    }
    try {
      repository.assetAccept(authToken, pAssetID);
    } catch (Exception e) {
    }
    try {
      repository.assetRegister(authToken, pAssetID);
    } catch (Exception e) {
    }
  }
}
4.4.3.2.8 ユースケース: プロジェクトからのコンプライアンス・テンプレートの適用と削除

説明

コンプライアンス・テンプレートのプロジェクトへの追加およびプロジェクトからの削除を行うことができます。


注意:

アセットがプロジェクトに適用されていて、そのアセットがコンプライアンス・テンプレートでない場合、OpenAPIExceptionが発生します。

サンプル・コード

例4-15 ユースケース: プロジェクトからのコンプライアンス・テンプレートの適用および削除

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AddRemoveTemplate {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ///////////////////////////////////////////////////////////
      // Read or Create a Compliance Template Type and Asset
      ///////////////////////////////////////////////////////////
      AssetType ctType = null;
      AssetTypeCriteria lAssetTypeCriteria = new AssetTypeCriteria();
      lAssetTypeCriteria.setArcheTypeCriteria("Compliance Template Type");
      AssetType[] lAssetTypes =
        repository.assetTypeQuery(authToken, lAssetTypeCriteria);
      if (lAssetTypes!=null && lAssetTypes.length>0) {
        ctType = lAssetTypes[0];
      } else {
        ctType = repository.assetTypeCreateComplianceTemplate(authToken,
            "My Compliance Template
 Type"+Calendar.getInstance().getTimeInMillis());
      }
      Asset lComplianceTemplateAsset = null;
      AssetCriteria lAssetCriteria = new AssetCriteria();
      lAssetCriteria.setAssetTypeCriteria(ctType.getID());
      Asset[] lAssets = repository.assetQuery(authToken, lAssetCriteria);
      if (lAssets!=null && lAssets.length>0) {
        lComplianceTemplateAsset = lAssets[0];
      } else {
        lComplianceTemplateAsset = repository.assetCreate(authToken, "My
 Compliance Template",
            ""+Calendar.getInstance().getTimeInMillis(), ctType.getID());
      }
      ///////////////////////////////////////////////////////////
      // Create a String array of Project IDs that the Compliance
      // Template is applied to.
      ///////////////////////////////////////////////////////////
      String[] lProjectIDs = { "50000" };
      // /////////////////////////////////////////////////////////
      // Apply template to the projects.
      // /////////////////////////////////////////////////////////
      repository.assetApplyToProjects(authToken, lProjectIDs,
          lComplianceTemplateAsset);
      ///////////////////////////////////////////////////////////
      // Retrieve an array of Projects that this template is
      // applied to.
      ///////////////////////////////////////////////////////////
      Project[] lProjects = repository.assetReadAppliedToProjects(
          authToken, lComplianceTemplateAsset);
      String lMsg = "Compliance Template '" + lComplianceTemplateAsset.getName();
      lMsg += "' applied to Project(s): ";
      for (int i=0; lProjects!=null && i<lProjects.length; i++) {
        lMsg += ""+lProjects[i].getName()+(i+1==lProjects.length ? "." : ", ");
      }
      System.out.println(lMsg);
      ///////////////////////////////////////////////////////////
      // Create a String array of Project IDs that the Compliance
      // Template is removed from.
      ///////////////////////////////////////////////////////////
      String[] lRemoveProjectIDs = { "50000" };
      ///////////////////////////////////////////////////////////
      // Remove template from the projects.
      ///////////////////////////////////////////////////////////
      repository.assetRemoveAppliedToProjects(authToken,
          lRemoveProjectIDs, lComplianceTemplateAsset);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.9 ユースケース: 新しいバージョンのアセットの作成および古いバージョンのリタイア

説明

リポジトリを更新して、新しいバージョンのアセットを使用できるようにし、以前のバージョンのアセットをリタイアします。

サンプル・コード

例4-16 ユースケース: 新しいバージョンのアセットの作成

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RelationshipType;
import com.flashline.registry.openapi.query.RelationshipTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewVersionOfAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ///////////////////////////////////////////////////////////
      // Read old asset.
      // Update metadata as necessary.
      // Save as new asset.
      ///////////////////////////////////////////////////////////
      Asset myAsset = repository.assetRead(authToken, 561);
      ///////////////////////////////////////////////////////////
      // Find the "next-version" relationship for the asset
      ///////////////////////////////////////////////////////////
      RelationshipType[] allRelationshipTypes =
 getAllRelationshipTypes(repository, authToken);
      for (int i = 0; i < allRelationshipTypes.length; i++) {
        if (allRelationshipTypes[i].getName().equals("next-version")) {
          ///////////////////////////////////////////////////////////
          // This is the relationship type, modify the assets that are related
          // using it
          ///////////////////////////////////////////////////////////
          RelationshipType myRelationshipType = allRelationshipTypes[i];
          ///////////////////////////////////////////////////////////
          // Add the old version to list of previous versions of the
          // newly created asset
          ///////////////////////////////////////////////////////////
          long[] oldSecondaryIDs = myRelationshipType.getSecondaryIDs();
          long[] newSecondaryIDs = new long[oldSecondaryIDs.length + 1];
          for (int j = 0; j < oldSecondaryIDs.length; j++) {
            newSecondaryIDs[j] = oldSecondaryIDs[j];
          }
          newSecondaryIDs[newSecondaryIDs.length - 1] = 561;
          myRelationshipType.setSecondaryIDs(newSecondaryIDs);
        }
      }
      Asset myNewAsset = repository.assetCreate(authToken,
          myAsset.getName(), ""+Calendar.getInstance().getTimeInMillis(),
 myAsset.getTypeID());
      myNewAsset.setRelationshipTypes(allRelationshipTypes);
      ///////////////////////////////////////////////////////////
      // Update the new asset
      ///////////////////////////////////////////////////////////
      myNewAsset = repository.assetUpdate(authToken, myNewAsset);
      ///////////////////////////////////////////////////////////
      // retire the old asset
      ///////////////////////////////////////////////////////////
      repository.assetRetire(authToken, 561);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  /**
   * This method returns every relationship type in the repository
   * @param repository
   * @param authToken
   * @return
   * @throws RemoteException
   */
  public static RelationshipType[] getAllRelationshipTypes(FlashlineRegistry
 repository, AuthToken authToken) throws RemoteException {
    //Create an empty relationship type criteria object
    RelationshipTypeCriteria criteria = new RelationshipTypeCriteria();
    criteria.setNameCriteria("");
    RelationshipType[] allRelationshipTypes =
 repository.relationshipTypeQuery(authToken, criteria);
    return allRelationshipTypes;
  }
}
4.4.3.2.10 ユースケース: アセットのグループの削除

説明

リポジトリに属さないアセットのグループを削除します。

サンプル・コード

例4-17 ユースケース: リポジトリからの不要なアセットの削除

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class DeleteAssets {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ///////////////////////////////////////////////////////////
      // find the assets to delete
      ///////////////////////////////////////////////////////////
      AssetCriteria criteria = new AssetCriteria();
      criteria.setGeneralCriteria("delete me");
      Asset[] assets = repository.assetQuery(authToken, criteria);
      ///////////////////////////////////////////////////////////
      // Iterate through assets, deleting them one at a time.
      ///////////////////////////////////////////////////////////
      for (int i = 0; i < assets.length; i++) {
        repository.assetDelete(authToken, assets[i].getID());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

短所:

アセットは完全に削除されます。オープンAPIでは、削除したアセットをリストアするメソッドがありません。

回避するメソッド:

次のメソッドはオープンAPIのコンテキストでは意味がないので、使用しないでください。

  • setAcceptedByID

  • setAcceptedByName

  • setAcceptedByDate

  • setActiveStatus

  • setAssigned

  • setAssignedToID

  • setAssignedDate

  • setCategorizationTypes

  • setCreatedByID

  • setCreatedByName

  • setCreatedByDate

  • setDeleted

  • setEntityType

  • setExtractable

  • setFullAsset

  • setInactive

  • setKey

  • setLoadedDate

  • setLongName

  • setNotifyUpdatedRelationships

  • setRegisteredByID

  • setRegisteredByName

  • setRegisteredDate

  • setRegistrationStatus

  • setRegistrationStatusBaseName

  • setRegistrationStatusRegistered

  • setRegistrationStatusRejected

  • setRegistrationStatusSubmittedPendingReview

  • setRegistrationStatusSubmittedUnderReview

  • setRegistrationStatusUnsubmitted

  • setRejectionReason

  • setRetired

  • setSubmittedByID

  • setSubmittedByName

  • setSubmittedDate

  • setTypeIcon

  • setTypeName

  • setUpdatedDate

  • setVendorName

  • setVisible

一般的なミスの回避

  • アセットのルール

    • アセットは、アクティブで有効なアセット・タイプに割り当てる必要があります。

    • アセットの名前/バージョンの文字列は一意のペアである必要があります。

    • 新しいアセットのIDは0にする必要があります。

    • 新しいアセットのアクティブなステータスはアクティブである必要があります。

提供されていない機能

  • カスタム・データを変更するためのヘルパー・メソッド

  • 追加の検証

    アセットを保存する場合、Oracle Enterprise Repositoryでは、現在、次の内容を検証しています。

    • アセット・タイプが有効でアクティブであること

    • 名前/バージョンが一意であること

    • アセットを作成する場合、アクティブなステータスが有効であること

    • アセットを更新する場合、アセットがすでに存在すること

    • コンタクトが重複していないこと

    • カテゴリ分けが有効であること

    • 今後のバージョンのリポジトリの検証内容

      • カスタム・データが正しいフォーマットのXMLであること

      • カスタム・データにはアセット・タイプに基づいて有効なXMLが含まれていること

4.4.3.2.11 ユースケース: アセットの検索およびカスタム・データのアップグレード

説明

特定のカスタム・データ値ですべてのアセットの検索を実行し、これらのアセットのそれぞれについてカスタム・データの一部を更新します。注意: assetUpdateCustomDataNodeメソッドを使用する場合、アセットは自動的に保存されます。

サンプル・コード

例4-18 ユースケース: アセットの検索およびカスタム・データのアップグレード

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetSummary;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.SearchTerm;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateAssetTestResults {
  public static void main(String pArgs[]) throws OpenAPIException,
      RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ///////////////////////////////////////////////////////////
      // create a criteria object searching for all assets with a
      // custom-data element for test-frequency equal to 'DAILY'
      ///////////////////////////////////////////////////////////
      SearchTerm[] searchTermArray = new SearchTerm[1];
      SearchTerm term = new SearchTerm();
      term.setKey("/asset/custom-data/test-frequency");
      term.setValue("DAILY");
      searchTermArray[0] = term;
      AssetCriteria criteria = new AssetCriteria();
      criteria.setSearchTerms(searchTermArray);
      ///////////////////////////////////////////////////////////
      // perform search, getting back summary objects. loop through
      // objects and perform an action on each one
      ///////////////////////////////////////////////////////////
      AssetSummary[] assets = repository.assetQuerySummary(authToken,
          criteria);
      ///////////////////////////////////////////////////////////
      // Loop through search results
      ///////////////////////////////////////////////////////////
      for (int i = 0; i < assets.length; i++) {
        long assetID = assets[i].getID();
        String testResult = null;
        ///////////////////////////////////////////////////////////
        // Update value in the asset
        ///////////////////////////////////////////////////////////
        repository.assetUpdateCustomDataNode(
            authToken, assetID, "/asset/custom-data/test-result", testResult);
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.12 ユースケース: アセットのタブの読込み

説明

アセットのタブを読み込みます。

サンプル・コード

例4-19 ユースケース: アセットのタブの読込み

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.TabBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AssetReadTabs {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      TabBean[] lTabBeans = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read an asset's tabs
      ///////////////////////////////////
      lTabBeans = repository.assetTabsRead(authToken, 559);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.13 ユースケース: タブ・タイプに基づいたアセットのタブの取得

説明

タブ・タイプ別に特定のアセット・タブを取得します。

サンプル・コード

例4-20 ユースケース: タブ・タイプに基づいたアセットのタブの取得

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.TabBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AssetGetTabByType {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      Asset lAsset = null;
      TabBean lTabBean = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read an asset
      ///////////////////////////////////
      lAsset = repository.assetRead(authToken, 559);
      ///////////////////////////////////
      // get an asset's tab by tabbeantype
      ///////////////////////////////////
      lTabBean = repository.assetTabRead(authToken, lAsset.getID(), 458);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.14 ユースケース: タブの承認および未承認

説明

アセットのタブを承認するか、または未承認にします。

サンプル・コード

例4-21 ユースケース: タブの承認および未承認

package com.flashline.sample.assetapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;

public class ApproveUnapproveTab {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // approve an asset tab
      ///////////////////////////////////
      repository.assetTabApprove(authToken, 559, 1864);
      ///////////////////////////////////
      // unapprove an asset tab
      ///////////////////////////////////
      repository.assetTabUnapprove(authToken, 559, 1864);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.3.2.15 ユースケース: 特定のタブ用のアセットのメタデータの読込み

説明

特定のタブに基づいたアセットのメタデータを読み込みます。

サンプル・コード

例4-22 ユースケース: 特定のタブ用のアセットのメタデータの読込み

package com.flashline.sample.assetapi;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetMetadataElement;
import com.flashline.registry.openapi.entity.AssetMetadataTableElement;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;

public class AssetGetMetadataByTab {
  public static void main(String pArgs[]) throws OpenAPIException,
RemoteException,
  ServiceException {
    try {

      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      Asset lAsset = null;

      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);

      ///////////////////////////////////
      // read an asset
      ///////////////////////////////////
      lAsset = repository.assetRead(authToken, 589);

      ///////////////////////////////////
      // Get the metadata elements based
      // on the asset ID and the tab name
      ///////////////////////////////////
      AssetMetadataElement[] lElements =
repository.assetReadTabMetadata(authToken, lAsset.getID(), "Overview");

      //An AssetMetadataElement represents a custom or mandatory data element of an asset
      for (AssetMetadataElement lElement : lElements) {
        //This represents a TABLE element type
        if (lElement.getValue() instanceof AssetMetadataTableElement) {
          AssetMetadataTableElement lTable =
(AssetMetadataTableElement)lElement.getValue();
          System.out.println(lElement.getDisplayName());
          //A TABLE can have multiple elements
          for (AssetMetadataElement lTableElement : lTable.getElements()) {
            //An element of a TABLE can be another TABLE
            if (lTableElement.getValue() instanceofAssetMetadataTableElement) {

System.out.println(((AssetMetadataTableElement)lTableElement.getValue()).getDisplayName());
              for (AssetMetadataElement lChildElement :
((AssetMetadataTableElement)lTableElement.getValue()).getElements()) {
                System.out.println(lChildElement.getDisplayName() + " : " +
lChildElement.getValue());
              }
            } else {
              //Or an element of a TABLE can be a regular value
              System.out.println(lTableElement.getDisplayName() + " : " +
lTableElement.getValue());
            }
          }
          //This represents a MULTIPLE ITEM LIST
        }  else if (lElement.getValue() instanceof String[]) {
          System.out.println(lElement.getDisplayName());
          for (String lString : (String[])lElement.getValue()) {
            System.out.println(lString);
          }
          //This represents a SINGLE ITEM
        } else {
          System.out.println(lElement.getDisplayName() + " : " +
lElement.getValue());
        }
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.4 アセット・タイプAPI

この項では、アセット・タイプAPIのユースケースについて説明します。このユースケースで、リポジトリへの新しいタイプの追加、新しいコンプライアンス・テンプレートのタイプの作成、タイプの特定、アセット・タイプで使用できるタブのリストの取得、およびOracle Enterprise Repository内でのすべてのアセット・タイプのタブの取得を行う方法について解説します。

4.4.4.1 概要

タイプ(アセット・タイプおよびコンプライアンス・テンプレート)では、アセットの構造を定義します。タイプは、主に2つの部分から構成されます。

  • エディタ

    アセットのために格納されるメタデータを定義し、アセット・エディタでのメタデータ要素の編成方法を指定します。

  • ビューア

    Oracle Enterprise Repositoryにおけるアセット詳細でのメタデータ要素の表示方法を定義します。

タイプを作成または編集する場合、許容値リストとカテゴリ分けタイプはメタデータ要素として使用します。これらのメタデータ要素は、タイプのエディタおよびビューアXMLで、ID別に参照します。アセットを作成または編集する場合、タイプはアセット(Asset.GetCustomData())のカスタム・データで使用されるメタデータ要素を定義します。


注意:

  • この項のコード例ではアセット・タイプを参照していますが、ユースケースで記述されたプロセスがアセット・タイプとコンプライアンス・テンプレートの両方を作成するために使用されることに注意してください。コンプライアンス・テンプレートの詳細は、『Oracle Fusion Middleware Oracle Enterprise Repository管理者ガイド』を参照してください。

  • エディタおよびビューアのメタデータは、CDATAをエスケープしたXMLとして表現されます。したがって、多数のアセット・タイプがassetTypeQueryのコールで返される場合、一部のXMLパーサーがエンティティの拡張の制限を超える可能性があります。一般的なパーサーでは、デフォルトのエンティティ拡張の制限が64,000に設定されているものがあります。この制限を超えた場合、コマンドライン・パラメータ(entityExpansionLimit)を渡して、この制限値をJAXP準拠のプロセッサ上で増加できます。たとえば、JVMに次のパラメータを渡すと、エンティティ拡張の制限が5MBに増加します。

    java -DentityExpansionLimit=5242880 com.example.MyApp


4.4.4.2 ユースケース

この項では、AssetType APIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.4.2.1 ユースケース: 新しいタイプの作成および編集

説明

新しいタイプをリポジトリに追加します。

サンプル・コード

例4-23 ユースケース: 新しいタイプの作成および編集

package com.flashline.sample.assettypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewAssetType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Select an existing Type on which to base the new one
      // //////////////////////////////
      String newAssetTypeName = "My AssetType";
      long baseAssetTypeID = 151;
      AssetType newAssetType = repository.assetTypeCreateClone(
          authToken, baseAssetTypeID, newAssetTypeName);
      System.out.println("The new Asset Type id =\"" + newAssetType.getID()
          + "\"");
      // //////////////////////////////
      // Manipulate xml strings
      // //////////////////////////////
      String lEditorXML = newAssetType.getEditorXML();
      String lViewerXML = newAssetType.getViewerXML();
      // Perform XML manipulation on the editor and viewer definitions...
      // //////////////////////////////
      // Set the new editor/viewer definitions on the asset type, and save the
      // type back to OER
      // //////////////////////////////
      newAssetType.setEditorXML(lEditorXML);
      newAssetType.setViewerXML(lViewerXML);
      repository.assetTypeUpdate(authToken, newAssetType);
      // ----------------------------------------
      // clean up sample
      repository.assetTypeDelete(authToken, newAssetType.getID());
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.4.2.2 ユースケース: コンプライアンス・テンプレート・タイプの作成

説明

新しいコンプライアンス・テンプレートをリポジトリに追加します。

サンプル・コード

例4-24 ユースケース: コンプライアンス・テンプレート・タイプの作成

package com.flashline.sample.assettypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewComplianceTemplateType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create a new compliance template.
      // //////////////////////////////
      String newAssetTypeName = "My Compliance
 Template"+Calendar.getInstance().getTimeInMillis();
      AssetType newAssetType = repository
          .assetTypeCreateComplianceTemplate(authToken, newAssetTypeName);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.4.2.3 ユースケース: タイプの検索

説明

リポジトリ内でタイプを検索します。

サンプル・コード

例4-25 ユースケース: タイプの検索

package com.flashline.sample.assettypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.query.SearchTerm;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindAssetType {
  public static void main(String pArgs[]) throws RemoteException,
 OpenAPIException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create SearchTerms and set them on the AssetSearchCriteria
      // //////////////////////////////
      AssetTypeCriteria assetTypeCriteria = new AssetTypeCriteria();
      SearchTerm[] searchTerms = new SearchTerm[1];
      searchTerms[0] = new SearchTerm();
      searchTerms[0].setKey("name");
      searchTerms[0].setValue("Component");
      assetTypeCriteria.setSearchTerms(searchTerms);
      // //////////////////////////////
      // Perform the search using the specified criteria
      // //////////////////////////////
      AssetType[] assetTypes = repository.assetTypeQuery(authToken,
          assetTypeCriteria);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

回避するメソッド:

  • setIcon

  • setID

4.4.4.2.4 ユースケース: アセット・タイプのタブの取得

説明

アセット・タイプに使用できるタブ・リストを取得します。

サンプル・コード

例4-26 ユースケース: アセット・タイプのタブ・リストの取得

package com.flashline.sample.assettypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.TabTypeBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadTabTypes {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      TabTypeBean[] lTabTypeBeans = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read the tab types of an assettype
      ///////////////////////////////////
      lTabTypeBeans = repository.assetTypeTabsRead(authToken, 100);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.4.2.5 ユースケース: すべてのアセット・タイプのタブの取得

説明

Oracle Enterprise Repository内のすべてのアセット・タイプのタブを取得します。

サンプル・コード

例4-27 ユースケース: すべてのアセット・タイプのタブの取得

package com.flashline.sample.assettypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.TabTypeBean;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadTabTypes {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      TabTypeBean[] lTabTypeBeans = null;
      ///////////////////////////////////
      // Login to OER
      ///////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      ///////////////////////////////////
      // read the tab types of an assettype
      ///////////////////////////////////
      lTabTypeBeans = repository.assetTypeTabsRead(authToken, 100);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

RelationshipTypeQueryの例

try
{
   RelationshipTypeCriteria rCriteria = new RelationshipTypeCriteria();
   RelationshipType[] allRelationshipTypes =
 FlashlineRegistry.relationshipQuery(lAuthToken, rCriteria);
}
catch (OpenAPIException e)
{
     e.printStackTrace();
}
catch (RemoteException re)
{
    re.printStackTrace();
}

4.4.5 カテゴリ分けタイプとカテゴリ分けAPI

この項では、カテゴリ分けタイプとカテゴリ分けAPIのユースケースについて説明します。このユースケースで、カテゴリ分けタイプの作成、カテゴリ分けの操作、およびカテゴリ分けタイプの操作を行う方法について解説します。

4.4.5.1 概要

カテゴリ分けとカテゴリ分けタイプの違いを理解することは重要です。

カテゴリ分けタイプは、カスタムの分類を定義する手段を提供します。カテゴリ分けはカテゴリ分けタイプのサブセットであり、アセットに割り当てられます。たとえば、テクノロジと呼ばれるカテゴリ分けタイプには、割当て可能なカテゴリ分けとして、Java、.NETおよびCOBOLが含まれていることがあります。さらに、Javaの下のサブカテゴリ分けには、サーブレットとアプレットが含まれています。したがって、Oracle Enterprise Repositoryのアセットは、Javaのカテゴリ分けに割り当てられるか、特にサーブレットのサブカテゴリ分けに割り当てられることがあります。

特定のアセットに割り当てられるカテゴリ分けは、そのアセットのタイプに定義されたカテゴリ分けタイプで決定されます。前述の例として、テクノロジのカテゴリ分けタイプがアセット・タイプXYZに対して定義されている場合、タイプXYZのアセットはJava、.NETまたはCOBOLのカテゴリ分けに割り当てるか、サーブレットまたはアプレットのサブカテゴリ分けに割り当てることができます。この分類の構造によって、アセットをグループ化し、Oracle Enterprise Repository内で様々な方法で表示できます。

カテゴリ分けタイプはプロジェクトに関連付けることもできます(Oracle Enterprise Repositoryがその機能用に構成されている場合)。すべてのプロジェクトに割当て可能なカテゴリ分けタイプは、すべてのプロジェクトに使用できます。アセットと同様に、プロジェクトは、割当て済カテゴリ分けタイプで使用可能なカテゴリ分けのいずれにも関連付けることができます。

カテゴリ分けタイプとカテゴリ分けのルールは、次のとおりです。

  • リポジトリは0からn個のカテゴリ分けタイプを含めることができ、それぞれのカテゴリ分けタイプには0からn個のカテゴリ分けが含まれます。

  • 各カテゴリ分けは、0からn個のサブカテゴリ分けを含むことができます。

  • 各カテゴリ分けタイプには一意の名前が付けられている必要があります。この名前には、空白や特殊文字は使用できません。

  • オプションとして、特定のカテゴリ分けタイプ内のカテゴリ分けは互いに排他的であることがあります。すなわち、カテゴリ分けのリストが表示された際は、1つしか選択できません。

  • カテゴリ分けタイプのために相互排他オプションが選択された場合、Oracle Enterprise Repositoryでは今後の使用のみにルールを強制します。タイプ内の複数選択されたカテゴリ分けへの既存の参照は変更されません。

  • このように構成した場合、カテゴリ分けタイプはプロジェクトに割り当てることができます。これによって、Oracle Enterprise Repositoryのプロジェクトをカテゴリ分けタイプまたはカテゴリ分けで編成できます。

  • 特定のカテゴリ分けタイプの構成がプロジェクトに割り当てることができないように変更された場合、この変更は後続のプロジェクトの割当てのみに影響します。既存のプロジェクトへのカテゴリ分けタイプの割当てには影響しません。

  • カテゴリ分けタイプはOracle Enterprise Repositoryから削除できます。ただし、これを実行すると、削除したカテゴリ分けタイプ内のすべてのカテゴリ分けも削除されます。この作業を実行する際は、注意してください。

  • カテゴリ分けは非アクティブ化できます。非アクティブ化を行うと、カテゴリ分け(およびすべてのサブカテゴリ分け)を今後使用できなくなりますが、Oracle Enterprise Repositoryから削除されません。カテゴリ分けへの既存の参照は、非アクティブ化によって影響を受けません。

  • 前述のプロセスとは逆に、非アクティブ化されたカテゴリ分けは、再度アクティブ化できます。

  • 特定のカテゴリ分けタイプ内では、すべてのカテゴリ分けには、一意の名前が付けられている必要があります。ただし、同じ名前は、別のカテゴリ分けタイプに存在する複数のカテゴリ分けで共有できます。

次のメソッドによって、カテゴリ分けタイプの作成、更新、表示、問合せおよび削除を行うことができます。

4.4.5.2 ユースケース

この項では、カテゴリ分けタイプおよびカテゴリ分けAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.5.2.1 ユースケース: カテゴリ分けタイプの作成

説明

新しく作成されたカテゴリ分けタイプに付けられた要素名には、空白や特殊文字は使用できません。単数および複数の表示名に使用される文字に制限はありません。pExclusiveAssignブールでは、カテゴリ分けタイプ内で割り当てることができるカテゴリ分けを1つにするか、または複数にするかを決定します。pExclusiveAssignブールは、カテゴリ分けタイプをプロジェクトに割り当てるかどうかも決定します。このメソッドでは、既存のカテゴリ分けの重複を避け、作成済のカテゴリ分けタイプを返します。

サンプル・コード

例4-28 ユースケース: カテゴリ分けタイプの作成

package com.flashline.sample.categorizationtypesandapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.CategorizationType;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateCategorizationType {
  public static void main(String pArgs[]) throws java.rmi.RemoteException,
      OpenAPIException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create the categorization type
      // //////////////////////////////
      String pName = "Name";
      String pSingularDisplay = "SingularDisplay";
      String pPluralDisplay = "PluralDisplay";
      boolean pExclusiveAssign = true;
      boolean pProjectAssign = true;
      CategorizationType lCategorizationType =
 repository.categorizationTypeCreate(authToken, pName,
          pSingularDisplay, pPluralDisplay, pExclusiveAssign, pProjectAssign);
      // ----------------------------------------
      // clean up
      repository.categorizationTypeDelete(authToken, lCategorizationType);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.5.2.2 ユースケース: カテゴリ分けタイプの操作

説明

次の操作を例に示します。

  • ID別のカテゴリ分けタイプの取得。

  • カテゴリ分けタイプの更新。

  • カテゴリ分けタイプの削除。

  • 注意が必要です。このメソッドでは、カテゴリ分けタイプ全体、およびこれに含まれているすべてのカテゴリ分けが削除されます。

  • カテゴリ分けタイプの問合せ。

  • 名前、タイプ、およびカテゴリ分けをプロジェクトに割り当てるかどうかを含め、様々な条件を使用します。

  • カテゴリ分けタイプの取得。

サンプル・コード

例4-29 ユースケース: カテゴリ分けタイプの操作

package com.flashline.sample.categorizationtypesandapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Categorization;
import com.flashline.registry.openapi.entity.CategorizationType;
import com.flashline.registry.openapi.query.CategorizationTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CategorizationExamples {
  public static void main(String pArgs[]) throws ServiceException,
 RemoteException,
      OpenAPIException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create a Categorization Type
      // //////////////////////////////
      CategorizationType categorizationType = repository
          .categorizationTypeCreate(authToken, "exampleType", "Example Type",
              "Example Types", false, true);
      // //////////////////////////////
      // Find and update a categorization type
      // //////////////////////////////
      CategorizationTypeCriteria categorizationTypeCriteria = new
 CategorizationTypeCriteria();
      boolean projectAssign = true;
      categorizationTypeCriteria.setProjectAssignCriteria(projectAssign + "");
      CategorizationType[] categorizationTypes = repository
          .categorizationTypeQuery(authToken, categorizationTypeCriteria);
      // Set plural display name
      categorizationType.setDisplayPlural("Updated Example Types");
      // Set singular display name
      categorizationType.setDisplaySingular("Updated Example Type");
      // Set Categorization Type name
      categorizationType.setName("updatedExampleType");
      // Set Categorization Type exclusive assign
      categorizationType.setExclusiveAssign(true);
      // Set Categorization Type project Assignable
      categorizationType.setProjectAssignable(false);
      // Update Categorization Type
      categorizationType = repository.categorizationTypeUpdate(
          authToken, categorizationType);
      // Read a Categorization Type
      CategorizationType categorizationTypeRead = repository
          .categorizationTypeRead(authToken, categorizationType.getID());
      // //////////////////////////////
      // Create a Categorization within a Categorization Type
      // //////////////////////////////
      Categorization categorization = repository.categorizationCreate(
          authToken, "Example Categorization", categorizationType);
      // //////////////////////////////
      // Create a Categorization within a Categorization (a.k.a. a
      // sub-categorization or child categorization)
      //
      // method validates that:
      //   - no child categorization with the same name exists within the
      //     parent categorization.
      //   - the categorization type is valid
      //   - the parent categorization is valid.
      // //////////////////////////////
      Categorization childCategorization = repository
          .categorizationChildCreate(authToken, "Example Child Categorization",
              categorizationType, categorization);
      childCategorization.setName("Updated Example Child Categorization");
      childCategorization = repository.categorizationUpdate(authToken,
          childCategorization, categorizationType);
      // //////////////////////////////
      // Observe various properties of a categorization. Note that the
      // properties are not being assigned to local variables in
      // the interest of brevity...
      // //////////////////////////////
      Categorization categorizationRead = repository.categorizationRead(
          authToken, childCategorization.getID());
      // Get Categorization parent id
      //categorizationRead.getParentID();
      // Get Categorization active status
      categorizationRead.getActiveStatus();
      // Get Categorization ID
      categorizationRead.getID();
      // Get Categorization name
      categorizationRead.getName();
      // Get Categorization recursive name
      categorizationRead.getRecursiveName();
      // Get Categorization Categorization Type ID
      categorizationRead.getTypeID();
      // //////////////////////////////
      // Retrieve the full tree of categorizations for a Categorization Type.
      // This means that the Categorization entity returned has children
      // which contain their children (if any), and so on.
      // //////////////////////////////
      // Get active Categorizations full tree
      boolean active = true;
      boolean fullTree = true;
      Categorization[] categorizationArray = repository.categorizationReadByType(
          authToken, categorizationType, active, fullTree);
      // Get children categorizations for categorization
      Categorization[] childCategorizations =
 repository.categorizationChildRead(authToken,
          categorizationType, categorization, active);
      // //////////////////////////////
      // Deactivate a Categorization
      // //////////////////////////////
      categorization = repository.categorizationDeactivate(authToken,
          categorization, categorizationType);
      // pActive is set to "true" so that the method returns
      // only active categorizations
      Categorization[] activeCategorizations = repository
          .categorizationChildRead(authToken, categorizationType,
              categorization, true);
      // Get inactive child Categorizations
      Categorization[] inactiveCategorizations =
 repository.categorizationChildRead(authToken,
          categorizationType, categorization, false);
      // /////////////////////////////
      // Reactivate Categorizations
      // /////////////////////////////
      for(int i=0; i<inactiveCategorizations.length; i++){
        categorization = repository.categorizationReactivate(authToken,
            inactiveCategorizations[i], categorizationType);
      }
      // //////////////////////////////
      // Delete a Categorization Type
      // //////////////////////////////
      repository.categorizationTypeDelete(authToken, categorizationType);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

回避するメソッド

次に示すメソッドは、Oracle Enterprise Repository内部でのみ使用します。これらのメソッドの誤った使用によって、カテゴリ分けタイプの機能が損われることがあります(回復できないダメージが起こることはありません)。これらのメソッドで提供される機能は、Oracle Enterprise RepositoryのCategorizationTypeメソッドに組み込まれています。

  • getActiveStatus() int - CategorizationType

  • getCategorizations() Categorizations[] - CategorizationType

  • GetEntityType() String - CategorizationType

  • getKey() String - CategorizationType

  • getTypeDesc() TypeDesc - CategorizationType

  • hashCode() int - CategorizationType

  • isCustom() boolean - CategorizationType

  • isFlat() boolean - CategorizationType

  • isSystemOnly() boolean - CategorizationType

  • setActiveStatus(int activeStatus) void - CategorizationType

  • setAssetAssignable(boolean assetAssignable) void - CategorizationType

  • setCategorizations(Categorizations[] categorizations) void - CategorizationType

  • setCustom(boolean custom) void - CategorizationType

  • setEntityType(String entityType) void - CategorizationType

  • setFlat(boolean flat) void - CategorizationType

  • setID(long ID) void - CategorizationType

  • setKey(String key) void - CategorizationType

  • setSystemOnly(boolean systemOnly) void - CategorizationType

4.4.5.2.3 ユースケース: カテゴリ分けの操作

説明

次のコード・サンプルに、カテゴリ分けの作成、更新、表示、非アクティブ化/再アクティブ化を示します。前述のように、カテゴリ分けはカテゴリ分けタイプの下位にあります。すなわち、カテゴリ分けはカテゴリ分けタイプに属しています。

サンプル・コード

例4-30 ユースケース: カテゴリ分けの操作

package com.flashline.sample.categorizationtypesandapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Categorization;
import com.flashline.registry.openapi.entity.CategorizationType;
import com.flashline.registry.openapi.query.CategorizationTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CategorizationExamples {
  public static void main(String pArgs[]) throws ServiceException,
 RemoteException,
      OpenAPIException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create a Categorization Type
      // //////////////////////////////
      CategorizationType categorizationType = repository
          .categorizationTypeCreate(authToken, "exampleType", "Example Type",
              "Example Types", false, true);
      // //////////////////////////////
      // Find and update a categorization type
      // //////////////////////////////
      CategorizationTypeCriteria categorizationTypeCriteria = new
 CategorizationTypeCriteria();
      boolean projectAssign = true;
      categorizationTypeCriteria.setProjectAssignCriteria(projectAssign + "");
      CategorizationType[] categorizationTypes = repository
          .categorizationTypeQuery(authToken, categorizationTypeCriteria);
      // Set plural display name
      categorizationType.setDisplayPlural("Updated Example Types");
      // Set singular display name
      categorizationType.setDisplaySingular("Updated Example Type");
      // Set Categorization Type name
      categorizationType.setName("updatedExampleType");
      // Set Categorization Type exclusive assign
      categorizationType.setExclusiveAssign(true);
      // Set Categorization Type project Assignable
      categorizationType.setProjectAssignable(false);
      // Update Categorization Type
      categorizationType = repository.categorizationTypeUpdate(
          authToken, categorizationType);
      // Read a Categorization Type
      CategorizationType categorizationTypeRead = repository
          .categorizationTypeRead(authToken, categorizationType.getID());
      // //////////////////////////////
      // Create a Categorization within a Categorization Type
      // //////////////////////////////
      Categorization categorization = repository.categorizationCreate(
          authToken, "Example Categorization", categorizationType);
      // //////////////////////////////
      // Create a Categorization within a Categorization (a.k.a. a
      // sub-categorization or child categorization)
      //
      // method validates that:
      //   - no child categorization with the same name exists within the
      //     parent categorization.
      //   - the categorization type is valid
      //   - the parent categorization is valid.
      // //////////////////////////////
      Categorization childCategorization = repository
          .categorizationChildCreate(authToken, "Example Child Categorization",
              categorizationType, categorization);
      childCategorization.setName("Updated Example Child Categorization");
      childCategorization = repository.categorizationUpdate(authToken,
          childCategorization, categorizationType);
      // //////////////////////////////
      // Observe various properties of a categorization. Note that the
      // properties are not being assigned to local variables in
      // the interest of brevity...
      // //////////////////////////////
      Categorization categorizationRead = repository.categorizationRead(
          authToken, childCategorization.getID());
      // Get Categorization parent id
      //categorizationRead.getParentID();
      // Get Categorization active status
      categorizationRead.getActiveStatus();
      // Get Categorization ID
      categorizationRead.getID();
      // Get Categorization name
      categorizationRead.getName();
      // Get Categorization recursive name
      categorizationRead.getRecursiveName();
      // Get Categorization Categorization Type ID
      categorizationRead.getTypeID();
      // //////////////////////////////
      // Retrieve the full tree of categorizations for a Categorization Type.
      // This means that the Categorization entity returned has children
      // which contain their children (if any), and so on.
      // //////////////////////////////
      // Get active Categorizations full tree
      boolean active = true;
      boolean fullTree = true;
      Categorization[] categorizationArray = repository.categorizationReadByType(
          authToken, categorizationType, active, fullTree);
      // Get children categorizations for categorization
      Categorization[] childCategorizations =
 repository.categorizationChildRead(authToken,
          categorizationType, categorization, active);
      // //////////////////////////////
      // Deactivate a Categorization
      // //////////////////////////////
      categorization = repository.categorizationDeactivate(authToken,
          categorization, categorizationType);
      // pActive is set to "true" so that the method returns
      // only active categorizations
      Categorization[] activeCategorizations = repository
          .categorizationChildRead(authToken, categorizationType,
              categorization, true);
      // Get inactive child Categorizations
      Categorization[] inactiveCategorizations =
 repository.categorizationChildRead(authToken,
          categorizationType, categorization, false);
      // /////////////////////////////
      // Reactivate Categorizations
      // /////////////////////////////
      for(int i=0; i<inactiveCategorizations.length; i++){
        categorization = repository.categorizationReactivate(authToken,
            inactiveCategorizations[i], categorizationType);
      }
      // //////////////////////////////
      // Delete a Categorization Type
      // //////////////////////////////
      repository.categorizationTypeDelete(authToken, categorizationType);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

回避するメソッド:

次に示すメソッドはOracle Enterprise Repository内部専用なので、使用しないでください。これらのメソッドを誤って使用すると、カテゴリ分けが正しく機能しないことがあります。これらのメソッドで提供される機能は、Oracle Enterprise RepositoryのCategorizationメソッドに組み込まれています。

  • getDescription() String - Categorization

  • GetEntityType() String - Categorization

  • getKey() String - Categorization

  • getLevel() long - Categorization

  • getType() CategorizationType - Categorization

  • getTypeDesc() TypeDesc - Categorization

  • hashCode() int - Categorization

  • set_super(Categorization _super) void - Categorization

  • setActiveStatus(int activeStatus) void - Categorization

  • setDeleted(boolean deleted) void - Categorization

  • setDescription(String description) void - Categorization

  • setEntityType(String entityType) void - Categorization

  • setID(long ID) void - Categorization

  • setKey(String key) void - Categorization

  • setRecursiveName(String recursiveName) void - Categorization

  • setType(CategorizationType type) void - Categorization

  • setTypeID(long ID) void - Categorization

4.4.6 CMFエントリ・タイプAPI

この項では、CMFエントリ・タイプAPIのユースケースについて説明します。また、Oracle Enterprise Repositoryへの新しいCMFエントリ・タイプの追加、およびアセットへの既存のCMFエントリ・タイプの割当てを行う方法について解説します。

4.4.6.1 概要

CMFエントリ・タイプは、アセットにアタッチできるメタデータを記述します。CMFエントリ・タイプは、IDと単一の名前の文字列で識別されます。

検証: CMFエントリ・タイプを保存する場合、Oracle Enterprise Repositoryは、現在、次の内容を検証します。

  • CMFエントリ・タイプ名の長さが範囲内であること

  • CMFエントリ・タイプ名が一意であること

  • CMFエントリ・タイプの更新時に、CMFエントリ・タイプIDが存在していること

関連するサブシステム

アセットの観点からでは、CMFエントリはアセットにリンクしています。CMFエントリ・タイプでは、これらのエントリのパラメータを定義します。

追加で必要なインポート

import com.flashline.registry.openapi.entity.MetadataEntryTypeSummary;
import com.flashline.registry.openapi.query.MetadataEntryTypeCriteria;

4.4.6.2 ユースケース: CMFエントリ・タイプの操作

この項では、CMFエントリ・タイプAPIを使用するユースケースについて説明します。

説明

  • 新しいCMFエントリ・タイプをOracle Enterprise Repositoryに追加します。

  • 既存のCMFエントリ・タイプをアセットに割り当てます。

サンプル・コード

例4-31 ユースケース: CMFエントリ・タイプの操作

package com.flashline.sample.metadataentrytypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.MetadataEntryTypeSummary;
import com.flashline.registry.openapi.query.MetadataEntryTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class MetadataEntryTypes {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      // -----------------------------------------
      // Create a new CMF Entry Type
      String newMetadataEntryTypeName = "Sample MetadataEntryType";
      MetadataEntryTypeSummary newMetadataEntryType =
 repository.metadataEntryTypeCreate(authToken, newMetadataEntryTypeName);
      System.out.println("The new MetadataEntryType id =\"" +
 newMetadataEntryType.getID() + "\"");
      // -----------------------------------------
      // Find a CMF Entry Type
      MetadataEntryTypeCriteria criteria = new MetadataEntryTypeCriteria();
      criteria.setNameCriteria("Sample");
      MetadataEntryTypeSummary[] metadataEntryTypes =
 repository.metadataEntryTypeQuery(authToken, criteria);
      long myMetadataEntryTypeID = metadataEntryTypes[0].getID();
      // -----------------------------------------
      // Read a CMF Entry Type
      MetadataEntryTypeSummary readMetadataEntryType =
 repository.metadataEntryTypeRead(authToken, myMetadataEntryTypeID);
      System.out.println("The MetadataEntryType name =\"" +
 readMetadataEntryType.getName() + "\"");
      // -----------------------------------------
      // Delete a CMF Entry Type
      repository.metadataEntryTypeDelete(authToken, myMetadataEntryTypeID);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.7 カスタム・アクセス設定API

この項では、カスタム・アクセス設定APIのユースケースについて説明します。また、カスタム・アクセス設定タイプ・リストの取得、およびOracle Enterprise Repository内にある特定のタイプのデフォルトのカスタム・アクセス設定リストの取得を行う方法について解説します。

4.4.7.1 概要

カスタム・アクセス設定サブシステムは、Oracle Enterprise Repositoryのカスタム・アクセス設定(CAS)を取得する、Webサービス・ベースのメカニズムを提供するために使用します。例4-32に、カスタム・アクセス設定のサンプル・コードを示します。

例4-32 カスタム・アクセス設定のサンプル・コード

カスタム・アクセス設定を行うオープンAPIメソッドの作業コードです。

package com.flashline.sample.customaccesssettingsapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CustomAccesssettings {
  public static void main(String pArgs[]) throws java.rmi.RemoteException,
      OpenAPIException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      // ////////////////////////////////////////////////////////////
      // Retrieve a List of Custom Access Setting Types
      // ////////////////////////////////////////////////////////////
      String[] lRoleContextTypes = null;
      lRoleContextTypes = repository
          .customAccessSettingTypesGet(authToken);
      // ////////////////////////////////////////////////////////////
      // Get Custom Access Setting Names
      // ////////////////////////////////////////////////////////////
      String[] lCustomAccessSettingNames = null;
      lCustomAccessSettingNames = repository
          .customAccessSettingNamesGet(authToken, "asset");
      // ////////////////////////////////////////////////////////////
      // Retrieve an array of Custom Access Setting Names of type "asset".
      // ////////////////////////////////////////////////////////////
      String[] rCustomAccessSettingNames = null;
      rCustomAccessSettingNames = repository
          .customAccessSettingDefaultNamesGet(authToken, "asset");
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.7.2 ユースケース: カスタム・アクセス設定タイプ・リストの取得

説明

このメソッドは、Oracle Enterprise Repositoryで使用可能なカスタム・アクセス設定タイプ・リストを取得するために使用します。

サンプル・コード

1. String[] lCustomAccessSettingNames = null;
2. lCustomAccessSettingNames = mFlashlineRegistry.customAccessSettingNamesGet
    (mAuthToken, "asset");

注釈

行2: タイプ"asset"のカスタム・アクセス設定名の配列を取得します。

4.4.7.3 デフォルトのカスタム・アクセス設定名の取得

説明

このメソッドは、特定のタイプのデフォルトのカスタム・アクセス設定リストを取得するために使用します。ファイルのデフォルトのカスタム・アクセス設定がすべての新しいファイルに適用されるように、アセットのデフォルトのカスタム・アクセス設定がすべての新しいアセットに適用されます。

サンプル・コード

1. String[] lCustomAccessSettingNames = null;
2. lCustomAccessSettingNames = mFlashlineRegistry.customAccessSettingDefault
     NamesGet(mAuthToken, "asset");

注釈

行2: タイプ"asset"のデフォルトのカスタム・アクセス設定名の配列を取得します。

4.4.8 部門API

この項では、部門APIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryの部門の作成、更新、問合せおよび削除を行う方法について解説します。

4.4.8.1 概要

部門の作成、読込み、問合せおよび変更を行うことができます。これらの操作は、次のとおりです。部門の作成後は削除できないことに注意してください。部門の2つの属性(名前と説明)のみがユーザーに有効です。

追加で必要なインポート

import com.flashline.registry.openapi.entity.Department;

4.4.8.2 ユースケース: 部門の操作

説明

次のサンプル・コードは、Oracle Enterprise Repositoryの部門の操作が含まれる典型的なタスクを示します。これには、作成、更新、問合せおよび削除が含まれます。

サンプル・コード

例4-33 ユースケース: 部門の操作

package com.flashline.sample.departmentapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Department;
import com.flashline.registry.openapi.query.DepartmentCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Departments {
  public static void main(String pArgs[]) throws java.rmi.RemoteException,
      OpenAPIException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // //////////////////////////////
      // Create a new department
      // Each Department requires a unique name. Descriptions are optional.
      // //////////////////////////////
      Department dept = repository.departmentCreate(authToken,
          "My Dept "+Calendar.getInstance().getTimeInMillis(), "A New
 Department");
      // //////////////////////////////
      // Read a department
      // To read a Department you must have the Department name.
      // //////////////////////////////
      Department dept2 = repository.departmentRead(authToken,
          "ADepartment");
      // //////////////////////////////
      // Query for a department
      //
      // To query for a Department you must fill out a
      // DepartmentCriteria object with an array of SearchTerms. A SearchTerm
      // is a key/value pair. Currently the only valid key is "name".
      //
      // A query for name is a match if the value for the name term
      // occurs anywhere in the name of the department. For example,
      // a search for fred matches fred, alfred, and fredrick.
      // //////////////////////////////
      DepartmentCriteria criteria = new DepartmentCriteria();
      criteria.setNameCriteria("DepartmentName");
      Department[] depts = repository.departmentQuery(authToken,
          criteria);
      // //////////////////////////////
      // Update a department
      //
      // To update a Department you need only to modify a Department
      // reference and call departmentUpdate...
      // //////////////////////////////
      String lOldName = dept.getName();
      String lNewName = "New " + dept.getName();
      Department dept3 = repository.departmentRead(authToken, lOldName);
      dept3.setName(lNewName);
      repository.departmentUpdate(authToken, dept3);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.9 抽出API

この項では、抽出APIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいて、アセットの抽出、抽出の読込み、抽出の更新を行う方法について解説します。

4.4.9.1 概要

「使用-ダウンロード」(抽出)プロセスの一部として、ユーザーは選択したアセットを特定のプロジェクトに関連付けるように要求されます。これらの使用状況のインスタンスは、調査(使用状況の更新に含まれます)とともに、Oracle Enterprise Repository内のメトリックの主要なドライバです。


注意:

以前の製品リリースでは、抽出という用語は、アセットのペイロードのダウンロードやアクセスなどの行為を説明するために使用されていました。その後、抽出という用語は使用 - ダウンロードという語句に置き換わりました。ただし、抽出APIのドキュメントのコンテキスト内で、抽出という用語の使用例(特にコード例)の多くは、REX APIの使用を単純化するためにそのままになっていることに注意してください。

定義

  • 状態

    状態は、使用またはダウンロードするために選択したアセットの使用状況のステータスのことです。次の4つの状態があります。

    • IN PROCESS

    • ACCEPTED

    • REJECTED

    • DEPLOYED (DEPLOYEDはプロジェクトで対応されています)。

  • 抽出ダウンロード

    抽出したアセットに関連付けられた情報が含まれています。抽出ダウンロードの値は、0または1です。

  • ファイル情報

    アセットに関連付けられた実際のファイルへのURLリンクと情報は、抽出ダウンロードに含まれているものとして、ファイル情報を作成します。抽出ダウンロードのファイル情報の値は、0から1です。

  • 関連するアセット

    Oracle Enterprise Repositoryでは、事前定義済の番号またはカスタム構成済のリレーションシップ(あるいはその両方)で、アセットを他のアセットと関連付けることができます。アセットは、0からn個の関連アセットを含むことができます。

関連するサブシステム

  • アセット・サブシステム

  • プロジェクト・サブシステム

  • カテゴリ分けタイプ・サブシステム

  • 調査サブシステム

4.4.9.2 ユースケース

この項では、抽出APIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.9.2.1 ユースケース: アセットの抽出

説明

抽出は、ユーザーがアセットをプロジェクトで使用するために関連付けると作成されます。このプロセス中に、関連しているアセットのリストも抽出用に使用可能になります。この場合、ユーザーは、プライマリ・アセットと関連アセットの両方を同時に抽出できます。各アセットに一意の抽出が記録されます。抽出を作成すると、0からn個の抽出ダウンロードを含む配列が作成されます。各ダウンロードのファイル情報の値は、0から1です。ファイル情報にはファイルに関する基本情報が含まれます。この情報は、ファイルへのリンクを作成するために使用します。

アセットを抽出するには、次の条件を満たす必要があります。

  • ユーザーは、アセットが抽出されるプロジェクトのメンバーである必要があります。

  • ユーザーは、適切なロール・タイプに割り当てられている必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 「カスタム・アクセス設定」が有効になっている場合、抽出を実行するユーザーは、指定したアセットに対して適切なアクセス権を持っている必要があります。

  • 「カスタム・アクセス設定」が有効になっている場合、抽出を実行するユーザーは、適切な権限を持っているファイルに対してのみファイル情報を受け取ります。

  • これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例4-34 ユースケース: アセットの抽出

package com.flashline.sample.extractionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.FileInfo;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ExtractAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1], pArgs[2]);
      long ASSET_ID_1 = 589;     // must be a valid asset id in OER
      long ASSET_ID_2 = 569;     // must be a valid asset id in OER
      long PROJECT_ID = 50000;   // must be a valid project id in OER
      long EXTRACTION_ID = 0;
      // ----------------------------------------
      // Create a new extraction
      long[] lAssetIDs = { ASSET_ID_1, ASSET_ID_2 };
      ExtractionDownload[] extractionDownloads =
 repository.extractionCreate(authToken, PROJECT_ID, lAssetIDs);
      System.out.println("Number of new extraction downloads created: " +
 extractionDownloads.length);
      // ----------------------------------------
      // Read an extraction by project and asset
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, PROJECT_ID, ASSET_ID_1);
      EXTRACTION_ID = extraction.getID();
      // ----------------------------------------
      // Read an extraction by ID
      Extraction extractionByID = repository.extractionRead(authToken, EXTRACTION
_ID);
      System.out.println("The extraction '"+extractionByID.getDisplayName()+"' was
 read by id ("+EXTRACTION_ID+")");
      // ----------------------------------------
      // Read asset extractions
      Extraction[] assetExtractions =
 repository.extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID_1,
 true);
      System.out.println("The number of extractions for this asset is:
 "+(assetExtractions==null ? 0 : assetExtractions.length));
      // ----------------------------------------
      // Read project extractions
      Extraction[] projectExtractions =
 repository.extractionReadProjectExtractions(authToken, PROJECT_ID, true);
      System.out.println("The number of extractions for this project is:
 "+(projectExtractions==null ? 0 : projectExtractions.length));
      // ----------------------------------------
      // Read related assets
      Asset[] relatedAssets = repository.extractionReadRelatedAssets(authToken,
 ASSET_ID_2);
      System.out.println("The number of related assets is: "+relatedAssets==null ?
 0 : relatedAssets.length);
      // ----------------------------------------
      // Read File-Info for an extraction
      List fileInfosList = new ArrayList();
      if (projectExtractions != null) {
        for (int i = 0; i < projectExtractions.length; i++) {
          extraction = repository.extractionRead(authToken,
 projectExtractions[i].getID());
          fileInfosList.add(repository.extractionReadFileInfos(authToken,
 extraction));
        }
      }
      // ----------------------------------------
      // Get File
      List fileInfoList = new ArrayList();
      Iterator fileInfosListIter = fileInfosList.iterator();
      while (fileInfosListIter.hasNext()) {
        FileInfo[] fileInfos = (FileInfo[]) fileInfosListIter.next();
        for (int i = 0; i < fileInfos.length; i++) {
          fileInfoList.add(fileInfos[i]);
        }
      }
      String[] fileLinks = new String[fileInfoList.size()];
      for (int i = 0; i < fileInfoList.size(); i++) {
        FileInfo fileInfo = (FileInfo) fileInfoList.get(i);
        fileLinks[i] = repository.repositoryFileTranslator(authToken, fileInfo);
        System.out.println("Project extraction file-info link: "+fileLinks[i]);
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

FileInfoオブジェクトについての注意

FileInfoオブジェクトは、抽出したアセットに関連付けられた個々のファイルを示します。ファイルの物理的な場所は、次の2つのメソッドで取得できます。

  1. FileInfoオブジェクトのdownloadURIプロパティ(fileInfo.getDownloadURI()など)を使用します。

  2. FileInfoオブジェクトを渡す、OpenAPIメソッドのrepositoryFileTranslator(flashlineRegistry.repositoryFileTranslator(authToken, fileInfo)など)を使用します。


    注意:

    Oracle Enterprise Repository固有のパスを示す、FileInfoオブジェクトのURIプロパティを使用しないでください。

4.4.9.2.2 ユースケース: 抽出の読込み

説明

アセットの抽出のユースケースで説明されたメソッド以外のメソッドを使用して、抽出を読み込みます。抽出は、アセット、プロジェクトまたはユーザーでグループ化できます。抽出のグループ化によって使用するメソッドが決定されます。

抽出を読み込むには、次の条件を満たす必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 抽出は、アクティブである必要があります。

これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例4-35 ユースケース: 抽出の読込み

package com.flashline.sample.extractionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ExtractRead {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      long PROJECT_ID = 50000; // must be a valid project id in the OER
      long ASSET_ID = 569;    // must be a valid asset id in the OER
      // ----------------------------------------
      // Read project extractions
      Extraction[] projectExtractions = repository
          .extractionReadProjectExtractions(authToken, PROJECT_ID, true);
      // ----------------------------------------
      // Read asset extractions
      Extraction[] assetExtractions = repository
          .extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID, true);
      // ----------------------------------------
      // Read user extractions
      Extraction[] userExtractions = repository
          .extractionReadUserExtractions(authToken, true);
      // ----------------------------------------
      // Read related assets
      Asset[] assets = repository.extractionReadRelatedAssets(authToken,
          ASSET_ID);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.9.2.3 ユースケース: 抽出の更新

説明

抽出レコードは、アセットの状態が変更されたか、アセットの使用者がアセットの調査を終了したときに更新されます。状態の変更と調査の完了は別のトランザクションにできます。また、一緒に行うこともできます。

抽出を更新するには、次の条件を満たす必要があります。

  • プロジェクトは、オープンである必要があります。

  • アセットは、登録済でアクティブである必要があります。

  • 抽出は、アクティブである必要があります。

  • 実行した調査は、アクティブである必要があります。

これらの条件は、使用される適切なメソッドでチェックされます。条件を満たさない場合、例外がスローされます。

サンプル・コード

例4-36 ユースケース: 抽出の更新

package com.flashline.sample.extractionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Categorization;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.IExtraction;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ExtractUpdate {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      long PROJECT_ID = 50000; // must be a valid project id in the OER
      long ASSET_ID = 569; // must be a valid asset id in the OER
      // ----------------------------------------
      // Create a new extraction
      long[] lAssetIDs = { ASSET_ID };
      ExtractionDownload[] extractionDownloads =
 repository.extractionCreate(authToken, PROJECT_ID, lAssetIDs);
      Extraction[] assetExtractions = repository
          .extractionReadAssetExtractions(authToken, PROJECT_ID, ASSET_ID, true);
      ///////////////////////////////////////////////////////////////////////////
      // this assumes that there is at least 1 extraction and the first one is
      // used
      ///////////////////////////////////////////////////////////////////////////
      IExtraction iExtraction = repository
          .extractionReadExtractionStates(authToken);
      Extraction extraction = repository.extractionRead(authToken,
          assetExtractions[0].getID());
      ///////////////////////////////////////////////////////////////////////////
      // can set the status of the extraction to 'Deployed', 'Rejected', or 'In
      // Process'.
      ///////////////////////////////////////////////////////////////////////////
      assetExtractions[0].setStatus("In Process");
      extraction = repository.extractionTentativelyAccept(authToken,
          extraction);
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken,
          extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, surveyTaken);
      extraction.setStatus(iExtraction.getInProcess());
      surveyTaken = repository.surveyTakenRead(authToken, extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, surveyTaken);
      Categorization[] rejectionReasons = repository
          .extractionReadRejectionReasons(authToken);
      surveyTaken = repository.surveyTakenRead(authToken, extraction);
      extraction = repository.extractionUpdateSurvey(authToken,
          extraction, surveyTaken);
      surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for (int i = 0; i < answers.length; i++) {
        answers[i] = new Answer();
      }
      answers[0].setQuestionId(questions[0].getId());
      choiceList = questions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(questions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(questions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(questions[3].getId());
      choiceList = questions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

短所

状態の変更または調査の実行は2つの手順のプロセスであることに注意してください。最初の手順は、状態の変更または調査の実行です。2番目の手順は、extractionUpdateStatusメソッドを使用して抽出のステータスを更新することです。状態の変更と調査の実行は別のトランザクションにできます。また、一緒に行うこともできます。一緒に行う場合、extractionUpdateStatusメソッドを一度だけ呼び出す必要があります。

extractionUpdateStatusメソッドはSurveyTakenが必要です。extractionUpdateStatusメソッドが呼び出されたときに調査が実行されたかどうかに関係なく、これは必要です(状態の変更など)。surveyTakenReadメソッドを使用して、この調査を取得します。この抽出の調査が行われていない場合、surveyTakenReadメソッドによって作成されます。

Oracle Enterprise Repositoryで、現在の調査は4つの質問から構成されます。調査が実行されると、4つの質問に対する回答を格納する配列が作成されます。それぞれの調査には有効な3つの情報が含まれている必要があります。

  • 値(質問に対するユーザーの回答)

  • 質問ID

  • 選択ID

質問2と3は回答が1つの質問なので、常に選択IDは0に設定されています。質問1と4は複数の回答があります。複数の回答はsurveyReadChoiceListメソッドを使用して取得されます。

回避するメソッド:

次のオブジェクトは、抽出サブシステムおよび調査サブシステムで使用します。

  • 抽出

  • ExtractionDownload

  • FileInfo

  • SurveyTaken

  • Question

  • ChoiceList

  • Choice

  • Answer

これらのオブジェクト内でgetメソッドのいずれかを使用することが可能です。残りのすべてのメソッド(特にsetメソッド)の使用は避ける必要があります。残りのメソッドで発生したイベントは、抽出および調査サブシステムのメソッドで対応されています。

4.4.10 REXクライアントのローカライズ

この項では、REXクライアントのローカライズのユースケースについて説明します。このユースケースで、Oracle Enterprise RepositoryのREX例外およびREX監査メッセージのローカライズ済のメッセージを作成する方法について解説します。

4.4.10.1 概要

ステータスは、OpenAPIExceptionまたはAuditMsgオブジェクトのいずれかとして、REXクライアントに渡されます。OpenAPIExceptionオブジェクトは例外用に使用されますが、AuditMsgオブジェクトは非同期的に実行されるプロセス用に使用されます。これらのオブジェクトの両方がREXクライアントにテキストのエラー・メッセージを返します。

両方のオブジェクトのインタフェースがエラー・コードおよびメッセージの引数のリストを含めるために拡張されたため、REXクライアントは別の言語でエラー・メッセージやステータス・メッセージを表示できます。クライアントは標準のエラー・メッセージを使用し続けるか、またはメッセージを無視し、エラー・コードとメッセージ引数を使用して専用のエラー・メッセージを作成できます。

たとえば、REXを使用するアプリケーションをローカライズする場合、最初に、想定されるすべてのエラー・メッセージを表示するプロパティ・ファイルを取得します。メッセージは次のようになります。

ERR_9008 = Error updating project with ID = [{0}].

次に、必要に応じて、すべてのメッセージを次のように翻訳する必要があります。

ERR_9008 = Errorway updatingay ojectpray ithway IDway = [{0}].

クライアント・コードはプロジェクトをID=123で変更しようとして、その変更が失敗した場合、エンドユーザーに例外が発生し、次のエラー・メッセージが表示されます。

Error updating project with ID = [123].

このエラーをローカルの言語(ピッグ・ラテン語など)で表示する場合、エラー・コード9008を選択し、これを翻訳済ファイルで検索して文字列"Errorway updatingay ojectpray ithway IDway = [{0}]."を取得します。次に、メッセージ引数を使用して、トークンを置き換えます。この場合、123という文字列が1つのみ検索されるので、メッセージ引数を1つ見つけることができます。

次のように、エンドユーザー用にカスタムのエラー・メッセージを作成できます。

Errorway updatingay ojectpray ithway IDway = [123].

4.4.10.2 ユースケース: REX例外からのローカライズ済のメッセージの作成

説明

  • OpenAPIExceptionから、サーバー・エラー・コードとメッセージ引数を取得します。

  • クライアント・ロケールに適切なOpenAPIExceptionsのリソース・バンドルを取得します。

  • エラー・コードに関連付けられた文字列を取得し、トークンをメッセージ引数で置き換えます。

サンプル・コード

例4-37 ユースケース: REX例外からのローカライズ済のメッセージの作成

package com.flashline.sample.localization;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class SyncTest {
    private static final int INVALID_PROJECT_ID = 8672609;
    public static void main(String[] args) throws Exception {
      URL lURL = new
 URL("http://localhost:9080/registry/services/FlashlineRegistry");
      FlashlineRegistry reg = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      AuthToken token = reg.authTokenCreate("admin", "n0pa55w0rd");
      try {
        Project project = reg.projectRead(token,INVALID_PROJECT_ID);
      } catch (OpenAPIException ex) {
        String msg =
 createMessage(ex.getServerErrorCode(),ex.getMessageArguments());
        System.out.println(msg);
      }
    }
    private static String createMessage(int pServerErrorCode, Object[] pArgs) {
      ResourceBundle mResourceBundle =
 ResourceBundle.getBundle("com.flashline.sample.localization.sync_error
_messages");
      return MessageFormat.format(mResourceBundle.getString("ERR
_"+pServerErrorCode), pArgs);
    }
}

4.4.10.3 REX監査メッセージからのローカライズ済のメッセージの作成

説明

  • AuditMsgとImpExpJobから、サーバー・エラー・コードとメッセージ引数を取得し、AuditMsgからメッセージ引数を取得します。

  • クライアント・ロケールに適切な監査メッセージのリソース・バンドルを取得します。

  • エラー・コードに関連付けられた文字列を取得し、トークンをメッセージ引数で置き換えます。

サンプル・コード

例4-38 REX監査メッセージからのローカライズ済のメッセージの作成

package com.flashline.sample.localization;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import javax.activation.DataHandler;
import javax.xml.rpc.ServiceException;
import org.apache.axis.client.Stub;
import org.apache.soap.util.mime.ByteArrayDataSource;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.ImpExpJob;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AsyncTest {
  public void run() throws MalformedURLException, ServiceException,
 OpenAPIException, RemoteException{
    URL lURL = new
 URL("http://localhost:9080/registry/services/FlashlineRegistry");
    FlashlineRegistry reg = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
    AuthToken token = reg.authTokenCreate("admin", "n0pa55w0rd");
    try {
      File lFile = new
 File("samples/com/flashline/sample/localization/asynctest.zip");
      //Import the file and save to db
      InputStream lIS = new FileInputStream(lFile);
      ByteArrayDataSource lDataSource = new ByteArrayDataSource(lIS,
 "application/x-zip-compressed");
      DataHandler lDH = new DataHandler(lDataSource);
      // add the attachment
      ((Stub)reg).addAttachment(lDH);
      ImpExpJob lJob = reg.importExecute(token, "flashline", null, "Import Assets
 Test", null);
      boolean lPassed = false;
      for(int i=0; i<1000; i++){
        lJob = reg.importStatus(token, lJob);
        System.out.println("Import Job ["+lJob.getID()+"] - State:
 "+lJob.getState());
        String msg =
createMessage(lJob.getAuditMsg().getSummaryID(),lJob.getAuditMsg().getSummaryArgs
());
        System.out.println(msg);
        if( lJob.getState().equals("completed")){
          lPassed = true;
          break;
        }
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
      if (lPassed){
         System.out.println("Import Completed");
      }
    } catch (OpenAPIException ex) {
      String msg =
 createMessage(ex.getServerErrorCode(),ex.getMessageArguments());
      System.out.println(msg);
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /**
   * @param args
   * @throws ServiceException
   * @throws RemoteException
   * @throws MalformedURLException
   * @throws OpenAPIException
   */
  public static void main(String[] args) throws OpenAPIException,
 MalformedURLException, RemoteException, ServiceException {
    AsyncTest test = new AsyncTest();
    test.run();
  }
  private static String createMessage(int pServerErrorCode, Object[] pArgs) {
    ResourceBundle mResourceBundle =
 ResourceBundle.getBundle("com.flashline.sample.localization.async_error
_messages");
    return MessageFormat.format(mResourceBundle.getString("ERR
_"+pServerErrorCode), pArgs);
  }
  private String readZip(String pFileName) throws IOException {
    int    lNumRead = 0;
    char[] lBuf = new char[2048];
    StringBuffer lQuery = new StringBuffer();
    InputStreamReader lReader = new
 InputStreamReader(getClass().getResourceAsStream(pFileName));
    while( (lNumRead=lReader.read(lBuf)) != -1){
      lQuery.append(lBuf, 0, lNumRead);
    }
    return lQuery.toString();
  }
}

4.4.11 通知API

この項では、通知APIのユースケースについて説明します。このユースケースで、新しい読込み通知置換リストを作成する方法およびOracle Enterprise Repositoryの通知を作成する方法について解説します。

4.4.11.1 概要

通知サブシステムは、Oracle Enterprise Repositoryの通知を作成する場合に使用する、Webサービス・ベースのメカニズムを提供します。

4.4.11.2 ユースケース: 読込み通知置換リストの作成と通知の作成

説明

読込み通知置換リストを作成し、Oracle Enterprise Repositoryの通知を作成します。

サンプル・コード

例4-39 ユースケース: 読込み通知置換リストの作成と通知の作成

    String[] lSubstitutions = null;
    String[] lRecipients = null;
    String lTemplateType = "asset_registered";
    NameValue[] lNameValues = null;
 
    
    lRecipients = new String[] {"recipient@xyz.com"};
            
    try {
      //////////////////////////
      // read the existing substitutions based on the given template
      lSubstitutions = mFlashlineRegistry.notificationSubstitutionsRead(mAuthToken, lTemplateType);               
      
      //////////////////////////
      // create an array of namevalue pairs; a namevalue pair for each required substitution
      lNameValues = new NameValue[lSubstitutions.length];
            
      // populate the namevalues
      for(int i=0; i<lSubstitutions.length; i++) {
        lNameValues[i] = new NameValue();
        lNameValues[i].setName(lSubstitutions[i]);
        lNameValues[i].setValue("valueof-"+lSubstitutions[i]);
      }
 
      ////////////////////////////////////////////
      // create the notification
      mFlashlineRegistry.notificationCreate(mAuthToken, lTemplateType, lRecipients, lNameValues);
           
    } catch(Exception e) {
      fail(e.getMessage());
    }

4.4.12 ポリシーAPI

この項では、ポリシーAPIのユースケースについて説明します。このユースケースで、新しいポリシーの作成、すべてのポリシーの取得、ポリシー・アサーションの取得または設定、アセットに適用されたポリシーの取得、および適用されたすべてのポリシーまたは特定のポリシーに対してアセットのコンプライアンスの判定を行う方法について解説します。

4.4.12.1 概要

REXにより、ポリシーに対して次の機能がサポートされるようになりました。

  • ポリシーの問合せ

    • アセットにおけるポリシーのステータス(合格/失敗)

    • アセットにおけるポリシーの収集ステータス

    • ポリシー・アサーションの技術的な説明フィールドからのXMLの取得

    • ポリシーも適用されているアセット

  • ビューア

    • ポリシーでの個々のポリシー・アサーション・リストの保持

    • アセットに対する個々のポリシー・アサーションのステータスの設定

    • ポリシーの適用とアセットからのポリシーの削除

必要な追加のインポート(すべての例で使用できないものもあります。)

import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.PolicyAssertion;
import com.flashline.registry.openapi.entity.PolicyAssertionResult;

注意:

  • Oracle Enterprise Repositoryのポリシーは、ポリシー・タイプに基づいた、特定のタイプのアセットです。ポリシーの作成、変更および削除の詳細は、アセットAPIのユースケースを参照してください。


定義

  • アサーション

    アサーションは、ポリシー・アセットに追加されたポリシー文です。

  • アサーション結果

    ポリシーがアセットに適用された場合、ポリシー内の各アサーションをアセット用に評価できます。アサーション結果は、アセットとアサーションのペアで、合格、失敗または不明のいずれかです。

メソッド

FlashlineRegistryサービスで使用可能な次の4つの新しいメソッドがあります。

  • assetReadAppliedPolicies()

  • assetUpdateAppliedPolicies()

  • assetEvaluateAgainstPolicy()

  • assetEvaluateAgainstAllPolicies()

4.4.12.2 ユースケース

この項では、ポリシーAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.12.2.1 ユースケース: ポリシーの作成

説明

新しいポリシーを作成するには、ポリシー・タイプ(102)に基づいた新しいアセットを作成します。

サンプル・コード

例4-40 ユースケース: ポリシーの作成

package com.flashline.sample.policies;
import java.net.URL;
import java.rmi.RemoteException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.PolicyAssertion;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreatePolicySample {
  private static final String POLICY_TYPE_NAME_PREFIX = "Policies-Test Policy
 Type";
  private static final long ASSET_POLICY_ARCHETYPE = 102;
  private static final String POLICY_NAME_PREFIX = "Policies-Test Policy";
  private static final String POLICY_VERSION = "1.0";
  private static FlashlineRegistry mRepository = null;
  private static AssetType mPolicyAssetType = null;
  private AuthToken mAuthToken = null;
  public CreatePolicySample(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
      mPolicyAssetType = createPolicyAssetType();
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      CreatePolicySample lCreatePolicySample = new CreatePolicySample(pArgs);
      // ---------------------------
      // create a new policy object
      Asset lPolicy = lCreatePolicySample.createPolicy();
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Creates an asset policy with a unique name
   */
  private Asset createPolicy() throws RemoteException {
    String lPolicyName = POLICY_NAME_PREFIX + " " + System.currentTimeMillis();
    // ---------------------------
    // create a policy (an asset whose assettype's archtype is "102" (policy)
    Asset lPolicy = mRepository.assetCreate(mAuthToken, lPolicyName, POLICY
_VERSION, mPolicyAssetType.getID());
    lPolicy.setCustomData("<custom-data></custom-data>");
    // ---------------------------
    // set some polcy assertions
    lPolicy.setPolicyAssertions(generateSampleAssertions());
    return mRepository.assetUpdate(mAuthToken, lPolicy);
  }
  /**
   * Returns several sample policy assertions for use in testing.
   * Located in a function to be shared between test calls.
   *
   * @return Array of policy assertions
   */
  private PolicyAssertion[] generateSampleAssertions() {
    PolicyAssertion[] lPolicyAssertions = new PolicyAssertion[3];
    String[] lPolicyAssertionNames = {"First", "Second", "Third"};
    for (int i=0; i<lPolicyAssertionNames.length; i++) {
      String lPolicyAssertionName = "My " + lPolicyAssertionNames[i] + "
 Assertion";
      lPolicyAssertions[i] = new PolicyAssertion();
      lPolicyAssertions[i].setName(lPolicyAssertionName);
      lPolicyAssertions[i].setDescription(lPolicyAssertionName + " Description");
      lPolicyAssertions[i].setTechnicalDefinition(lPolicyAssertionName + "
 Technical Definition");
    }
    return lPolicyAssertions;
  }
  /**
   * Creates an asset policy asset type with a unique name
   */
  private AssetType createPolicyAssetType() throws RemoteException {
    String lPolicyTypeName = POLICY_TYPE_NAME_PREFIX + " " +
 System.currentTimeMillis();
    // ---------------------------
    // create a new asset type
    AssetType lPolicyType = mRepository.assetTypeCreate(mAuthToken,
 lPolicyTypeName);
    // ---------------------------
    // update the asset type to be a policy asset type by settings the archtype =
 102
    lPolicyType.setArcheTypeIDs(new long[] {ASSET_POLICY_ARCHETYPE});
    return mRepository.assetTypeUpdate(mAuthToken, lPolicyType);
  }
}
4.4.12.2.2 ユースケース: すべてのポリシーの取得

説明

すべてのポリシーを取得するには、アセット・タイプの原型がポリシーの原型(102)であるアセットをすべて見つけます。

サンプル・コード

例4-41 ユースケース: すべてのポリシーの取得

package com.flashline.sample.policies;
import java.net.URL;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindPoliciesSample {
  private static FlashlineRegistry mRepository = null;
  private static AuthToken mAuthToken = null;
  public FindPoliciesSample(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      FindPoliciesSample lFindPoliciesSample = new FindPoliciesSample(pArgs);
      AssetType[] lPolicyAssetTypes = null;
      Asset[] lPolicies = null;
      AssetTypeCriteria lAssetTypeCriteria = null;
      AssetCriteria lAssetCritera = null;
      List lListPolicies = new LinkedList();
      // -----------------------
      // search for all asset types that have the policy (102) archetype
      lAssetTypeCriteria = new AssetTypeCriteria();
      lAssetTypeCriteria.setArcheTypeCriteria("102");
      lPolicyAssetTypes = mRepository.assetTypeQuery(mAuthToken,
 lAssetTypeCriteria);
      for(int i=0; i<lPolicyAssetTypes.length; i++) {
        // -----------------------
        // for each policy assettype, search for all assets that are of policy
 assettype
        lAssetCritera = new AssetCriteria();
        lAssetCritera.setAssetTypeCriteria(lPolicyAssetTypes[i].getID());
        lPolicies = mRepository.assetQuery(mAuthToken, lAssetCritera);
        // -----------------------
        // add polices to list
        lListPolicies.addAll(Arrays.asList(lPolicies));
      }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}
4.4.12.2.3 ユースケース: ポリシー・アサーションの取得または設定

説明

ポリシー・アサーションを取得するには、getPolicyAssertionsを呼び出します。ポリシー・アサーションを設定するには、setPolicyAssertionsを呼び出し、ポリシーを更新します。

サンプル・コード

例4-42 ユースケース: ポリシー・アサーションの取得または設定

package com.flashline.sample.policies;
import java.net.URL;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.PolicyAssertion;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class GetSetPolicyAssertionsSample {
  private static FlashlineRegistry mRepository = null;
  private static AuthToken mAuthToken = null;
  public GetSetPolicyAssertionsSample(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      GetSetPolicyAssertionsSample lGetSetPolicyAssertionsSample = new
 GetSetPolicyAssertionsSample(pArgs);
      AssetType[] lPolicyAssetTypes = null;
      Asset[] lPolicies = null;
      AssetTypeCriteria lAssetTypeCriteria = null;
      AssetCriteria lAssetCritera = null;
      List lListPolicies = new LinkedList();
      // -----------------------
      // search for all asset types that have the policy (102) archetype
      lAssetTypeCriteria = new AssetTypeCriteria();
      lAssetTypeCriteria.setArcheTypeCriteria("102");
      lPolicyAssetTypes = mRepository.assetTypeQuery(mAuthToken,
 lAssetTypeCriteria);
      for(int i=0; i<lPolicyAssetTypes.length; i++) {
        // -----------------------
        // for each policy assettype, search for all assets that are of policy
 assettype
        lAssetCritera = new AssetCriteria();
        lAssetCritera.setAssetTypeCriteria(lPolicyAssetTypes[i].getID());
        lPolicies = mRepository.assetQuery(mAuthToken, lAssetCritera);
        // -----------------------
        // add polices to list
        lListPolicies.addAll(Arrays.asList(lPolicies));
      }
      if(lListPolicies.size() > 0) {
        // -----------------------
        // get the first policy
        Asset lPolicy = (Asset)lListPolicies.get(0);
        // -----------------------
        // get the policy assertions
        PolicyAssertion[] lPolicyAssetions = lPolicy.getPolicyAssertions();
        // -----------------------
        // print out the policy assertions
        for(int i=0; i<lPolicyAssetions.length; i++) {
          lPolicyAssetions[i].toString();
        }
        // -----------------------
        // set different policy assertions
        lPolicy.setPolicyAssertions(generateNewAssertions());
        // -----------------------
        // update the asset with new assertions
        mRepository.assetUpdate(mAuthToken, lPolicy);
      } else {
        System.out.println("No policies were found in OER.");
      }
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Returns several sample policy assertions for use in testing.
   * Located in a function to be shared between test calls.
   *
   * @return Array of policy assertions
   */
  private static PolicyAssertion[] generateNewAssertions() {
    PolicyAssertion[] lPolicyAssertions = new PolicyAssertion[3];
    String[] lPolicyAssertionNames = {"NEW-First", "NEW-Second", "NEW-Third"};
    for (int i=0; i<lPolicyAssertionNames.length; i++) {
      String lPolicyAssertionName = "My " + lPolicyAssertionNames[i] + "
 Assertion";
      lPolicyAssertions[i] = new PolicyAssertion();
      lPolicyAssertions[i].setName(lPolicyAssertionName);
      lPolicyAssertions[i].setDescription(lPolicyAssertionName + " Description");
      lPolicyAssertions[i].setTechnicalDefinition(lPolicyAssertionName + "
 Technical Definition");
    }
    return lPolicyAssertions;
  }
}
4.4.12.2.4 ユースケース: アセットに適用されたポリシーの取得

説明

アセットに適用されたポリシーを取得するには、assetReadAppliedPoliciesを呼び出します。

サンプル・コード

例4-43 ユースケース: アセットに適用されたポリシーの取得

package com.flashline.sample.policies;
import java.net.URL;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.PolicyAssertion;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class GetAppliedPoliciesSample {
  private static FlashlineRegistry mRepository = null;
  private static AuthToken mAuthToken = null;
  public GetAppliedPoliciesSample(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      GetAppliedPoliciesSample lGetAppliedPoliciesSample = new
 GetAppliedPoliciesSample(pArgs);
      long lAssetId = 50000;
      // ---------------
      // read the policed appled to asset 50000
      Asset[] lAppliedPolicies = mRepository.assetReadAppliedPolicies(mAuthToken,
 lAssetId);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}
4.4.12.2.5 ユースケース: アセットに適用されたポリシーの設定

説明

アセットに適用されたポリシーを更新するには、 assetUpdateAppliedPoliciesを呼び出します。

サンプル・コード

例4-44 ユースケース: アセットに適用されたポリシーの更新

package com.flashline.sample.policies;
import java.net.URL;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AssetType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.PolicyAssertion;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.query.AssetTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ApplyPoliciesSample {
  private static FlashlineRegistry mRepository = null;
  private static AuthToken mAuthToken = null;
  public ApplyPoliciesSample(String pArgs[]) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      ApplyPoliciesSample lApplyPoliciesSample = new ApplyPoliciesSample(pArgs);
      long lAssetId = 50000;
      long[] lPolicyIds = {50000, 50001, 50002};
      mRepository.assetUpdateAppliedPolicies(mAuthToken, lAssetId, lPolicyIds);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}
4.4.12.2.6 ユースケース: アセット・コンプライアンスの評価

説明

指定したポリシーでアセットのコンプライアンスを判定するには、assetEvaluateAgainstPolicyを使用します。適用済のすべてのポリシーに対して、アセットのコンプライアンスを判定するには、assetEvaluateAgainstAllPoliciesを使用します。

サンプル・コード

例4-45 ユースケース: アセット・コンプライアンスの評価

package com.flashline.sample.policies;
import java.net.URL;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class PolicyEvaluationSample {
  private static FlashlineRegistry mRepository = null;
  private static AuthToken mAuthToken = null;
  public PolicyEvaluationSample(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      mRepository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      mAuthToken  = mRepository.authTokenCreate(pArgs[1], pArgs[2]);
    } catch(Exception e) {
    }
  }
  public static void main(String[] pArgs) {
    try {
      PolicyEvaluationSample lPolicyEvalSamp = new PolicyEvaluationSample(pArgs);
      long lAssetId = 50000;
      long lPolicyId = 50001;
      String lEvaluationResult = null;
      // --------------------
      // evaluate asset id 50000 against policy id 50001
      // the return is one of the following values "pass", "fail", "unknown"
      lEvaluationResult = mRepository.assetEvaluateAgainstPolicy(mAuthToken,
 lAssetId, lPolicyId);
      // --------------------
      // evaluate asset id 50000 against all polices applied to the asset
      // the return is one of the following values "pass", "fail", "unknown"
      lEvaluationResult = mRepository.assetEvaluateAgainstAllPolicies(mAuthToken,
 lAssetId);
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}

4.4.13 プロジェクトAPI

この項では、プロジェクトAPIのユースケースについて説明します。このユースケースで、プロジェクトの作成、読込み、更新、問合せおよび検証を行う方法、プロジェクト・アセットと連携する方法、およびOracle Enterprise Repositoryでプロジェクト・ユーザーに変更を加える方法について解説します。

4.4.13.1 概要

この項では、プロジェクトの作成、読込み、更新、問合せおよび検証について説明します。いくつかのエンティティがプロジェクト(関連プロジェクト、ユーザー、使用済アセットおよび作成済アセット)にアタッチされます。これらのエンティティの追加および削除についても、この項で説明します。

必要な追加のインポート(すべての例で使用できないものもあります。)

import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.query.ProjectCriteria;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.entity.Results;
import java.text.SimpleDateFormat;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.ProjectEntities;

4.4.13.2 ユースケース

この項では、プロジェクトAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.13.2.1 ユースケース: 新しいプロジェクトの作成

説明

このメソッドは、プロジェクトの作成、ユーザーの割当ておよび関連プロジェクトの割当てを行います。

プロジェクトのルール

  • プロジェクトには、割当て済のプロジェクト・リーダーが含まれている必要があります。

  • プロジェクト名は一意である必要があります。nullにすることはできません。

  • プロジェクトは部門に割り当てられている必要があります。

  • プロジェクトに見積もられた時間は0より大きい整数である必要があります。

サンプル・コード

例4-46 ユースケース: 新しいプロジェクトの作成

package com.flashline.sample.projectapi;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      ProjectEntities lProjectEntities = null;
      String[] lLeaderIds = null;
      //
---------------------------------------------------------------------------------
--
      lProject = new Project();
      lProjectEntities = new ProjectEntities();
      //
-----------------------------------------------------------------------------------
      // set the name of project
      lProject.setName("NEW_PROJECT_NAME");
      //
---------------------------------------------------------------------------------
--
      // set the name of the project's department
      lProject.setDepartmentID(50000); // a department with id 50000 must
                                        // already exist
      //
---------------------------------------------------------------------------------
--
      // set the userids of the project leaders
      lLeaderIds = new String[] { "99" };
      lProjectEntities.setLeaderIDs(lLeaderIds);
      //
---------------------------------------------------------------------------------
--
      repository.projectCreate(authToken, lProject, lProjectEntities);
    } catch (OpenAPIException oapie) {
      System.out.println("\t --- ServerCode = " + oapie.getServerErrorCode());
      System.out.println("\t --- Message    = " + oapie.getMessage());
    } catch (Exception e) {
      System.out.println("\t --- ErrorMessage = " + e.getMessage());
    }
  }
}
4.4.13.2.2 ユースケース: プロジェクトの読込み

説明

プロジェクトを検索し、そのプロジェクトの抽出、作成済アセット、ユーザーおよび関連プロジェクトを読み込みます。

サンプル・コード

例4-47 ユースケース: プロジェクトの読込み

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.ProjectCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Read a project
      ProjectCriteria projectCriteria = new ProjectCriteria();
      projectCriteria.setNameCriteria("Project A");
      Project[] projects = repository.projectQuery(authToken,
          projectCriteria);
      if (projects.length > 0) {
        try {
          Project projectRead = (Project) projects[0];
          Extraction[] lExtractions = repository.projectReadExtractions(
              authToken, projectRead);
          Asset[] lAssets = repository.projectReadProducedAssets(
              authToken, projectRead);
          Project[] childProjects = repository.projectReadChildProjects(
              authToken, projectRead);
          Project[] parentProjects = repository
              .projectReadParentProjects(authToken, projectRead);
          RegistryUser[] members = repository.projectReadMembers(
              authToken, projectRead);
          RegistryUser[] leaders = repository.projectReadLeaders(
              authToken, projectRead);
        } catch (OpenAPIException ex) {
          ex.printStackTrace();
        }
      } else {
        System.out.println("No projects found");
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.3 ユースケース: プロジェクトの検証

説明

プロジェクトを検証すると、ユーザーは、プロジェクトの保存が試行される前に、検証エラーを取得できます。

サンプル・コード

例4-48 ユースケース: プロジェクトの検証

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Department;
import com.flashline.registry.openapi.entity.KeyValuePair;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Results;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ValidateProject {
  public static void main(String pArgs[]) throws OpenAPIException,
      RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = new Project();
      Results lResults = new Results();
      String[] lLeaders = { "100" };
      Department department = repository.departmentRead(authToken, "Department
 Name");
      ProjectEntities lProjectEntities = new ProjectEntities();
      // -----------------------------------
      // set the project data
      lProjectEntities.setLeaderIDs(lLeaders);
      lProject.setName("Project Name");
      lProject.setDepartmentName("DEPARTMENT_NAME");
      // -----------------------------------
      // Validate a project
      lResults = repository.projectValidate(authToken, lProject,
 lProjectEntities);
      KeyValuePair[] lPairs = lResults.getErrors();
      for (int i = 0; i < lPairs.length; i++) {
        KeyValuePair lPair = lPairs[i];
        System.out.println(lPair.getValue());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.4 ユースケース: プロジェクトの更新

説明

特定のプロジェクトに関連付けられた情報およびデータを更新します。

サンプル・コード

例4-49 ユースケース: プロジェクトの更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Department;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = new Project();
      Department department = new Department();
      ProjectEntities lProjectEntities = new ProjectEntities();
      // -----------------------------------
      // creating a new temporary project for sample
      Project lSampleProject = createProject(repository, authToken);
      // -----------------------------------
      // read an existing project
      try {
        lProject = repository.projectRead(authToken, lSampleProject.getID());
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // change project data
      lProject.setName("Update "+lProject.getName());
      lProject.setDescription("Updated Description");
      try {
        department = repository.departmentRead(authToken,
            "Different Department");
        if (department==null) {
          System.out.println("dept is null");
          department = repository.departmentCreate(authToken, "Different
 Department",
              "Different Department description...");
        }
      } catch (OpenAPIException ex) {
        throw ex;
      }
      lProject.setDepartmentID(department.getID());
      lProject.setAddByDefault(true);
      lProject.setEstimatedHours(50);
      java.util.Calendar lCal = new java.util.GregorianCalendar();
      SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy");
      lCal.setTime(sdf.parse("1/1/04"));
      lProject.setStartDate(lCal);
      // -----------------------------------
      // Update the project
      lProject = (Project) repository.projectUpdate(authToken,
          lProject, lProjectEntities);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    } catch (Exception e) {
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
}
4.4.13.2.5 ユースケース: プロジェクトの作成済アセットの更新

説明

ユーザーが、プロジェクトの作成済アセットを設定するために、単一のデータベース・トランザクションを実行できるようになります。

サンプル・コード

例4-50 ユースケース: プロジェクトの作成済アセットの更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectProducedAssets {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ProjectEntities lProjectEntities = new ProjectEntities();
      Asset lSampleAsset1 = createAsset(repository, authToken);
      Asset lSampleAsset2 = createAsset(repository, authToken);
      String[] assetIds = { ""+lSampleAsset1.getID(), ""+lSampleAsset2.getID() };
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the produced asset ids
        lProjectEntities.setAssetIDs(assetIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead,
            lProjectEntities);
      } catch (APIValidationException ex) {
        ex.printStackTrace();
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Asset createAsset(FlashlineRegistry repository, AuthToken
 authToken)
      throws OpenAPIException, RemoteException {
    Asset myAsset = repository.assetCreate(authToken,
        "My Produced Asset", ""+Calendar.getInstance().getTimeInMillis(), 144);
    return myAsset;
  }
}
4.4.13.2.6 ユースケース: プロジェクトからの作成済アセットの削除

説明

プロジェクトから作成済アセットを削除します。

サンプル・コード

例4-51 ユースケース: プロジェクトからの作成済アセットの削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveProducedAssetsFromProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      ProjectEntities lProjectEntities = new ProjectEntities();
      String[] assetIds = { "569", "589" };
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the remove assets ids
        lProjectEntities.setRemovedAssetIDs(assetIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead,
            lProjectEntities);
      } catch (APIValidationException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
As an alternative, produced assets may be removed by specifying the assets that
 are to remain on the project.
    Sample Code:
package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveProducedAssetsFromProject2 {
  public static void main(String pArgs[])
      throws OpenAPIException, RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // An alternate way of removing produced assets is to specify which assets
      // you wish to remain on the project.
      String[] assetIDs = { "569" };
      ProjectEntities lEntities = new ProjectEntities();
      Project projectRead = new Project();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // set the entities of the produced assets
        lEntities.setAssetIDs(assetIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.7 ユースケース: プロジェクトのアセット使用状況の更新

説明

ユーザーが、プロジェクトに関連付けられた抽出を拒否できるようになります。

サンプル・コード

例4-52 ユースケース: プロジェクトのアセット使用状況の更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.List;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAsset;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractions {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Update a project's extractions
      ProjectEntities lProjectEntities = null;
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // get an extraction or create one
        long lExtractionID = 0;
        ProjectAsset[] lProjectAssets = projectRead.getAssets();
        if (lProjectAssets!=null && lProjectAssets.length>0) {
          lProjectAssets[0].getStatus();
          lExtractionID = lProjectAssets[0].getID();
        } else {
          lProjectEntities = new ProjectEntities();
          lExtractionID = repository.assetRead(authToken, 569).getID();
          String[] lAssetIDs = { ""+lExtractionID };
          lProjectEntities.setAssetIDs(lAssetIDs);
          repository.projectUpdate(authToken, projectRead, lProjectEntities);
        }
        // -----------------------------------
        // set the rejected assets ids
        String[] rejectedIds = null;
        projectRead = repository.projectRead(authToken, 50000); // reload modified
 project
        Extraction[] lExtractions = repository.projectReadExtractions(authToken,
 projectRead);
        rejectedIds = new String[lExtractions.length];
        for (int i=0; lExtractions!=null && i<lExtractions.length; i++) {
          rejectedIds[i] = ""+lExtractions[i].getID();
        }
        lProjectEntities = new ProjectEntities();
        lProjectEntities.setRejectedIDs(rejectedIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lProjectEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.8 ユースケース: 非表示のアセットのあるプロジェクトの終了

説明

プロジェクトを終了する際に、DEPLOYEDまたはREJECTEDとして指定されていないプロジェクトで使用されたアセットの使用状況ステータスを更新する必要があります。

ただし、AquaLogic Enterprise Repositoryの拡張ロール・ベース・アクセス制御(RBAC)設定では、プロジェクト・リーダーはプロジェクトで使用されたすべてのアセットを表示できないことがあります。

プロジェクトが終了した場合、拒否されていない非表示のアセットは、自動的にDEPLOYEDとして指定されます。

AquaLogic Enterprise Repositoryを使用している場合、プロジェクト・リーダーは、プロジェクトに非表示のアセットが含まれていることを通知され、非表示のアセットの使用状況ステータスを更新してアセット値の調査を完了するために必要なアクセス権を持っているユーザーに問い合せる機会を与えられます。適切なユーザーが必要なアクションを行ったことをプロジェクト・リーダーが認識すると、プロジェクトを終了できます。

次の例に、プロジェクトの終了時にプロジェクト・リーダーに非表示となっているアセットのステータスを更新するための、プログラムでのFLEXメカニズムを示します。

サンプル・コード

例4-53 ユースケース: 非表示のアセットのあるプロジェクトの終了

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.List;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAsset;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractions {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Update a project's extractions
      ProjectEntities lProjectEntities = null;
      try {
        // -----------------------------------
        // read an existing project
        Project projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // get an extraction or create one
        long lExtractionID = 0;
        ProjectAsset[] lProjectAssets = projectRead.getAssets();
        if (lProjectAssets!=null && lProjectAssets.length>0) {
          lProjectAssets[0].getStatus();
          lExtractionID = lProjectAssets[0].getID();
        } else {
          lProjectEntities = new ProjectEntities();
          lExtractionID = repository.assetRead(authToken, 569).getID();
          String[] lAssetIDs = { ""+lExtractionID };
          lProjectEntities.setAssetIDs(lAssetIDs);
          repository.projectUpdate(authToken, projectRead, lProjectEntities);
        }
        // -----------------------------------
        // set the rejected assets ids
        String[] rejectedIds = null;
        projectRead = repository.projectRead(authToken, 50000); // reload modified
 project
        Extraction[] lExtractions = repository.projectReadExtractions(authToken,
 projectRead);
        rejectedIds = new String[lExtractions.length];
        for (int i=0; lExtractions!=null && i<lExtractions.length; i++) {
          rejectedIds[i] = ""+lExtractions[i].getID();
        }
        lProjectEntities = new ProjectEntities();
        lProjectEntities.setRejectedIDs(rejectedIds);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lProjectEntities);
      } catch (OpenAPIException ex) {
        ex.printStackTrace();
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.9 ユースケース: プロジェクトへのユーザーと関連プロジェクトの追加

説明

ユーザーをプロジェクトに追加するプロセスは、関連ユーザーを追加するプロセスと同様です。

サンプル・コード

例4-54 ユースケース: プロジェクトへのユーザーと関連プロジェクトの追加

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AddUsersAndRelatedProjectsToProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Add users and related projects to a project
      Project projectRead = new Project();
      String[] newLeaderIDs = { "99" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // create two new projects
        Project lParentProject = createNewProject(repository, authToken, "My
 Parent Project");
        Project lChildProject = createNewProject(repository, authToken, "My Child
 Project");
        String[] newParentIDs = { ""+lParentProject.getID() };
        String[] newChildIDs = { ""+lChildProject.getID() };
        // -----------------------------------
        // create two new users
        RegistryUser lUserOne = createNewUser(repository, authToken, "one");
        RegistryUser lUserTwo = createNewUser(repository, authToken, "two");
        String[] newMemberIDs = { ""+lUserOne.getID(), ""+lUserTwo.getID() };
        // -----------------------------------
        // set the added leader ids
        lEntities.setAddedLeaderIDs(newLeaderIDs);
        // -----------------------------------
        // set the added member ids
        lEntities.setAddedMemberIDs(newMemberIDs);
        // -----------------------------------
        // set the added children project ids
        lEntities.setAddedChildIDs(newChildIDs);
        // -----------------------------------
        // set the added parent project ids
        lEntities.setAddedParentIDs(newParentIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createNewProject(FlashlineRegistry repository,
 AuthToken authToken, String pName)
      throws APIValidationException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName(pName+" "+Calendar.getInstance().getTimeInMillis()); // force
 uniqueness
    lProject.setDepartmentID(50000); // a department with id 50000 must already
 exist
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createNewUser(FlashlineRegistry repository,
 AuthToken authToken, String pUserName)
      throws APIValidationException, RemoteException {
    String lUserName = pUserName + Calendar.getInstance().getTimeInMillis(); //
 force uniqueness
    RegistryUser lRegistryUser = repository.userCreate(authToken, lUserName,
 "First", pUserName,
        pUserName+"@example.com", pUserName, false, false, false);
    return lRegistryUser;
  }
}

次に例に、ユーザーと関連プロジェクトの別の追加方法を示します。この例では、追加済のユーザーまたはプロジェクトは、プロジェクトに割当て済のユーザーまたはプロジェクトのみです。IDの文字列配列に含まれていないユーザーまたはプロジェクトは、プロジェクトから削除されます。この方法を選択すると、ユーザーの追加と削除が1つの手順で行えます。

サンプル・コード

例4-55 ユースケース: プロジェクトに対するユーザーの追加と削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.APIValidationException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class AddUsersAndRelatedProjectsToProject2 {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // The following example presents an alternate way of adding users and
      // related projects.
      // In this example the added users/projects are the ONLY
      // users/projects assigned to the project.
      // Any users/projects not included in the String Array of IDs are
      // removed from the project.
      // This option combines adding and removing users into one step.
      Project projectRead = new Project();
      String[] newLeaderIDs = { "50003" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        // -----------------------------------
        // read an existing project
        projectRead = repository.projectRead(authToken, 50000);
        // -----------------------------------
        // create two new projects
        Project lParentProject = createNewProject(repository, authToken, "My
 Parent Project");
        Project lChildProject = createNewProject(repository, authToken, "My Child
 Project");
        String[] newParentIDs = { ""+lParentProject.getID() };
        String[] newChildIDs = { ""+lChildProject.getID() };
        // -----------------------------------
        // create two new users
        RegistryUser lUserOne = createNewUser(repository, authToken, "one");
        RegistryUser lUserTwo = createNewUser(repository, authToken, "two");
        String[] newMemberIDs = { ""+lUserOne.getID(), ""+lUserTwo.getID() };
        // -----------------------------------
        // set the leader ids
        lEntities.setLeaderIDs(newLeaderIDs);
        // -----------------------------------
        // set the member ids
        lEntities.setMemberIDs(newMemberIDs);
        // -----------------------------------
        // set the children project ids
        lEntities.setChildIDs(newChildIDs);
        // -----------------------------------
        // set the parent project ids
        lEntities.setParentIDs(newParentIDs);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createNewProject(FlashlineRegistry repository,
 AuthToken authToken, String pName)
      throws APIValidationException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName(pName+" "+Calendar.getInstance().getTimeInMillis()); // force
 uniqueness
    lProject.setDepartmentID(50000); // a department with id 50000 must already
 exist
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createNewUser(FlashlineRegistry repository,
 AuthToken authToken, String pUserName)
      throws APIValidationException, RemoteException {
    String lUserName = pUserName + Calendar.getInstance().getTimeInMillis(); //
 force uniqueness
    RegistryUser lRegistryUser = repository.userCreate(authToken, lUserName,
 "First", pUserName,
        pUserName+"@example.com", pUserName, false, false, false);
    return lRegistryUser;
  }
}
4.4.13.2.10 ユースケース: プロジェクトからの関連プロジェクトとユーザーの削除

説明

ユーザーをプロジェクトから削除するプロセスは、関連プロジェクトを削除するプロセスと同様です。

サンプル・コード

例4-56 ユースケース: プロジェクトからの関連プロジェクトとユーザーの削除

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveRelatedProjectsAndUsersFromProject {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      long lParentProjectID = createProject(repository, authToken).getID();
      long lChildProject1ID = createProject(repository, authToken).getID();
      long lChildProject2ID = createProject(repository, authToken).getID();
      long lUser1ID = createUser(repository, authToken).getID();
      long lUser2ID = createUser(repository, authToken).getID();
      long lUser3ID = createUser(repository, authToken).getID();
      long lUser4ID = createUser(repository, authToken).getID();
      long lUser5ID = createUser(repository, authToken).getID();
      long lUser6ID = createUser(repository, authToken).getID();
      // -----------------------------------
      // Remove related projects and users from a project
      Project projectRead = new Project();
      String[] removedParentProjectIDs = { ""+lParentProjectID };
      String[] removedChildProjectIDs = { ""+lChildProject1ID, ""+lChildProject2ID
 };
      String[] removedLeaderIDs = { ""+lUser1ID };
      String[] removedMemberIDs = { ""+lUser2ID };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        projectRead = repository.projectRead(authToken, 50000);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      try {
        // -----------------------------------
        // set the removed parent project ids
        lEntities.setRemovedParentIDs(removedParentProjectIDs);
        // -----------------------------------
        // set the removed children project ids
        lEntities.setRemovedChildIDs(removedChildProjectIDs);
        // -----------------------------------
        // set the remove leader ids
        lEntities.setRemovedLeaderIDs(removedLeaderIDs);
        // -----------------------------------
        // set the removed member ids
        lEntities.setRemovedMemberIDs(removedMemberIDs);
        // -----------------------------------
        // set the exraction reassignment decisions
        ExtractionReassignmentDecision[] decisions = new
 ExtractionReassignmentDecision[2];
        ExtractionReassignmentDecision decision = new
 ExtractionReassignmentDecision();
        decision.setUserID(lUser3ID);
        decision.setReassignUserID(lUser4ID);
        decisions[0] = decision;
        decision = new ExtractionReassignmentDecision();
        decision.setUserID(lUser5ID);
        decision.setReassignUserID(lUser6ID);
        decisions[1] = decision;
        // -----------------------------------
        // set the userid for the reassigned extracions
        lEntities.setReassignIDs(decisions);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

別の方法として、次の例では、削除するユーザーまたはプロジェクトを指定するのではなく、残すユーザーまたはプロジェクトを指定します。

サンプル・コード

例4-57 ユースケース: プロジェクトに特定のユーザーとプロジェクトを残す

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class RemoveRelatedProjectsAndUsersFromProject2 {
  public static void main(String pArgs[])
      throws OpenAPIException, RemoteException, ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // As an alternative, the following example tells the system which
      // users/projects to keep,
      // rather than telling it which ones to remove.
      Project projectRead = new Project();
      String[] lParentProjectIDs = { "50003" };
      String[] lChildProjectIDs = { "50002", "50001" };
      String[] lLeaderIDs = { "50001" };
      String[] lMemberIDs = { "50005" };
      ProjectEntities lEntities = new ProjectEntities();
      try {
        projectRead = repository.projectRead(authToken, 50000);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      try {
        // -----------------------------------
        // set the parent project ids
        lEntities.setParentIDs(lParentProjectIDs);
        // -----------------------------------
        // set the children project ids
        lEntities.setChildIDs(lChildProjectIDs);
        // -----------------------------------
        // set the leader ids
        lEntities.setLeaderIDs(lLeaderIDs);
        // -----------------------------------
        // set the member ids
        lEntities.setMemberIDs(lMemberIDs);
        // -----------------------------------
        // set the extraction reassignment decisions
        ExtractionReassignmentDecision[] decisions = new
 ExtractionReassignmentDecision[2];
        ExtractionReassignmentDecision decision = new
 ExtractionReassignmentDecision();
        decision.setUserID(50011);
        decision.setReassignUserID(50001);
        decisions[0] = decision;
        decision = new ExtractionReassignmentDecision();
        decision.setUserID(50012);
        decision.setReassignUserID(50005);
        decisions[1] = decision;
        // -----------------------------------
        // set the userid for the reassigned extracions
        lEntities.setReassignIDs(decisions);
        // -----------------------------------
        // update the project
        repository.projectUpdate(authToken, projectRead, lEntities);
      } catch (OpenAPIException ex) {
        throw ex;
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.13.2.11 ユースケース: プロジェクトの抽出の更新 - 同じプロジェクトまたは別のプロジェクトにおける別のユーザーへの抽出の再割当て

説明

抽出はユーザー間で再度割り当てることができます。抽出を再度割り当てられるユーザーは、同じプロジェクトまたは別のプロジェクトに存在できます。

サンプル・コード

例4-58 ユースケース: プロジェクトの抽出の更新

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractionswithReassign {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      long currentProjectID = 50000; // an existing project with id 50000 must
                                      // exist
      long someProjectID = 0; // an existing project with id 50001 must
                                  // exist where re-extractions are being
                                  // assigned to
      long extractionID = 50002; // the id of the extraction being reassigned
      long reassignUserID = 0; // the id of the user being assigned to this
                                    // extraction
      // -----------------------------------
      // Update a project's extractions - reassign extractions to a different
      // user on the same or different project
      // -----------------------------------
      // read a project, get a sample project
      lProject = repository.projectRead(authToken, currentProjectID);
      someProjectID = createProject(repository, authToken).getID();
      // -----------------------------------
      // get a member of the project to reassign
      Project lReassignProject = repository.projectRead(authToken, someProjectID);
      String[] memberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
      if (memberIDs!=null && memberIDs.length>0) {
        reassignUserID = Long.parseLong(memberIDs[0]);
      }
      // -----------------------------------
      // if no members exist, create a user and add them
      if (reassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        reassignUserID = createUser(repository, authToken).getID();
        String[] newMemberIDs = { ""+reassignUserID };
        lProjectEntities.setAddedMemberIDs(newMemberIDs);
        repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
      }
      // -----------------------------------
      // set the extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // -----------------------------------
      // set the reassigned project id
      lDecision.setProjectID(someProjectID);
      // -----------------------------------
      // specify which extraction (by id)
      lDecision.setExtractionID(extractionID);
      // -----------------------------------
      // set the reassigned user id
      lDecision.setReassignUserID(reassignUserID);
      lDecisions[0] = lDecision;
      // -----------------------------------
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}
4.4.13.2.12 ユースケース: プロジェクトのユーザーの更新 - 別のプロジェクトへのユーザーとその抽出の再割当て

説明

ユーザーとその抽出を別のプロジェクトに再度割り当てます。

サンプル・コード

例4-59 ユースケース: 別のプロジェクトへのプロジェクト・ユーザーとユーザーの抽出の再割当て

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectExtractionswithReassign {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      Project lProject = null;
      long currentProjectID = 50000; // an existing project with id 50000 must
                                      // exist
      long someProjectID = 0; // an existing project with id 50001 must
                                  // exist where re-extractions are being
                                  // assigned to
      long extractionID = 50002; // the id of the extraction being reassigned
      long reassignUserID = 0; // the id of the user being assigned to this
                                    // extraction
      // -----------------------------------
      // Update a project's extractions - reassign extractions to a different
      // user on the same or different project
      // -----------------------------------
      // read a project, get a sample project
      lProject = repository.projectRead(authToken, currentProjectID);
      someProjectID = createProject(repository, authToken).getID();
      // -----------------------------------
      // get a member of the project to reassign
      Project lReassignProject = repository.projectRead(authToken, someProjectID);
      String[] memberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
      if (memberIDs!=null && memberIDs.length>0) {
        reassignUserID = Long.parseLong(memberIDs[0]);
      }
      // -----------------------------------
      // if no members exist, create a user and add them
      if (reassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        reassignUserID = createUser(repository, authToken).getID();
        String[] newMemberIDs = { ""+reassignUserID };
        lProjectEntities.setAddedMemberIDs(newMemberIDs);
        repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
      }
      // -----------------------------------
      // set the extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // -----------------------------------
      // set the reassigned project id
      lDecision.setProjectID(someProjectID);
      // -----------------------------------
      // specify which extraction (by id)
      lDecision.setExtractionID(extractionID);
      // -----------------------------------
      // set the reassigned user id
      lDecision.setReassignUserID(reassignUserID);
      lDecisions[0] = lDecision;
      // -----------------------------------
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}
4.4.13.2.13 ユースケース: プロジェクトのユーザーの更新 - 別のプロジェクトへのユーザーのみ(ユーザーの抽出は除く)の再割当て

説明

ユーザーはプロジェクト間で再度割り当てることができます。抽出を伴わないでユーザーを移動する場合、ユーザーを再度割り当てる前に、まず、抽出を別のプロジェクト・メンバーに再度割り当てる必要があります。

サンプル・コード

例4-60 ユースケース: 別のプロジェクトへのユーザーのみの再割当て

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.decision.ExtractionReassignmentDecision;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.ProjectUserType;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateProjectUserWithReassign2 {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      Project lProject = null;
      Project someProject = null; // the id the other project
      Project reassignProject = null; // the id of the project being reassigned
      long currentProjectID = 50000; // the id of the current project
      long extractionID = 0; // the id of the extraction
      long extractionReassignUserID = 0; // the id of the user being
                                              // reassigned
      long projectReassignUserID = 0; // the id of the user being reassigned
      // -----------------------------------
      // Update a project's user - reassign only the user (not their
      // extractions) to another project
      // -----------------------------------
      // read a project
      lProject = repository.projectRead(authToken, currentProjectID);
      // -----------------------------------
      // create some projects
      someProject = createProject(repository, authToken);
      reassignProject = createProject(repository, authToken);
      // -----------------------------------
      // get a member of the project to reassign
      String[] memberIDs = repository.projectReadMemberIDs(authToken, lProject);
      if (memberIDs!=null && memberIDs.length>0) {
        extractionReassignUserID = Long.parseLong(memberIDs[0]);
        if (memberIDs.length>1) {
          projectReassignUserID = Long.parseLong(memberIDs[0]);
        }
      }
      // -----------------------------------
      // if no members exist, create users and add them
      if (extractionReassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        extractionReassignUserID = createUser(repository, authToken).getID();
        lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      if (projectReassignUserID==0) {
        ProjectEntities lProjectEntities = new ProjectEntities();
        projectReassignUserID = createUser(repository, authToken).getID();
        lProjectEntities.setAddedMemberIDs(new String[]{ ""+projectReassignUserID
 });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      // get extraction for user or create one
      Extraction[] lAssetExtractions =
 repository.projectReadExtractions(authToken, lProject);
      if (lAssetExtractions!=null && lAssetExtractions.length>0) {
        extractionID = lAssetExtractions[0].getID();
      }
      if (extractionID==0) {
        // create new extraction
        ProjectEntities lProjectEntities = new ProjectEntities();
        Asset lAsset = repository.assetRead(authToken, 569);
        lProjectEntities.setAssetIDs(new String[]{ ""+lAsset.getID() });
        repository.projectUpdate(authToken, lProject, lProjectEntities);
      }
      // -----------------------------------
      // add users to reassign project (if they aren't already)
      {
        Project lReassignProject = repository.projectRead(authToken,
 reassignProject.getID());
        boolean isMemberExtraction = false, isMemberProject = false;
        String[] reassignMemberIDs = repository.projectReadMemberIDs(authToken,
 lReassignProject);
        for (int i=0; reassignMemberIDs!=null && i<reassignMemberIDs.length; i++)
 {
          if
 (Long.parseLong(reassignMemberIDs[i].trim())==extractionReassignUserID)
 isMemberExtraction = true;
          if (Long.parseLong(reassignMemberIDs[i].trim())==projectReassignUserID)
 isMemberProject = true;
        }
        if (!isMemberExtraction) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
          repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
        }
        if (!isMemberProject) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+projectReassignUserID });
          repository.projectUpdate(authToken, lReassignProject, lProjectEntities);
        }
      }
      // -----------------------------------
      // add users to some project (if they aren't already)
      {
        Project lSomeProject = repository.projectRead(authToken,
 someProject.getID());
        boolean isMemberExtraction = false, isMemberProject = false;
        String[] SomeMemberIDs = repository.projectReadMemberIDs(authToken,
 lSomeProject);
        for (int i=0; SomeMemberIDs!=null && i<SomeMemberIDs.length; i++) {
          if (Long.parseLong(SomeMemberIDs[i].trim())==extractionReassignUserID)
 isMemberExtraction = true;
          if (Long.parseLong(SomeMemberIDs[i].trim())==projectReassignUserID)
 isMemberProject = true;
        }
        if (!isMemberExtraction) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+extractionReassignUserID });
          repository.projectUpdate(authToken, lSomeProject, lProjectEntities);
        }
        if (!isMemberProject) {
          ProjectEntities lProjectEntities = new ProjectEntities();
          lProjectEntities.setAddedMemberIDs(new String[]{
 ""+projectReassignUserID });
          repository.projectUpdate(authToken, lSomeProject, lProjectEntities);
        }
      }
      // -----------------------------------
      // set extraction reassignment decision
      ExtractionReassignmentDecision[] lDecisions = new
 ExtractionReassignmentDecision[1];
      ExtractionReassignmentDecision lDecision = new
 ExtractionReassignmentDecision();
      // set the reassign decision's project id
      lDecision.setProjectID(someProject.getID());
      // set the reassign decision's extraction id
      lDecision.setExtractionID(extractionID);
      // set the reassign decision's reassigned user ids
      lDecision.setReassignUserID(extractionReassignUserID);
      lDecisions[0] = lDecision;
      // reassign project extractions
      repository.projectReassignExtractions(authToken, lProject,
          lDecisions);
      // verify reassignment
      lProject = repository.projectRead(authToken, currentProjectID);
      ProjectUserType userType = repository
          .projectReadUserTypes(authToken);
      lDecisions = new ExtractionReassignmentDecision[1];
      lDecision = new ExtractionReassignmentDecision();
      lDecision.setProjectID(reassignProject.getID());
      lDecision.setReassignUserID(projectReassignUserID);
      lDecision.setReassignType(userType.getUserTypeLeader());
      lDecisions[0] = lDecision;
      repository.projectReassignUsers(authToken, lProject, lDecisions);
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static Project createProject(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    Project lProject = new Project();
    ProjectEntities lProjectEntities = new ProjectEntities();
    lProject.setName("Project "+Calendar.getInstance().getTimeInMillis());
    lProject.setDepartmentID(50000); // a department with id 50000 must
    String[] lLeaderIds = new String[] { "99" };
    lProjectEntities.setLeaderIDs(lLeaderIds);
    lProject = repository.projectCreate(authToken, lProject, lProjectEntities);
    return lProject;
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}
4.4.13.2.14 ユースケース: プロジェクトとアセット用に指定された値の読込み

説明

プロジェクトとアセット用に値を指定された詳細情報を読み込みます。

サンプル・コード

例4-61 ユースケース: プロジェクトとアセット用に指定された値の読込み

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadValueProvidedForProjectAndAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------
      // Read the value provided for a project and asset
      long projectid = 50000; // the id of the project
      long assetid = 569; // the id of the asset
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetid };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectid, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectid, assetid);
      // -----------------------------------
      // take survey and update
      SurveyTaken surveyTaken = takeSurvey(repository, authToken, extraction);
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // read project asset values
      ProjectAssetValue[] projectAssetValues = repository
          .projectAssetValueRead(authToken, projectid, assetid);
      if (projectAssetValues != null) {
        for (int i = 0; i < projectAssetValues.length; i++) {
          ProjectAssetValue projectAssetValue = projectAssetValues[i];
          projectAssetValue.getUserInfo().getUserName();
          projectAssetValue.getExtractionDate();
          projectAssetValue.getExtractionStatus();
          projectAssetValue.getPredictedValue();
          projectAssetValue.isPredictedValueSelected();
          projectAssetValue.getConsumerFoundValue();
          projectAssetValue.getConsumerUsage();
          projectAssetValue.getConsumerValue();
          projectAssetValue.isConsumerValueSelected();
          projectAssetValue.getProjectLeadUsage();
          projectAssetValue.getProjectLeadValue();
          projectAssetValue.isProjectLeadValueSelected();
          projectAssetValue.getAssetUsage();
          projectAssetValue.getAssetValue();
          projectAssetValue.getAssetValueSource();
        }
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static SurveyTaken takeSurvey(FlashlineRegistry repository, AuthToken
 authToken, Extraction extraction)
      throws OpenAPIException, RemoteException {
    // -----------------------------------
    // take survey
    SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
    Question[] questions = repository.surveyReadQuestions(authToken);
    ChoiceList choiceList = null;
    Choice[] choices = null;
    Answer[] answers = new Answer[4];
    for(int i=0; i<answers.length; i++){
      answers[i] = new Answer();
    }
    // -----------------------------------
    //Sort questions
    Question[] sortedQuestions = new Question[4];
    for (int i=0;i<questions.length;i++) {
      if (questions[i].getId()==100) {
        sortedQuestions[0] = questions[i];
      }
      if (questions[i].getId()==101) {
        sortedQuestions[1] = questions[i];
      }
      if (questions[i].getId()==102) {
        sortedQuestions[2] = questions[i];
      }
      if (questions[i].getId()==103) {
        sortedQuestions[3] = questions[i];
      }
    }
    answers[0].setQuestionId(sortedQuestions[0].getId());
    choiceList = sortedQuestions[0].getChoiceList();
    choices = choiceList.getChoices();
    answers[0].setChoiceId(choices[0].getId());
    answers[0].setValue(choices[0].getValue());
    answers[1].setQuestionId(sortedQuestions[1].getId());
    answers[1].setChoiceId(0);
    answers[1].setValue("100");
    answers[2].setQuestionId(sortedQuestions[2].getId());
    answers[2].setChoiceId(0);
    answers[2].setValue("200");
    answers[3].setQuestionId(sortedQuestions[3].getId());
    choiceList = sortedQuestions[3].getChoiceList();
    choices = choiceList.getChoices();
    answers[3].setChoiceId(choices[3].getId());
    answers[3].setValue(choices[3].getValue());
    surveyTaken.setAnswers(answers);
    return surveyTaken;
  }
}
4.4.13.2.15 ユースケース: プロジェクトとアセット用に指定された値の更新 - 予測値の使用

説明

予測値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例4-62 ユースケース: プロジェクトとアセット用に指定された値の更新 - 予測値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithPredictedValue {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value provided for a project and asset - use predicted value
      long userid = repository.userReadByAuthToken(authToken).getID(); // the id
 of the user
      long projectid = 50000; // the id of the project
      long assetid = 569; // the id of the asset
      repository.testExtractionResetDatabaseForProject(projectid); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectid);
      // -----------------------------------
      // if no user id exists, create a user
      if (userid==0) {
        userid = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userid });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get a RegistryUser for a user
      RegistryUser user = repository.userRead(authToken, userid);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetid };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectid, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectid, assetid);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectid, assetid, user);
      if (projectAssetValue != null) {
        // -----------------------------------
        // update the project asset value
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "predicted_selected");
      }
      // -----------------------------------
      // revert extractions
      repository.extractionResetDatabase();
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}
4.4.13.2.16 ユースケース: プロジェクトとアセット用に指定された値の更新 - 使用者の値の使用

説明

使用者の値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例4-63 ユースケース: プロジェクトとアセット用に指定された値の更新 - 使用者の値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithConsumerValue {
  public static void main(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value-provided for a project and asset - use consumer value
      long userID = repository.userReadByAuthToken(authToken).getID(); // ID of
 the user being read
      long projectID = 50000; // ID of project being updated
      long assetID = 569; // ID of asset
      repository.testExtractionResetDatabaseForProject(projectID); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectID);
      // -----------------------------------
      // if no user id exists, create a user
      if (userID==0) {
        userID = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userID });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get the user
      RegistryUser user = repository.userRead(authToken, userID);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetID };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectID, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectID, assetID);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectID, assetID, user);
      if (projectAssetValue != null) {
        // If a ProjectAssetValue does not exist for this project, asset, and
        // user combination a null value is returned.
        ProjectAssetValue projectAssetValueSelection = new ProjectAssetValue();
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "consumer_selected");
      }
    } catch (OpenAPIException oapie) {
      System.out.println("ServerCode = " + oapie.getServerErrorCode());
      System.out.println("Message    = " + oapie.getMessage());
      System.out.println("StackTrace:");
      oapie.printStackTrace();
    } catch (RemoteException re) {
      re.printStackTrace();
    } catch (ServiceException se) {
      se.printStackTrace();
    } catch (MalformedURLException mue) {
      mue.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}
4.4.13.2.17 ユースケース: プロジェクトとアセット用に指定された値の更新 - プロジェクト・リーダーの値の使用

説明

プロジェクト・リーダーの値を使用して、プロジェクトとアセット用に指定された値を更新します。

サンプル・コード

例4-64 ユースケース: プロジェクトとアセット用に指定された値の更新 - プロジェクト・リーダーの値の使用

package com.flashline.sample.projectapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Answer;
import com.flashline.registry.openapi.entity.AssetUsageType;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Choice;
import com.flashline.registry.openapi.entity.ChoiceList;
import com.flashline.registry.openapi.entity.Extraction;
import com.flashline.registry.openapi.entity.ExtractionDownload;
import com.flashline.registry.openapi.entity.Project;
import com.flashline.registry.openapi.entity.ProjectAssetValue;
import com.flashline.registry.openapi.entity.ProjectEntities;
import com.flashline.registry.openapi.entity.Question;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.entity.SurveyTaken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class UpdateValueProvidedForProjectAndUserWithLeadValue {
  public static void main(String[] pArgs) {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(
          pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // -----------------------------------
      // Update the value provided for a project and asset - use project lead
 value
      long userID = repository.userReadByAuthToken(authToken).getID(); // ID of
 the user being read
      long projectID = 50000; // ID of project being updated
      long assetID = 569; // ID of asset
      float newValue = 50.0f; // Project asset value
      repository.testExtractionResetDatabaseForProject(projectID); // for sample
 *only*
      Project lProject = repository.projectRead(authToken, projectID);
      // -----------------------------------
      // if no user id exists, create a user
      if (userID==0) {
        userID = createUser(repository, authToken).getID();
      }
      ProjectEntities lProjectEntities = new ProjectEntities();
      lProjectEntities.setAddedLeaderIDs(new String[]{ ""+userID });
      repository.projectUpdate(authToken, lProject, lProjectEntities);
      // -----------------------------------
      // Get a RegistryUser for a user.
      RegistryUser user = repository.userRead(authToken, userID);
      // -----------------------------------
      // Make sure the project has an extraction
      long[] lAssetIDs = { assetID };
      ExtractionDownload[] extractionDownload =
 repository.extractionCreate(authToken, projectID, lAssetIDs);
      Extraction extraction =
 repository.extractionReadByProjectAndAsset(authToken, projectID, assetID);
      // -----------------------------------
      // take survey
      SurveyTaken surveyTaken = repository.surveyTakenRead(authToken, extraction);
      Question[] questions = repository.surveyReadQuestions(authToken);
      ChoiceList choiceList = null;
      Choice[] choices = null;
      Answer[] answers = new Answer[4];
      for(int i=0; i<answers.length; i++){
        answers[i] = new Answer();
      }
      // -----------------------------------
      //Sort questions
      Question[] sortedQuestions = new Question[4];
      for (int i=0;i<questions.length;i++) {
        if (questions[i].getId()==100) {
          sortedQuestions[0] = questions[i];
        }
        if (questions[i].getId()==101) {
          sortedQuestions[1] = questions[i];
        }
        if (questions[i].getId()==102) {
          sortedQuestions[2] = questions[i];
        }
        if (questions[i].getId()==103) {
          sortedQuestions[3] = questions[i];
        }
      }
      answers[0].setQuestionId(sortedQuestions[0].getId());
      choiceList = sortedQuestions[0].getChoiceList();
      choices = choiceList.getChoices();
      answers[0].setChoiceId(choices[0].getId());
      answers[0].setValue(choices[0].getValue());
      answers[1].setQuestionId(sortedQuestions[1].getId());
      answers[1].setChoiceId(0);
      answers[1].setValue("100");
      answers[2].setQuestionId(sortedQuestions[2].getId());
      answers[2].setChoiceId(0);
      answers[2].setValue("200");
      answers[3].setQuestionId(sortedQuestions[3].getId());
      choiceList = sortedQuestions[3].getChoiceList();
      choices = choiceList.getChoices();
      answers[3].setChoiceId(choices[3].getId());
      answers[3].setValue(choices[3].getValue());
      surveyTaken.setAnswers(answers);
      // -----------------------------------
      // update survey
      surveyTaken = repository.surveyTakenUpdate(authToken, surveyTaken);
      extraction = repository.extractionUpdateSurvey(authToken, extraction,
 surveyTaken);
      // -----------------------------------
      // Get a ~ProjectAssetValue for a project asset and user.
      ProjectAssetValue projectAssetValue = repository
          .projectAssetValueReadForUser(authToken, projectID, assetID, user);
      if (projectAssetValue != null) {
        // A null value is returned if no If a ProjectAssetValue does not exists
        // for this project, asset, and user combination.
        // -----------------------------------
        // Get an ~AssetUsageType array.
        AssetUsageType[] usageTypes = repository
            .projectAssetValueReadTypes(authToken);
        projectAssetValue.setProjectLeadUsage(usageTypes[1].getName()); 
// Set the projectAssetValue to a AssetUsageType value.
        projectAssetValue.setProjectLeadValue(newValue); // Set to a new value.
        ProjectAssetValue projectAssetValueSelection = new ProjectAssetValue();
        projectAssetValue = repository.projectAssetValueUpdate(
            authToken, projectAssetValue, "predicted_selected");
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
  protected static RegistryUser createUser(FlashlineRegistry repository, AuthToken
 authToken) throws OpenAPIException, RemoteException {
    String lUserName = "user"+Calendar.getInstance().getTimeInMillis();
    return repository.userCreate(authToken, lUserName, "First", "User",
 "user@example.com", "user", false, false, false);
  }
}

4.4.14 リレーションシップ・タイプAPI

この項では、リレーションシップ・タイプAPIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいて、新しいリレーションシップ・タイプの作成、および関連アセットの変更または問合せを行う方法について解説します。

4.4.14.1 概要

リレーションシップ・タイプは、2つのアセットを関連付けるために使用するリレーションシップの構造を定義します。

アセット・サブシステム

アセットを作成または編集する場合、リレーションシップ・タイプは、アセット間に存在するリレーションシップを定義または変更するために使用します。

4.4.14.2 ユースケース

この項では、リレーションシップ・タイプAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.14.2.1 ユースケース: 新しいリレーションシップ・タイプの作成

説明

アセット間で使用されるリレーションシップの新しいタイプを作成します。

サンプル・コード

例4-65 ユースケース: 新しいリレーションシップ・タイプの作成

package com.flashline.sample.relationshiptypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RelationshipType;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateNewRelationshipType {
         public static void main(String pArgs[]) throws java.rmi.RemoteException,
 OpenAPIException {
                    try{
          ///////////////////////////////////////////////////////////
          // Connect to Oracle Enterprise Repository
          ///////////////////////////////////////////////////////////
                      URL lURL = null;
                      lURL = new URL(pArgs[0]);
                      FlashlineRegistry repository =new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
          // //////////////////////////////
          // Authenticate with OER
          // //////////////////////////////
                      AuthToken authToken = repository.authTokenCreate(pArgs[1],
 pArgs[2]);
                      // -----------------------------------------
                      // create the new relationship type
                      String newRelationshipTypeName
 ="My-NewRelationshipTypeName";  //Relationship Type name must contain only alpha
 characters or hyphens
                      RelationshipType newRelationshipType =
 repository.relationshipTypeCreate(authToken, newRelationshipTypeName);
                      System.out.println("The new relationshipType id =
 "+newRelationshipType.getID()+" ");
          // -----------------------------------------
          // set the direction definition and the display text describing the
 relationship type
          //// Two-way = "BIDIRECTIONAL"
          //// Two-way, order matters = "ORDERED-BIDIRECTIONAL"
          //// One-way = "UNIDIRECTIONAL"
          newRelationshipType.setDirection("ORDERED-BIDIRECTIONAL");
          newRelationshipType.setDisplayPrimary("Contained In"); // Source Asset -
 'Contained In' - Target Asset
          newRelationshipType.setDisplaySecondary("Contains");   // Target Asset -
 'Contains' - Source Asset
          newRelationshipType = repository.relationshipTypeUpdate(authToken,
 newRelationshipType);
          // -----------------------------------------
          // delete the new relationship type
          repository.relationshipTypeDelete(authToken,
 newRelationshipType.getID());
                    }catch(OpenAPIException  lEx) {
                      System.out.println("ServerCode = "+
 lEx.getServerErrorCode());
                      System.out.println("Message    = "+ lEx.getMessage());
                      System.out.println("StackTrace:");
                      lEx.printStackTrace();
                    } catch (RemoteException lEx) {
                      lEx.printStackTrace();
                    } catch (ServiceException lEx) {
                      lEx.printStackTrace();
                    } catch (MalformedURLException lEx) {
                      lEx.printStackTrace();
                    }
                  }
}
4.4.14.2.2 ユースケース: 関連アセットの変更

説明

My RelationshipTypeを使用して、ターゲット・アセットを他のアセットに関連付けます。同じリレーションシップ・タイプを使用して、追加のアセットに対するリレーションシップを設定します。

サンプル・コード

例4-66 ユースケース: 関連アセットの変更

package com.flashline.sample.relationshiptypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RelationshipType;
import com.flashline.registry.openapi.query.RelationshipTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindRelationshipTypeAndUseInAsset {
         public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException, ServiceException {
                    try{
          ///////////////////////////////////////////////////////////
          // Connect to Oracle Enterprise Repository
          ///////////////////////////////////////////////////////////
                      URL lURL = null;
                      lURL = new URL(pArgs[0]);
                      FlashlineRegistry repository =new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
          // //////////////////////////////
          // Authenticate with OER
          // //////////////////////////////
                      AuthToken authToken = repository.authTokenCreate(pArgs[1],
 pArgs[2]);
          Asset myAsset = repository.assetRead(authToken, 563);
                      //MY_OTHER_ASSET_ID should be an integer and should be the
 id of an asset in the repository
                      RelationshipType[] allRelationshipTypes =
 getAllRelationshipTypes(repository, authToken);
                      for (int i = 0; i < allRelationshipTypes.length; i++) {
                        if
 (allRelationshipTypes[i].getName().equals("MyRelationshipType2")) {
                          //This is the relationship type, modify the assets that
 are related
                          // using it
                          RelationshipType myRelationshipType =
 allRelationshipTypes[i];
                          Asset otherAsset = repository.assetRead(authToken, 569); 
 //569= MY_OTHER_ASSET_ID
                          //MY_OTHER_ASSET_ID should be an integer and should be
 the id of an asset in the repository
                          //add this asset to the list of related assets
                          long[] oldSecondaryIDs =
 myRelationshipType.getSecondaryIDs();
                          long[] newSecondaryIDs = new long[oldSecondaryIDs.length
 + 1];
                          for (int j = 0; j < oldSecondaryIDs.length; j++) {
                            newSecondaryIDs[j] = oldSecondaryIDs[j];
                          }
                          newSecondaryIDs[newSecondaryIDs.length - 1] =
 otherAsset.getID();
                          myRelationshipType.setSecondaryIDs(newSecondaryIDs);
                        }
                      }
                      myAsset.setRelationshipTypes(allRelationshipTypes);
                      repository.assetUpdate(authToken, myAsset);
                    }catch(OpenAPIException  lEx) {
                      System.out.println("ServerCode = "+
 lEx.getServerErrorCode());
                      System.out.println("Message    = "+ lEx.getMessage());
                      System.out.println("StackTrace:");
                      lEx.printStackTrace();
                    } catch (RemoteException lEx) {
                      lEx.printStackTrace();
                    } catch (ServiceException lEx) {
                      lEx.printStackTrace();
                    } catch (MalformedURLException lEx) {
                      lEx.printStackTrace();
                    }
                  }
   /**
     * This method returns every relationship type in the repository
     * @param repository
     * @param authToken
     * @return
     * @throws RemoteException
     */
    public static RelationshipType[] getAllRelationshipTypes(FlashlineRegistry
 repository, AuthToken authToken) throws RemoteException {
      //Create an empty relationship type criteria object
      RelationshipTypeCriteria criteria = new RelationshipTypeCriteria();
      criteria.setNameCriteria("");
      RelationshipType[] allRelationshipTypes =
 repository.relationshipTypeQuery(authToken, criteria);
      return allRelationshipTypes;
    }
}

注意:

回避するメソッド: SetPromptNotifySecondary()

4.4.14.2.3 ユースケース: 関連アセットの問合せ

説明

関連アセット・タイプを問い合せます。

サンプル・コード

例4-67 ユースケース: 関連アセットの問合せ

package com.flashline.sample.relationshiptypeapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RelationshipType;
import com.flashline.registry.openapi.query.RelationshipTypeCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class FindRelationshipTypeAndUseInAsset {
         public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException, ServiceException {
                    try{
          ///////////////////////////////////////////////////////////
          // Connect to Oracle Enterprise Repository
          ///////////////////////////////////////////////////////////
                      URL lURL = null;
                      lURL = new URL(pArgs[0]);
                      FlashlineRegistry repository =new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
          // //////////////////////////////
          // Authenticate with OER
          // //////////////////////////////
                      AuthToken authToken = repository.authTokenCreate(pArgs[1],
 pArgs[2]);
          Asset myAsset = repository.assetRead(authToken, 563);
                      //MY_OTHER_ASSET_ID should be an integer and should be the
 id of an asset in the repository
                      RelationshipType[] allRelationshipTypes =
 getAllRelationshipTypes(repository, authToken);
                      for (int i = 0; i < allRelationshipTypes.length; i++) {
                        if
 (allRelationshipTypes[i].getName().equals("MyRelationshipType2")) {
                          //This is the relationship type, modify the assets that
 are related
                          // using it
                          RelationshipType myRelationshipType =
 allRelationshipTypes[i];
                          Asset otherAsset = repository.assetRead(authToken, 569); 
 //569= MY_OTHER_ASSET_ID
                          //MY_OTHER_ASSET_ID should be an integer and should be
 the id of an asset in the repository
                          //add this asset to the list of related assets
                          long[] oldSecondaryIDs =
 myRelationshipType.getSecondaryIDs();
                          long[] newSecondaryIDs = new long[oldSecondaryIDs.length
 + 1];
                          for (int j = 0; j < oldSecondaryIDs.length; j++) {
                            newSecondaryIDs[j] = oldSecondaryIDs[j];
                          }
                          newSecondaryIDs[newSecondaryIDs.length - 1] =
 otherAsset.getID();
                          myRelationshipType.setSecondaryIDs(newSecondaryIDs);
                        }
                      }
                      myAsset.setRelationshipTypes(allRelationshipTypes);
                      repository.assetUpdate(authToken, myAsset);
                    }catch(OpenAPIException  lEx) {
                      System.out.println("ServerCode = "+
 lEx.getServerErrorCode());
                      System.out.println("Message    = "+ lEx.getMessage());
                      System.out.println("StackTrace:");
                      lEx.printStackTrace();
                    } catch (RemoteException lEx) {
                      lEx.printStackTrace();
                    } catch (ServiceException lEx) {
                      lEx.printStackTrace();
                    } catch (MalformedURLException lEx) {
                      lEx.printStackTrace();
                    }
                  }
   /**
     * This method returns every relationship type in the repository
     * @param repository
     * @param authToken
     * @return
     * @throws RemoteException
     */
    public static RelationshipType[] getAllRelationshipTypes(FlashlineRegistry
 repository, AuthToken authToken) throws RemoteException {
      //Create an empty relationship type criteria object
      RelationshipTypeCriteria criteria = new RelationshipTypeCriteria();
      criteria.setNameCriteria("");
      RelationshipType[] allRelationshipTypes =
 repository.relationshipTypeQuery(authToken, criteria);
      return allRelationshipTypes;
    }
}

RelationshipTypeQueryの例

try
{
   RelationshipTypeCriteria rCriteria = new RelationshipTypeCriteria();
   RelationshipType[] allRelationshipTypes =
 FlashlineRegistry.relationshipQuery(lAuthToken, rCriteria);
}
catch (OpenAPIException e)
{
     e.printStackTrace();
}
catch (RemoteException re)
{
    re.printStackTrace();
}

4.4.15 ロールAPI

この項では、ロールAPIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryのロールの作成、読込み、更新、削除または問合せを行う方法について解説します。

4.4.15.1 概要

ロール・サブシステムは、Oracle Enterprise Repositoryのロールの作成、読込み、更新、問合せまたは操作に使用する、Webサービス・ベースのメカニズムを提供します。

関連するサブシステム

詳細は、4.4.18項「ユーザーAPI」を参照してください。

追加で必要なインポート

import com.flashline.registry.openapi.entity.Role;
import com.flashline.registry.openapi.query.RoleCriteria;

4.4.15.2 ユースケース: ロールの操作

説明

  • 新しいロールを作成します。

  • ロールを読み込みます。

  • ロールを更新します。

  • ロールを削除します。

  • ロールを問い合せます。

サンプル・コード

例4-68 ユースケース: ロールの操作

package com.flashline.sample.roleapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Role;
import com.flashline.registry.openapi.query.RoleCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Roles {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------------
      // Create a new role
      String lName = "new_role_type_name";
      String lDesc = "new_role_type_desc";
      boolean lDeafultForNewUser = true;
      Role lRole = null;
      lRole = repository.roleCreate(authToken, lName, lDesc,
          lDeafultForNewUser);
      // -----------------------------------------
      // Read a Role
      String lRoleName = lName;
      Role lRole2 = null;
      lRole2 = repository.roleRead(authToken, lRoleName);
      // -----------------------------------------
      // Update a Role
      String lRoleName3 = lName;
      Role lRole3 = null;
      lRole3 = repository.roleRead(authToken, lRoleName3);
      lRole3.setName("user_modified");
      lRole3.setStatus(20);
      lRole3 = repository.roleUpdate(authToken, lRole);
      // -----------------------------------------
      // Delete a Role
      String lRoleName4 = "user_modified"; // role name must exist in OER
      Role lRole4 = repository.roleRead(authToken, lRoleName4);
      if (lRole4==null) {
        lRole4 = repository.roleRead(authToken, lName);
      }
      if (lRole4!=null) {
        try {
          repository.roleDelete(authToken, lRole4.getName());
        } catch (OpenAPIException e) {
          e.printStackTrace();
        }
      }
      // -----------------------------------------
      // This method is used to query for roles.
      Role[] lRoles = null;
      RoleCriteria lRoleCriteria = null;
      lRoleCriteria = new RoleCriteria();
      lRoleCriteria.setNameCriteria("user");
      lRoles = repository.roleQuery(authToken, lRoleCriteria);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.16 サブスクリプションAPI

この項では、サブスクリプションAPIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいてアセットに対するサブスクリプションの作成、読込みまたは削除を行う方法、およびアセットに対してサブスクライブされたユーザーを読み込む方法について解説します。

4.4.16.1 概要

サブスクリプションAPIでは、サブスクライブされているアセットをユーザーが管理するメカニズムを提供します。この場合、サブスクリプションは、具体的には電子メール・サブスクリプションを示します。このAPIを介して作成されるサブスクリプションは、アセットの詳細ページで「サブスクライブ」ボタンをクリックするユーザーに相当します。ユーザーがアセットに対してサブスクライブした後、アセットに発生しているイベントについて電子メールで通知されます。サブスクライブ済のユーザーが通知されるイベントのリストは、Oracle Enterprise Repositoryの電子メール・テンプレートに関する項を参照してください。

REXのサブスクリプションAPIを使用すると、開発者はアセットのリストに対するサブスクリプションを作成、削除および検査できます。この操作は、常に、様々なサブスクリプション・メソッドに引数として渡された認証トークンで識別されたユーザーに対して実行されます。

4.4.16.1.1 ユースケース

この項では、サブスクリプションAPIを使用するユースケースについて説明します。内容は次のとおりです。

4.4.16.1.2 ユースケース: アセットに対するサブスクリプションの作成

説明

  • REXで認証します。

  • 問合せを介してアセットのサマリーのリストを読み込みます。

  • 一致したアセットに対してサブスクライブします。

サンプル・コード

例4-69 ユースケース: アセットに対するサブスクリプションの作成

package com.flashline.sample.subscriptionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetSummary;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class CreateSubscription {
  public static void main(String pArgs[]) throws OpenAPIException,
      RemoteException, ServiceException {
    try {
      // /////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      // /////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // /////////////////////////////////////////////////////////
      // Login to OER
      // /////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1], pArgs[2]);
      // /////////////////////////////////////////////////////////
      // find the assets to which to subscribe
      // /////////////////////////////////////////////////////////
      AssetCriteria criteria = new AssetCriteria();
      criteria.setNameCriteria("%");
      AssetSummary[] lAssetSummaries = repository.assetQuerySummary(authToken,
          criteria);
      // /////////////////////////////////////////////////////////
      // Iterate through assets, pulling out the ids and adding
      // to the array of longs
      // /////////////////////////////////////////////////////////
      long[] lAssetIDs = new long[lAssetSummaries.length];
      for (int i = 0; i < lAssetSummaries.length; i++) {
        lAssetIDs[i] = lAssetSummaries[i].getID();
      }
      // /////////////////////////////////////////////////////////
      // Create the subscriptions. The value of "false" for the
      // parameter pFailOnAnyError, causes the operation to NOT
      // fail for any asset to which the user does not have VIEW
      // privileges, or for which the asset is not subscribable.
      //
      // If this value is not "false", the operation throws
      // an exception if any asset in the array of asset IDs is
      // not subscribable or viewable by the user, and NONE of the
      // subscriptions are recorded in the repository.
      // /////////////////////////////////////////////////////////
      repository.subscriptionCreate(authToken, lAssetIDs, false);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.16.1.3 ユースケース: アセットに対するサブスクリプションの削除

説明

  • REXで認証します。

  • 問合せを介してアセットのサマリーのリストを読み込みます。

  • 一致したアセットに対して存在するサブスクリプションを削除します。

サンプル・コード

例4-70 ユースケース: アセットに対するサブスクリプションの削除

package com.flashline.sample.subscriptionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetSummary;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class DeleteSubscription {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      ///////////////////////////////////////////////////////////
      // find the assets for which to delete subscriptions
      ///////////////////////////////////////////////////////////
      AssetCriteria criteria = new AssetCriteria();
      criteria.setNameCriteria("%");
      AssetSummary[] lAssetSummaries = repository.assetQuerySummary(authToken,
 criteria);
      ///////////////////////////////////////////////////////////
      // Iterate through assets, pulling out the ids and adding
      // to the array of longs
      ///////////////////////////////////////////////////////////
      long[] lAssetIDs = new long[lAssetSummaries.length];
      for (int i = 0; i < lAssetSummaries.length; i++) {
        lAssetIDs[i] = lAssetSummaries[i].getID();
      }
      ///////////////////////////////////////////////////////////
      // Delete the subscriptions on the list of assets.
      ///////////////////////////////////////////////////////////
      repository.subscriptionDelete(authToken, lAssetIDs);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.16.1.4 ユースケース: アセットに対するサブスクリプションの読込み

説明

  • REXで認証します。

  • 認証済のユーザーに対してサブスクライブされたアセットのリストを読み込みます。

サンプル・コード

例4-71 ユースケース: アセットに対するサブスクリプションの読込み

package com.flashline.sample.subscriptionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadSubscriptions {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      //////////////////////////////////////////////////////////
      // Read all of the assets to which the user is subscribed.
      //////////////////////////////////////////////////////////
      long[] lSubscribedAssets =
 repository.subscriptionReadSubscribedAssets(authToken);
      //////////////////////////////////////////////////////////
      // Print out the assets to which the user is subscribed
      //////////////////////////////////////////////////////////
      Asset[] lAssets = repository.assetReadArray(authToken, lSubscribedAssets);
      System.out.println("Subscribed Assets for user "+pArgs[1]);
      for(int i=0; i<lAssets.length; i++){
        System.out.println("  -> "+lAssets[i].getLongName());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}
4.4.16.1.5 ユースケース: アセットに対してサブスクライブされたユーザーの読込み

説明

  • REXで認証します。

  • 特定のユーザーに対してサブスクライブされたアセットのリストを読み込みます。

サンプル・コード

例4-72 ユースケース: アセットに対してサブスクライブされたユーザーの読込み

package com.flashline.sample.subscriptionapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AssetSummary;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.AssetCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class ReadSubscribersToAsset {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      ///////////////////////////////////////////////////////////
      // Login to OER
      ///////////////////////////////////////////////////////////
      AuthToken authToken = repository.authTokenCreate(
          pArgs[1],pArgs[2]);
      //////////////////////////////////////////////////////////
      // Assume that this query returns some number of assets...
      //////////////////////////////////////////////////////////
      AssetCriteria lCriteria = new AssetCriteria();
      lCriteria.setNameCriteria("%");
      AssetSummary[] lAssetSummaries = repository.assetQuerySummary(authToken,
 lCriteria);
      //////////////////////////////////////////////////////////
      // Read the users that are subscribed to the first asset
      //////////////////////////////////////////////////////////
      RegistryUser[] lSubscribedUsers =
        repository.subscriptionReadUsersSubscribedToAsset(authToken,
 lAssetSummaries[0].getID());
      for (int i=0; i<lSubscribedUsers.length; i++){
        System.out.println("Subscribed Users:
 "+lSubscribedUsers[i].getUserName());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.17 システム設定API

この項では、システム設定APIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryのシステム設定について問合せを行う方法について解説します。

4.4.17.1 概要

Oracle Enterprise Repositoryのシステム設定セクションで、管理者は基本的な操作を構成して、特定の機能を有効または無効にできます。システム設定APIでは、これらのシステム設定を問い合せるメカニズムを提供します。


注意:

ユーザーは、システム設定の値を問い合せることのみを許可されています。REXでは、システム設定を設定または変更することはできません。

システム設定を問い合せるには、次のパッケージ・インポートが必要です。

import com.flashline.registry.openapi.entity.SettingValue;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.query.SystemSettingsCriteria;

予約済メソッド

systemSettingsAddBundleメソッドは、今後の使用のために予約されています。一般的な用途向けではありません。

4.4.17.2 ユースケース: システム設定の問合せ

説明

REXでシステム設定を問い合せます。

サンプル・コード

例4-73 ユースケース: システム設定の問合せ

package com.flashline.sample.systemsettingsapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.SettingValue;
import com.flashline.registry.openapi.query.SystemSettingsCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class SystemSettings {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      // //////////////////////////////
      // Set Application Token on AuthToken object.  This is supplied by OER
      //authToken.setApplicationToken("TokenString");
      // //////////////////////////////////////
      //Read all available system settings
      //Create an empty Criteria object.  No criteria returns all settings.
      SystemSettingsCriteria lCriteria = new SystemSettingsCriteria();
      lCriteria.setNameCriteria("enterprise.defaults.displayname.field");
      SettingValue[] lValues = repository.systemSettingsQuery(authToken,
 lCriteria);
      for (int i=0;i<lValues.length;i++) {
        SettingValue lValue = lValues[i];
        System.out.println("Setting Name: " + lValue.getDescriptor().getName());
        System.out.println("Setting Value: " + lValue.getValue());
      }
      // /////////////////////////////////////
      //Read a specific setting
      lCriteria.setNameCriteria("cmee.server.companyname");
      lValues = repository.systemSettingsQuery(authToken, lCriteria);
      for (int i=0;i<lValues.length;i++) {
        SettingValue lValue = lValues[i];
        System.out.println("Setting Name: " + lValue.getDescriptor().getName());
        System.out.println("Setting Value: " + lValue.getValue());
      }
      // /////////////////////////////////////
      //Read a specific section
      lCriteria.setSectionCriteria("general");
      lValues = repository.systemSettingsQuery(authToken, lCriteria);
      for (int i=0;i<lValues.length;i++) {
        SettingValue lValue = lValues[i];
        System.out.println("Setting Name: " + lValue.getDescriptor().getName());
        System.out.println("Setting Value: " + lValue.getValue());
      }
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.18 ユーザーAPI

この項では、ユーザーAPIのユースケースについて説明します。このユースケースで、ユーザーの作成、取得、更新および非アクティブ化を行う方法、またはユーザーについて問い合せる方法について解説します。

4.4.18.1 概要

ユーザー・サブシステムは、Oracle Enterprise Repositoryのユーザー・アカウントの作成、読込み、更新、問合せまたは操作に使用する、Webサービス・ベースのメカニズムを提供します。

関連するサブシステム

詳細は、4.4.15項「ロールAPI」を参照してください。

追加で必要なインポート

import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.UserCriteria;

4.4.18.2 ユースケース: ユーザーの操作

説明

  • 新規ユーザーを作成します。

  • 既存のユーザーを取得します。

  • ユーザーを更新します。

  • ユーザーを非アクティブ化します。

  • ユーザーについて問い合せます。

サンプル・コード

例4-74 ユースケース: ユーザーの操作

package com.flashline.sample.userapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.UserCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Users {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------------
      // Create a new user
      String lUserName = "testUserCreate
_"+Calendar.getInstance().getTimeInMillis();
      String lFirstName = "testUserCreate_FirstName";
      String lLastName = "testUserCreate_LastName";
      String lEmail = lUserName+"@example.com";
      String lPassword = "testUserCreate_Password";
      boolean lMustChangePassword = false;
      boolean lPasswordNeverExpires = false;
      boolean lAssignDefafultRoles = true;
      RegistryUser RbacRegistrySecUser = repository.userCreate(
          authToken, lUserName, lFirstName, lLastName, lEmail, lPassword,
          lMustChangePassword, lPasswordNeverExpires, lAssignDefafultRoles);
      // -----------------------------------------
      // Read a User
      long lId = 50000; // user id must exist in OER
      RegistryUser lUser1 = repository.userRead(authToken,
          lId);
      // -----------------------------------------
      // Update a User
      lUser1.setActiveStatus(10);
      lUser1.setUserName("xxx");
      lUser1.setPhoneNumber("412-521-4914");
      lUser1.setMustChangePassword(true);
      lUser1.setPasswordNeverExpires(false);
      lUser1.setPassword("changed_password");
      lUser1.setEmail("newaddress@bea.com");
      try {
        lUser1 = repository.userUpdate(authToken,
            lUser1);
      } catch (OpenAPIException e) {
        e.printStackTrace();
      }
      // -----------------------------------------
      // Deactivate a User
      RegistryUser lUser2 = null;
      try {
        lUser2 = repository.userDeactivate(authToken, lId);
      } catch (OpenAPIException e) {
        e.printStackTrace();
      }
      // -----------------------------------------
      // Query for Users
      RegistryUser lUsers[] = null;
      UserCriteria lUserCriteria = null;
      lUserCriteria = new UserCriteria();
      lUserCriteria.setNameCriteria("testname");
      lUsers = repository.userQuery(authToken,
          lUserCriteria);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}

4.4.19 ベンダーAPI

この項では、ベンダーAPIのユースケースについて説明します。このユースケースで、Oracle Enterprise Repositoryにおいてベンダーの追加または割当てを行う方法について解説します。

4.4.19.1 概要

ベンダーはアセットの元のソースであり、アセットをサポートします。ベンダーは、単一の名前の文字列で識別されます。

検証: ベンダーを保存する場合、Oracle Enterprise Repositoryは、現在、次の内容を検証します。

  • ベンダー名は、250文字未満にする必要があります。

  • ベンダー名は一意です。

関連するサブシステム

アセットとベンダー間には1対多の関係があります(たとえば、複数のアセットは同じベンダーにリンクできますが、1つのアセットは1つのベンダーしか持つことができません)。アセットを作成または編集する場合、ベンダーをアセットに関連付けるベンダーIDメタデータ要素を変更できます。

追加で必要なインポート

import com.flashline.registry.openapi.entity.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;

4.4.19.2 ユースケース: ベンダーの操作

説明

  • 新しいベンダーをOracle Enterprise Repositoryに追加します。

  • 既存のベンダーをアセットに割り当てます。

サンプル・コード

例4-75 ユースケース: ベンダーの追加または割当て

package com.flashline.sample.vendorapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.Asset;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.Vendor;
import com.flashline.registry.openapi.query.VendorCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Vendors {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new
 FlashlineRegistryServiceLocator().getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],pArgs[2]);
      // -----------------------------------------
      // Create a new vendor
      String newVendorName = "My Vendor";
      Vendor newVendor = repository.vendorCreate(authToken, newVendorName);
      System.out.println("The new vendor id =\"" + newVendor.getID() + "\"");
      // -----------------------------------------
      // Find a vendor and update an asset to use it
      VendorCriteria criteria = new VendorCriteria();
      criteria.setNameCriteria(newVendorName);
      Vendor[] vendors = repository.vendorQuery(authToken, criteria);
      long myVendorID = vendors[0].getID();
      long MY_ASSET_ID = 569;
      Asset myAsset = repository.assetRead(authToken, MY_ASSET_ID);
      // MY_ASSET_ID must be the asset id of an asset in the repository
      myAsset.setVendorID(myVendorID);
      repository.assetUpdate(authToken, myAsset);
      // ----------------------------------------
      // clean up
      myAsset.setVendorID(0);
      repository.vendorDelete(authToken, newVendor.getID());
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}