Component: Portal Resources | Version: 7.+
Purpose of this article
Starting with version 7.0 and with all the following versions, more and more resources are available to a user with the Administrator profile to download from the Resources Menu in the Bonita Portal.
As the documentation explains, it's pretty straight forward, just select the resource that you want to export, and click on the Export button. You can't do simpler than that: https://documentation.bonitasoft.com/bonita/7.10/resource-management
However, even if the forms installed at the tenant level are available to download, the forms that are specific to a unique process and installed with your .bar aren't.
You may also want to retrieve the process .bar file itself, but this one isn't downloadable from the portal either.
And what about the bdm.zip deployed for your business data?
Well, in this article, I'll give you a few tips to retrieve some of these resources directly from your platform.
Two methods to export my process forms
1. Use the page download service in HTTP with the pageID (where YOUR_HOSTNAME is your hostname and YOUR_PORT is your port):
http://YOUR_HOSTNAME:YOUR_PORT/bonita/portal/pageDownload?id=pageID
You can get the page ID of your form by looking at the response of the request sent to API/portal/page when you display the process forms section.
2. Retrieve the file content with this Engine API call: https://documentation.bonitasoft.com/javadoc/api/7.10/org/bonitasoft/engine/api/PageAPI.html#getPageContent-long- byte[] getPageContent(long pageId) throws PageNotFoundException
The idea is to use this Engine API call to retrieve each form file content in turn and save the content in new zip files on the disk.
Export my process .bar
The bar file content can be retrieved with this Engine API call:
https://documentation.bonitasoft.com/javadoc/api/7.10/org/bonitasoft/engine/api/ProcessManagementAPI.html#exportBarProcessContentUnderHome-long- byte[] exportBarProcessContentUnderHome(long processDefinitionId) throws ProcessExportException
The idea is to use this Engine API call to retrieve each bar file content in turn and save the content in new bar files on the disk.
Here is a groorvy script example to show how to use this method:
import com.bonitasoft.engine.api.ProcessAPI; import org.bonitasoft.engine.bpm.process.ProcessExportException; import java.io.StringWriter; import java.io.PrintWriter; /** * MODIFY THE ARRAY */ long[] processDefinitionIds = [<proc_def_1>, <proc_def_2>, ...]; /** * END OF EDIT SECTION */ StringWriter strWriter = new StringWriter(); PrintWriter printer = new PrintWriter(strWriter); printer.println(Calendar.getInstance().getTime().toString()); ProcessAPI processAPI = (com.bonitasoft.engine.api.ProcessAPI) apiAccessor.getProcessAPI(); try { for (long processDefinitionId : processDefinitionIds) { try { String processName = processAPI.getProcessDefinition(processDefinitionId).getName(); String processVersion = processAPI.getProcessDefinition(processDefinitionId).getVersion(); String processBarFileName = processName + "_" + processVersion + ".bar"; byte[] processBar = null; printer.print("Export BAR for process: " + processName + " (version " + processVersion + ") - id: " + processDefinitionId); processBar = processAPI.exportBarProcessContentUnderHome(processDefinitionId); printer.println(" => Export OK"); printer.print("Write BAR file: " + processBarFileName); def os = new File("/tmp", processBarFileName).newOutputStream(); os.bytes = processBar; os.close(); printer.println(" => Write file OK"); } catch (ProcessExportException pee) { printer.println(" => not found - " + pee.getMessage()); } } } catch (Exception e) { printer.println("\n########### KO - " + e.getMessage()); e.printStackTrace(printer); } String output = strWriter.toString(); strWriter.close(); printer.close(); return output;
Two methods to retrieve the BDM deployed in the engine
1. From the file system:
- Go to:
{JAVA_IO_TMP_DIRECTORY}/bonita_engine_{app_server_pid}@{hostname}/platform/classloaders/local/TENANT/{tenant_id}/engine-classloader{random_id}/BDR{random_id_2}.jar
- Note: JAVA_IO_TMP_DIRECTORY, by default, will vary depending on the application server used:
- Tomcat:
- Before 7.4.x:
{TOMCAT_HOME}/temp/
- 7.4.x and after:
{TOMCAT_HOME}/server/temp/
- Before 7.4.x:
- JBoss/Wildfly:
- Linux:
/tmp/
or/var/tmp/
- Windows: it will take the value of %TEMP% environment variable
- Linux:
- Tomcat:
- Unzip the file:
BDR{random_id_2}.jar
- You will retrieve the
bom.xml
, which is in fact the content of anybdm.zip
2. From the Database: (Warning: Querying the database directly should be done under the supervision of a Database administrator).
- Run one of the two following SQL queries in your engine's database:
- Retrieve and unzip the file:
client-bdm.zip
- You will find a
bom.zip
, which you can rename asbdm.zip
- Retrieve and unzip the file:
BDR.jar
- You will retrieve the
bom.xml
, which is in fact the content of anybdm.zip
SELECT content FROM tenant_resource WHERE (tenantid = <tenant_id> AND name = 'client-bdm.zip');
SELECT value_ FROM dependency WHERE (tenantid = <tenant_id> AND filename = 'BDR.jar');
That's it for now! Congrats, you have retrieved some hidden resources from your platform...