新規翻訳コネクタの作成
新しい翻訳コネクタをRESTfulサービスとして構築するには、開発者は、コネクタ・フレームワークによって提供されるRESTfulインタフェースを実装する必要があります。
Oracle Content Managementクラウド・コネクタ・フレームワークには次のインタフェースがあります:
- APIResourceインタフェース: このインタフェースは、翻訳コネクタの開始ポイントです。 サポートされているバージョンのみを返します。
- ServerResourceインタフェース: 管理者または開発者がOracle Content Management (OCM)サーバーに翻訳コネクタを登録すると、OCMはこのサービスをコールして、変換コネクタの認可タイプ、カスタム・フィールド、プロパティなど、コネクタ・サーバーに関する基本的な詳細を取得します:
- 承認タイプ:
-
OAUTH_CLIENT_CREDENTIALS: 翻訳コネクタは、クライアント資格証明(2脚のOAuth)をサポートしています。
Identity Cloud Store (IDCS) (2-Legged OAuth)の「クライアント資格証明」を使用して言語サービス・プロバイダにアクセスするには、クライアント・アプリケーションにトークンがリクエストされ、言語サービス・プロバイダAPIへのコールはこのクライアント・アプリケーションのトークンを使用して行われます。 コネクタは、トークンを取得するために必要なカスタム・フィールド(
Client ID、Client Secret、Scopeなど)を宣言します。 また、フィールドIDがaccessTokenのカスタム・フィールドを宣言する必要があります。 コネクタに対するすべてのリクエストには、リクエスト・ヘッダーにこれらのカスタム・フィールドが含まれます。 新しいコネクタ・インスタンスでは、accessTokenフィールドの値は空です。 コネクタは、Client ID、Client Secret、Scopeなどの他のカスタム・フィールドの値を含むアクセス・トークンを取得する必要があります。 アクセス・トークンを取得したら、レスポンス・ヘッダーに値を設定する必要があります。 OCMコネクタ・フレームワークは、レスポンス・ヘッダーにaccessToken値を保存します。 コネクタに対する後続のリクエストは、accessTokenを受信します。2-legged OAuthフローで生成されたアクセス・トークンを取り消すには、左側のナビゲーション・パネルから「統合」を選択し、ドロップダウン・メニューで「変換コネクタ」を選択します。 翻訳コネクタに対応するチェック・ボックスを選択し、「アクセス・トークンの取消」ボタンをクリックします。
ノート:
「アクセス・トークンの取消」ボタンが表示されるのは、コネクタに対応するチェック・ボックスを選択し、コネクタのタイプがOAUTH_CLIENT_CREDENTIALSの場合のみです。 そうしないと、「アクセス・トークンの取消」ボタンは表示されません。 - NO_AUTH: 翻訳コネクタは、カスタム・フィールドを使用して、認証に
Bearer tokenなどのフィールドを指定します。
-
- カスタム・フィールドおよびプロパティ: このインタフェースを使用して、翻訳コネクタのカスタム・フィールドを定義することもできます。 カスタム・プロパティはコネクタに固有であるため、コネクタ・フレームワークではそのようなプロパティ・リストを単独で提供できません。 すべての翻訳コネクタには、リモート・ストアに接続するための独自の要件があります。たとえば、ある翻訳コネクタには
Client IDとClient Secretのみが必要で、別の翻訳コネクタにはClient ID,Client Secret,App IDなどが必要になる場合があります。 各翻訳コネクタは、ServerResourceによってOracle Content Managementサーバーにカスタム・プロパティ・リストを提供できます。 これらのプロパティを構成中に管理者が入力する必要がある場合は、コネクタ・フレームワークによって管理webインタフェースに表示され、翻訳コネクタへの各リクエストのヘッダー・パラメータとして渡すことができます。
このサービスは、登録時に一度だけ呼び出されます。
- 承認タイプ:
- TranslationResourceインタフェース: コネクタ・フレームワークはこのサービスを使用して、Oracle Content Management翻訳ジョブを翻訳コネクタに送信します。 その後、翻訳コネクタは言語サービス・プロバイダをコールして翻訳し、ジョブに指定されたZipファイルを呼び出して、翻訳済zipを返します。
これらの各インタフェースの詳細は、RESTペイロードの例とともに、次のセクションで説明します:
構成および承認用のRESTインタフェース
翻訳コネクタには、コネクタ構成を定義して認可を設定するために、次のREST APIを実装する必要があります。
/rest/api
Implements intradoc.connectorcommon.server.APIResource
Here you return the latest version supported by the content connector.
GET http://host:port/connector/rest/api
[ "v1"]
/rest/api/v1/server
Implements intradoc.connectorcommon.server.ServerResource
これにより、公開される認証タイプやカスタム・フィールドなど、翻訳コネクタ構成に関する情報が戻されます。
GET http://host:port/connector/rest/api/v1/server
{
"name": "",
"nameLocalizations": [{
"locale": "en_US",
"localizedString": "Sample Connector"
}],
"version": "(1,0,0)",
"about": "This is a sample connector.Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.",
"aboutLocalizations": [{
"locale": "en_US",
"localizedString": "This is a sample connector.Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved."
}],
"authenticationType": "NO_AUTH",
"pickerType": "",
"enableMultiUserCopyBack": false,
"maxUploadSize": 1073741824,
"fields": [{
"ID": "ProxyHost",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "HTTP Proxy Hostname",
"labelLocalizations": [{
"locale": "en",
"localizedString": "HTTP Proxy Hostname"
}],
"description": "The HTTP proxy hostname, leave blank to disable.",
"descriptionLocalizations": [{
"locale": "en",
"localizedString": "The HTTP proxy hostname, leave blank to disable."
}],
"required": false
}, {
"ID": "ProxyPort",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "HTTP Proxy Port",
"labelLocalizations": [{
"locale": "en",
"localizedString": "HTTP Proxy Port"
}],
"description": "The HTTP proxy port number, leave blank to default to port 80.",
"descriptionLocalizations": [{
"locale": "en",
"localizedString": "The HTTP proxy port number, leave blank to default to port 80."
}],
"required": false
}, {
"ID": "ProxyScheme",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "HTTP Proxy Scheme",
"labelLocalizations": [{
"locale": "en",
"localizedString": "HTTP Proxy Scheme"
}],
"description": "The HTTP proxy scheme, leave blank to default to http.",
"descriptionLocalizations": [{
"locale": "en",
"localizedString": "The HTTP proxy scheme, leave blank to default to http."
}],
"required": false
}, {
"ID": "BearerToken",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Bearer Token",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Bearer Token"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
}, {
"ID": "WorkflowId",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Workflow Id",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Bearer Token"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
}],
"supportedConnectorTypes": [],
"proprietorName": "",
"serviceProviderName": "Sample APIs INC.",
"nativeAppInfos": null
},
/rest/api/v1/authorization/authorizationURLs
Implements intradoc.connectorcommon.server.AuthorizationResourceこれは、カスタム翻訳UIを構成する場合にのみ必要です。 Oracle Content Managementのカスタム翻訳コネクタのフィールドに新しいフィールド「翻訳ジョブ・エディタ」が追加されます。
{
"ID": "CustomTranslationUI_name",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Custom Translation UI",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Custom Translation UI"
}],
"description": null,
"descriptionLocalizations": [],
"required": false
},
{
"ID": "CustomTranslationUI_id",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Translation Job Editor",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Custom Translation UI Id"
}],
"description": null,
"descriptionLocalizations": [],
"required": false
},window.translationEditorSDK: {
properties = {
"connector": {
"jobId": "string returned by the connector for the ID of the job",
"title": "string for the name of the job"
},
"translationJob": {
"type": ['assets' | 'sites']
"data": "object providing additional information about the selected items based on job type"
},
"componentName": "string for the name of the translation editor component",
"locale": "string for the locale of the page"
}
}
これは、翻訳コネクタがOAUTH_CLIENT_CREDENTIALSをサポートしている場合にのみ必要です。 アクセス・トークンおよび必須のaccessTokenフィールドを取得するためのカスタム・フィールドを追加します。
{
"ID": "ClientID",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "ClientID",
"labelLocalizations": [{
"locale": "en",
"localizedString": "ClientID"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
},
{
"ID": "ClientSecret",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "ClientSecret",
"labelLocalizations": [{
"locale": "en",
"localizedString": "ClientSecret"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
},
{
"ID": "Scope",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Scope",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Scope"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
},
{
"ID": "accessToken",
"datatype": "STRING",
"siteSettable": false,
"userSettable": false,
"connectorSettable": true,
"authorizationURLParameter": false,
"label": "null",
"labelLocalizations": [{
"locale": "en",
"localizedString": null
}],
"description": null,
"descriptionLocalizations": [],
"required": false
}
これは、翻訳コネクタが「追加データ」フィールドをサポートする場合に必要です。
"addtionalSettings": {
"AdditionalDataFields": [
{
"id": "business_division",
"name": "Business Division",
"type": "String"
},
{
"id": "email",
"name": "Email",
"type": "String"
},
{
"id": "purchase_order",
"name": "Purchase Order",
"type": "String"
},
{
"id": "finish_by",
"name": "Finish By",
"type": "Date"
}
]
}
"fields": [{
<<Other data>>
{
"ID": "AdditionalData",
"datatype": "STRING",
"siteSettable": true,
"userSettable": false,
"connectorSettable": false,
"authorizationURLParameter": false,
"label": "Additional Data",
"labelLocalizations": [{
"locale": "en",
"localizedString": "Additional Data"
}],
"description": null,
"descriptionLocalizations": [],
"required": true
},
}
<<Other fields>>
]
翻訳ジョブを作成して翻訳済コンテンツを戻すRESTインタフェース
翻訳コネクタでは、翻訳ジョブを作成し、コネクタ翻訳ジョブのステータスを提供し、各翻訳ジョブ結果を返すために、次のREST APIを実装する必要があります。
/rest/api/v1/job
Implements intradoc.connectorcommon.server.TranslationJobResource
Given an OCE Translation Job ID, create and return a connector project ID for the translation job.
POST http://host:port/connector/rest/api/v1/job
Request Headers
X-CEC-ClientID:client-id
X-CEC-ProxyHost:proxy-host
X-CEC-ProxyPort:80
X-CEC-ProxyScheme:http
X-CEC-TranslationJob:translation-job-name
Request Body
{Zipfilecontent}
Response Headers
content-type application/zip
content-length {zip file size}
Response Body
{
"properties": {
"status": "IMPORTING",
"id": "{{connectorJobId}}"
}
}
/rest/api/v1/job/{id}/translation
Implements intradoc.connectorcommon.server.TranslationJobResource
Given a connector job id, return the translated zip file.
GET http://host:port/connector/rest/api/v1/job/{id}/translation
Request Headers
X-CEC-ClientID:client-id
X-CEC-ProxyHost:proxy-host
X-CEC-ProxyPort:80
X-CEC-ProxyScheme:http
X-CEC-TranslationConnectorJobId:connector-job-id
Request Body
Response Headers
content-type application/zip
content-size {zip file size}
Response Body
{streamed zip file}
/rest/api/v1/job/{id}
Implements intradoc.connectorcommon.server.TranslationJobResource
Given a connector job id, delete the connector job from the connector.
DELETE http://host:port/connector/rest/api/v1/job/{id}
Request Headers
X-CEC-ClientID:client-id
X-CEC-ProxyHost:proxy-host
X-CEC-ProxyPort:80
X-CEC-ProxyScheme:http
X-CEC-TranslationConnectorJobId:connector-job-id
Request Body
Response Headers
content-type application/json
Response Body
{Message noting successful deletion}