com.jaspersoft.jasperserver.util
Class ExportResource

java.lang.Object
  extended by com.jaspersoft.jasperserver.util.ExportResource

public class ExportResource
extends java.lang.Object

This module handles the exporting of metadata from the JasperServer repository to an XML file. This XML file and the binary data that is written to disk is used to import to a target repository. Users can specify which resources in the repository are desired for export. For example, this can be a FileResource (such as an image, jrxml, etc), a ReportUnit, a DataSource, a Folder, etc. If the exported resource is a folder, all of the files and folders will be recursively exported. The attributes of the resource are written to a "bean" representation class. This class is processed (unmarshalled) by the Castor library to turn it directly into XML. This process is very straightforward for an object such as a DataSource which does not contain any binary information. However, for a FileResource such as an image, a jar, or even a JRXML, this module must manage the writing out of this binary (or in the case of JRXML, text data) information to disk in order to save it. Binary data is written out to disk and saved under a folder/directory structure that matches the repository URI structure specified by the uriString member variable for each resource. A typical export structure would look like the following: ji-catalog/ji-catalog.xml - xml file describing all exported resources /dir1/dir2/myImage - data on disk /dir1/dir2/myJrxml - data on disk /dir1/dir2/myClassJar - data on disk There is a heirarchy of bean objects that can hold each of the exported resources. The highest level bean object is ExportImportBean.


Field Summary
static java.lang.String CATALOG_DIR_NAME
           
static java.lang.String CATALOG_FILE_NAME
           
static boolean NOT_TOP_LEVEL_OBJECT
           
static java.lang.String PATH_SEP
           
static java.lang.String PRODUCT_VERSION
           
static java.lang.String PRODUCT_VERSION_0_9_2
           
static java.lang.String PRODUCT_VERSION_1_0
           
static java.lang.String PRODUCT_VERSION_1_1_0
           
static boolean TOP_LEVEL_OBJECT
           
 
Constructor Summary
ExportResource(RepositoryService repo, UserAuthorityService userAuthService, ReportSchedulingService reportSchedulingService, ExecutionContext context, java.lang.String startUri, boolean processUsersRoles, java.lang.String[] userNames, java.lang.String[] roleNames, boolean processReportJobs, java.lang.String[] reportJobUnitNames, java.lang.String catalogDirName, java.lang.String catalogFileName)
           
ExportResource(RepositoryService repo, UserAuthorityService userAuthService, ReportSchedulingService reportSchedulingService, ExecutionContext context, java.lang.String startUri, boolean processUsersRoles, java.lang.String[] userNames, java.lang.String[] roleNames, boolean processReportJobs, java.lang.String[] reportJobUnitNames, java.lang.String catalogDirName, java.lang.String catalogFileName, java.lang.String characterEncoding)
          Constructor
 
Method Summary
protected  void checkForProcessing()
           
protected  void checkForUserRoleProcessing()
          Determine the processing operations for Users and Roles.
protected  java.io.File createParentPath(ResourceBean bean)
          Create a path on disk.
 Resource dereference(ExecutionContext mContext, ResourceReference ref)
           
protected  void fillBean(ContentResourceBean bean, ContentResource contentResource)
           
protected  void fillBean(DataTypeBean bean, DataType dt)
           
protected  void fillBean(FileResourceBean bean, FileResource fileResource)
           
protected  void fillBean(InputControlBean bean, InputControl ic)
           
protected  void fillBean(JdbcDataSourceBean bean, JdbcReportDataSource dataSource)
           
protected  void fillBean(JndiJdbcDataSourceBean bean, JndiJdbcReportDataSource dataSource)
           
protected  void fillBean(ListOfValuesBean bean, ListOfValues listOfValues)
           
protected  void fillBean(MondrianConnectionBean bean, MondrianConnection conn)
           
protected  void fillBean(MondrianXmlaDefinitionBean bean, MondrianXMLADefinition xDef)
           
protected  void fillBean(OlapUnitBean bean, OlapUnit unit)
           
protected  void fillBean(QueryBean bean, Query query)
           
protected  void fillBean(XmlaConnectionBean bean, XMLAConnection conn)
           
protected  void fillCommonBeanFields(ResourceBean bean, Resource res)
          Set the member vars found in the ResourceBean
protected  RoleBean[] getRolesFromUser(User user)
           
protected  UserBean[] getUsersFromRole(RoleBean[] exportRoleBeans)
           
