You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by KyleMarchant <ky...@agilex.com> on 2012/12/19 22:58:45 UTC

Import a Java Library into CouchDB JavaScript Validation Function

I would like to use a java library within a validation function for accessing
an external properties file. Something like the following:

importPackage(Packages.java.io);
importPackage(Packages.java.util);

var file = new File(sPropertyFile);
var fis = new FileInputStream(file);

var prop = new Properties();
prop.load(fis);
var field = prop.getProperty("FIELD1");

Can anyone tell me if CouchDB allows the importing of Java Library
(Packages) and if so can you provide me instructions or an example of how to
go about doing this?

Much appreciated.
Kyle



--
View this message in context: http://couchdb-development.1959287.n2.nabble.com/Import-a-Java-Library-into-CouchDB-JavaScript-Validation-Function-tp7582437.html
Sent from the CouchDB Development mailing list archive at Nabble.com.

Re: Import a Java Library into CouchDB JavaScript Validation Function

Posted by Robert Newson <rn...@apache.org>.
You might find a Java view server around, though evaluating Java
snippets is a bit of a black art, but no sane view server will permit
reading local files.

On 19 December 2012 22:22, Travis Paul <Tr...@vispaul.me> wrote:
> AFAIK, this is not possible as validate_doc_update functions can only be
> written in javascript. (Maybe also Erlang? But I don't think so)
>
> You might want to use something like JSON schema for consistent client and
> server validation, as you can import  more javascript with CommonJS modules.
>
>
> On Wed, Dec 19, 2012 at 4:58 PM, KyleMarchant <ky...@agilex.com>wrote:
>
>> I would like to use a java library within a validation function for
>> accessing
>> an external properties file. Something like the following:
>>
>> importPackage(Packages.java.io);
>> importPackage(Packages.java.util);
>>
>> var file = new File(sPropertyFile);
>> var fis = new FileInputStream(file);
>>
>> var prop = new Properties();
>> prop.load(fis);
>> var field = prop.getProperty("FIELD1");
>>
>> Can anyone tell me if CouchDB allows the importing of Java Library
>> (Packages) and if so can you provide me instructions or an example of how
>> to
>> go about doing this?
>>
>> Much appreciated.
>> Kyle
>>
>>
>>
>> --
>> View this message in context:
>> http://couchdb-development.1959287.n2.nabble.com/Import-a-Java-Library-into-CouchDB-JavaScript-Validation-Function-tp7582437.html
>> Sent from the CouchDB Development mailing list archive at Nabble.com.
>>

Re: Import a Java Library into CouchDB JavaScript Validation Function

Posted by Travis Paul <Tr...@visPaul.me>.
AFAIK, this is not possible as validate_doc_update functions can only be
written in javascript. (Maybe also Erlang? But I don't think so)

You might want to use something like JSON schema for consistent client and
server validation, as you can import  more javascript with CommonJS modules.


On Wed, Dec 19, 2012 at 4:58 PM, KyleMarchant <ky...@agilex.com>wrote:

> I would like to use a java library within a validation function for
> accessing
> an external properties file. Something like the following:
>
> importPackage(Packages.java.io);
> importPackage(Packages.java.util);
>
> var file = new File(sPropertyFile);
> var fis = new FileInputStream(file);
>
> var prop = new Properties();
> prop.load(fis);
> var field = prop.getProperty("FIELD1");
>
> Can anyone tell me if CouchDB allows the importing of Java Library
> (Packages) and if so can you provide me instructions or an example of how
> to
> go about doing this?
>
> Much appreciated.
> Kyle
>
>
>
> --
> View this message in context:
> http://couchdb-development.1959287.n2.nabble.com/Import-a-Java-Library-into-CouchDB-JavaScript-Validation-Function-tp7582437.html
> Sent from the CouchDB Development mailing list archive at Nabble.com.
>