ColdFusion 11 Update 6 and ColdFusion 10 Update 17 now available

August 27, 2015 / Piyush Kumar Nayak

  Security | Adobe ColdFusion | Adobe ColdFusion 10 | Adobe ColdFusion 11 | ColdFusion | ColdFusion 11

The following ColdFusion updates are now available for download. These updates address a common XXE vulnerability in BlazeDS. For details refer the security bulletin hyperlinks in the sections below.

Users who are using LCDS with ColdFusion, should refer this technote, for updating their LCDS installation.

ColdFusion 11 Update 6

This Update addresses a vulnerability mentioned in the security bulletin APSB15-21. This update is cumulative and includes fixes from previous ColdFusion 11 updates.

For details, refer this technote.

ColdFusion 10 Update 17

This Update addresses a vulnerability mentioned in the security bulletin APSB15-21. This update is cumulative and includes fixes from previous ColdFusion 10 updates. 

For details, refer this technote.


Connector Backup

August 25, 2015 / Milan Chandna

Everyone using ColdFusion  with connector might have faced a scenario where connector has to be uninstalled and then installed back again. Though it looks straightforward but some times it is not as user might have one's own customizations in connector. So before uninstalling, the connector files had to be backed up and after installing the changes had to be merged back. Though upgrade feature in connector is the best answer to this problem but we will save that discussion for some other time. In this blog I will focus on backing up connector files before uninstalling.

 

Important files or files which users might want to refer later are usually in connector magic_number directory. These directories are present in ".../ColdFusion11/config/wsconfig/...". Now the good part is that as part of ColdFusion11 update, we have pushed in a feature which backs up all the connector files by default on uninstallation. After uninstalling you will notice that a new directory called backup will be created in ".../ColdFusion11/config/wsconfig/...". This backup directory will contain directories like 1.1, 1.2, 2.1, 2.2, depending on your connector directories. These directories are the backed up magic_number directories. Yes, we backup whole magic_number directory as user might have his own files(new or modified). Now coming to the naming convention of backed up directories.

 Let's take an example of directory 2.1, The first number denotes the actual magic_number of the connector directory which is uninstalled and the second number denotes the number of times it is uninstalled. So in case you have multiple connectors configured, the magic_number directories will be present in wsconfig/ directory as "1" and "2" and "3" and so on. Now if you decide to uninstall a connector which is in directory "2", after uninstallation it will be backed up in backup directory as "2.1". How will you know that the connector you uninstalled was in directory "2"? You can always check the properties file to find out. So that part explains the first number of "2.1". And as I said the second number denotes the number of times it has been uninstalled. Let's assume that after uninstalling connector "2", you installed another connector, by default it will be installed under directory "2", as it's space is empty. And this time again if you uninstall it, it will be backed up in backup directory as "2.2", because it has been uninstalled second time. May be not so easy to understand by reading this but trust me, try this in your development server and you will get it in a snap.

 

Just wanted to let you know that this feature has been pushed in so that you will never lose your work, not even unknowingly. And yeah almost forgot to tell you, connector will be backed up by default if you uninstall it from command prompt but if you uninstall it from wsconfig UI tool, you will be asked if you want the backup or not. Trust me, if you are not sure then take a backup for safety reasons. Hope it will you.

 

Thanks,

Milan.


Machine Learning in ColdFusion

August 25, 2015 / Avinash Bukkittu

  Adobe ColdFusion | General