protected  InputControlBean[] handleInputControls(ReportUnit unit, boolean isTopLevel)
           
protected  ResourceBean[] handleResourcesInFolder(Folder folder)
           
 RoleBean[] handleRoles(java.lang.String[] rolenames, boolean isTopLevel)
           
protected  FolderBean[] handleSubFolders(Folder topFolder)
           
 UserBean[] handleUsers(java.lang.String[] usernames, boolean isTopLevel)
           
static void main(java.lang.String[] args)
           
 void process()
           
 ContentResourceBean process(ContentResource contentResource, boolean isTopLevel)
           
 DataSourceBean process(DataSource dataSource, boolean isTopLevel)
           
 DataTypeBean process(DataType dataType, boolean isTopLevel)
           
 FileResourceBean process(FileResource fileResource, boolean isTopLevel)
           
 FolderBean process(Folder topFolder, boolean isTopLevel)
           
 InputControlBean process(InputControl inputControl, boolean isTopLevel)
           
 JdbcDataSourceBean process(JdbcReportDataSource dataSource, boolean isTopLevel)
           
 JndiJdbcDataSourceBean process(JndiJdbcReportDataSource dataSource, boolean isTopLevel)
           
 ListOfValuesBean process(ListOfValues listOfValues, boolean isTopLevel)
           
 MondrianConnectionBean process(MondrianConnection conn, boolean isTopLevel)
           
 MondrianXmlaDefinitionBean process(MondrianXMLADefinition xDef, boolean isTopLevel)
           
 OlapClientConnectionBean process(OlapClientConnection conn, boolean isTopLevel)
           
 OlapUnitBean process(OlapUnit unit, boolean isTopLevel)
           
 QueryBean process(Query query, boolean isTopLevel)
           
 ReportJobBean process(ReportJob job, boolean isTopLevel)
           
 ReportUnitBean process(ReportUnit reportUnit, boolean isTopLevel)
           
 XmlaConnectionBean process(XMLAConnection conn, boolean isTopLevel)
           
 UserRoleHolderBean processAllUsersRoles(boolean isTopLevel)
           
 void processFolder(Folder folder, FolderBean bean)
           
 UserRoleHolderBean processNamedRoles(java.lang.String[] rolenames, boolean isTopLevel)
          Processing of named roles is a bit different than similar processing for users.
 UserRoleHolderBean processNamedUsers(java.lang.String[] usernames, boolean isTopLevel)
           
 UserRoleHolderBean processNamedUsersRoles(java.lang.String[] usernames, java.lang.String[] rolenames, boolean isTopLevel)
           
 void processReportJobs(boolean isTopLevel)
          Main processing routine for Report Jobs (ie scheduled reports).
 void processUri()
          Main processing routine for all repository resources that inherit from the Resource interface (and are handled by the RepositoryService).
 void processUsersRoles()
          Main processing routine for Users and Roles.
protected  void writeCatalogData(ContentResourceBean bean)
           
protected  void writeCatalogData(FileResourceBean bean)
           
protected  void writeCatalogData(FolderBean bean)
           
protected  void writeCatalogData(MondrianXmlaDefinitionBean bean)
           
protected  void writeCatalogData(OlapClientConnectionBean bean)
           
protected  void writeCatalogData(OlapUnitBean bean)
           
protected  void writeCatalogData(ReportUnitBean bean)
           
protected  void writeCatalogDataFolder(FolderBean bean)
           
protected  void writeCatalogDataMainReport(FileResourceBean bean)
           
protected  void writeCatalogFile(ExportImportBean bean)
          Write out the ji-catalog xml file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEP

public static final java.lang.String PATH_SEP
See Also:
Constant Field Values

CATALOG_DIR_NAME

public static final java.lang.String CATALOG_DIR_NAME
See Also:
Constant Field Values

CATALOG_FILE_NAME

public static final java.lang.String CATALOG_FILE_NAME
See Also:
Constant Field Values

PRODUCT_VERSION_1_0

public static final java.lang.String PRODUCT_VERSION_1_0
See Also:
Constant Field Values

PRODUCT_VERSION_0_9_2

public static final java.lang.String PRODUCT_VERSION_0_9_2
See Also:
Constant Field Values

PRODUCT_VERSION_1_1_0

public static final java.lang.String PRODUCT_VERSION_1_1_0
See Also:
Constant Field Values

PRODUCT_VERSION

public static final java.lang.String PRODUCT_VERSION
See Also:
Constant Field Values

TOP_LEVEL_OBJECT

