[rules-users] DRL always posting the format as txt instead of model.drl

learnbrms srivats.rayaprolu at gmail.com
Wed Jul 17 01:15:50 EDT 2013


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.


More information about the rules-users mailing list