Tag Archives: java

Assurance

Introducing Assurance

Over the last few months, I’ve been working on a project and, today, I’m releasing the result of that project as Open Source Software. Assurance by Digital Generalists is an application that enables comprehensive file and folder comparison with tools to merge data on multiple operating systems.

Where to Find It

The project is hosted on GitHub at https://github.com/shelterbelt/assurance.

Inspiration for the Application

Over many years, I’ve collected a substantial library of electronic files ranging from simple text documents, spreadsheets from the very early ’90s, games, MP3s, videos, email archives, source code, etc… Because I had so much stuff, I had backups…plural. And backups of backups. And some stuff was on thumb drives because I needed it to be portable at some point. And some stuff eventually moved to newer machines, but I never deleted the copy on the older machine.

*sigh*

In short, I came to a point where I wanted to be able to compare the many copies of my digital archive, eliminate the redundant stuff, know where the latest version of everything was, and move things into a ‘repository-of-record’.

I easily could have purchased a tool to accomplish that task. There are highly-rated options available. Or I probably could have written a shell script that would have done the job from the command line.

However, I felt the problem presented a good opportunity to try out several software development frameworks and techniques I’ve been interested in learning more about. So I wrote Assurance instead.

What Is Assurance

Assurance is a cross-platform, client-only application written in Java that leverages both Spring and Hibernate with a Swing-based UI.

At it’s core, it is a tool to comprehensively compare and optionally synchronize the contents of files and directories.

While on first glance, Assurance may appear to be a good fit as a backup tool, it wasn’t really designed for those needs.  A backup tool should provide features like scheduling of jobs, conflict resolution, automated monitoring of the file system, one-click system restore, etc…  Assurance wasn’t built to solve those problems.  Assurance is very good at comparing files and directories and provides tools to manage differences.  It does those jobs well, but doesn’t claim to do more than that.

License

Assurance is released under the Apache License 2.0.

Prerequisites

The following tools need to be installed to build Assurance:

The Maven configuration will download and install the appropriate versions of the following tools:

  • Spring Framework
  • Hibernate
  • JUnit
  • H2
  • Apache Commons
  • Apple Java Extensions
  • SLF4J
  • Log4J

The following dependencies are required to run binary distributions of Assurance on Windows machines:

Mac distributions of Assurance package the appropriate JRE with the application bundle, eliminating the need to separately install Java on a Mac to run the application.  Windows distributions require that the JRE be installed prior to starting the application.

Building and Packaging

Assurance uses Maven as its primary build and dependency management system.

To build the application:

Mac

cd project_root/assurance
mvn clean package -Pdevelopment

Windows

cd project_root\assurance
mvn clean package -Pdevelopment-windows

To run the unit tests:

Mac

cd project_root/assurance
mvn clean test -Pdevelopment

Windows

cd project_root\assurance
mvn clean test -Pdevelopment-windows

To package the application for internal release:

Mac

cd project_root/assurance
mvn clean package -Pintrelease

Windows

cd project_root\assurance
mvn clean package -Pintrelease-windows

To package the application for release:

Mac

cd project_root/assurance
mvn clean package -Prelease

Windows

cd project_root\assurance
mvn clean package -Prelease-windows

IDE

Assurance was developed using Spring Tool Suite 3.6.1. Project files for the IDE are included with the distribution.

Acknowledgments

Assurance includes a modified version of the

com.ibatis.common.jdbc.ScriptRunner

class from the iBATIS Apache project.

Why a Digital Generalists Product?

Digital Generalists serves as the primary way I deliver products to the world. For full products, I want Digital Generalists to hold the copyright and serve as the primary entity releasing the software to the world.

The fact that Digital Generalists, rather than me personally, is the entity releasing the product, doesn’t affect or impact how you can use the software.  As long as you abide the attached software license, you can use the product and source as you wish.

How to Convert a String Representing a Unicode Character Sequence to the Unicode Character

I recently received some translated resource files from the Translations team at work.  To my surprise, all of the files, even those for double-byte languages, were returned in ASCII encoded files.  After some inquiry, I found out that because of the technical limitations of a proven legacy system, all translation files were encoded as ASCII.  What this meant is that I was confronted with a set of ASCII text files containing Unicode escape sequences (\uxxxx) that I was responsible for converting to a proper Unicode encoding.

While solving the problem, I came across a couple solutions for converting Unicode escape sequences to a different encoding.  The first was to use the StringEscapeUtils class in Apache Commons Lang.

String lineOfUnicodeText = StringEscapeUtils.unescapeJava(lineOfASCIIText);

Using the StringEscapeUtils class is very straightforward; simply read the contents of the the ASCII file line-by-line, feed the line of data in to the unescapeJava method, and write the unescaped text to a properly-encoded new file.  But this technique requires writing a utility program to feed the contents of the ASCII files into the StringEscapeUtils methods and then write the transformed string to a new file.  Not hard to do, but much more work than ideal.

The second solution is to use the native2ascii utility included with the Java JDK.  The utility can take the input file and perform effectively the same unescape transformation that Apache Commons does.

native2ascii -encoding utf8 c:\source.txt c:\output.txt

A very simple solution that works as advertised.  No quirks or caveats that I’ve noticed.  There’s even an ANT task for incorporating native2ascii into build scripts.