<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi, there is no REST API for updating
      or creating package from DRL using ATOM. You can create a package
      using DRL (using DRL as octet-stream): <br>
      <br>
      <table summary="Accessing Rule Assets by Package" border="1">
        <tbody>
          <tr>
            <td>/packages</td>
            <td>POST</td>
            <td>application/atom+xml</td>
            <td>application/octet-stream</td>
            <td>Creates a new package from an input stream of DRL.
              Returns the newly created package in Atom Entry format.</td>
          </tr>
        </tbody>
      </table>
      <br>
      <table summary="Accessing Rule Assets by Package" border="1">
        <tbody>
          <tr>
            <td>/packages</td>
            <td>POST</td>
            <td>application/json and application/xml</td>
            <td>application/octet-stream</td>
            <td>Creates a package from an input stream of DRL. Returns
              the newly created package in JSON or XML format.</td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <br>
      You can also update package metadata once you have the package
      created (through posting DRL for example) using ATOM:<br>
      <br>
      <table summary="Accessing Rule Assets by Package" border="1">
        <tbody>
          <tr>
            <td>/packages/{packageName}</td>
            <td>PUT</td>
            <td>application/atom+xml</td>
            <td>none</td>
            <td>Updates the metadata of package {packageName} with a
              given Atom Entry.</td>
          </tr>
        </tbody>
      </table>
      <br>
      <table summary="Accessing Rule Assets by Package" border="1">
        <tbody>
          <tr>
            <td>/packages/{packageName}</td>
            <td>PUT</td>
            <td>application/json and application/xml</td>
            <td>none</td>
            <td>Updates the metadata of package {packageName} with a
              given JSON or XML.</td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      I am sorry that the 5.5 doc is not very clear on what you can do
      with POST to package URL. 5.4 doc is actually more accurate:
<a class="moz-txt-link-freetext" href="http://docs.jboss.org/drools/release/5.4.0.Final/drools-guvnor-docs/html/ch09.html#d0e3080">http://docs.jboss.org/drools/release/5.4.0.Final/drools-guvnor-docs/html/ch09.html#d0e3080</a><br>
      <br>
      Thanks,<br>
      Jervis<br>
      <br>
      On 2013/7/17 13:15, learnbrms wrote:<br>
    </div>
    <blockquote cite="mid:1374038150633-4024952.post@n3.nabble.com"
      type="cite">
      <pre wrap="">Hi,
I am using the following code to post or update the DRL using ATOM. But I am
seeing that DRL is always posted and displayed in Guvnor as .txt
(Format:txt) instead of Format:model.drl. 

public int createUpdateTextAsset(String assetLoc, String ruleName, String
ruleDescription, String fileToUpload, String requestMethod) 
        {
                System.out.println("--------Begin createUpdateTextAsset ----------");  
                System.out.println("assetLoc "+assetLoc+"\nruleName
"+ruleName+"\nruleDescription "+ruleDescription+"\nfileToUpload
"+fileToUpload+"\nrequestMethod "+requestMethod);
                String authCode = user+":"+password;
                StringBuilder content = null;
                Scanner scanner = null;
                client = WebClient.create(baseURL);
                try
                {   File f = new File(fileToUpload);
                        content = new StringBuilder();
                        String NL = System.getProperty("line.separator");
                        scanner = new Scanner(new FileInputStream(f));
                        while (scanner.hasNextLine()) {
                                content.append(scanner.nextLine() + NL);
                        }
                        String ruleContent=content.toString();
                 String atom = "";
                 
                 Response response = null;
                        String authString = "";
         authString = "Basic " + org.apache.cxf.common.util.Base64Utility
                                                        .encode(authCode.getBytes());
                 client.header("Authorization", authString);
                
                 atom = "&lt;entry xmlns=\&amp;quot;<a class="moz-txt-link-freetext" href="http://www.w3.org/2005/Atom\&amp;quot">http://www.w3.org/2005/Atom\&amp;quot</a>;
xml:base=\&amp;quot;&amp;quot;;
                 atom += assetLoc;
                 atom += &amp;quot;\&amp;quot;&gt;&lt;title type=\"text\"&gt;";
                 atom += ruleName;
                 atom += "&lt;/title&gt;&lt;summary type=\"text\"&gt;";
                 atom += ruleDescription;
                 atom += "&lt;/summary&gt;";
                 atom +="&lt;metadata&gt;";
                 atom +="&lt;property name=\"archived\" value=\"false\" /&gt;";
                 atom +="&lt;property name=\"rule-format\" value=\"model.drl\"/&gt;";
                 atom +="&lt;/metadata&gt;";
                 atom += "&lt;content type=\"application/xml\"&gt;";
                 atom += ruleContent;
                 atom += "&lt;/content&gt;&lt;/entry&gt;";
                 
                 
                 
                 System.out.println("Atom :"+atom);
                 if(requestMethod=="POST"){
                         response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
                                            .header("slug", ruleName+".drl") 
                                                .post(atom);
                 }else{
                         response = client.path(assetLoc).type(MediaType.APPLICATION_ATOM_XML)
                                                .put(atom);
                 }
                 System.out.println("--------End createUpdateTextAsset ----------status
"+response.getStatus());  
                 return response.getStatus();
                }


*Output:* 
Title: bre-validation-service-processing-model
Categories:
Last modified : 2013-07-17 00:07
by:
Note:
Initial:
Created on:2013-07-17 00:07
Created by:admin
Package:TestPackage6
Edit
Is Disabled:
*Format:txt*
UUID:c8247b22-1a14-4258-9cdf-5033518adf6b



--
View this message in context: <a class="moz-txt-link-freetext" href="http://drools.46999.n3.nabble.com/DRL-always-posting-the-format-as-txt-instead-of-model-drl-tp4024952.html">http://drools.46999.n3.nabble.com/DRL-always-posting-the-format-as-txt-instead-of-model-drl-tp4024952.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>