Machine learning has been a buzz word in recent times. I often hear people talking about this and their profound interest to learn more and gain expertise in this field. As a consequence, many programming languages are now having machine learning libraries available in their toolbox. For example, Java has ML libraries like WEKA, C++ has Encog (Encog is available for Java as well), PyBrain for Python etc.  These libraries come in handy and obviates the need to write basic algorithms from scratch. One such tool is WEKA (http://www.cs.waikato.ac.nz/ml/weka/)-  A data mining software in Java. You can use it as a standalone application or use it's APIs in your own Java program.

 

In this article, I will show you how to use WEKA library in ColdFusion. I am going to write a very simple Java program and add wrappers to it in ColdFusion. These wrappers can then be called from ColdFusion pages. In short, I am making the WEKA library available to ColdFusion. 

 

I will be using weather dataset located at data/weather.numeric.arff  in downloaded weka package. Weka uses ARFF format for datasets. Below is the dataset

@relation weather

@attribute outlook {sunny, overcast, rainy}
@attribute temperature numeric
@attribute humidity numeric
@attribute windy {TRUE, FALSE}
@attribute play {yes, no}

@data
sunny,85,85,FALSE,no
sunny,80,90,TRUE,no
overcast,83,86,FALSE,yes
rainy,70,96,FALSE,yes
rainy,68,80,FALSE,yes
rainy,65,70,TRUE,no
overcast,64,65,TRUE,yes
sunny,72,95,FALSE,no
sunny,69,70,FALSE,yes
rainy,75,80,FALSE,yes
sunny,75,70,TRUE,yes
overcast,72,90,TRUE,yes
overcast,81,75,FALSE,yes
rainy,71,91,TRUE,no


The above dataset contains five attributes namely outlook , temperature, humidity, windy & play. outlook is a categorical variable(it can take only three values - sunny,overcast, rainy) temperature and humidity are numeric variables, windy is again a categorical variable(it can take two values - TRUE, FALSE) and play is a categorical variable(it can take two values - yes,no). play is the class variable in our problem which means we have to predict the value of this variable for given test datapoint which contains remaining four values. 

 

So the problem at hand is a classification problem. We are given a training dataset which can be used to train a classifier and then use this model to predict the label for a test datapoint. There are many classifiers which can be used to solve this problem. But I am going to use naïve Bayes to solve this problem. It's a very simple classifier based on probability and it assumes that features are independent of one another. This means that the value outlook takes is independent of the values other attributes take.  I will not explain the mathematical background of naïve Bayes but rather provide an implementation for it. To understand the theory behind naïve Bayes, check this link.

 

Here is the Java program

 

import weka.classifiers.Classifier;
import weka.classifiers.Evaluation;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.trees.J48;
import weka.core.Attribute;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.SparseInstance;
import java.util.*;


public class Demo {

	public static Classifier naiveBayesClassifierTrainedWithCV(Instances data, int numFolds) throws Exception
	{
		Classifier cls = new NaiveBayes();
		Evaluation eval = new Evaluation(data);
		
		if(data.classAttribute().isNominal())
			data.stratify(numFolds);
		
		for(int i=0;i outlookValues = new ArrayList();
		outlookValues.add("sunny");
		outlookValues.add("overcast");
		outlookValues.add("rainy");
		Attribute outlook = new Attribute("outlook", outlookValues); 
		
		//Create numeric attribute
		Attribute temperature = new Attribute("temperature");
		Attribute humidity = new Attribute("humidity");
		
		List windyValues = new ArrayList();
		windyValues.add("TRUE");
		windyValues.add("FALSE");
		
		Attribute windy = new Attribute("windy",windyValues); 
		
		
		Instance testSample = new SparseInstance(5);
		
		testSample.setDataset(data);
		testSample.setValue(outlook, outlookValue);
		testSample.setValue(temperature, temp);
		testSample.setValue(humidity, hum);
		testSample.setValue(windy, wind);
		
		return testSample;
	}
	
	public static double[] getDistributionInstanceForATestSample(Classifier cls, Instance data) throws Exception	{
		
		return cls.distributionForInstance(data);
	}
}


Download weka.jar from http://www.cs.waikato.ac.nz/ml/weka/downloading.html. Add this jar to the classpath and compile the above program.

 

In the above program, naiveBayesClassifierTrainedWithCV is used to train a naïve Bayes classifier with the dataset that is passed as an argument. The second argument numFolds is used to mentioned the number of folds for cross-validation. For e.g., 10-fold cross-validation requires numFolds = 10. generateTestSample is used to generate a test sample for which a class label will be predicted by the classifier. getDistributionInstanceForATestSample is used to get the probability distribution for a test sample predicted by the classifier.

 

Following is a wrapper for these methods in ColdFusion. I have created a CFC for the same

component output=false
{
	property name="demo";
	property name="bufferedReference";
	property name="fileReference";
	property name="fileObj";
	property name="bufferedObj";
	property name="instanceReference";
	property name="instanceObj";
	property name="model";
	
	//This function loads ARFF file
	function Init()
	{
		demo = CreateObject("java","Demo");
		
		//Create a buffered reference
		bufferedReference = CreateObject("java","java.io.BufferedReader");
		
		//Create a file reference
		fileReference = CreateObject("java","java.io.FileReader");
		
		//Create a file object
		fileObj = fileReference.init("C:/ColdFusion11/cfusion/wwwroot/weka/weather.numeric.arff");
		
		//Create a buffered reader object
		bufferedObj = bufferedReference.init(fileObj);
			
		instanceReference = CreateObject("java","weka.core.Instances");
		instanceObj = instanceReference.init(bufferedObj);
		
		instanceObj.setClassIndex(instanceObj.numAttributes() - 1);
	
	}
	
	function naiveBayesClassifierTrainedWithCV()	{
		
		model = demo.naiveBayesClassifierTrainedWithCV(instanceObj,10);
		return model;
	}
	
	function  getDistributionInstanceForATestSample(required string outlook, required numeric temp, required numeric humidity, required string windy)	{
		
		sample = demo.generateTestSample(JavaCast("string",outlook),JavaCast("int",temp),JavaCast("int",humidity),JavaCast("string",windy),instanceObj);
		distribution = demo.getDistributionInstanceForATestSample(model,sample);
		return distribution;
	}
}

Above file is named as MachineLearning.cfc. Init() method is used to load the ARFF file. Rest of the methods are just wrappers around the corresponding Java methods. This CFC is used as follows

<cfset mlObj = CreateObject("MachineLearning")>
<cfset mlObj.Init()>
<cfset NB = mlObj.naiveBayesClassifierTrainedWithCV()>
<cfset distributionForTestSample = mlObj.getDistributionInstanceForATestSample("sunny",80,95,"TRUE")>
<cfsavecontent variable="html">
	<cfoutput>
		<html>
			<head>
				<title>WEKA Demo</title>
			</head>
			<body>
				<h3>Naive Bayes</h3>
				<p><pre>#NB#</pre></p>
				<hr />
				<h3>Classifying a sample</h3>
				<h4>t = (Outlook = "sunny", Temperature = 76, Humidity = 95, Windy = "TRUE")</h4>
				<p>
					Yes = #distributionForTestSample[1]#, No = #distributionForTestSample[2]#
				</p>
			</body>
		</html>
	</cfoutput>
</cfsavecontent>
<cfoutput>#html#</cfoutput>

MachineLearning object is created and naïve Bayes classifier is called on that object. Once the model is trained, a test sample is created and we want to know what is the label that is predicted by the classifier. Instead of getting the label, probability distribution of the test sample over the class labels is calculated i.e. probability of test sample being yes and probability of the sample being no. This is achieved by calling getDistributionInstanceForATestSample method. Below is the output that we get

As you can see, for test sample("sunny",76,95,"TRUE") the classifier predicts with 60% probability that play=yes and with 40% that play=no.

 

So this was a simple example on how to use Weka in ColdFusion. Perhaps, this idea can extended and a ML library for ColdFusion can be created.


Using ColdFusion DDX for attaching files to PDF

August 24, 2015 / Pooja Vadiraja

ColdFusion allows users to attach files to PDF Documents using processddx action of CFPDF tag. DDX provides FileAttachments source element to attach files.

Below is the DDX script for attaching files to PDF documents:

<?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/coldfusion_ddx.xsd">

<PDF result="Out1">

	<FileAttachments source="attach0" >
		<File filename="file1.pdf" mimetype="application/pdf"/>
		<FilenameEncoding encoding="UTF-8"/>
		<Description>Attaching file1</Description>
	</FileAttachments>

	<FileAttachments source="attach1" >
		<File filename="file2.pdf" mimetype="application/pdf"/>
		<FilenameEncoding encoding="UTF-8"/>
		<Description>Attaching file2</Description>
	</FileAttachments>

       <PDF source="In1" access="deptA"/>

</PDF>

<PasswordAccessProfile name="deptA">
       <Password>1</Password>
</PasswordAccessProfile>

</DDX>

The FileAttachments contains the following attributes:

·        source specifies the document to attach

·        filename denotes the name of the file that appears in the PDF document

·        mimetype is optional and can be specified as null

·        description provides the description for the file.

PasswordAccessProfile is used for password protected documents. Password sub element specifies the password for PDF source (i.e, In1).

The DDX script attaches “attach0” and “attach1” to “In1” and writes the PDF document to “Out1”. However, we need to pass the values for “attach0”, “attach1”, “In1” and “Out1” via ColdFusion struct.

Below is the cfm file for executing the above DDX script:

<cfset ddxfile = ExpandPath('.\ddx_test1.ddx')>
<cfset sourcefile = ExpandPath('.\ddx_test1.pdf')>
<cfset attachfile1 = ExpandPath('.\ddx_test2.pdf')>
<cfset attachfile2 = ExpandPath('.\ddx_test3.pdf')>
<cfset destinationfile = ExpandPath('.\ddx_result1.pdf')>

<cffile action="read" variable="myVar" file="#ddxfile#"/>

<cfset inputStruct=StructNew()>
<cfset inputStruct.In1="#sourcefile#">
<cfset inputStruct.attach0="#attachfile1#">
<cfset inputStruct.attach1="#attachfile2#">

<cfset outputStruct=StructNew()>
<cfset outputStruct.Out1="#destinationfile#">


<cfpdf action="processddx" ddxfile="#myVar#" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="ddxVar">

In the cfm, the source file and the attachments are passed to the inputStruct and the resultant file is passed to the outputStruct. Thought this example demonstrates using pdf files, in general any file can be attached to a PDF document.

 

 


New Product Roadmap for ColdFusion

August 18, 2015 / Rakshith Naresh

  Announcements

Here is the public facing roadmap for the upcoming two major versions of ColdFusion. The document lists out only the high level directions that are being considered for the future releases.

Here is the disclaimer about this public facing roadmap.

The intended future features or directions described in this document are under consideration by Adobe Systems and are not commitments for future products, technologies, or services. The roadmap is subject to change at Adobe Systems’ sole discretion and Adobe Systems does not guarantee the features or release dates.


Blue Mango Theme Design By Mark Aplet

Super Powered by Mango Blog