The asset repository and any asset stored in the repository can be accessed via the Rest API. Assets can be accessed by package name or by category name.
The base http address to access the rest API is http://localhost:8080/jboss-brms/rest/, where localhost is replaced by the server name. If the default port has been changed, substitute the default 8080 port number for the new port number.
The GET method return all packages contained in the repository in the requested format (Atom feed, JSON, or XML).
The POST method produces MIME-Types:
application/atom+XML
application/json
application/xml
The POST method consumes MIME-Types:
application/octet-stream
application/atom+xml
application/json
application/xml
The POST method creates a new package from an input stream of DRL, an Atom feed, JSON, or XML, and returns the newly created package in the requested format (Atom feed, JSON, or XML).
The GET method returns the metadata of the package {packageName} as an Atom entry when the MIME-Type is application/atom+xml and as a package element when the MIME-Type is application/json or application/xml.
The PUT method produces MIME-Types:
application/atom+xml
The PUT method updates the metadata of package {packageName} with the given Atom Entry.
The GET method returns the compiled binary of the package {packageName} as a binary stream. If the package has not been compiled yet or its binary is not up to date, this will compile the package first.
The GET method returns the binary (compiled code) of package {packageName} and of version {version} as an octet stream. If the package version has not been built, it returns HTTP code 500 with an error message.
The GET method returns the list of rule assets contained in package {packageName} in the requested format (Atom feed, JSON, or XML).
The POST method produces MIME-Types:
application/atom+xml
application/octet-stream
The POST method creates an asset in package {packageName}.
When an Atom Entry is provided, the following information must be included in the input: asset name, asset description, asset initial category, and asset format.
When an octet-stream is provided, the value of slug header is used to indicate the name of the asset. If the slug header is missing, a HTTP 500 error is returned.
The GET method returns the rule asset {assetName} contained in package {packageName} in the requested format (Atom feed, JSON, or XML).
The PUT method produces MIME-Types:
application/atom+xml
application/json
application/xml
The PUT method updates the metadata of the rule asset {assetName} contained in package {packageName} with the provided format (Atom Entry, JSON, or XML).
The DELETE method deletes the rule asset {assetName} contained in package {packageName}.
The GET method returns the binary content of rule asset {assetName} contained in package {packageName}. If this asset has no binary content, the source content is returned instead.
The PUT method produces MIME-Types:
application/octet-stream
The PUT method updates the binary content of the rule asset {assetName} contained in package {packageName}.
The GET method returns the content of rule asset {assetName} contained in package {packageName}. If this is a binary asset, the binary data is returned as a byte array.
The PUT method produces MIME-Types:
plain/text
The PUT method updates the source code of the rule asset {assetName} contained in package {packageName}.
The GET method returns the binary content of rule asset {assetName} of version {version} contained in package {packageName}. If this asset has no binary content, the source content is returned instead.
The GET method returns a list of asset objects representing rules assets that have the listed category {categoryPath} and retrieves page {page}, which is a numeric value starting at 1. A page contains 10 elements. If the list contains 20 elements then the list will have 2 pages. Page 1 must be called before page 2 and so on.
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The first line of the example creates the a WebClient variable that points to the server.
The second line of the example retrieves the source code by accessing the /rest/packages/{packageName}/assets/{assetName}/source, where in our case packageName is "essaiRest" and assetName is "tab2".
The third line of the example transforms the string variable (the source code that contains the xml of the data structure of the web decision table) in the java structure (a java class) for web decision table GuidedDecisionTable52.
Example 6.2. Updating the source code of the web decision table
String authorizationHeader = "Basic " + org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes());
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
..
Do some stuff here
..
String newContent = GuidedDTXMLPersistence.getInstance().marshal(dt);
WebClient client2 = WebClient.create("http://127.0.0.1:8080/");
client2.header("Authorization", authorizationHeader);
Response response= client2.path("jboss-brms/rest/packages/essaiRest/assets/tab2/source").accept("application/xml").put(newContent);
String authorizationHeader = "Basic " + org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes());
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
..
Do some stuff here
..
String newContent = GuidedDTXMLPersistence.getInstance().marshal(dt);
WebClient client2 = WebClient.create("http://127.0.0.1:8080/");
client2.header("Authorization", authorizationHeader);
Response response= client2.path("jboss-brms/rest/packages/essaiRest/assets/tab2/source").accept("application/xml").put(newContent);
Copy to ClipboardCopied!Toggle word wrapToggle overflow
The first line of the example creates a java String variable that contains the authorization element needed to update an asset in the asset repository.
The code that modifies the web decision table is not shown in this example.
The third line transforms the java structure into an XML structure that is put into a java String variable.
Next, the WebClient variable is created, but this time the authorization variable that contains the string from the first line (and contains the user name 'guest') is included in the header.
The final line adds the new content to the asset repository.
We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.
Making open source more inclusive
Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.
About Red Hat
We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.