Hey Luciano, Meanwhile i tries pumping in the rule with a webdav api (Sardine in my case) and that seems to work and trigger ok for me. this is how i did that

public class SardineTest {

public static void main(String[] args) throws SardineException {
Sardine sardine = SardineFactory.begin("admin", "admin");
List<DavResource> resources = sardine
.getResources("http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages");
for (DavResource res : resources) {
System.out.println(res); // calls the .toString() method.
}

addARule();
}

private static void addARule() throws SardineException {
Sardine sardine = SardineFactory.begin("username", "password");
String ruleDescription = "when Entity(entityName==\"Car1s\") then System.out.println( \"*************rule executed\")";
byte[] data = ruleDescription.getBytes();
sardine.put("http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/packages/Analytics/SimpleDRLRule.drl", data);
System.out.println("Rule added ...");
}

}


once i did this, I could see the rule added as a technical rule on the guvnor web app ... the and then triggered to rule with something like this


public class GuvnorTest {
@Test
public void testDroolsWithGuvnor() throws Exception {
KnowledgeBase knowledgeBase = createKnowledgeBase();
StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession();
try {
Entity entity = new Entity();
entity.setEntityName("Car1s");
session.insert(entity);
Assert.assertTrue(session.getFactCount() == 1);
System.out.println("And the count is  " + session.getFactCount());
session.fireAllRules();
System.out.println("And the count is  " + session.getFactCount());
Assert.assertEquals(1, session.getFactCount());
}
finally {
session.dispose();
}
}

private static KnowledgeBase createKnowledgeBase() {
KnowledgeAgentConfiguration kaconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
kaconf.setProperty( "drools.agent.scanDirectories", "false" );
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "test agent", kaconf );
kagent.applyChangeSet( ResourceFactory.newClassPathResource("opal-guvnor.xml"));
return kagent.getKnowledgeBase();
}
}

where opal-guvnor.xml is my change set file and goes like this

<change-set xmlns='http://drools.org/drools-5.0/change-set'
    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
    xs:schemaLocation='http://drools.org/drools-5.0/change-set http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd' >
    <add>
         <resource source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Analytics/LATEST.drl' type='DRL' basicAuthentication="enabled" username="admin" password="admin"/>
    </add>
</change-set>


not sure if this is the right / best way but at least could add a rule to the repository with this. Ideally, 

1) I would like to run a validate / verify to see that the rule has been added correctly, I dont know the api to do that
2) I would like to rebuild my package and/or create a new snapshot, dont know how to do that either though the rule seems to execute without doing that.
3) Have not given any thoughts about security etc right now ...


@Drools experts, your thoughts?

Regards | Vikas


On Sat, Feb 12, 2011 at 12:20 AM, Luciano A. Andrade <andrade.luciano@gmail.com> wrote:
I think i am in the same situation, i following
http://www.reverttoconsole.com/blog/java/accessing-drools-5-rules-via-a-restful-api-using-drools-server-and-groovy-restclient/
it recomends
http://www.amazon.com/JBoss-Drools-Business-Rules-Browne/dp/1847196063/ref=sr_1_1?ie=UTF8&s=books&qid=1259786026&sr=8-1
but i found a similar example on the chapter 11 of
http://www.amazon.com/Drools-JBoss-Rules-Developers-Guide/dp/1847195644/ref=pd_bxgy_b_text_b#reader_1847195644

i didn't manage to run properly first and foremost since i didn't have
the rules in place as the example requires, and since i have to run it
from PHP, i am working on it, so if you make any progress please i am
really interested.

Also i don't really understand how it sopuse to run the rules from the
webdav interface.

2011/2/11 Vikas Hazrati <vhazrati@inphina.com>:
> Hi Luciano,
> Believe me ;) I already did that before posting to the group but the
> information that I found is skeletal or anywhere near it. Do we have the api
> documented somewhere?
> Also i see that people on this group talk about the KnowledgeAgent and
> KBuilder etc. Where is all that documented? I would like to use the api to
> pump rules into the govrnor from my flex UI. Any pointers to the api which I
> can explore to do that are appreciated.
> On the IRC channel i met Rikkola who suggested to use the webdav, I would
> like to explore that but at the same time I would like to see if REST or any
> alternate api suits my need. Again, help appreciated :)
> Regards | Vikas
>
> On Fri, Feb 11, 2011 at 8:01 PM, Luciano A. Andrade
> <andrade.luciano@gmail.com> wrote:
>>
>> I think you are looking for the "Drools REST API", google it and you
>> find some documentation.
>>
>> 2011/2/11 Vikas Hazrati <vhazrati@inphina.com>:
>> >
>> > Hi,
>> >
>> > I am looking at using Guvnor for our project where users would be
>> > creating
>> > rules using our UI. For this i need to add / modify rule or any asset
>> > for
>> > that matter using an api.
>> >
>> > Unfortunately, i could not find enough documentation to suggest the best
>> > way
>> > to use the REST api, which I guess is provided by Guvnor. Could someone
>> > let
>> > me know the location of where i can get some information for this api. I
>> > also see that the issue GUVNOR-1080
>> > (https://issues.jboss.org/browse/GUVNOR-1080) is marked resolved so the
>> > api
>> > should exist right? or that we cannot access it remotely until we have
>> > the
>> > Atom Pub Interface done?
>> >
>> > Help appreciated .
>> > --
>> > View this message in context:
>> > http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Guvnor-API-information-tp2471798p2471798.html
>> > Sent from the Drools - User mailing list archive at Nabble.com.
>> > _______________________________________________
>> > rules-users mailing list
>> > rules-users@lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Best Regards | Vikas
>
> Inphina Technologies
> Co-Founder and Technical Architect
> Mobile: +91-9899174194
> Landline: +91-11-25126026
> http://inphina.com
> http://thoughts.inphina.com
> http://twitter.com/inphina
>
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
Best Regards | Vikas

Inphina Technologies
Co-Founder and Technical Architect
Mobile: +91-9899174194
Landline: +91-11-25126026 

http://inphina.com
http://thoughts.inphina.com
http://twitter.com/inphina