Export Config

DataWedge 14.1

EXPORT_CONFIG

The EXPORT_CONFIG API enables the export of DataWedge Profiles and Configuration settings file, allowing configuration settings to be saved for future import or to replicate DataWedge configurations on other devices.

A DataWedge Profile is a collection of settings that control how DataWedge interacts specific applications and devices. A DataWedge Config file may include multiple Profiles and encompass all other DataWedge settings, such as status (enabled/disabled), logging and various configurable parameters.

There are limitations for exporting DataWedge configurations to public folders:

  • Android File Access Restrictions (Scoped Storage): Apps cannot directly export files to public folders, such as /Documents, using the DataWedge Intent API. Android restricts app access to public directories unless the app is granted elevated permissions (MANAGE_EXTERNAL_STORAGE), which is not available to the custom app.
  • Exporting to Public Folders: Exporting configurations to public folders can only be performed through the DataWedge UI, which has elevated system-level permissions to bypass these restrictions.

Intent Behavior

EXPORT_CONFIG sends an intent to export DataWedge Profiles or Config file to a specified folder, which can be accessed for backup or transferred to other devices.

When EXPORT_CONFIG intent is invoked, the files are exported to the specified folder, each file name reflecting the type of configuration exported:

  • datawedge.db - Contains the current DataWedge configuration settings saved as a database file
  • dwprofile_<profilename>.db - Contains the individual DataWedge profile settings

Function Prototype

Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.EXPORT_CONFIG", <mainbundle>);

Parameters

ACTION [String]: "com.symbol.datawedge.api.ACTION"

EXTRA_DATA [String]: "com.symbol.datawedge.api.EXPORT_CONFIG"

BUNDLE: <mainbundle> (see parameters below)

Main Bundle

The main EXPORT_CONFIG bundle includes the following properties:

  • FOLDER_PATH [String]: Required folder path where the configuration file(s) is exported.
  • EXPORT_TYPE [String]: Specifies the file type exported: "PROFILE_CONFIG" for Profile or "FULL_CONFIG" for Config file.
  • PROFILE_NAME [String] (Optional): Name of the profile to be exported. Required only if EXPORT_TYPE is "PROFILE_CONFIG".

Result Bundle

After an EXPORT_CONFIG intent is sent, DataWedge broadcasts a result intent with the status (success or failure) of the export. Result info is returned as an ArrayList of bundles containing RESULT_CODE and RESULT_CODE_INFO sections to describe the additional information.

RESULT [String]: "SUCCESS" or "FAILURE"

RESULT_INFO [ArrayList<bundles>]

RESULT_CODE: The following result codes are returned with the specified folder/file name or the RESULT_CODE_INFO as indicated:

  • EMPTY_FOLDER_PATH – FOLDER_PATH is empty or not specified
  • INVALID_FOLDER_PATH – Specified FOLDER_PATH is invalid
    • RESULT_CODE_INFO - “<folder path>”
  • INVALID_CONFIG_FILE – Corrupted database files present in specified folder
  • CONFIG_FILE_NOT_EXIST - No valid DataWedge database files in specified folder
    • RESULT_CODE_INFO - “dwprofile_<profilename>.db" or “datawedge.db”
  • INVALID_FILE_NAME – Folder contains valid and invalid DataWedge .db file names
    • RESULT_CODE_INFO - "<invalid file name>"

More about Result Codes

Example Code

Export Files

    private void exportConfig() {

        // Main Bundle properties

        Bundle bMain = new Bundle();
        bMain.putString("FOLDER_PATH", path);  // FOLDER_PATH: /storage/emulated/0/Download/
        bMain.putString("EXPORT_TYPE", configType); // EXPORT_TYPE: PROFILE_CONFIG or FULL_CONFIG
        if (configType.equals("PROFILE_CONFIG")) {
            bMain.putString("PROFILE_NAME", profileName);
        }

        // Send the intent

        Intent i = new Intent();
        i.setAction("com.symbol.datawedge.api.ACTION");
        i.putExtra("com.symbol.datawedge.api.EXPORT_CONFIG", bMain);

        // Request and identify the result code

        i.putExtra("SEND_RESULT", "true");
        i.putExtra("COMMAND_IDENTIFIER", "123456789");
        this.sendBroadcast(i);

    }

Receive Results of the Export

    Private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            Log.d(TAG, "Received intent: " + intent);

            // Validate expected extras
            if (!intent.hasExtra("COMMAND_IDENTIFIER") || !intent.hasExtra("RESULT")) {
                Log.d(TAG, "Received intent without expected extras: " + intent.getExtras());
                return;
            }

            String commandIdentifier = intent.getStringExtra("COMMAND_IDENTIFIER");
            String result = intent.getStringExtra("RESULT");

            // Check if the command identifier matches
            if (!"123456789".equals(commandIdentifier)) {
                Log.d(TAG, "Unrecognized COMMAND_IDENTIFIER: " + commandIdentifier);
                return;
            }

            if ("SUCCESS".equals(result)) {
                Toast.makeText(context, "Export Successful", Toast.LENGTH_LONG).show();
                Log.d(TAG, "Export Successful");
            } else {
                handleExportFailure(context, intent);
            }
        }

        /**
        * Handles export failure by processing the RESULT_INFO bundle.
        *
        * @param context The application context.
        * @param intent  The intent containing failure details.
        */

        private void handleExportFailure(Context context, Intent intent) {
            ArrayList<Bundle> bundleList = intent.getParcelableArrayListExtra("RESULT_INFO");

            if (bundleList == null || bundleList.isEmpty()) {
                Log.d(TAG, "Export failed but RESULT_INFO is empty or missing.");
                Toast.makeText(context, "Export Failed: Unknown Error", Toast.LENGTH_LONG).show();
                return;
            }

            StringBuilder resultInfo = new StringBuilder();
            for (Bundle resultBundle : bundleList) {
                for (String key : resultBundle.keySet()) {
                    String value = resultBundle.getString(key);
                    resultInfo.append(key).append(": ").append(value).append("\n");

                    // Show error details in toast if RESULT_CODE_INFO exists
                    if ("RESULT_CODE_INFO".equalsIgnoreCase(key)) {
                        String errorCode = resultBundle.getString("RESULT_CODE");
                        Toast.makeText(context, "Export Failed: (Error Code: " + errorCode + ")", Toast.LENGTH_LONG).show();
                    }
                }
            }

            Log.d(TAG, "Export Failed Details: " + resultInfo.toString());
        }
    };

SEE ALSO:

Intent | Android Developers

Intents and Intent Filters | Android Developers

Android Intents | Tutorial