SpagoBI SDK 3.5.1 User Guide

SpagoBI SDK 3.5.1 User Guide

1 Introduction

SpagoBI SDK 3.5.1 is a collection of web services, tags and javascript API that permit other applications to interact with a SpagoBI Server 3.5.1 installation. It is very similar to SpagoBI SDK 2.3, the main new feature is the Import functionality through web services.

2 The import functionality

Using this functionality you can import some SpagoBI documents programmatically. It handles an export file produced using the SpagoBI Export tool provided by SpagoBI Server, i.e. you have first of all to export some documents from a SpagoBI instance using the standard web administration interface, then you have to pass this export file to your SpagoBI SDK - based application, in order to let it import those documents into another SpagoBI Server instance. Optionally it handles also an associations file: this file contains associations between incoming roles and existing roles, incoming engines and existing engines, incoming datasources and existing datasources; it must be obtained by an import operation using the standard Import tool provided by SpagoBI Server; in case the associations file is not provided, associations between roles, engines and datasources are created automatically matching items with the same identifier (as the standard web import procedure works).

The ImportExportSDKService interface is:

package it.eng.spagobi.sdk.importexport;

import it.eng.spagobi.sdk.exceptions.NotAllowedOperationException;

public interface ImportExportSDKService {
	SDKFile importDocuments(SDKFile importExportFile, SDKFile associationsFile, boolean override) throws NotAllowedOperationException;

2.1 importDocuments(SDKFile importExportFile, SDKFile associationsFile, boolean override) method

This method takes in input the export file (obtained using the Export administration tool on SpagoBI Server web interface), the associations file (optional) and a boolean flag for overriding or not existing documents; it return a file containing information about the imported items (the same log file you obtain when you import documents using the Import administration tool on SpagoBI Server web interface). A NotAllowedOperationException is thrown is the specified user is not enabled to use the import functionality (i.e. the user must be a SpagoBI administrator, since other users haven't privileges to import documents).
Here below you find an usage example.

String user = "biadmin"; // an administration user is needed for this operation
String pwd = "biadmin";
ImportExportSDKServiceProxy proxy = new ImportExportSDKServiceProxy(user, pwd);
SDKFile response = null;

String workingFolder = "/home/spagobi/temp/";
String exportFileName = "";
String associationsFileName = "associations.xml";

// defines the export SDKFile using the export file produced by Export administration web interface
FileDataSource exportFileDataSource = new FileDataSource(workingFolder + exportFileName);
DataHandler exportFileDataHandler = new DataHandler(exportFileDataSource);			
SDKFile exportSDKFile = new SDKFile();

// defines the associations SDKFile using the associations file produced by a previous import operated by the Import administration web interface
// this is not mandatory: in case it is not specified, associations will be performed automatically by items' identifiers
FileDataSource associationsFileDataSource = new FileDataSource(workingFolder + associationsFileName);
DataHandler associationsFileDataHandler = new DataHandler(associationsFileDataSource);			
SDKFile associationsSDKFile = new SDKFile();

try {
	response = proxy.importDocuments(exportSDKFile, associationsSDKFile, true);
} catch (RemoteException e) {

writeResponseFile(response); // writes the response file somewhere...
Created by Davide Zerbetto on 2012/08/22 16:43
Last modified by Davide Zerbetto on 2012/08/22 17:34

This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 2.7.33694 - Documentation