Working with Domains

The repository services can also be used to read and write Domains. Like JasperReport resources, Domains are complex resources that contain other files. The files that make up a Domain are its Domain schema, its optional security files, and its optional language bundles. You can find the name and location of these files by requesting the Domain itself. For example, the following request shows the contents of the Supermart Domain:

GET http://localhost:8080/jasperserver-pro/rest/resource/Domains/supermartDo...

All repository URIs sent and received are relative the organization of the user ID that performs the REST operation. The URIs in this section assume the user is an organization admin such as jasperadmin.

Looking carefully through the resulting descriptor, we find the relevant information:

<resourceDescriptor name="supermartDomain" wsType="domain"
  uriString="/Domains/supermartDomain" isNew="false">
  <label>Supermart Domain</label>
  <description>Comprehensive example of Domain (pre-joined table sets for complex reporting, custom query based dataset, column and row security, I18n bundles)</description>
  <resourceProperty name="PROP_RESOURCE_TYPE">
    <value>com.jaspersoft.commons.semantic.datasource.SemanticLayerDataSource
  ...
  <resourceDescriptor name="supermartDomain_schema" wsType="xml"
    uriString="/Domains/supermartDomain_files/supermartDomain_schema" isNew="false">
    <label>supermartDomain_schema</label>
    <description>supermartDomain_schema</description>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
    ...
  </resourceDescriptor>
  <resourceDescriptor name="supermart_domain.properties" wsType="prop"
    uriString="/Domains/supermartDomain_files/supermart_domain.properties"
    isNew="false">
    <label>supermart_domain.properties</label>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
    ...
  </resourceDescriptor>
  <resourceDescriptor name="supermart_domain_en_US.properties" wsType="prop"
    uriString="/Domains/supermartDomain_files/supermart_domain_en_US.properties" 
    isNew="false">
    <label>supermart_domain_en_US.properties</label>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
    ...
  </resourceDescriptor>
  ...
  <resourceDescriptor name="supermartDomain_domain_security" wsType="xml"
    uriString="/Domains/supermartDomain_files/supermartDomain_domain_security"
    isNew="false">
    <label>supermartDomain_domain_security</label>
    <description>supermartDomain_domain_security</description>
    <resourceProperty name="PROP_RESOURCE_TYPE">
      <value>com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource
    ...
    <resourceProperty name="PROP_SECURITY_BUNDLE">
      <value>true</value>
    </resourceProperty>
  </resourceDescriptor>
  <resourceDescriptor name="dsFoodMart" wsType="reference" referenceType="jndi"
    uriString="/analysis/datasources/FoodmartDataSourceJNDI" isNew="false">
    <resourceProperty name="PROP_REFERENCE_URI">
      <value>/analysis/datasources/FoodmartDataSourceJNDI</value>
    </resourceProperty>
  </resourceDescriptor>
</resourceDescriptor>

The files contained in this Domain are:

/Domains/supermartDomain_files/supermartDomain_schema
/Domains/supermartDomain_files/supermartDomain_domain_security
/Domains/supermartDomain_files/supermart_domain.properties
/Domains/supermartDomain_files/supermart_domain_en_US.properties
...

To download these files, use the same syntax as for downloading file resource contents:

GET http://localhost:8080/jasperserver-pro/rest/resource/Domains/supermartDo...
supermartDomain_schema?fileData=true

Domain schema files, security files, and language bundles have a special syntax described in the JasperReports Server User Guide. To process these files automatically, you would need to write your own parser.

If you have valid schema files, security files, and language bundles, you can also create Domain resources in the repository using the PUT method described in section Creating a Resource. The following procedure outlines the step required to create a Domain resource programmatically through the REST API:

1. Create the resource descriptor for the Domain using the descriptor shown above as an example. Make sure the files are referenced correctly in the descriptor.
2. Create the PUT request to the resource service using the resource descriptor created in the previous step.
3. Add the files to the request as multi-part request. For example use the class org.apache.http.entity.mime. MultipartEntity to build a multi-part request. Add each file as a separate part to the request.
4. Send the multi-part request to JasperReports Server.
5. Process the response to verify the request was successful.
Version: 
Feedback
randomness