Repository: incubator-systemml
Updated Branches:
  refs/heads/master 88030df8f -> 32f075695


[SYSTEMML-1440] Automate Release Artifact verification

Closes #469.


Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/32f07569
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/32f07569
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/32f07569

Branch: refs/heads/master
Commit: 32f075695b8d64e5df17137ed6da9517a0c1325d
Parents: 88030df
Author: Arvind Surve <[email protected]>
Authored: Tue Apr 25 08:42:53 2017 -0700
Committer: Arvind Surve <[email protected]>
Committed: Tue Apr 25 08:42:53 2017 -0700

----------------------------------------------------------------------
 dev/release/artifact-verify.sh                  | 131 ----------
 dev/release/release-verify.sh                   | 197 +++++++++++++++
 dev/release/src/test/bin/verifyBuild.sh         | 173 +++++++++++++
 .../org/apache/sysml/validation/Constants.java  |  75 ++++++
 .../org/apache/sysml/validation/Utility.java    | 195 ++++++++++++++
 .../sysml/validation/ValidateLicAndNotice.java  | 253 +++++++------------
 6 files changed, 725 insertions(+), 299 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/artifact-verify.sh
----------------------------------------------------------------------
diff --git a/dev/release/artifact-verify.sh b/dev/release/artifact-verify.sh
deleted file mode 100755
index fbe7b96..0000000
--- a/dev/release/artifact-verify.sh
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-function exit_with_usage {
-  cat << EOF
-
-artifact-verify - Verifies the artifacts from a given directory.
-
-SYNOPSIS
-
-usage: artifact-verify.sh [--compile | --verify]
-
-DESCRIPTION
-
-Once artifacts are generated, this utility will verify the artifacts.
-
---compile
-This will compile the utility source code which is not on regular source code 
path.
-
---verify [--distDir="Directory Containing zip/tgz files]
-Publish the maven artifacts of a release to the Apache staging maven 
repository.
-
-OPTIONS
-
---distDir            - Directory containing release artifacts (zip/tzg) files.
-
-
-EXAMPLES
-
-# To compile utility source code
-artifact-verify.sh --compile
-
-# To verify release artifacts
-artifact-verify.sh --verify 
--distDir="../../../target/release/incubator-systemml/target"
-
-EOF
-  exit 1
-}
-
-set -e
-
-if [ $# -eq 0 ]; then
-  exit_with_usage
-fi
-
-
-# Process each provided argument configuration
-while [ "${1+defined}" ]; do
-  IFS="=" read -ra PARTS <<< "$1"
-  case "${PARTS[0]}" in
-    --compile)
-      GOAL="compile"
-      COMPILE_CODE=true
-      shift
-      ;;
-    --verify)
-      GOAL="verify"
-      ARTIFACT_VERIFY=true
-      shift
-      ;;
-    --distDir)
-      DIST_DIR="${PARTS[1]}"
-      shift
-      ;;
-
-    *help* | -h)
-      exit_with_usage
-     exit 0
-     ;;
-    -*)
-     echo "Error: Unknown option: $1" >&2
-     exit 1
-     ;;
-    *)  # No more options
-     break
-     ;;
-  esac
-done
-
-ORIG_DIR=$(pwd)
-EXEC_DIR="`dirname \"$0\"`"
-if [[ ${EXEC_DIR:0:1} != "/" ]]; then
-    EXEC_DIR=$ORIG_DIR/$EXEC_DIR
-fi
-cd $EXEC_DIR/src/test/java
-
-if [[ "$ARTIFACT_VERIFY" == "true" && -z "$DIST_DIR" ]]; then
-    echo "WARNING: Since --distDir has not passed, default distribution 
directory '$EXEC_DIR/target/release/incubator-systemml/target' has been used."
-    DIST_DIR="$EXEC_DIR/target/release/incubator-systemml/target"
-elif [[ ${DIST_DIR:0:1} != "/" ]]; then
-    DIST_DIR="$ORIG_DIR/$DIST_DIR"
-fi
-
-if [[ "$COMPILE_CODE" == "true" ]]; then
-    echo "Compiling artifact utility..."
-
-    javac -Xlint:unchecked -classpath 
../../../../..//target/lib/commons-compress-1.4.1.jar:../../../../..//target/lib/commons-io-2.4.jar:.
 org/apache/sysml/validation/ValidateLicAndNotice.java
-
-    cd "$ORIG_DIR" # Return to directoryt from it was called.
-    exit 0
-fi
-
-
-if [[ "$ARTIFACT_VERIFY" == "true" ]]; then
-    echo "Verifying artifats from '$DIST_DIR' directory"
-
-    java -classpath 
../../../../..//target/lib/commons-compress-1.4.1.jar:../../../../..//target/lib/commons-io-2.4.jar:.
 org/apache/sysml/validation/ValidateLicAndNotice $DIST_DIR
