Displaying Oracle Documents Cloud Services File Picker and Link Picker from other Domains

Introduction

The Oracle Documents File Picker and Link Picker allow web applications to select files and folders that reside in the Oracle Documents Cloud Service. These Pickers can start from a specific folder and can further be restricted to a folder structure for a specific user and role when combined with the Oracle Documents App Link. Some of these integration calls are made from external domains therefore this embedded content transfer needs to be properly allowed and configured.

Main Article

The FilePicker tutorial allows the user to choose a List or a Grid Layout and the Sort Order. Some options include the ability to select a single item, to select folders only, to select files only, and to allow the upload of new files as shown below:

File Picker Tutorial

 

Most applications run on a different domain from that where the Oracle Documents Cloud Service (DOCS) instance is running. Therefore an additional configuration step is required to embed a DOCS web user inline frame interface:

  1. 1) Goto the Administration page on the source DOCS instance (http://hostname:port/documents/admin)
  2. 2) Goto the System-wide Settings tab
  3. 3) Goto the Embedded Content section and select YES
  4. 4) Add the target domain and the CAPTCHA/SafeMode options

Further information is available in the document “Administering Oracle Documents Cloud Service” – section: “Displaying Content from Other Domains” in the link below:
http://docs.oracle.com/cloud/latest/documentcs_welcome/WCCCA/GUID-6511347B-87ED-43D9-A183-BBD91E9E17C8.htm#WCCCA-GUID-6511347B-87ED-43D9-A183-BBD91E9E17C8
The example below shows a Java Cloud Service (JCS) application invoking the DOCS File Picker from a different domain.

First of all, the domain where the app is going to be invoking the File Picker needs to be added to the list of allowed domains:

File Picker Embedded Content YES

Note that CAPTCHA was enabled for the invoking domain. This will challenge users to perform a simple visual test. Therefore preventing automated scripts from reaching out to the DOCS instance.

A simple application was created to call the DOCS File Picker from an HTML page. This application was deployed in JDeveloper so that the EAR file could be deployed in the Java Cloud Service.

File Picker App in JDeveloper

The application was deployed successfully in JCS:

File Picker App deployed in JCS

When running the App, the below simple visual challenge is issued since CAPTCHA was enabled for this target domain:

File Picker CAPTCHA

Note the two different domains from the application running on JCS and from the DOCS instance:

File Picker App running on JCS

After select the item to be picked, DOCS returns a JSON with data corresponding to the selection made:

File Picker returns data

The preClick mechanism allows options to be passed to the createFilePickerButton. For example the ID of the initial folder may not be available until page load. The File or Line Picker could create a button or a custom one could be used. Using the
pre-configured button from DOCS is simpler but may not match UI requirements and a custom button would be desired.

function onPreClick(options) {
	
	var foldId = //Application logic to obtain folder id  
	option.id = getFolderId();
};

function onOk(selection) {
	//Do something with the selection 	
};
	
window.onload=function() {	
	options = {
	   preClick : onPreClick,
	   ok : onOk,
	   id: ""  // Id not yet known  
	};

	var button = OracleDCS.createFilePickerButton(options);
	document.getElementById("button-container").appendChild(button);		
};

Both the File and Link Picker could be used in combination with AppLink to restrict access to a folder structure for a specified user and role. The Picker would need an appLinkID, an accessToken, and a refreshToken. These are returned by the createAppLink service.

function onOk(selection) {
	//Do something with the selection 	
};
	
window.onload=function() {	

	//Call application logic to get AppLink target folder id
	var appLinkFolderId = getFolderId(); 

	//Application logic to invoke create folder AppLink service with folder id
	var createApplink = createAppLink(appLinkFolderId);

	options = {
		ok: onOk,
		id:appLinkFolderId;
		appLinkId: createApplink.appLinkID,
		appLinkAccessToken: createApplink.accessToken,
		appLinkRefreshToken: createApplink.refreshToken
	};

	var button = OracleDCS.createFilePickerButton(options);
	document.getElementById("button-container").appendChild(button);		
};

The source for the above code is available at the Picker Tutorials:
http://hostname:port/documents/static/api/FilePickerTutorial.html
http://hostname:port/documents/static/api/LinkPickerTutorial.html
The hostname and port variables identify the Oracle Documents Cloud Service instance.

In summary, invoking domains need to be added to the list of allowed domains in the Embedded Content DOCS Administration section. If not present, the application would remain at the File Picker screen. It will not proceed with any action when clicking OK until the File/Link Picker section was cancelled and closed. The simple JDeveloper application called DOCS File Picker. However, the sample principles apply for the case of Link Picker.

 

Add Your Comment