FTP Facade Utility for ColdFusion

Posted by & filed under ColdFusion.

In a recent project at work, we needed a simpler approach to using the FTP solution built into Adobe ColdFusion.  A couple of the drawbacks to the current implementation of cfftp in ColdFusion are:

  • A cached connection variable must be stored at the template page level.  Using a class facade, we are able to store the persisted connection within the component (class).
  • Deleting files and folders does not check if the file exists first, our facade takes care of that.  If the file doesn’t exist, and we are attempting to remove a directory or file, it throws a custom exception type that we can catch.
  • If the connection is closed on the remote server, we want our facade to handle reconnecting, not each implementation of cfftp.
  • Recursive putting and deleting of directories.  This was a big deal for our project, and it didn’t make sense to implement this in the code specific to the project, but to have a general purpose method to putDirectory() and removeDirectory().

Our facade/utility does have a dependency on our Exception factory, which is stored in the application.exceptions application variable.  If you would like to use this code, you can replace these with your own exception handling, or just plain cfthrow tags.  Our utility class also uses a logger factory that follows the principles of the Java logging utility logf4j.  You can read more about my simple logging utility.  Lastly, the facade is programmed using CFML rather than the more succinct cfscript as our project required this.

(more…)

OS X Mavericks and Apache

Posted by & filed under Apache, ColdFusion, PHP.

OS-X-Mavericks-logo

Web Development with Apache, PHP and ColdFusion on OS X Mavericks

Getting your web development environment set up on OS X Mavericks is very similar to setting it up on Mountain Lion, or other previous releases of Apple’s OS.  If you already had your environment set up previously, and upgraded to OS X 10.9 (Mavericks), then you will notice that your httpd.conf configuration has been replaced.  But, don’t fret.  You can find your old configuration located at: /private/etc/apache2/httpd.conf.pre-update.  Let’s go ahead and get started!

(more…)

Logger Service for ColdFusion

Posted by & filed under ColdFusion.

In an effort to show how easy it is to use cfscript and object-oriented ColdFusion to create a simple logger service layer in your application, I am releasing some code that I use in my projects.  In this example I will show the implementation for a simple ColdFusionLogLogger — this means that my implementation will be logging to the application log in ColdFusion.  You can extend this example to implement a new Logger class (component) that logs to a database, or sends an email when an error occurs, or whatever your project requires.  This simple example will compose several classes:

  • LoggerService (implement IService)
  • Logger (implements ILogger)
  • LogLevel
  • ColdFusionLogLogger (extends Logger)

(more…)

Getting Started with Composer and CakePHP

Posted by & filed under PHP.

Composer is a dependency management tool for PHP; perhaps comparable to using Maven for a Java project.  I have used Maven for building both a Java project, as well as building a mobile application for Android and iOS using flex-mojos and Adobe AIR.  So, getting to learn about Composer has been a very enjoyable.  I wanted to learn how to user Composer to use the following libraries:

  1. CakePHP
  2. DebugKit
  3. Localized
  4. BoostCake

(more…)

JavaScript’s hasOwnProperty() method

Posted by & filed under JavaScript.

A common question asked by students who are learning JavaScript is: “what is the purpose of the hasOwnProperty() method?”  This is a good question.  It can be confusing why you would need to use this method, and what it actually does.  We will look at what the method does, why you need to use it, and what are some ways to avoid having to use it.

(more…)

Custom Maven 2 settings for Elastic Bamboo

Posted by & filed under Maven.

We use Atlassian’s Bamboo for continuous integration, which has a build step for performing a clean install of our app.  This build step relies on using Maven, which then relies on pulling artifacts from our Nexus server.  In short, I want to document how you can populate an EBS instance with a custom Maven settings.xml file that will be deployed to an elastic Amazon EC2 instance each time it is started on demand.

(more…)

Add new sudo user to EC2 Ubuntu

Posted by & filed under Ubuntu.

This post is more for me as a reference guide for adding a new user to Ubuntu. I just spun up a new instance on AWS and want to create a new user that has sudo privileges so I can use this user rather than the default ubuntu root user. I also want to have SSH use my computer’s private key rather than having to authenticate using the private key generated by AWS.

(more…)

Deploying Files to Archiva

Posted by & filed under Maven.

After successfully installing Apache Archiva, the next step is to set up your local maven installation and to deploy the necessary artifacts to the Archiva server.  We will be:

  1. Configuring access to our repositories in the ~/.m2/settings.xml file.
  2. Copying out any dependencies from an existing project.
  3. Creating a bash script to install the dependencies into our local repository (stored in ~/.m2/repository).
  4. Creating a bash script to deploy the dependencies to our remote repository.

(more…)