6.4.2. Accessing Rules by Package
The GET method produces MIME-Types:
application/atom+XML
application/json
application/xml
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 produces MIME-Types:
application/atom+xml
application/json
application/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:
The PUT method updates the metadata of package {packageName} with the given Atom Entry.
The DELETE method deletes package {packageName}.
The GET method produces MIME-Types:
The GET method returns the source code of the package {packageName} as a text file.
The GET method produces MIME-Types:
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 produces MIME-Types:
The GET method returns the list of package {packageName} versions as an Atom Feed.
The GET method produces MIME-Types:
The GET method returns the metadata of package {packageName} and of version {version} as an Atom Entry.
The GET method produces MIME-Types:
The GET method returns the source code of package {packageName} and of version {version} as a text file.
The GET method produces MIME-Types:
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 produces MIME-Types:
application/atom+xml
application/json
application/xml
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 produces MIME-Types:
application/atom+xml
application/json
application/xml
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 produces MIME-Types:
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:
The PUT method updates the binary content of the rule asset {assetName} contained in package {packageName}.
The GET method produces MIME-Types:
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:
The PUT method updates the source code of the rule asset {assetName} contained in package {packageName}.
The GET method produces MIME-Types:
The GET method returns the list of rule asset {assetName} versions contained in package {packageName} as an Atom Feed.
The GET method produces MIME-Types:
The GET method returns the metadata of rule asset {assetName} of version {version} contained in package {packageName} as an Atom Entry.
The GET method produces MIME-Types:
The GET method returns the source code of rule asset {assetName} of version {version} contained in package {packageName} as a text file.
The GET method produces MIME-Types:
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.
6.4.4. Source Code Examples
The following example uses apache CXF to show how to access the Rest API.
Example 6.1. Retrieving the source code for the web decision table
WebClient client = WebClient.create("http://127.0.0.1:8080/");
String content=client.path("jboss-brms/rest/packages/essaiRest/assets/tab2/source").accept("text/plain").get(String.class);
GuidedDecisionTable52 dt = GuidedDTXMLPersistence.getInstance().unmarshal(content);
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);
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.
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.