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):

/packages POST application/atom+xml application/octet-stream Creates a new package from an input stream of DRL. Returns the newly created package in Atom Entry format.

/packages POST application/json and application/xml application/octet-stream Creates a package from an input stream of DRL. Returns the newly created package in JSON or XML format.



You can also update package metadata once you have the package created (through posting DRL for example) using ATOM:

/packages/{packageName} PUT application/atom+xml none Updates the metadata of package {packageName} with a given Atom Entry.

/packages/{packageName} PUT application/json and application/xml none Updates the metadata of package {packageName} with a given JSON or XML.


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: http://docs.jboss.org/drools/release/5.4.0.Final/drools-guvnor-docs/html/ch09.html#d0e3080

Thanks,
Jervis

On 2013/7/17 13:15, learnbrms wrote:
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 = "<entry xmlns=\&quot;http://www.w3.org/2005/Atom\&quot;
xml:base=\&quot;&quot;;
		 atom += assetLoc;
		 atom += &quot;\&quot;><title type=\"text\">";
		 atom += ruleName;
		 atom += "</title><summary type=\"text\">";
		 atom += ruleDescription;
		 atom += "</summary>";
		 atom +="<metadata>";
		 atom +="<property name=\"archived\" value=\"false\" />";
		 atom +="<property name=\"rule-format\" value=\"model.drl\"/>";
		 atom +="</metadata>";
		 atom += "<content type=\"application/xml\">";
		 atom += ruleContent;
		 atom += "</content></entry>";
		 
		 
		 
		 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: http://drools.46999.n3.nabble.com/DRL-always-posting-the-format-as-txt-instead-of-model-drl-tp4024952.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users