-
-    cd "$ORIG_DIR" # Return to directoryt from it was called.
-    exit 0
-fi
-
-cd "$ORIG_DIR" #return to original dir
-echo "ERROR: wrong execution goals"
-exit_with_usage

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/release-verify.sh
----------------------------------------------------------------------
diff --git a/dev/release/release-verify.sh b/dev/release/release-verify.sh
new file mode 100755
index 0000000..ddccb5b
--- /dev/null
+++ b/dev/release/release-verify.sh
@@ -0,0 +1,197 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+function exit_with_usage {
+  cat << EOF
+
+release-verify - Verifies the artifacts from a given directory.
+
+SYNOPSIS
+
+usage: release-verify.sh [--compile | --verifyAll | verifyLic | verifyBin]
+
+DESCRIPTION
+
+Once artifacts are generated, this utility will verify the artifacts.
+
+--compile
+This will compile the utility source code which is not on regular source code 
path.
+
+--verifyAll <--tag="Code based on Git tag will be validated."> 
[--workDir="Directory where output files will be created]
+This will verify license, notice and binary files. 
+
+--verifyLic [--distDir="Directory Containing zip/tgz files]
+This will verify license, notice in zip/tgz files. 
+
+--verifyBin <--tag="Code based on Git tag will be validated."> 
[--workDir="Directory where output files will be created]
+This will verify binary distribution files for runtime correctness. 
+
+OPTIONS
+
+--distDir            - Directory containing release artifacts (zip/tzg) files.
+
+--workDir             - Directory where output files will be created.
+
+EXAMPLES
+
+# To compile utility source code
+release-verify.sh --compile
+
+# To verify release artifacts
+release-verify.sh --verifyAll --tag=<tagName>
+e.g. ./release-verify.sh --verifyAll --tag=v0.14.0-incubating-rc4
+
+# To verify license and notices
+release-verify.sh --verifyLic --distDir=<DistribLocation>
+e.g. ./release-verify.sh --verifyLic --distDir=tmp/relValidation/downloads
+
+# To verify binary files
+release-verify.sh --verifyBin --tag=<tagName>
+e.g. ./release-verify.sh --verifyBin --tag=v0.14.0-incubating-rc4
+
+
+EOF
+  exit 1
+}
+
+set -e
+
+if [ $# -eq 0 ]; then
+  echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Insuffient parameters passed.";
+  exit_with_usage
+fi
+
+
+# Process each provided argument configuration
+while [ "${1+defined}" ]; do
+  IFS="=" read -ra PARTS <<< "$1"
+  case "${PARTS[0]}" in
+    --compile)
+      COMPILE_CODE=true
+      shift
+      ;;
+    --verifyAll)
+      LIC_NOTICE_VERIFY=true
+      BIN_VERIFY=true
+      shift
+      ;;
+    --verifyLic)
+      LIC_NOTICE_VERIFY=true
+      shift
+      ;;
+    --verifyBin)
+      BIN_VERIFY=true
+      shift
+      ;;
+    --distDir)
+      DIST_DIR="${PARTS[1]}"
+      shift
+      ;;
+    --workDir)
+      WORK_DIR="${PARTS[1]}"
+      shift
+      ;;
+    --tag)
+      TAG="${PARTS[1]}"
+      shift
+      ;;
+    *help* | -h)
+      exit_with_usage
+     exit 0
+     ;;
+    -*)
+     echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Unknown option: $1" >&2
+     exit_with_usage
+     ;;
+    *)  # No more options
+     break
+     ;;
+  esac
+done
+
+ORIG_DIR=$(pwd)
+EXEC_DIR="`dirname \"$0\"`"
+if [[ ${EXEC_DIR:0:1} != "/" ]]; then
+    EXEC_DIR=$ORIG_DIR/$EXEC_DIR
+fi
+
+if [[ -z "$WORK_DIR" ]]; then
+    WORK_DIR="$EXEC_DIR/tmp/relValidation"
+elif [[ ${WORK_DIR:0:1} != "/" ]]; then
+    WORK_DIR="$ORIG_DIR/$WORK_DIR"
+fi
+
+# If --verifyAll has been specified en license and notice validation should be 
done from place where all files downloaded in --verifyBin step.
+if [[ "$BIN_VERIFY" == "true" && "$LIC_NOTICE_VERIFY" == "true" ]]; then
+    DIST_DIR=$WORK_DIR/downloads
+fi
+
+if [[ "$BIN_VERIFY" == "true" && -z "$TAG" ]]; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Argument --tag is a mandatory 
variable for binary verification."
+    exit_with_usage
+fi
+
+if [[ "$LIC_NOTICE_VERIFY" == "true" && -z "$DIST_DIR" ]]; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: WARNING: Since --distDir has not passed, 
default distribution directory 
'$EXEC_DIR/target/release/incubator-systemml/target' has been used."
+    DIST_DIR="$EXEC_DIR/target/release/incubator-systemml/target"
+elif [[ ${DIST_DIR:0:1} != "/" ]]; then
+    DIST_DIR="$ORIG_DIR/$DIST_DIR"
+fi
+
+cd $EXEC_DIR/src/test/java
+if [[ "$COMPILE_CODE" == "true" ]]; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Compiling release verify utility..."
+
+    javac -Xlint:unchecked -classpath 
../../../../..//target/lib/commons-compress-1.4.1.jar:../../../../..//target/lib/commons-io-2.4.jar:.
 org/apache/sysml/validation/*.java
+
+    cd "$ORIG_DIR" # Return to directoryt from it was called.
+    exit 0
+fi
+
+if [[ "$BIN_VERIFY" == "true" ]]; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying binary files for runtime 
execution..."
+
+#    java -classpath 
../../../../..//target/lib/commons-compress-1.4.1.jar:../../../../..//target/lib/commons-io-2.4.jar:.
 org/apache/sysml/validation/ValidateBuildAndBinary $TAG $WORK_DIR
+    $EXEC_DIR/src/test/bin/verifyBuild.sh $TAG $WORK_DIR
+    RET_CODE=$?
+    if [[ $RET_CODE == 0 ]]; then
+       echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verification of binary files for 
runtime execution completed successfully."
+    else
+       echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Verification of binary files 
for runtime execution failed."
+       cd $ORIG_DIR
+       exit $RET_CODE
+    fi
+    echo 
"*********************************************************************************************************************"
+fi
+
+if [[ "$LIC_NOTICE_VERIFY" == "true" ]]; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying license and notices from 
zip/tgz files..."
+
+    java -classpath 
../../../../..//target/lib/commons-compress-1.4.1.jar:../../../../..//target/lib/commons-io-2.4.jar:.
 org/apache/sysml/validation/ValidateLicAndNotice $DIST_DIR
+    RET_CODE=$?
+    if [[ $RET_CODE == 0 ]]; then
+       echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verification of license and 
notices completed successfully."
+    else
+       echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Verification of license and 
notices failed."
+    fi
+    echo 
"*********************************************************************************************************************"
+fi
+
+cd "$ORIG_DIR" # Return to directory from it was called.
+exit $RET_CODE

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/src/test/bin/verifyBuild.sh
----------------------------------------------------------------------
diff --git a/dev/release/src/test/bin/verifyBuild.sh 
b/dev/release/src/test/bin/verifyBuild.sh
new file mode 100755
index 0000000..1133bc8
--- /dev/null
+++ b/dev/release/src/test/bin/verifyBuild.sh
@@ -0,0 +1,173 @@
+#!/usr/bin/env bash
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+# error help print
+printUsageExit()
+{
+cat << EOF
+Usage: $0 <Tag Name> [Working Directory] [-help]
+    Tag Name:           is the name of tag for which verification will be done
+    Working Directory:  will be used to clone/download repo/files for 
validation
+    -help:              Print this usage message and exit
+EOF
+  exit 1
+}
+
+runCommand()
+{
+    command=$1
+    echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Running command '$command' ..." 
>>$OUT_FILE
+    eval ${command} 1>>$OUT_FILE 2>>$ERR_FILE
+
+    RETURN_CODE=$?
+
+    # if there was an error, display the full command
+    if [ $RETURN_CODE -ne 0 ]
+    then
+        echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Failed to run command 
'$command' with exit code: $RETURN_CODE"
+        echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Failed to run command 
'$command' with exit code: $RETURN_CODE" >>$OUT_FILE
+        LF=$'\n'
+        exit 1
+    fi
+}
+
+while getopts "h:" options; do
+  case $options in
+    h ) echo Warning: Help requested. Will exit after usage message
+        printUsageExit
+        ;;
+    \? ) echo Warning: Help requested. Will exit after usage message
+        printUsageExit
+        ;;
+    * ) echo Error: Unexpected error while processing options
+  esac
+done
+
+if [ -z "$1" ] ; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Insuffient parameters passed."; # 
TagName has not passed.
+    printUsageExit;
+fi
+
+if [ -z "$SPARK_HOME" ] ; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Environment variable 'SPARK_HOME' 
has not been defined.";
+    printUsageExit;
+fi
+
+if [ -z "$HADOOP_HOME" ] ; then
+    echo "`date +%Y-%m-%dT%H:%M:%S`: ERROR: Environment variable 'HADOOP_HOME' 
has not been defined.";
+    printUsageExit;
+fi
+
+# find the root path which contains the script file
+# tolerate path with spaces
+SCRIPT_DIR=$( dirname "$0" )
+USER_DIR=$( cd "${SCRIPT_DIR}/../../../" ; pwd -P )
+
+TAG_NAME=$1
+shift
+WORKING_DIR=$1
+
+if [ -z $WORKING_DIR ] ; then
+    WORKING_DIR="$USER_DIR/tmp/relValidation"
+fi
+
+mkdir -p "$WORKING_DIR"
+OUT_FILE=$WORKING_DIR/relValidation.out
+ERR_FILE=$WORKING_DIR/relValidation.err
+
+## Clone the branch and build distribution package
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Cloning branch and building 
distribution package..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Cloning branch and building 
distribution package." >> $OUT_FILE
+echo 
"========================================================================================================="
 >> $OUT_FILE
+runCommand "cd $WORKING_DIR"
+runCommand "git clone https://github.com/apache/incubator-systemml.git";
+runCommand "cd incubator-systemml"
+runCommand "git checkout tags/$TAG_NAME -b $TAG_NAME"
+runCommand "mvn -Dmaven.repo.local=$HOME/.m2/temp-repo clean package -P 
distribution"
+echo 
"========================================================================================================="
 >> $OUT_FILE
+
+# Removes v from tag to get distribution directory name
+if [[ ${TAG_NAME:0:1} == "v" ]]; then
+    DIST_DIR=${TAG_NAME:1}
+else
+    DIST_DIR=$TAG_NAME
+fi
+
+VER_NAME=`expr "$DIST_DIR" : '^\(.[.0-9]*\)'`
+
+## Download binaries from distribution location and verify them
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Downloading binaries from distribution 
location..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Downloading binaries from distribution 
location." >> $OUT_FILE
+runCommand "mkdir -p $WORKING_DIR/downloads"
+runCommand "cd $WORKING_DIR/downloads"
+runCommand "wget -r -nH -nd -np -R 'index.html*' 
https://dist.apache.org/repos/dist/dev/incubator/systemml/$DIST_DIR/";
+echo 
"========================================================================================================="
 >> $OUT_FILE
+
+## Verify binary tgz files
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying binary tgz files..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying binary tgz files..." >> 
$OUT_FILE
+runCommand "rm -rf systemml-$VER_NAME-incubating-bin"
+runCommand "tar -xvzf systemml-$VER_NAME-incubating-bin.tgz"
+runCommand "cd systemml-$VER_NAME-incubating-bin"
+runCommand "echo \"print('hello world');\" > hello.dml"
+runCommand "./runStandaloneSystemML.sh hello.dml"
+runCommand "cd .."
+
+## Verify binary zip files
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying binary zip files..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying binary zip files..." >> 
$OUT_FILE
+runCommand "rm -rf systemml-$VER_NAME-incubating-bin"
+runCommand "unzip systemml-$VER_NAME-incubating-bin.zip"
+runCommand "cd systemml-$VER_NAME-incubating-bin"
+runCommand "echo \"print('hello world');\" > hello.dml"
+runCommand "./runStandaloneSystemML.sh hello.dml"
+runCommand "cd .."
+
+## Verify src tgz files
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying source tgz files..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying source tgz files..." >> 
$OUT_FILE
+runCommand "rm -rf systemml-$VER_NAME-incubating-src"
+runCommand "tar -xvzf systemml-$VER_NAME-incubating-src.tgz"
+runCommand "cd systemml-$VER_NAME-incubating-src"
+runCommand "mvn clean package -P distribution"
+runCommand "cd target"
+runCommand "java -cp \"./lib/*:systemml-$VER_NAME-incubating.jar\" 
org.apache.sysml.api.DMLScript -s \"print('hello world');\""
+runCommand "java -cp \"./lib/*:SystemML.jar\" org.apache.sysml.api.DMLScript 
-s \"print('hello world');\""
+runCommand "cd ../.."
+
+## Verify Spark batch mode
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying Spark batch mode..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying Spark batch mode..." >> 
$OUT_FILE
+runCommand "cd systemml-$VER_NAME-incubating-bin/lib"
+runCommand "$SPARK_HOME/bin/spark-submit systemml-$VER_NAME-incubating.jar -s 
\"print('hello world');\" -exec hybrid_spark"
+
+## Verify Hadoop batch mode
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying Hadoop batch mode..."
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verifying Hadoop batch mode..." >> 
$OUT_FILE
+runCommand "$HADOOP_HOME/bin/hadoop jar systemml-$VER_NAME-incubating.jar -s 
\"print('hello world');\""
+runCommand "cd ../.."
+
+echo "`date +%Y-%m-%dT%H:%M:%S`: INFO: Verification of binary files completed 
successfully."
+# echo 
"================================================================================"
+
+exit 0
+

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/src/test/java/org/apache/sysml/validation/Constants.java
----------------------------------------------------------------------
diff --git 
a/dev/release/src/test/java/org/apache/sysml/validation/Constants.java 
b/dev/release/src/test/java/org/apache/sysml/validation/Constants.java
new file mode 100644
index 0000000..056ed8f
--- /dev/null
+++ b/dev/release/src/test/java/org/apache/sysml/validation/Constants.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.sysml.validation;
+
+
+/**
+ * This class includes constants used across validation programs.
+ */
+public class Constants
+{
+       //Return codes
+       public static final int SUCCESS = 0;
+       public static final int NO_ZIP_TGZ = 1;                 // 0000 0000 
0000 0001
+       public static final int FILE_NOT_IN_LIC = 2;    // 0000 0000 0000 0010
+       public static final int FILE_NOT_IN_ZIP = 4;    // 0000 0000 0000 0100
+       public static final int FAILED_TO_EXTRACT = 8;  // 0000 0000 0000 1000
+       public static final int LIC_NOT_EXIST = 16;             // 0000 0000 
0001 0000
+       public static final int JS_CSS_LIC_NOT_EXIST = 32;      // 0000 0000 
0010 0000
+       public static final int INVALID_NOTICE = 64;    // 0000 0000 0100 0000
+       public static final int FAILED_TO_CREATE_DIR = 128;     // 0000 0000 
1000 0000
+       public static final int FAILURE = 0xFFFF;
+
+       public static final boolean bSUCCESS = true;
+       public static final boolean bFAILURE = false;
+
+
+       //DEBUG PRINT CODE
+       public static final int DEBUG_PRINT_LEVEL = 3;
+
+       public static final int DEBUG_ERROR = 0;
+       public static final int DEBUG_WARNING = 1;
+       public static final int DEBUG_INFO = 2;
+       public static final int DEBUG_INFO2 = 3;
+       public static final int DEBUG_INFO3 = 4;
+       public static final int DEBUG_CODE = 5;
+
+       static final int BUFFER = 2048;
+
+       //String constants
+       public static final String SYSTEMML_NAME = "SystemML";
+       public static final String SYSTEMML_PACKAGE = "org/apache/sysml";
+
+       public static final String ZIP = "zip";
+       public static final String TGZ = "tgz";
+       public static final String LICENSE = "LICENSE";
+       public static final String NOTICE = "NOTICE";
+       public static final String JAR = "jar";
+       public static final String DLL = "dll";
+       public static final String EXP = "exp";
+       public static final String LIB = "lib";
+       public static final String PDB = "pdb";
+       public static final String EXE = "exe";
+       public static final String CLASS = "class";
+       public static final String JS = "js";
+       public static final String CSS = "css";
+       public static final String LIC_TEXT_DELIM = "=====";
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/src/test/java/org/apache/sysml/validation/Utility.java
----------------------------------------------------------------------
diff --git a/dev/release/src/test/java/org/apache/sysml/validation/Utility.java 
b/dev/release/src/test/java/org/apache/sysml/validation/Utility.java
new file mode 100644
index 0000000..e73a2a4
--- /dev/null
+++ b/dev/release/src/test/java/org/apache/sysml/validation/Utility.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.sysml.validation;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.lang.Process;
+import java.lang.ProcessBuilder;
+import java.time.format.DateTimeFormatter;
+import java.time.LocalDateTime;
+
+
+/**
+ * This is an utility class to include any utility functios.
+ */
+public class Utility
+{
+       /**
+        * This will be used to output on console in consistent and controlled 
based on DEBUG flag.
+        *
+        * @param       debugLevel is the debuglevel message user wants to 
prrint message.
+        * @param       message is the message to be displayed.
+        * @return
+        */
+       public static void debugPrint(int debugLevel, String message) {
+               debugPrint(debugLevel, message, null);
+       }
+
+       /**
+        * This will be used to output on console in consistent and controlled 
based on DEBUG flag.
+        *
+        * @param       debugLevel is the debuglevel message user wants to 
prrint message.
+        * @param       message is the message to be displayed.
+        * @param   strOutputFile is the filename to print output.
+        * @return
+        */
+       public static void debugPrint(int debugLevel, String message, String 
strOutputFile) {
+
+               if(debugLevel > Constants.DEBUG_PRINT_LEVEL)
+                       return;
+
+               String displayMessage = "";
+               switch (debugLevel) {
+                       case Constants.DEBUG_ERROR:
+                               displayMessage = "ERROR: " + message;
+                               break;
+                       case Constants.DEBUG_WARNING:
+                               displayMessage = "WARNING: " + message;
+                               break;
+                       case Constants.DEBUG_INFO:
+                               displayMessage = "INFO: " + message;
+                               break;
+                       case Constants.DEBUG_INFO2:
+                               displayMessage = "INFO2: " + message;
+                               break;
+                       case Constants.DEBUG_INFO3:
+                               displayMessage = "INFO3: " + message;
+                               break;
+                       case Constants.DEBUG_CODE:
+                               displayMessage = "DEBUG: " + message;
+                               break;
+                       default:
+                               break;
+               }
+
+               LocalDateTime currentDateTime = LocalDateTime.now();
+               String strDateTime = 
currentDateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
+
+               if(strOutputFile == null || strOutputFile.trim().length() == 0)
+                       System.out.println(strDateTime + ": " + displayMessage);
+               else {
+                       PrintWriter printWriter = null;
+                       try {
+                               printWriter = new PrintWriter(new 
BufferedWriter(new FileWriter(strOutputFile, true)));
+                               printWriter.println(strDateTime + ": " + 
displayMessage);
+                       } catch (IOException ioe) {
+                               debugPrint(Constants.DEBUG_ERROR, "Exception 
while printing message to file " + strOutputFile + ioe);
+                               debugPrint(debugLevel, message);
+                       }
+                       if(printWriter != null)
+                               printWriter.close();
+               }
+       }
+
+       /**
+        * This function will run command specified abd redirect stdout/stderr 
per instruction.
+        *
+        * @param
+        * @param
+        * @return
+        */
+       public static int runCommand(String [] command, String strCurDir, 
String strOutputFile, String strErrorFile, String strMessage)
+               throws IOException
+       {
+               if(strMessage != null && strMessage.trim().length() > 0)
+                       debugPrint(Constants.DEBUG_INFO, strMessage, 
strOutputFile);
+
+               debugPrint(Constants.DEBUG_CODE, "Running command: '" + 
String.join(" ", command) + "'", strOutputFile);
+
+               ProcessBuilder processBuilder = new ProcessBuilder(command);
+
+               // Set current working directory for command to run.
+               if(strCurDir != null && strCurDir.trim().length() > 0)
+                       processBuilder.directory(new File(strCurDir));
+
+               // Start the process
+               Process process = processBuilder.start();
+
+               // Read the output from runtime and redirect to file/stdout
+               InputStreamReader insIn = new 
InputStreamReader(process.getInputStream());
+               BufferedReader bufIn = new BufferedReader(insIn);
+
+               boolean bWriteOutToFile = false;
+               PrintWriter writerOut = null;
+               try {
+                       if(strOutputFile != null && 
strOutputFile.trim().length() > 0)
+                               bWriteOutToFile = true;
+                       if(bWriteOutToFile)
+                               writerOut = new PrintWriter(new 
BufferedWriter(new FileWriter(strOutputFile,true)));
+
+                       // Read standard output after running the command.
+                       String strLine;
+                       while ((strLine = bufIn.readLine()) != null) {
+                               if (bWriteOutToFile)
+                                       writerOut.println(strLine);
+                               else
+                                       debugPrint(Constants.DEBUG_INFO2, 
"StdOut: " + strLine);
+                       }
+               } catch (IOException ioe) {
+                       debugPrint(Constants.DEBUG_ERROR, "Exception occured 
while reading from process output: " + ioe, strOutputFile);
+               }
+               if(bWriteOutToFile && writerOut != null)
+                       writerOut.close();
+
+               // Read the output from runtime and redirect to file/stdout
+               InputStreamReader insErr = new 
InputStreamReader(process.getErrorStream());
+               BufferedReader bufErr = new BufferedReader(insErr);
+
+               boolean bWriteErrToFile = false;
+               PrintWriter writerErr = null;
+               try {
+                       if(strErrorFile != null && strErrorFile.trim().length() 
> 0)
+                               bWriteErrToFile = true;
+                       if(bWriteErrToFile)
+                               writerErr = new PrintWriter(new 
BufferedWriter(new FileWriter(strErrorFile,true)));
+
+                       // Read standard output after running the command.
+                       String strLine;
+                       while ((strLine = bufErr.readLine()) != null) {
+                               if (bWriteErrToFile)
+                                       writerErr.println(strLine);
+                               else
+                                       debugPrint(Constants.DEBUG_INFO2, 
"StdErr: " + strLine);
+                       }
+               } catch (IOException ioe) {
+                       debugPrint(Constants.DEBUG_ERROR, "Exception occured 
while reading from process error stream: " + ioe, strOutputFile);
+               }
+               if(bWriteErrToFile && writerErr != null)
+                       writerErr.close();
+
+               // Wait for program to exit.
+               int exitValue = -1;
+               try {
+                       exitValue = process.waitFor();
+               } catch (InterruptedException ie) {
+                       debugPrint(Constants.DEBUG_ERROR, "Program 
interrunpted: " + ie);
+               }
+               debugPrint(Constants.DEBUG_CODE, "Program '" + String.join(" ", 
command) + "' exited with exit status " + exitValue, strOutputFile);
+
+               return exitValue;
+       }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/32f07569/dev/release/src/test/java/org/apache/sysml/validation/ValidateLicAndNotice.java
----------------------------------------------------------------------
diff --git 
a/dev/release/src/test/java/org/apache/sysml/validation/ValidateLicAndNotice.java
 
b/dev/release/src/test/java/org/apache/sysml/validation/ValidateLicAndNotice.java
index 74300ef..21099d3 100644
--- 
a/dev/release/src/test/java/org/apache/sysml/validation/ValidateLicAndNotice.java
+++ 
b/dev/release/src/test/java/org/apache/sysml/validation/ValidateLicAndNotice.java
@@ -52,54 +52,7 @@ import org.apache.commons.io.FileUtils;
  */
 public class ValidateLicAndNotice 
 {
-       //Return codes
-       public static final int SUCCESS = 0;
-       public static final int NO_ZIP_TGZ = 1;                 // 0000 0000 
0000 0001
-       public static final int FILE_NOT_IN_LIC = 2;    // 0000 0000 0000 0010
-       public static final int FILE_NOT_IN_ZIP = 4;    // 0000 0000 0000 0100
-       public static final int FAILED_TO_EXTRACT = 8;  // 0000 0000 0000 1000
-       public static final int LIC_NOT_EXIST = 16;             // 0000 0000 
0001 0000
-       public static final int JS_CSS_LIC_NOT_EXIST = 32;      // 0000 0000 
0010 0000
-       public static final int INVALID_NOTICE = 64;    // 0000 0000 0100 0000
-       public static final int FAILURE = 0xFFFF;
-
-       public static final boolean bSUCCESS = true;
-       public static final boolean bFAILURE = false;
-
-
-       //DEBUG PRINT CODE
-       public static final int DEBUG_PRINT_LEVEL = 3;
-
-       public static final int DEBUG_ERROR = 0;
-       public static final int DEBUG_WARNING = 1;
-       public static final int DEBUG_INFO = 2;
-       public static final int DEBUG_INFO2 = 3;
-       public static final int DEBUG_INFO3 = 4;
-       public static final int DEBUG_CODE = 5;
-
-
-       static final int BUFFER = 2048;
-
-       //String constants
-       public static final String SYSTEMML_NAME = "SystemML";
-       public static final String SYSTEMML_PACKAGE = "org/apache/sysml";
-
-       public static final String ZIP = "zip";
-       public static final String TGZ = "tgz";
-       public static final String LICENSE = "LICENSE";
-       public static final String NOTICE = "NOTICE";
-       public static final String JAR = "jar";
-       public static final String DLL = "dll";
-       public static final String EXP = "exp";
-       public static final String LIB = "lib";
-       public static final String PDB = "pdb";
-       public static final String EXE = "exe";
-       public static final String CLASS = "class";
-       public static final String JS = "js";
-       public static final String CSS = "css";
-       public static final String LIC_TEXT_DELIM = "=====";
-
-       public static String[] fileTypes = {JAR, DLL, EXP, LIB, PDB, EXE};
+       public static String[] fileTypes = {Constants.JAR, Constants.DLL, 
Constants.EXP, Constants.LIB, Constants.PDB, Constants.EXE};
 
        // Zip Distribution directory.
        private String strDistroDir =  
"../../../target/release/incubator-systemml/target/";
@@ -147,13 +100,13 @@ public class ValidateLicAndNotice
         */
        public int validate() throws Exception {
 
-               int retCode = SUCCESS, retCodeForAllFileTypes = SUCCESS, 
retCodeAll = SUCCESS;
+               int retCode = Constants.SUCCESS, retCodeForAllFileTypes = 
Constants.SUCCESS, retCodeAll = Constants.SUCCESS;
 
                File distroRoot = new File( getDistroDir());
                File libDirectory = distroRoot;
                if (!libDirectory.exists()) {
-                       debugPrint(DEBUG_ERROR, "Distribution folder '" + 
libDirectory.getAbsoluteFile().toString() + "' does not exist.");
-                       return NO_ZIP_TGZ;
+                       Utility.debugPrint(Constants.DEBUG_ERROR, "Distribution 
folder '" + libDirectory.getAbsoluteFile().toString() + "' does not exist.");
+                       return Constants.NO_ZIP_TGZ;
                }
 
                File outTempDir = File.createTempFile("outTemp", "");
@@ -162,37 +115,37 @@ public class ValidateLicAndNotice
 
                List<String> zips = getZipsInDistro(libDirectory);
                if(zips.size() == 0) {
-                       debugPrint(DEBUG_ERROR, "Can't find zip/tgz files in 
folder: " + libDirectory.getAbsoluteFile().toString());
-                       return NO_ZIP_TGZ;
+                       Utility.debugPrint(Constants.DEBUG_ERROR, "Can't find 
zip/tgz files in folder: " + libDirectory.getAbsoluteFile().toString());
+                       return Constants.NO_ZIP_TGZ;
                }
 
                for (String zipFile: zips)
                {
-                       retCodeForAllFileTypes = SUCCESS;
-                       debugPrint(DEBUG_INFO, 
"======================================================================================");
-                       debugPrint(DEBUG_INFO, "Validating zip file : " + 
zipFile + " ...");
+                       retCodeForAllFileTypes = Constants.SUCCESS;
+                       Utility.debugPrint(Constants.DEBUG_INFO, 
"======================================================================================");
+                       Utility.debugPrint(Constants.DEBUG_INFO, "Validating 
zip file : " + zipFile + " ...");
 
                        for (String fileType: fileTypes) {
-                               retCode = SUCCESS;
+                               retCode = Constants.SUCCESS;
 
                                List<String> filesAll = null;
                                // Extract license/notice only at first time in 
all filetypes validation for a given zip.
-                               if(fileType == JAR) {
-                                       if 
(!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, LICENSE, 
outTempDir.getAbsolutePath(), true))
-                                               return FAILED_TO_EXTRACT;
-                                       if 
(!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, NOTICE, 
outTempDir.getAbsolutePath(), true))
-                                               return FAILED_TO_EXTRACT;
+                               if(fileType == Constants.JAR) {
+                                       if 
(!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, 
Constants.LICENSE, outTempDir.getAbsolutePath(), true))
+                                               return 
Constants.FAILED_TO_EXTRACT;
+                                       if 
(!ValidateLicAndNotice.extractFile(libDirectory + "/" + zipFile, 
Constants.NOTICE, outTempDir.getAbsolutePath(), true))
+                                               return 
Constants.FAILED_TO_EXTRACT;
                                }
 
                                filesAll = getFiles(libDirectory + "/" + 
zipFile, fileType);
 
-                               File licenseFile = new File(outTempDir, 
LICENSE);
+                               File licenseFile = new File(outTempDir, 
Constants.LICENSE);
                                List<String> files = new ArrayList<String>();
                                List<String> fileSysml = new 
ArrayList<String>();
                                for (String file : filesAll) {
-                                       int sysmlLen = SYSTEMML_NAME.length();
+                                       int sysmlLen = 
Constants.SYSTEMML_NAME.length();
                                        String strBegPart = file.substring(0, 
sysmlLen);
-                                       if 
(strBegPart.compareToIgnoreCase(SYSTEMML_NAME) != 0)
+                                       if 
(strBegPart.compareToIgnoreCase(Constants.SYSTEMML_NAME) != 0)
                                                files.add(file);
                                        else
                                                fileSysml.add(file);
@@ -201,43 +154,43 @@ public class ValidateLicAndNotice
 
                                List<String> bad2 = 
getLICENSEFilesNotInList(licenseFile, files, fileType);
                                if (bad2.size() > 0) {
-                                       debugPrint(DEBUG_WARNING,"Files in 
LICENSE but not in Distribution: " + bad2);
-                                       retCode += FILE_NOT_IN_ZIP;
+                                       
Utility.debugPrint(Constants.DEBUG_WARNING,"Files in LICENSE but not in 
Distribution: " + bad2);
+                                       retCode += Constants.FILE_NOT_IN_ZIP;
                                }
 
                                List<String> bad1 = 
getFilesNotInLICENSE(licenseFile, files, fileType);
                                if (bad1.size() > 0) {
-                                       debugPrint(DEBUG_ERROR,"Files in 
distribution but not in LICENSE: " + bad1);
-                                       retCode += FILE_NOT_IN_LIC;
+                                       
Utility.debugPrint(Constants.DEBUG_ERROR,"Files in distribution but not in 
LICENSE: " + bad1);
+                                       retCode += Constants.FILE_NOT_IN_LIC;
                                }
 
                                // Validate shaded jar and notice only one time 
for each zip/tgz file.
-                               if(fileType == JAR) {
+                               if(fileType == Constants.JAR) {
                                        for (String file : fileSysml)
                                                retCode += 
ValidateLicAndNotice.validateShadedLic(libDirectory + "/" + zipFile, file, 
outTempDir.getAbsolutePath());
-                                       if 
(!validateNotice(outTempDir.getAbsolutePath()+"/"+NOTICE)) {
-                                               debugPrint(DEBUG_ERROR, "Notice 
validation falied, please check notice file manually in this zip/tgz file.");
-                                               retCode += INVALID_NOTICE;
+                                       if 
(!validateNotice(outTempDir.getAbsolutePath()+"/"+Constants.NOTICE)) {
+                                               
Utility.debugPrint(Constants.DEBUG_ERROR, "Notice validation falied, please 
check notice file manually in this zip/tgz file.");
+                                               retCode += 
Constants.INVALID_NOTICE;
                                        }
                                        if (!validateJSCssLicense(licenseFile, 
libDirectory + "/" + zipFile)) {
-                                               debugPrint(DEBUG_ERROR, "JS/CSS 
license validation falied, please check license file manually in this zip/tgz 
file.");
-                                               retCode += JS_CSS_LIC_NOT_EXIST;
+                                               
Utility.debugPrint(Constants.DEBUG_ERROR, "JS/CSS license validation falied, 
please check license file manually in this zip/tgz file.");
+                                               retCode += 
Constants.JS_CSS_LIC_NOT_EXIST;
                                        }
                                }
 
-                               if (retCode  == SUCCESS)
-                                       debugPrint(DEBUG_INFO3, "Validation of 
file type '." + fileType + "' in zip/tgz file : " + zipFile + " completed 
successfully.");
+                               if (retCode  == Constants.SUCCESS)
+                                       
Utility.debugPrint(Constants.DEBUG_INFO3, "Validation of file type '." + 
fileType + "' in zip/tgz file : " + zipFile + " completed successfully.");
                                else {
-                                       debugPrint(DEBUG_ERROR, "License/Notice 
validation failed for zip/tgz file " + zipFile + " with error code " + retCode 
+ ", please validate file manually.");
-                                       retCodeForAllFileTypes = FAILURE;
+                                       
Utility.debugPrint(Constants.DEBUG_ERROR, "License/Notice validation failed for 
zip/tgz file " + zipFile + " with error code " + retCode + ", please validate 
file manually.");
+                                       retCodeForAllFileTypes = 
Constants.FAILURE;
                                }
                        }
-                       if(retCodeForAllFileTypes == SUCCESS)
-                               debugPrint(DEBUG_INFO, "Validation of zip/tgz 
file : " + zipFile + " completed successfully.");
+                       if(retCodeForAllFileTypes == Constants.SUCCESS)
+                               Utility.debugPrint(Constants.DEBUG_INFO, 
"Validation of zip/tgz file : " + zipFile + " completed successfully.");
 
-                       retCodeAll = retCodeForAllFileTypes != 
SUCCESS?FAILURE:retCodeAll;
+                       retCodeAll = retCodeForAllFileTypes != 
Constants.SUCCESS?Constants.FAILURE:retCodeAll;
                }
-               debugPrint(DEBUG_INFO, 
"======================================================================================");
+               Utility.debugPrint(Constants.DEBUG_INFO, 
"======================================================================================");
 
                FileUtils.deleteDirectory(outTempDir);
                return retCodeAll;
@@ -257,15 +210,15 @@ public class ValidateLicAndNotice
                File outTempDir2 = new File (outTempDir + "/" + "2");
                outTempDir2.mkdir();
                if(!ValidateLicAndNotice.extractFile(zipFileName, file, 
outTempDir2.getAbsolutePath(), false))
-                       return FAILED_TO_EXTRACT;
-               
if(!ValidateLicAndNotice.extractFile(outTempDir2.getAbsolutePath()+"/"+file, 
LICENSE, outTempDir2.getAbsolutePath(), true))
-                       return FAILED_TO_EXTRACT;
+                       return Constants.FAILED_TO_EXTRACT;
+               
if(!ValidateLicAndNotice.extractFile(outTempDir2.getAbsolutePath()+"/"+file, 
Constants.LICENSE, outTempDir2.getAbsolutePath(), true))
+                       return Constants.FAILED_TO_EXTRACT;
 
                HashMap<String, Boolean> hashMapPackages = 
getPackagesFromZip(outTempDir2.getAbsolutePath() + "/" + file);
                for (String packageName: hashMapPackages.keySet())
-                       debugPrint(DEBUG_CODE, "Package: " + packageName + " 
Licensed: " + hashMapPackages.get(packageName));
+                       Utility.debugPrint(Constants.DEBUG_CODE, "Package: " + 
packageName + " Licensed: " + hashMapPackages.get(packageName));
 
-               int iRetCode = 
ValidateLicAndNotice.validatePackages(outTempDir2.getAbsolutePath()+"/"+LICENSE,
 hashMapPackages);
+               int iRetCode = 
ValidateLicAndNotice.validatePackages(outTempDir2.getAbsolutePath()+"/"+Constants.LICENSE,
 hashMapPackages);
 
                FileUtils.deleteDirectory(outTempDir2);
                return iRetCode;
@@ -280,7 +233,7 @@ public class ValidateLicAndNotice
         */
        public static int validatePackages(String licenseFile, HashMap<String, 
Boolean> hashMapPackages) throws Exception
        {
-               int iRetCode = SUCCESS;
+               int iRetCode = Constants.SUCCESS;
                BufferedReader reader = new BufferedReader(new 
FileReader(licenseFile));
                String line = null;
                HashSet <String> packageValidLic = new HashSet<String>();
@@ -289,7 +242,7 @@ public class ValidateLicAndNotice
                        for(int i=0; i <packageLicenses.length; ++i) {
                                if (line.contains(packageLicenses[i][1])) {
                                        
packageValidLic.add(packageLicenses[i][0]);
-                                       debugPrint(DEBUG_INFO3, "License for 
package " + packageLicenses[i][0] + " exists.");
+                                       
Utility.debugPrint(Constants.DEBUG_INFO3, "License for package " + 
packageLicenses[i][0] + " exists.");
                                }
                        }
                }
@@ -308,8 +261,8 @@ public class ValidateLicAndNotice
                while (itPackages.hasNext()) {
                        Map.Entry pairPackage = (Map.Entry) itPackages.next();
                        if(!(Boolean)pairPackage.getValue()) {
-                               debugPrint(DEBUG_WARNING, "Could not validate 
license for package " + pairPackage.getKey() + ", please validate manually.");
-                               iRetCode = LIC_NOT_EXIST;
+                               Utility.debugPrint(Constants.DEBUG_WARNING, 
"Could not validate license for package " + pairPackage.getKey() + ", please 
validate manually.");
+                               iRetCode = Constants.LIC_NOT_EXIST;
                        }
                }
 
@@ -330,13 +283,13 @@ public class ValidateLicAndNotice
                        Enumeration e = zipfile.entries();
                        while(e.hasMoreElements()) {
                                entry = (ZipEntry) e.nextElement();
-                               if(! 
entry.getName().startsWith(SYSTEMML_PACKAGE) &&
-                                    entry.getName().endsWith("." + CLASS)) {
+                               if(! 
entry.getName().startsWith(Constants.SYSTEMML_PACKAGE) &&
+                                    entry.getName().endsWith("." + 
Constants.CLASS)) {
                                        int iPos = 
entry.getName().lastIndexOf("/");
                                        if (iPos > 0) {
                                                String strPackageName = 
entry.getName().substring(0, iPos);
                                                packages.put(strPackageName, 
Boolean.FALSE);
-                                               debugPrint(DEBUG_CODE, "Package 
found : " + strPackageName);
+                                               
Utility.debugPrint(Constants.DEBUG_CODE, "Package found : " + strPackageName);
                                        }
                                }
                        }
@@ -452,7 +405,7 @@ public class ValidateLicAndNotice
        private List<String> getZipsInDistro(File directory) {
                List<String> zips = new ArrayList<String>();
                for (String fileName : directory.list())
-                       if ((fileName.endsWith("." + ZIP)) || 
(fileName.endsWith("." + TGZ)))
+                       if ((fileName.endsWith("." + Constants.ZIP)) || 
(fileName.endsWith("." + Constants.TGZ)))
                                zips.add(fileName);
                return zips;
        }
@@ -487,12 +440,12 @@ public class ValidateLicAndNotice
         * @return  Success or Failure
         */
        public static boolean extractFile(String zipFileName, String fileName, 
String strDestLoc, boolean bFirstDirLevel) {
-               debugPrint(DEBUG_CODE, "Extracting " + fileName + " from 
jar/zip/tgz file " + zipFileName);
-               if (zipFileName.endsWith("." + ZIP) || zipFileName.endsWith("." 
+ JAR))
+               Utility.debugPrint(Constants.DEBUG_CODE, "Extracting " + 
fileName + " from jar/zip/tgz file " + zipFileName);
+               if (zipFileName.endsWith("." + Constants.ZIP) || 
zipFileName.endsWith("." + Constants.JAR))
                        return extractFileFromZip(zipFileName, fileName, 
strDestLoc, bFirstDirLevel);
-               else if (zipFileName.endsWith("." + TGZ))
+               else if (zipFileName.endsWith("." + Constants.TGZ))
                        return extractFileFromTGZ(zipFileName, fileName, 
strDestLoc, bFirstDirLevel);
-               return bFAILURE;
+               return Constants.bFAILURE;
        }
 
 
@@ -506,7 +459,7 @@ public class ValidateLicAndNotice
         * @return  Sucess or Failure
         */
        public static boolean extractFileFromZip (String zipFileName, String 
fileName, String strDestLoc, boolean bFirstDirLevel) {
-               boolean bRetCode = bFAILURE;
+               boolean bRetCode = Constants.bFAILURE;
                try {
                        BufferedOutputStream bufOut = null;
                        BufferedInputStream bufIn = null;
@@ -523,17 +476,17 @@ public class ValidateLicAndNotice
                                        continue;
                                bufIn = new 
BufferedInputStream(zipfile.getInputStream(entry));
                                int count;
-                               byte data[] = new byte[BUFFER];
+                               byte data[] = new byte[Constants.BUFFER];
                                String strOutFileName = strDestLoc == null ? 
entry.getName(): strDestLoc + "/" + fileName; 
                                FileOutputStream fos = new 
FileOutputStream(strOutFileName);
-                               bufOut = new BufferedOutputStream(fos, BUFFER);
-                               while ((count = bufIn.read(data, 0, BUFFER)) != 
-1) {
+                               bufOut = new BufferedOutputStream(fos, 
Constants.BUFFER);
+                               while ((count = bufIn.read(data, 0, 
Constants.BUFFER)) != -1) {
                                        bufOut.write(data, 0, count);
                                }
                                bufOut.flush();
                                bufOut.close();
                                bufIn.close();
-                               bRetCode = bSUCCESS;
+                               bRetCode = Constants.bSUCCESS;
                                break;
                        }
                } catch(Exception e) {
@@ -553,7 +506,7 @@ public class ValidateLicAndNotice
         */
        public static boolean extractFileFromTGZ (String tgzFileName, String 
fileName, String strDestLoc, boolean bFirstDirLevel) {
 
-               boolean bRetCode = bFAILURE;
+               boolean bRetCode = Constants.bFAILURE;
 
                TarArchiveInputStream tarIn = null; 
 
@@ -564,7 +517,7 @@ public class ValidateLicAndNotice
                                                        new BufferedInputStream(
                                                                new 
FileInputStream(tgzFileName))));
                } catch(Exception e) {
-                       debugPrint(DEBUG_ERROR, "Exception in unzipping tar 
file: " + e);
+                       Utility.debugPrint(Constants.DEBUG_ERROR, "Exception in 
unzipping tar file: " + e);
                        return bRetCode;
                } 
 
@@ -581,17 +534,17 @@ public class ValidateLicAndNotice
                                        continue;
                                bufIn = new BufferedInputStream (tarIn);
                                int count;
-                               byte data[] = new byte[BUFFER];
+                               byte data[] = new byte[Constants.BUFFER];
                                String strOutFileName = strDestLoc == null ? 
tarEntry.getName(): strDestLoc + "/" + fileName; 
                                FileOutputStream fos = new 
FileOutputStream(strOutFileName);
-                               bufOut = new BufferedOutputStream(fos, BUFFER);
-                               while ((count = bufIn.read(data, 0, BUFFER)) != 
-1) {
+                               bufOut = new BufferedOutputStream(fos, 
Constants.BUFFER);
+                               while ((count = bufIn.read(data, 0, 
Constants.BUFFER)) != -1) {
                                        bufOut.write(data, 0, count);
                                }
                                bufOut.flush();
                                bufOut.close();
                                bufIn.close();
-                               bRetCode = bSUCCESS;
+                               bRetCode = Constants.bSUCCESS;
                                break;
                        }
                } catch(Exception e) {
@@ -608,9 +561,9 @@ public class ValidateLicAndNotice
         * @return      Returns list of files having specified extention from 
zip file .
         */
        public static List<String> getFiles (String zipFileName, String 
fileExt) {
-               if (zipFileName.endsWith("." + ZIP))
+               if (zipFileName.endsWith("." + Constants.ZIP))
                        return getFilesFromZip (zipFileName, fileExt);
-               else if (zipFileName.endsWith("." + TGZ))
+               else if (zipFileName.endsWith("." + Constants.TGZ))
                        return getFilesFromTGZ (zipFileName, fileExt);
                return null;
        }
@@ -661,7 +614,7 @@ public class ValidateLicAndNotice
                                                        new BufferedInputStream(
                                                                new 
FileInputStream(tgzFileName))));
                } catch(Exception e) {
-                       debugPrint(DEBUG_ERROR, "Exception in unzipping tar 
file: " + e);
+                       Utility.debugPrint(Constants.DEBUG_ERROR, "Exception in 
unzipping tar file: " + e);
                        return null;
                } 
 
@@ -691,7 +644,7 @@ public class ValidateLicAndNotice
         */
        public static boolean validateNotice(String noticeFile) throws 
Exception {
 
-               boolean bValidNotice = bSUCCESS;
+               boolean bValidNotice = Constants.bSUCCESS;
 
                LocalDateTime currentTime = LocalDateTime.now();
 
@@ -716,12 +669,12 @@ public class ValidateLicAndNotice
 
                for (int i = 0; i < noticeLines.length; i++) {
                        if (!noticeLineIn[i]) {
-                               bValidNotice = bFAILURE;
+                               bValidNotice = Constants.bFAILURE;
                        }
                }
 
-               if(bValidNotice == bSUCCESS)
-                       debugPrint(DEBUG_INFO2, "Notice validation 
successful.");
+               if(bValidNotice == Constants.bSUCCESS)
+                       Utility.debugPrint(Constants.DEBUG_INFO2, "Notice 
validation successful.");
 
                return bValidNotice;
        }
@@ -735,11 +688,11 @@ public class ValidateLicAndNotice
         */
        public static boolean validateJSCssLicense(File licenseFile, String 
zipFileName) throws Exception
        {
-               boolean bRetCode = bSUCCESS;
+               boolean bRetCode = Constants.bSUCCESS;
 
                try {
-                       List<String> jsFiles = getFiles(zipFileName, JS);
-                       List<String> cssFiles = getFiles(zipFileName, CSS);
+                       List<String> jsFiles = getFiles(zipFileName, 
Constants.JS);
+                       List<String> cssFiles = getFiles(zipFileName, 
Constants.CSS);
                        HashMap<String, Boolean> jsCssFileHashMap = new 
HashMap<String, Boolean>();
                        for (String jsFile : jsFiles)
                                if(jsFile.compareTo("main.js") != 0)
@@ -754,7 +707,7 @@ public class ValidateLicAndNotice
                        while ((line = reader.readLine()) != null) {
                                line = line.trim();
                                //Move to beginning of individual License text
-                               if (line.startsWith(LIC_TEXT_DELIM))
+                               if (line.startsWith(Constants.LIC_TEXT_DELIM))
                                        break;
                        }
 
@@ -763,7 +716,7 @@ public class ValidateLicAndNotice
 
                                List<String> curLicense = new 
ArrayList<String>();
                                //Read all lines until end of individual 
License text
-                               while (!line.startsWith(LIC_TEXT_DELIM)) {
+                               while 
(!line.startsWith(Constants.LIC_TEXT_DELIM)) {
                                        curLicense.add(line);
                                        if ((line = reader.readLine()) == null)
                                                break;
@@ -799,8 +752,8 @@ public class ValidateLicAndNotice
 
                                String[][] jsFileLicList = 
hmJSLicenses.get(pairJSCSSFile.getKey());
                                if(jsFileLicList == null) {
-                                       debugPrint(DEBUG_WARNING, "JS/CSS 
license does not exist for file " + pairJSCSSFile.getKey());
-                                       bRetCode = bFAILURE;
+                                       
Utility.debugPrint(Constants.DEBUG_WARNING, "JS/CSS license does not exist for 
file " + pairJSCSSFile.getKey());
+                                       bRetCode = Constants.bFAILURE;
                                        continue;
                                }
 
@@ -814,16 +767,16 @@ public class ValidateLicAndNotice
 
                                if (bValidLic) {
                                        
jsCssFileHashMap.put(pairJSCSSFile.getKey(), Boolean.TRUE);
-                                       debugPrint(DEBUG_INFO3, "JS/CSS license 
exists for file " + pairJSCSSFile.getKey());
+                                       
Utility.debugPrint(Constants.DEBUG_INFO3, "JS/CSS license exists for file " + 
pairJSCSSFile.getKey());
                                }
                                else {
-                                       debugPrint(DEBUG_WARNING, "JS/CSS 
license does not exist for file " + pairJSCSSFile.getKey());
-                                       bRetCode = bFAILURE;
+                                       
Utility.debugPrint(Constants.DEBUG_WARNING, "JS/CSS license does not exist for 
file " + pairJSCSSFile.getKey());
+                                       bRetCode = Constants.bFAILURE;
                                }
                        }
 
-                       if (bRetCode == bSUCCESS)
-                               debugPrint(DEBUG_INFO2, "JS/CSS license 
validation successful.");
+                       if (bRetCode == Constants.bSUCCESS)
+                               Utility.debugPrint(Constants.DEBUG_INFO2, 
"JS/CSS license validation successful.");
 
                } catch (Exception e) {
                        System.out.println(e);
@@ -848,47 +801,11 @@ public class ValidateLicAndNotice
                try { 
                        int retCode = valLic.validate();
 
-                       debugPrint(DEBUG_INFO, "Return code = " + retCode);
+                       Utility.debugPrint(Constants.DEBUG_INFO, "Return code = 
" + retCode);
                }
                catch (Exception e) {
-                       debugPrint(DEBUG_ERROR, "Error while validating license 
in zip/tgz file." + e);
+                       Utility.debugPrint(Constants.DEBUG_ERROR, "Error while 
validating license in zip/tgz file." + e);
                }
        }
 
-       /**
-        * This will be used to output on console in consistent and controlled 
based on DEBUG flag.
-        *
-        * @param       debugLevel is the debuglevel message user wants to 
prrint message.
-        * @param       message is the message to be displayed.
-        * @return
-        */
-       public static void debugPrint(int debugLevel, String message) {
-               String displayMessage = "";
-               switch (debugLevel) {
-                       case DEBUG_ERROR:
-                               displayMessage = "ERROR: " + message;
-                               break;
-                       case DEBUG_WARNING:
-                               displayMessage = "WARNING: " + message;
-                               break;
-                       case DEBUG_INFO:
-                               displayMessage = "INFO: " + message;
-                               break;
-                       case DEBUG_INFO2:
-                               displayMessage = "INFO2: " + message;
-                               break;
-                       case DEBUG_INFO3:
-                               displayMessage = "INFO3: " + message;
-                               break;
-                       case DEBUG_CODE:
-                               displayMessage = "DEBUG: " + message;
-                               break;
-                       default:
-                               break;
-               }
-
-               if(debugLevel <= DEBUG_PRINT_LEVEL)
-                       System.out.println(displayMessage);
-       }
-
 }

Reply via email to