[rules-users] Guvnor REST API and XLS decision tables

Jervis Liu jliu at redhat.com
Mon May 14 23:20:03 EDT 2012


On 2012/5/14 19:38, anchi wrote:
> Hi!
>
> I'm wondering how does Guvnor REST api handle Excel decision tables? I'm
> using 5.3.1.Final version.
>
> It seems that when I use url for binary e.g.
> /http://{guvnor_url}/rest/packages/package_name/assets/excel_table_name/binary/
> , I get a source (.xls) file.
> And when I use source url e.g.
> /http://{guvnor_url}/rest/packages/package_name/assets/excel_table_name/source/
> , I get a binary file.
> Is this some bug or is it really expected to work this way?
Hi, below is from the documentation:

/packages/{packageName}/assets/{assetName}/source 	GET 	plain/text 
none 	Returns the content of rule asset {assetName} contained in package 
{packageName}. If this is a binary asset, returns the binary data as a 
byte array. If the asset {assetName} does not exist, status 404 is 
returned.



Essentially this means /packages/{packageName}/assets/{assetName}/source 
and /packages/{packageName}/assets/{assetName}/binary both return the 
same content, which is a binary stream of the xls file in your case. The 
only difference between 
/packages/{packageName}/assets/{assetName}/source and 
/packages/{packageName}/assets/{assetName}/binary is that 
/packages/{packageName}/assets/{assetName}/binary has the returned file 
extension set, but /packages/{packageName}/assets/{assetName}/source 
does not.


>
> Also, when I try to build binary file (which I get using source url:) )
> using knowledge builder I'm getting exceptions, I have tried it in two ways:
To verify if the file returned from REST is corrupted or not, you can 
open it with Excel. If it works, then its sth else wrong with your 
KBuilder client.

Cheers,
Jervis

> 1. kbuilder.add(urlResource, ResourceType.DTABLE);
>
> Exception in thread "main"
> org.drools.template.parser.DecisionTableParseException: An error occurred
> opening the workbook. It is possible that the encoding of the document did
> not match the encoding of the reader.
> 	at
> org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:90)
> 	at
> org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:89)
> 	at
> org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:68)
> 	at
> org.drools.decisiontable.DecisionTableProviderImpl.compileStream(DecisionTableProviderImpl.java:38)
> 	at
> org.drools.decisiontable.DecisionTableProviderImpl.loadFromInputStream(DecisionTableProviderImpl.java:21)
> 	at
> org.drools.compiler.DecisionTableFactory.loadFromInputStream(DecisionTableFactory.java:18)
> 	at
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:613)
> 	at
> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
> 	at Main.main(Main.java:101)
> Caused by: jxl.read.biff.BiffException: Unable to recognize OLE stream
> 	at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
> 	at jxl.read.biff.File.<init>(File.java:127)
> 	at jxl.Workbook.getWorkbook(Workbook.java:268)
> 	at
> org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:75)
> 	... 8 more
>
>
> 2. kbuilder.add(urlResource, ResourceType.DRL);
>
> java.lang.IndexOutOfBoundsException: Index: 693, Size: 693
> 	at java.util.ArrayList.get(ArrayList.java:352)
> 	at org.antlr.runtime.CommonTokenStream.LT(CommonTokenStream.java:103)
> 	at org.drools.lang.ParserHelper.reportError(ParserHelper.java:386)
> 	at org.drools.lang.DRLParser.compilationUnit(DRLParser.java:182)
> 	at org.drools.compiler.DrlParser.compile(DrlParser.java:225)
> 	at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
> 	at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
> 	at
> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
> 	at
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
> 	at
> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
> 	at Main.main(Main.java:101)
> Exception in thread "main" java.lang.RuntimeException:
> org.drools.compiler.DroolsParserException: Unexpected exception raised while
> parsing. This is a bug. Please contact the Development team :
> Index: 693, Size: 693
> 	at
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:692)
> 	at
> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)
> 	at Main.main(Main.java:101)
> Caused by: org.drools.compiler.DroolsParserException: Unexpected exception
> raised while parsing. This is a bug. Please contact the Development team :
> Index: 693, Size: 693
> 	at org.drools.compiler.DrlParser.compile(DrlParser.java:242)
> 	at org.drools.compiler.DrlParser.parse(DrlParser.java:136)
> 	at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
> 	at
> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:394)
> 	at
> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:586)
> 	... 2 more
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Guvnor-REST-API-and-XLS-decision-tables-tp3985574.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120515/795d357a/attachment-0001.html 


More information about the rules-users mailing list