Windchill のその他の機能 > サービス情報管理 > Customizing Windchill Service Information Manager and Windchill Service Parts > 受け取った翻訳済みコンテンツを検証するカスタムフック
  
受け取った翻訳済みコンテンツを検証するカスタムフック
CustomXMLValidationHook では、翻訳ベンダーから XML ファイルとして受け取った翻訳済みコンテンツを Service Information Manager にインポートする前に検証できます。検証に成功した場合、インポートプロセスが続行します。検証で例外が生成された場合、インポートプロセスは失敗し、その例外に関する情報がインポート失敗ログファイルに追加されます。翻訳パッケージに含まれている一部のファイルは CustomXMLValidationHook の検証に合格した場合でも、例外が生成されるだけでなく、その翻訳パッケージのコンテンツはインポートされません。
このフックを実装するには、以下の詳細を指定する必要があります。
「翻訳パッケージをインポート」プロセスを失敗と見なすタイミングを指定します (XML 検証の最初の失敗時または XML 検証の最後の失敗後)。
インポートログファイルに記録する、XML 検証に失敗したファイルに関するエラーメッセージを設定します。
「翻訳パッケージをインポート」プロセスで、XML ファイルのコンテンツが壊れていないか翻訳済みパッケージがチェックされた後、翻訳済みコンテンツがチェックインされる前に、CustomXMLValidationHook の検証が行われます。
インタフェース
package com.ptc.tml.validation;
import java.io.InputStream;
/**The interface provides the custom XML validation service for the translation *contents. The interface receives the file name and input stream of the file which is to be validated for the XML and need to throw the exception to indicate the XML validation
*failure for given file. The implementation must state whether the Import Translation Process should fail if the first XML validation failure has *encountered or after the last XML validation failure. The implementation also needs to populate the error message
*for failed XML validation for logging purpose.
*/
public interface CustomXMLValidationHook {
/**
* @return boolean Boolean value to indicate whether the translation process should be failed when the first XML validation failure is encountered
*/
public boolean failOnFirstError();
/**
* @param fileName Name of file in the translation zip to validated for XML
* @param is InputStream of the file to be validated for XML
* @throws TranslationException
*/
public void validateXML (String fileName, InputStream is) throws TranslationException;
/**
* @return Error message to be logged for XML validation failures
*/
public String getErrorMessage();
}
参照用に提供されているサンプルの実装 SampleCustomXMLValidationFailFastHookImpl.java および SampleCustomXMLValidationHookImpl.java も参照してください。これらは $WT_HOME\codebase\com\ptc\tml\sample にあります。
レジストリ
1. xconfmanager ユーティリティを使用して translation.service.properties.xconf を編集します。<Windchill>/codebase/com/ptc/core/components にある components.service.properties ファイルでこれを登録することもできます。xconfmanager ユーティリティの使用方法については、xconfmanager ユーティリティについてを参照してください。
2. 次のプロパティを追加します。
<Service context="default"
name="com.ptc.tml.validation.CustomXMLValidationHook">
<Option serviceClass="YourCustomXMLValidationHookClassName"
selector="null"/>
</Service>
3. ファイルを保存します。
4. xconfmanager ユーティリティを使用して変更を適用します。<Windchill>\bin ディレクトリで、以下のコマンドを入力します。
xconfmanager -pF
5. メソッドサーバーを再起動します。