Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Importing custom XML files for input streams

Updated on August 25, 2021

Use custom XML files for use as an input stream by importing the XML files as a Java archive (JAR) and extracting the files using an activity.

Import, integrate, and access XML files as an input stream using Pega Platform™ with the following procedure:
Note: You cannot use import custom XML files in order to modify configuration files for Pega-managed external database instances. Instead, modify the connection pool properties using dynamic system settings (DSS). For more information, see Configuring connectivity parameters for an external Pega Platform database.
  1. Using the command line on your local system, create a JAR file with your selected XML files using the following Java method:  jar cf jar-file-name-or-directory chosen-xml-files-or-directories -c /directory
  2. In the header of Dev Studio, click ConfigureApplicationDistribution Import.
  3. In the Import Wizard, select a location from which to import the JAR file you created in step 1. Select from the following locations:
    • Local File
    • From Repository
    • File on Server
  4. Click Next.
  5. Confirm the details of the JAR file, then click Next.
  6. In the Code Archive page, enter Pega-EngineCode and the codeset version of your current release in which to integrate the XML.

    If your application uses a unique codeset for the input stream, enter the unique codeset name and codeset version.

  7. Click Next.
  8. Confirm Java archive content, then click Next.
  9. Restart your environment.
    • For Pega Cloud environments, file a service request from My Support Portal to restart the application server of your Pega Cloud instance.
    • For on-premises environments, restart the application server.

      After the restart, Pega Platform imports the JAR file into the version of the codeset.

  10. In the header of Dev Studio, click CreateTechnicalActivity.
  11. In the Label field, add a name for the activity.
  12. In the Context section, select the application, class, and ruleset on which the codeset version resides.
  13. Click Create and open.
  14. In the Label field, enter a unique identifier for the step.
  15. In the Method list, select Java.
  16. To the left of the Method list, click the expand icon.
  17. In the Method Parameters section, in the Java source field, enter a Java method that you want to use to access the XML file integrated into your source code and Pega Platform database similar to the one below.
    Note: The following Java method displays a guideline for using an XML file imported into a Pega Platform codeset for input streams, and not as a direct function. Individual custom imports require unique Java methods. Talk to your software architecture team for more information.
    String fileName = (String) tools.getParameterPage().getParameterValue("fileName");
    java.io.InputStream theInputStream = null;
    ClassLoader ctxCL = Thread.currentThread().getContextClassLoader();
    ClassLoader loader = com.pega.pegarules.pub.PegaRULES.class.getClassLoader();
    
    if (theInputStream == null && ctxCL != null) {
        theInputStream = ctxCL.getResourceAsStream(fileName);
    }
    if (theInputStream == null && loader != null) {
        theInputStream = loader.getResourceAsStream(fileName);
    }
    if (theInputStream == null) {
        theInputStream = ClassLoader.getSystemResourceAsStream(fileName);
    }
    
    if (theInputStream == null) {
      throw new PRRuntimeException("Unable to locate resource '" + fileName + "'");
    }
  18. Click Save.
  19. Create a new parameter for use as an input field that calls the Java method when running the activity with the following task:
    1. Select the Parameters tab.
    2. Enter a name and description for the parameter.
    3. In Data type, select String.
    4. In Required, select Yes.
  20. In the Actions list, select Run to run the activity.

    Pega Platform displays the activity window containing the field you created from the Parameters tab.

  21. In the field of the activity, enter the name of the XML file.
  22. Run the activity to complete the import process.
  • Previous topic Ensuring that users migrate applications with a pipeline by restricting the Import wizard
  • Next topic Importing custom Java archives and classes

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us