<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 2012/5/14 19:38, anchi wrote:
<blockquote cite="mid:1336995501270-3985574.post@n3.nabble.com"
type="cite">
<pre wrap="">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.
/<a class="moz-txt-link-freetext" href="http://">http://</a>{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.
/<a class="moz-txt-link-freetext" href="http://">http://</a>{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?
</pre>
</blockquote>
Hi, below is from the documentation:<br>
<br>
<table summary="Accessing Rule Assets by Package" border="1">
<tbody>
<tr>
<td>/packages/{packageName}/assets/{assetName}/source</td>
<td>GET</td>
<td>plain/text</td>
<td>none</td>
<td>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.</td>
</tr>
</tbody>
</table>
<br>
<br>
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. <br>
<br>
<br>
<blockquote cite="mid:1336995501270-3985574.post@n3.nabble.com"
type="cite">
<pre wrap="">
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:
</pre>
</blockquote>
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. <br>
<br>
Cheers,<br>
Jervis<br>
<br>
<blockquote cite="mid:1336995501270-3985574.post@n3.nabble.com"
type="cite">
<pre wrap="">
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: <a class="moz-txt-link-freetext" href="http://drools.46999.n3.nabble.com/Guvnor-REST-API-and-XLS-decision-tables-tp3985574.html">http://drools.46999.n3.nabble.com/Guvnor-REST-API-and-XLS-decision-tables-tp3985574.html</a>
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</body>
</html>