public static final boolean TOP_LEVEL_OBJECT
See Also:
Constant Field Values

NOT_TOP_LEVEL_OBJECT

public static final boolean NOT_TOP_LEVEL_OBJECT
See Also:
Constant Field Values
Constructor Detail

ExportResource

public ExportResource(RepositoryService repo,
                      UserAuthorityService userAuthService,
                      ReportSchedulingService reportSchedulingService,
                      ExecutionContext context,
                      java.lang.String startUri,
                      boolean processUsersRoles,
                      java.lang.String[] userNames,
                      java.lang.String[] roleNames,
                      boolean processReportJobs,
                      java.lang.String[] reportJobUnitNames,
                      java.lang.String catalogDirName,
                      java.lang.String catalogFileName)

ExportResource

public ExportResource(RepositoryService repo,
                      UserAuthorityService userAuthService,
                      ReportSchedulingService reportSchedulingService,
                      ExecutionContext context,
                      java.lang.String startUri,
                      boolean processUsersRoles,
                      java.lang.String[] userNames,
                      java.lang.String[] roleNames,
                      boolean processReportJobs,
                      java.lang.String[] reportJobUnitNames,
                      java.lang.String catalogDirName,
                      java.lang.String catalogFileName,
                      java.lang.String characterEncoding)
Constructor

Parameters:
repo -
userAuthService -
reportSchedulingService -
context -
startUri -
processUsersRoles -
userNames -
roleNames -
processReportJobs -
reportJobUnitNames -
catalogDirName -
catalogFile -
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

checkForProcessing

protected void checkForProcessing()

process

public void process()

processUri

public void processUri()
Main processing routine for all repository resources that inherit from the Resource interface (and are handled by the RepositoryService).


processUsersRoles

public void processUsersRoles()
Main processing routine for Users and Roles. Users and Roles are handled by the UserAuthorityService (not RepositoryService). They do not inherit from the Resource interface and do not have URIs associated with them. However, they are stored in the repository as are any JasperIntelligence objects. Processing of Users and Roles has four operations: 1) if usernames and rolenames are empty, get all users and roles in the system 2) if usernames array has values, export all of these names and keep information on any roles they reference 3) if rolenames array has values *and* usernames does not have values, export all of these roles and include all users that reference these roles (but don't include any additional roles that users reference) 4) if usernames and rolesnames has values then export the users and export the roles.


processReportJobs

public void processReportJobs(boolean isTopLevel)
Main processing routine for Report Jobs (ie scheduled reports). This routine processes all jobs for reportUris that are specified via a constructor parameter.


process

public FolderBean process(Folder topFolder,
                          boolean isTopLevel)

processFolder

public void processFolder(Folder folder,
                          FolderBean bean)

process

public FileResourceBean process(FileResource fileResource,
                                boolean isTopLevel)

process

public ContentResourceBean process(ContentResource contentResource,
                                   boolean isTopLevel)

process

public ReportUnitBean process(ReportUnit reportUnit,
                              boolean isTopLevel)

process

public OlapUnitBean process(OlapUnit unit,
                            boolean isTopLevel)

process

public OlapClientConnectionBean process(OlapClientConnection conn,
                                        boolean isTopLevel)

process

public XmlaConnectionBean process(XMLAConnection conn,
                                  boolean isTopLevel)

process

public MondrianConnectionBean process(MondrianConnection conn,
                                      boolean isTopLevel)

process

public MondrianXmlaDefinitionBean process(MondrianXMLADefinition xDef,
                                          boolean isTopLevel)

process

public DataSourceBean process(DataSource dataSource,
                              boolean isTopLevel)

process

public JdbcDataSourceBean process(JdbcReportDataSource dataSource,
                                  boolean isTopLevel)

process

public JndiJdbcDataSourceBean process(JndiJdbcReportDataSource dataSource,
                                      boolean isTopLevel)

process

public InputControlBean process(InputControl inputControl,
                                boolean isTopLevel)

process

public QueryBean process(Query query,
                         boolean isTopLevel)

process

public DataTypeBean process(DataType dataType,
                            boolean isTopLevel)

process

public ListOfValuesBean process(ListOfValues listOfValues,
                                boolean isTopLevel)

process

public ReportJobBean process(ReportJob job,
                             boolean isTopLevel)

processAllUsersRoles

public UserRoleHolderBean processAllUsersRoles(boolean isTopLevel)

processNamedUsers

public UserRoleHolderBean processNamedUsers(java.lang.String[] usernames,
                                            boolean isTopLevel)

processNamedRoles

public UserRoleHolderBean processNamedRoles(java.lang.String[] rolenames,
                                            boolean isTopLevel)
Processing of named roles is a bit different than similar processing for users. By default, if the user has included a list of roles to export, then we are also going to get the users that this role.

Parameters:
rolenames -
isTopLevel -
Returns:

processNamedUsersRoles

public UserRoleHolderBean processNamedUsersRoles(java.lang.String[] usernames,
                                                 java.lang.String[] rolenames,
                                                 boolean isTopLevel)

handleUsers

public UserBean[] handleUsers(java.lang.String[] usernames,
                              boolean isTopLevel)

handleRoles

public RoleBean[] handleRoles(java.lang.String[] rolenames,
                              boolean isTopLevel)

getRolesFromUser

protected RoleBean[] getRolesFromUser(User user)

getUsersFromRole

protected UserBean[] getUsersFromRole(RoleBean[] exportRoleBeans)

handleInputControls

protected InputControlBean[] handleInputControls(ReportUnit unit,
                                                 boolean isTopLevel)

handleSubFolders

protected FolderBean[] handleSubFolders(Folder topFolder)

handleResourcesInFolder

protected ResourceBean[] handleResourcesInFolder(Folder folder)

checkForUserRoleProcessing

protected void checkForUserRoleProcessing()
Determine the processing operations for Users and Roles. 1) if processAll, then export all users and all roles 2) if namedUsers, then export the users listed in the input parameter (usernames) (do not include any roles) 3) if namesdRoles, then export the roles listed in the input paramter (rolenames), *AND* include any users that are referenced by these roles. 4) if namedUserRoles, then export the users and roles listed in the two input parameters (usernames and rolenames).


