Blog Projects
Escape Keys
A ColdFusion and Web Development Blog by Tom de Manincor
 
Coldbox Install and Cookie Datasource Error

If you are using ColdBox and run into the missing Cookie Datasource error, it's most likely because you have your Cookies set to NONE in the ColdFusion Administrator and the Debug Console ENABLED in the ColdBox config. Toggle one of your settings and you'll be back in business.

Coldbox Config File:

<Setting name="DebugMode" value="true" />

If you are running a VM with VMWare and using Apache, you may run into some trouble mapping your Virtual Host.

Try doubling your slashes.

For example

"\\.host\Shared Folders\My Drive"

would be

I am running ColdFusion on my Windows 2003 Server VM. I have my files on my local machine, available to my VM via a shared folder. Meaning, IIS and CF see it as \.hostShared FoldersWebroot When Coldspring is initialized it runs theshrinkFullRelativePath method in the DefaultXmlBeanFactory.cfc

If you are passing in an expanded path then Coldspring will thrown an error because of the rebuilding of the path and the '\' before '.host' gets stripped down to '/' and is not a valid path.

Or, you are sending in a relative path and its just not found at all.

In the meantime modify this check before the return of the shrinkFullRelativePath method to:

<!--- Modified for Shared Folders in VMs --->
<cfif left(retVal,2) is "/.">
<cfset retVal = "/" & retVal>
</cfif>
<!--- Modified to Allow Relative Path --->
<cfif not directoryExists(getDirectoryFrompath(retVal)) and not directoryExists(getDirectoryFrompath(expandPath(retVal)))>
<cfthrow message="You have specified an invalid directory" detail="The directory path specified, #getDirectoryFromPath(retVal)# does not exist." />
</cfif>

If your're not dealing with a VM but still want to use Relative Paths, only use the second if statement.

** This may only be good for people using ColdFusion 7 and Up. (Application root mapping support issues)

This is a simple guide for a simple SVN server solution. I am installing Subversion with a MacPorts nice little auto-installer for public packages.

I started off by using MacPorts to search for the package with:

port search subversion

then installed the package with

sudo port install subversion

MacPorts installs all the required packages and the latest subversion release.

Subversion is now installed. Now let's get the Server setup.

Create a folder where you will be storing all your Repository files. (/RepoHome)

Then to create a new repo from the shell run:

svnadmin create /RepoHome/NewRepoName

This next step is Optional. If you want to have user authentication, you need to go to the folder of the repo you want to add security to. In the /conf folder you will see 3 files. Open all 3 and the comments say it all.

Now, to start up our SVN server.

svnserve -d -r /RepoHome
(this loads it in daemon mode with a root path of /RepoHome)

If running a Firewall be sure ports 3690 and 80 are open.

To connect to the repo point your SVN client to:

Using a Decorator with Transfer

Transfer was built to allow you to extend its capabilities. Using the Decorator Pattern you can overlay/overwrite methods of a TransferObject and add methods of your own. Remember its a Decorator to the Transfer Object(the Bean). So the methods you add should be relative to the Bean. To add DB or other external functions, there are other ways.

Here's how you setup the Decorator.

1. Add the decorator attribute to the object element in your Transfer Config XML file.

<objectDefinitions>
<package name="Account">
<object name="Account" table="Account" decorator="model.account.accountDecorator" >
<id name="AccountId" type="UUID" generate="true"/>
<property name="Username" type="string" nullable="false" />
<property name="Password" type="string" nullable="false" />
<property name="FirstName" type="string" nullable="true" />
<property name="LastName" type="string" nullable="true" />
<property name="Email" type="string" nullable="false" />
<property name="UpdatedOn" type="date" nullable="false" />
<property name="CreatedOn" type="date" ignore-update="true" />
</object>
</package>
</objectDefinitions>

2. Create your Decorator CFC and extend the Transfer Decorator Object.

<cfcomponent displayname="accountDecorator" hint="Decorates Account TransferObject" output="false" extends="transfer.com.TransferDecorator">

<cffunction name="setPassword" access="public" returntype="void" output="false" hint="Replaces original setPassword to MD5 Hash the Password">
<cfargument name="password" type="string" required="true" />
<cfset getTransferObject().setPassword(hash(password)) />
</cffunction>

</cfcomponent>

You also have access to getTransfer() when you extend the Transfer Decorator Object.

That's it. Re-init Transfer and your Decorator methods will now be available from your Transfer Objects.

To take it a step further, I have created a Base Decorator to share methods accross Decorators. But that's another Blog.

I just posted about doing this on a Mac. After I did that, I realized I need to install this on my server and start reading up on the security settings. But anyway, very similar to the Mac install, this is even easier, actually.

Grab the latest windows installer package from the Subversion Tigris Site.

Run the installer with the defaults.

Create a folder to house the Repositories. (/RepoHome)

Bring up a command promt and run: (startuncmd)

svnadmin create /RepoHome/NewRepoName

To setup user authentication and permissions go to the /RepoHome/NewRepoName/conf folder and open the 3 files in there. The comments in the files explain it all.

To start the SVN daemon run:

svnserve -d -r /RepoHome
(this starts it with a root of /RepoHome)

Ports used: 3690 and 80

To connect to the repo point your SVN client to:

Extending a Base Decorator with Transfer

So you have a few methods you want to include in every Transfer Object, and you don't want mess with mix-ins, and copy/paste isn't an option. You want to extend it but its already extending the transfer.com.TransferDecorator. So what can you do?

1. Create your Base Decorator CFC, and extend the transfer.com.TransferDecorator.

<cfcomponent displayname="baseDecorator" hint="This is the baseDecorator component" output="false" extends="transfer.com.TransferDecorator">

<cffunction name="listProperties" access="public" returntype="string" output="false" hint="Returns a List of the Properties">
<cfset var lReturn = '' />
<cfset var oIterator = getTransfer().getTransferMetaData(this.getClassName()).getPropertyIterator() />

<cfloop condition="#oIterator.hasNext()#">
<cfset lReturn = listAppend(lReturn,oIterator.next().getName()) />
</cfloop>

<cfreturn lReturn />
</cffunction>

<cffunction name="listColumns" access="public" returntype="string" output="false" hint="Returns a List of the Properties">
<cfset var lReturn = '' />
<cfset var oIterator = getTransfer().getTransferMetaData(this.getClassName()).getPropertyIterator() />

<cfloop condition="#oIterator.hasNext()#">
<cfset lReturn = listAppend(lReturn,oIterator.next().getColumn()) />
</cfloop>

<cfreturn lReturn />
</cffunction>

</cfcomponent>

2. Now change the 'extends' in the object decorator to extend the Base Decorator CFC

<cfcomponent displayname="accountDecorator" hint="This is the accountDecorator component" output="false" extends="model.baseDecorator">

<cffunction name="setPassword" access="public" returntype="void" output="false" hint="Replaces default setPassword method to MD5 Hash the Password">
<cfargument name="password" type="string" required="true" />
<cfset getTransferObject().setPassword(hash(password)) />
</cffunction>

</cfcomponent>

Now you'll have the baseDecorator and the accountDecorator methods available to you from your TransferObject.

Wait...What if you only need to extend the baseDecorator to your TransferObject and don't forsee a need for an accountDecorator? Dont create an empty accountDecorator just to extend the baseDecorator.

Change the value of the decorator attriute in the Transfer Config XML to the path of your baseDecorator.

<object name="Account" table="Account" decorator="model.baseDecorator" >