writeCatalogFile

protected void writeCatalogFile(ExportImportBean bean)
Write out the ji-catalog xml file

Parameters:
bean -

writeCatalogData

protected void writeCatalogData(FolderBean bean)

writeCatalogDataFolder

protected void writeCatalogDataFolder(FolderBean bean)

writeCatalogData

protected void writeCatalogData(ReportUnitBean bean)

writeCatalogData

protected void writeCatalogData(OlapUnitBean bean)

writeCatalogData

protected void writeCatalogData(OlapClientConnectionBean bean)

writeCatalogData

protected void writeCatalogData(MondrianXmlaDefinitionBean bean)

writeCatalogDataMainReport

protected void writeCatalogDataMainReport(FileResourceBean bean)

writeCatalogData

protected void writeCatalogData(FileResourceBean bean)

writeCatalogData

protected void writeCatalogData(ContentResourceBean bean)

createParentPath

protected java.io.File createParentPath(ResourceBean bean)
Create a path on disk. This will be the path to the resource data to be written out. The on-disk path matches the path for the resource in the repository.

Parameters:
ResourceBean -
Returns:
File

dereference

public Resource dereference(ExecutionContext mContext,
                            ResourceReference ref)

fillCommonBeanFields

protected void fillCommonBeanFields(ResourceBean bean,
                                    Resource res)
Set the member vars found in the ResourceBean

Parameters:
uri -
Throws:
java.lang.Exception

fillBean

protected void fillBean(FileResourceBean bean,
                        FileResource fileResource)

fillBean

protected void fillBean(ContentResourceBean bean,
                        ContentResource contentResource)

fillBean

protected void fillBean(JdbcDataSourceBean bean,
                        JdbcReportDataSource dataSource)

fillBean

protected void fillBean(JndiJdbcDataSourceBean bean,
                        JndiJdbcReportDataSource dataSource)

fillBean

protected void fillBean(OlapUnitBean bean,
                        OlapUnit unit)

fillBean

protected void fillBean(XmlaConnectionBean bean,
                        XMLAConnection conn)

fillBean

protected void fillBean(MondrianConnectionBean bean,
                        MondrianConnection conn)

fillBean

protected void fillBean(MondrianXmlaDefinitionBean bean,
                        MondrianXMLADefinition xDef)

fillBean

protected void fillBean(InputControlBean bean,
                        InputControl ic)

fillBean

protected void fillBean(DataTypeBean bean,
                        DataType dt)

fillBean

protected void fillBean(ListOfValuesBean bean,
                        ListOfValues listOfValues)

fillBean

protected void fillBean(QueryBean bean,
                        Query query)


Copyright © 2007. All Rights Reserved.