[snofyre] r1808 committed - Commit after changes to 1.8 release to add installer modifications.

0 views
Skip to first unread message

sno...@googlecode.com

unread,
Feb 3, 2011, 2:54:16 AM2/3/11
to snofy...@googlegroups.com
Revision: 1808
Author: jay.kola
Date: Wed Feb 2 23:53:21 2011
Log: Commit after changes to 1.8 release to add installer modifications.
http://code.google.com/p/snofyre/source/detail?r=1808

Added:

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/extract-pack.bat
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/extract-pack.sh
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp-get.bat
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp-get.sh
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp_info.txt

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/packextract.properties

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/ZipArchiveUtils.java
Modified:
/tags/srth-osgi/srth-osgi-1.8/distribution
/tags/srth-osgi/srth-osgi-1.8/distribution/pom.xml
/tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/install.xml
/tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/processPanelSpec.xml
/tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/userInputSpec.xml

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/temp/post-install.bat

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/DocumentationLauncher.java

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/FileDownloader.java

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/ProcessExecutor.java

/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/TRUDConnectionValidator.java

=======================================
--- /dev/null
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/extract-pack.bat
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,5 @@
+# -- script for unpacking trud pack manually -- #
+@ECHO OFF
+cd $INSTALL_PATH\configurator
+java -jar ${app.configurator.name}.jar
+@ECHO OFF
=======================================
--- /dev/null
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/extract-pack.sh
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,3 @@
+#!/bin/sh
+cd %{INSTALL_PATH}/configurator
+java -jar ${app.configurator.name}.jar
=======================================
--- /dev/null
+++ /tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp-get.bat
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,4 @@
+@ECHO OFF
+cd $INSTALL_PATH
+ftp -n -s:ftp_info.txt
+@ECHO OFF
=======================================
--- /dev/null
+++ /tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp-get.sh
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,14 @@
+#!/bin/sh
+####### FTP Script for downloading TRUD archive #########
+cd %{INSTALL_PATH}
+ftp -n www.uktcdownload.nss.cfh.nhs.uk << EOF
+user %{trud.user.name} %{trud.password}
+prompt off
+cd NHSSNOFYRE
+cd 2.0.0
+cd NHS_SNOFYREDATA
+bin
+get ${trud.pack.name}
+disconnect
+bye
+EOF
=======================================
--- /dev/null
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/ftp_info.txt
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,11 @@
+open www.uktcdownload.nss.cfh.nhs.uk
+user $trud.user.name
+$trud.password
+prom off
+cd NHSSNOFYRE
+cd 2.0.0
+cd NHS_SNOFYREDATA
+binary
+get ${trud.pack.name}
+disconnect
+bye
=======================================
--- /dev/null
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/bin/packextract.properties
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,5 @@
+# -- properties file that determines how the trud pack is extracted -- #
+trud.pack.name=${trud.pack.name}
+installation.path=$INSTALL_PATH
+snofyre.pack.name=snofyre-data.zip
+snomed.pack.name=snomed-data.zip
=======================================
--- /dev/null
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/ZipArchiveUtils.java
Wed Feb 2 23:53:21 2011
@@ -0,0 +1,159 @@
+package uk.nhs.cfh.dsp.srth.distribution;
+
+
+
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipFile;
+
+import java.io.*;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.logging.FileHandler;
+import java.util.logging.Logger;
+
+/**
+ * An utility class for performing zip operations on a zip archive
+ *
+ * <br>Version : @#VersionNumber#@
+ * <br>Written by @author Jay Kola
+ * <br>Created on Feb 1, 2011 at 5:19:10 PM
+ */
+public class ZipArchiveUtils {
+
+ private static Logger logger =
Logger.getLogger(FileDownloader.class.getName());
+ private static final String SEPARATOR =
System.getProperty("file.separator");
+ private static final String USER_DIR = System.getProperty("user.dir");
+ private static final String ERR_MESSAGE = "Nested exception message
is : ";
+
+ public ZipArchiveUtils() {
+ try
+ {
+ logger.addHandler(new
FileHandler(System.getProperty("java.io.tmpdir")+
+ SEPARATOR+"configurator.log", true));
+ }
+ catch (IOException e) {
+ logger.warning(ERR_MESSAGE+ e.fillInStackTrace().getMessage());
+ }
+ }
+
+ public static void copyInputStream(InputStream in, OutputStream out)
+ throws IOException{
+ byte[] buffer = new byte[1024];
+ int len;
+
+ while((len = in.read(buffer)) >= 0)
+ out.write(buffer, 0, len);
+
+ in.close();
+ out.close();
+ logger.info("Finished copying inputstream.");
+ }
+
+ public static void extractZipFileContents(File file){
+ if (file != null) {
+ extractZipFileContents(file, file.getParent());
+ }
+ }
+
+ public static void extractZipFileContents(File file, String
destinationFolder) {
+ try
+ {
+ logger.info("Extracting zip file contents...");
+ ZipFile zipFile = new ZipFile(file);
+
+ Enumeration entries = zipFile.getEntries();
+
+ while(entries.hasMoreElements()) {
+ ZipArchiveEntry entry =
(ZipArchiveEntry)entries.nextElement();
+
+ if(entry.isDirectory()) {
+
+ logger.info("Extracting directory: " +
entry.getName());
+ File dir = new File(destinationFolder,
entry.getName());
+ boolean canWrite = dir.exists();
+ if(! canWrite)
+ {
+ canWrite = dir.mkdir();
+ }
+
+ if(canWrite){
+ continue;
+ }
+ else{
+ logger.warning("Error creating directory during
extraction");
+ }
+ }
+
+ logger.info("Extracting file: " + entry.getName());
+ copyInputStream(zipFile.getInputStream(entry),
+ new BufferedOutputStream(new FileOutputStream(new
File(destinationFolder, entry.getName()))));
+ }
+
+ zipFile.close();
+ logger.info("Closed zip file.");
+ } catch (IOException e) {
+ logger.warning("Nested exception is : " +
e.fillInStackTrace());
+ }
+ }
+
+ public static void main(String[] args) {
+
+ String propsFilePath = "packextract.properties";
+ // check properties file exists in configurator folder
+ File propsFile = new File(USER_DIR, propsFilePath);
+ if(propsFile.exists() && propsFile.canRead())
+ {
+ // load values from properties file
+ Properties props = new Properties();
+ try
+ {
+ props.load(new FileInputStream(propsFile));
+ String trudPackName = props.getProperty("trud.pack.name");
+ String installationPath =
props.getProperty("installation.path");
+ String snofyrePackName =
props.getProperty("snofyre.pack.name");
+ String snomedPackName =
props.getProperty("snomed.pack.name");
+
+ // check downloaded pack exists
+// String downloadedPackPath =
installationPath+SEPARATOR+trudPackName;
+ logger.info("Verifying downloaded pack and starting
extraction");
+ File downloadedPack = new File(installationPath,
trudPackName);
+ if(downloadedPack.exists() && downloadedPack.canRead())
+ {
+// // extract pack into same folder
+//
ZipArchiveUtils.extractZipFileContents(downloadedPack);
+
+ // extract snofyre data to installation folder
+ logger.info("Extracting TRUD Pack");
+ ZipArchiveUtils.extractZipFileContents(downloadedPack,
installationPath);
+
+ File snofyrePack = new File(installationPath,
snofyrePackName);
+ if(snofyrePack.exists() && snofyrePack.canRead())
+ {
+ logger.info("Extracting SNOFYRE CT DATA");
+
ZipArchiveUtils.extractZipFileContents(snofyrePack, installationPath);
+ }
+
+ File snomedPack = new File(installationPath,
snomedPackName);
+ if(snomedPack.exists() && snomedPack.canRead())
+ {
+ logger.info("Extracting SNOMED CT DATA");
+ ZipArchiveUtils.extractZipFileContents(snomedPack,
installationPath);
+ }
+
+ logger.info("Finished downloading all packs from
TRUD");
+ }
+ else
+ {
+ logger.info("Error unpacking downloaded pack. Pack has
not been downloaded or is corrupt!");
+ }
+ }
+ catch (IOException e) {
+ logger.warning(ERR_MESSAGE + e.fillInStackTrace());
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Can not find properties
file. It must located at : "+USER_DIR+SEPARATOR+propsFilePath);
+ }
+ }
+}
=======================================
--- /tags/srth-osgi/srth-osgi-1.8/distribution/pom.xml Fri Jan 28 13:03:23
2011
+++ /tags/srth-osgi/srth-osgi-1.8/distribution/pom.xml Wed Feb 2 23:53:21
2011
@@ -10,8 +10,8 @@
<properties>
<spring.dm.version>1.2.0</spring.dm.version>
<spring.core.version>2.5.6.SEC01</spring.core.version>
- <snobj.project.version>0.8-SNAPSHOT</snobj.project.version>
- <yasb.project.version>0.8-SNAPSHOT</yasb.project.version>
+ <snobj.project.version>0.8</snobj.project.version>
+ <yasb.project.version>0.8</yasb.project.version>
<staging.dir>${project.build.directory}/staging</staging.dir>

<configurator.staging.dir>${project.build.directory}/configurator-staging</configurator.staging.dir>
<osgi.dir>osgi</osgi.dir>
@@ -23,17 +23,11 @@
<app.configurator.name>AppPathFormatter</app.configurator.name>
<executable.name>bin</executable.name>

<installer.free.packs.location>/Users/Shared/Sappheiros/</installer.free.packs.location>
-
<!--<snomed.data.file.name>snomed-data.zip</snomed.data.file.name>-->
- <!--<snomed.index.file.name>index.zip</snomed.index.file.name>-->
-
<!--<sappheiros.data.file.name>snofyre-data.zip</sappheiros.data.file.name>-->
-
<!--<sappheiros.javadoc.file.name>apidocs.zip</sappheiros.javadoc.file.name>-->
- <!--<snomed.mrcm.file.name>mrcm.zip</snomed.mrcm.file.name>-->
<inst.man.name>snofyre-installation-manual.pdf</inst.man.name>

<func.serv.man.name>snofyre-functional-services-manual.pdf</func.serv.man.name>

<tech.arch.man.name>snofyre-technical-architecture-manual.pdf</tech.arch.man.name>
<user.man.name>snofyre-user-manual.pdf</user.man.name>
<packs.folder>packs</packs.folder>
- <!--<trud.pack.name>Archive.zip</trud.pack.name>-->
<trud.url>www.uktcdownload.nss.cfh.nhs.uk</trud.url>

<snofyre.download.url>http://snofyre.googlecode.com/files/</snofyre.download.url>
<!--<trud.pack.name>nhs_snofyre_test_pack.zip</trud.pack.name>-->
@@ -41,12 +35,7 @@
<trud.pack.path>NHSSNOFYRE/2.0.0/NHS_SNOFYREDATA/</trud.pack.path>
<api.code.site>http://code.google.com/p/snofyre/</api.code.site>

<api.contact.email>snofyr...@googlegroups.com</api.contact.email>
-
<installation.guide.location>http://docs.snofyre.googlecode.com/hg/install-guide/html/frameset.html</installation.guide.location>
-
<!--<snomed.index.location>/Applications/SRTHApp/bin/index</snomed.index.location>-->
-
<!--<snomed.data.location>/Users/Shared/Sappheiros/</snomed.data.location>-->
-
<!--<snomed.index.location>/Users/Shared/Sappheiros/</snomed.index.location>-->
-
<!--<sappheiros.javadoc.location>/Users/Shared/Sappheiros/</sappheiros.javadoc.location>-->
-
<!--<sappheiros.data.location>/Users/Shared/Sappheiros/</sappheiros.data.location>-->
+
<installation.guide.location>https://snofyre.googlecode.com/svn/docs/installationmanual/index.html</installation.guide.location>
</properties>

<modelVersion>4.0.0</modelVersion>
@@ -344,7 +333,8 @@
<configuration>
<archive>
<manifest>
-
<mainClass>uk.nhs.cfh.dsp.srth.distribution.DocumentationLauncher</mainClass>
+
<!--<mainClass>uk.nhs.cfh.dsp.srth.distribution.DocumentationLauncher</mainClass>-->
+
<mainClass>uk.nhs.cfh.dsp.srth.distribution.ZipArchiveUtils</mainClass>

<!--<mainClass>uk.nhs.cfh.dsp.srth.distribution.FileDownloader</mainClass>-->
</manifest>

<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
@@ -399,7 +389,6 @@

<outputDirectory>${staging.dir}/temp</outputDirectory>
</artifactItem>
</artifactItems>
-
<!--<outputDirectory>${project.build.directory}/wars</outputDirectory>-->
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
@@ -424,7 +413,7 @@
</configuration>
</execution>
<execution>
- <id>config-assembly</id> <!-- this is used for
inheritance merges -->
+ <id>config-assembly</id>
<phase>package</phase> <!-- append to the
packaging phase. -->
<goals>
<goal>single</goal>
@@ -432,7 +421,8 @@
<configuration>
<archive>
<manifest>
-
<mainClass>uk.nhs.cfh.dsp.srth.distribution.DocumentationLauncher</mainClass>
+
<!--<mainClass>uk.nhs.cfh.dsp.srth.distribution.DocumentationLauncher</mainClass>-->
+
<mainClass>uk.nhs.cfh.dsp.srth.distribution.ZipArchiveUtils</mainClass>
</manifest>
</archive>
<finalName>${app.configurator.name}</finalName>
@@ -443,7 +433,7 @@
</configuration>
</execution>
<execution>
- <id>installer-assembly</id> <!-- this is used for
inheritance merges -->
+ <id>installer-assembly</id>
<phase>deploy</phase> <!-- append to the packaging
phase. -->
<goals>
<goal>single</goal>
=======================================
--- /tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/install.xml Tue
Jan 25 06:33:34 2011
+++ /tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/install.xml Wed
Feb 2 23:53:21 2011
@@ -35,7 +35,7 @@
</authors>
<url>${api.code.site}</url>
<javaversion>1.6</javaversion>
-
<summarylogfilepath>$INSTALL_PATH/Uninstaller/install.log</summarylogfilepath>
+ <summarylogfilepath>$INSTALL_PATH/install.log</summarylogfilepath>
<uninstaller name="${application.name}-Uninstaller.jar"/>

<!--<webdir>https://svn.connectingforhealth.nhs.uk/svn/public/srp/installer</webdir>-->
</info>
@@ -165,8 +165,8 @@
<packs>
<pack name="License" required="yes">
<description>The license files</description>
- <file src="README.TXT" targetdir="$INSTALL_PATH" />
- <file src="LICENSE.TXT" targetdir="$INSTALL_PATH" />
+ <file src="readme.html" targetdir="$INSTALL_PATH" />
+ <file src="license.html" targetdir="$INSTALL_PATH" />
</pack>
<pack id="doc" name="Documentation" required="no" loose="false">
<description>The documentation for ${application.name}
</description>
@@ -180,8 +180,36 @@
<description>The application</description>
<file src="${executable.name}.zip" targetdir="$INSTALL_PATH/"
unpack="true"/>
</pack>
- <pack name="Post installation scripts" required="yes">
- <description>Post-installation scripts that handle
configuration and clean up</description>
+ <pack name="Snofyre FTP scripts" required="yes">
+ <description>Post-installation scripts that download Snofyre
Data from TRUD</description>
+ <file src="bin/ftp-get.sh" targetdir="$INSTALL_PATH" os="mac"/>
+ <file src="bin/ftp-get.sh" targetdir="$INSTALL_PATH"
os="unix"/>
+ <file src="bin/ftp-get.bat" targetdir="$INSTALL_PATH"
os="windows"/>
+ <file src="bin/extract-pack.sh"
targetdir="$INSTALL_PATH/configurator" os="mac"/>
+ <file src="bin/extract-pack.sh"
targetdir="$INSTALL_PATH/configurator" os="unix"/>
+ <file src="bin/extract-pack.bat"
targetdir="$INSTALL_PATH/configurator" os="windows"/>
+ <file src="bin/ftp_info.txt" targetdir="$INSTALL_PATH"
os="windows"/>
+ <file src="bin/packextract.properties"
targetdir="$INSTALL_PATH/configurator"/>
+
+ <parsable type="shell"
targetfile="$INSTALL_PATH/configurator/extract-pack.sh" os="mac"
encoding="utf-8"/>
+ <parsable type="shell"
targetfile="$INSTALL_PATH/configurator/extract-pack.sh" os="unix"
encoding="utf-8"/>
+ <parsable type="plain"
targetfile="$INSTALL_PATH/configurator/extract-pack.bat" os="windows"
encoding="utf-8"/>
+ <parsable type="shell" targetfile="$INSTALL_PATH/ftp-get.sh"
os="mac" encoding="utf-8"/>
+ <parsable type="shell" targetfile="$INSTALL_PATH/ftp-get.sh"
os="unix" encoding="utf-8"/>
+ <parsable type="plain" targetfile="$INSTALL_PATH/ftp-get.bat"
os="windows" encoding="utf-8"/>
+ <parsable type="plain" targetfile="$INSTALL_PATH/ftp_info.txt"
os="windows" encoding="utf-8"/>
+ <parsable type="javaprop"
targetfile="$INSTALL_PATH/configurator/packextract.properties"
encoding="utf-8"/>
+
+ <executable
targetfile="$INSTALL_PATH/configurator/extract-pack.sh" stage="never"
keep="true" os="mac"/>
+ <executable
targetfile="$INSTALL_PATH/configurator/extract-pack.sh" stage="never"
keep="true" os="unix"/>
+ <executable
targetfile="$INSTALL_PATH/configurator/extract-pack.bat" stage="never"
keep="true" os="windows"/>
+ <executable targetfile="$INSTALL_PATH/ftp-get.sh"
stage="never" keep="false" os="mac"/>
+ <executable targetfile="$INSTALL_PATH/ftp-get.sh"
stage="never" keep="false" os="unix"/>
+ <executable targetfile="$INSTALL_PATH/ftp-get.bat"
stage="never" keep="false" os="windows"/>
+ <executable targetfile="$INSTALL_PATH/ftp_info.txt"
stage="never" keep="false" os="windows"/>
+ </pack>
+ <pack name="Application Launch scripts" required="yes">
+ <description>Application Launch and other scripts</description>
<file src="bin/run.sh" targetdir="$INSTALL_PATH/bin" os="mac"/>
<file src="bin/run.sh" targetdir="$INSTALL_PATH/bin"
os="unix"/>
<file src="bin/run.bat" targetdir="$INSTALL_PATH/bin"
os="windows"/>
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/processPanelSpec.xml
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/processPanelSpec.xml
Wed Feb 2 23:53:21 2011
@@ -19,7 +19,36 @@

<processing>

+ <job name="Download TRUD Data">
+ <os family="windows" />
+ <executefile name="$INSTALL_PATH/ftp-get.bat">
+ </executefile>
+ </job>
+ <job name="Download TRUD Data">
+ <os family="mac" />
+ <executefile name="$INSTALL_PATH/ftp-get.sh">
+ </executefile>
+ </job>
+ <job name="Download TRUD Data">
+ <os family="unix" />
+ <executefile name="$INSTALL_PATH/ftp-get.sh">
+ <!--<arg>doit</arg><arg>$variable</arg>-->
+ </executefile>
+ </job>
<!-- Do not change the order of the arguments - they are hard coded -->
+ <!--<job name="Downloading IHTSDO Licensed Data">-->
+ <!--<executeclass
name="uk.nhs.cfh.dsp.srth.distribution.ProcessExecutor">-->
+ <!--<arg>${trud.pack.path}</arg>-->
+ <!--<arg>${trud.pack.name}</arg>-->
+ <!--<arg>$trud.user.name</arg>-->
+ <!--<arg>$trud.password</arg>-->
+ <!--<arg>${packs.folder}</arg>-->
+ <!--<arg>$install.type.selection</arg>-->
+ <!--<arg>$INSTALL_PATH</arg>-->
+ <!--<arg>${trud.url}</arg>-->
+ <!--</executeclass>-->
+ <!--</job>-->
+
<job name="Downloading IHTSDO Licensed Data">
<executeclass
name="uk.nhs.cfh.dsp.srth.distribution.ProcessExecutor">
<arg>${trud.pack.path}</arg>
@@ -37,6 +66,7 @@
<executeclass
name="uk.nhs.cfh.dsp.srth.distribution.DocumentationLauncher">
<arg>$pdf.doc.url</arg>
<arg>$INSTALL_PATH</arg>
+ <arg>${installation.guide.location}</arg>
</executeclass>
</job>
<onFail previous="true" next="false" />
=======================================
--- /tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/userInputSpec.xml
Tue Jan 25 06:33:34 2011
+++ /tags/srth-osgi/srth-osgi-1.8/distribution/src/izpack/userInputSpec.xml
Wed Feb 2 23:53:21 2011
@@ -67,8 +67,7 @@
<field type="staticText" align="left"
txt="Please follow all the steps described in the
${application.name} Installation Manual that the installer automatically
opened for you. The installation manual describes how to import
${application.name} and SNOMED CT data into the local installation of MySQL
server."/>
<field type="space"/>
- <field type="staticText" align="left" txt="If you closed the
manual or the installer did not open it for you, it is located at
$INSTALL_PATH\docs\${sappheiros.configuration.guide.name}."/>
- <!--<field type="space"/>-->
+ <field type="staticText" align="left" txt="If you closed the
manual or the installer did not open it for you, it is located at
$INSTALL_PATH\docs\${inst.man.name}."/> <!--<field type="space"/>-->
<field type="divider" align="top"/>

<!-- MySQL Server Installed -->
@@ -81,11 +80,11 @@
</field>
<field type="space"/>
<field type="check" align="left"
variable="mysql.snomed.data.import.check">
- <spec txt="Have you imported the supplied SNOMED CT data into
MySQL?" true="Yes" false="No"/>
+ <spec txt="Have you imported SNOMED CT data into MySQL?"
true="Yes" false="No"/>
</field>
<field type="space"/>
<field type="check" align="left"
variable="mysql.sappheiros.data.import.check">
- <spec txt="Have you imported the supplied ${application.name}
data into MySQL?" true="Yes" false="No"/>
+ <spec txt="Have you imported the imported ${application.name}
data into MySQL?" true="Yes" false="No"/>
</field>
<field type="space"/>
<field type="check" align="left"
variable="mysql.server.snomed.db.permissions.check">
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/temp/post-install.bat
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/etc/temp/post-install.bat
Wed Feb 2 23:53:21 2011
@@ -1,4 +1,4 @@
# -- post installation scripts for clean up and configuration -- #
@ECHO OFF
-start $INSTALL_PATH/docs/${sappheiros.configuration.guide.name}
+start $INSTALL_PATH\docs\${sappheiros.configuration.guide.name}
# start docs/${sappheiros.configuration.guide.name}
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/DocumentationLauncher.java
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/DocumentationLauncher.java
Wed Feb 2 23:53:21 2011
@@ -20,6 +20,9 @@
import java.awt.*;
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
import java.util.logging.FileHandler;
import java.util.logging.Logger;

@@ -63,22 +66,53 @@
}
}
}
+
+ public void launchOnlineDocumentation(URL url){
+
+ if(Desktop.isDesktopSupported())
+ {
+ Desktop desktop = Desktop.getDesktop();
+ // open the file
+ try
+ {
+ if (url != null) {
+ desktop.browse(url.toURI());
+ }
+ }
+ catch (IOException e) {
+ logger.warning("Error launching browser. Nested exception
is : " + e.fillInStackTrace().getMessage());
+ }
+ catch (URISyntaxException e) {
+ logger.warning("Error launching browser. Nested exception
is : " + e.fillInStackTrace().getMessage());
+ }
+ }
+ }

public void run(AbstractUIProcessHandler handler, String[] args) {

DocumentationLauncher documentationLauncher = new
DocumentationLauncher();
logger.info("args = " + args.length);
- // check there are exactly four arguments
- if(args.length == 2)
+ // check there are exactly three arguments
+ if(args.length == 3)
{
String pdfDocUrl = args[0];
String installPath = args[1];
+ String onlineDocURL = args[2];
File f = new File(installPath, pdfDocUrl);
logger.info("pdf file getAbsolutePath() = " +
f.getAbsolutePath());
if(f.exists())
{
documentationLauncher.launchDocumentation(f);
}
+ else
+ {
+ try {
+ documentationLauncher.launchOnlineDocumentation(new
URL(onlineDocURL));
+ }
+ catch (MalformedURLException e) {
+ logger.warning("Error launching document. Nested
exception is : " + e.fillInStackTrace().getMessage());
+ }
+ }

logger.info("Finished launching "+pdfDocUrl);
}
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/FileDownloader.java
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/FileDownloader.java
Wed Feb 2 23:53:21 2011
@@ -15,21 +15,17 @@
*/
package uk.nhs.cfh.dsp.srth.distribution;

-import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
-import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
-import org.apache.commons.compress.archivers.zip.ZipFile;
-import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.jdesktop.swingx.JXLoginPane;

+import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import java.net.URL;
-import java.util.Enumeration;
import java.util.logging.FileHandler;
import java.util.logging.Logger;

@@ -48,6 +44,7 @@
private FTPClient ftpClient;
private final static int BUFFER = 1024;
private static final String ERR_MESSAGE = "Nested exception message
is : ";
+ private long maxBytes = 0;

public FileDownloader() {
this(new FTPClient());
@@ -102,178 +99,119 @@
}
}

- public void getFileFromURL(URL inputURL, String outputURL) throws
IOException {
- getFileFromStream(inputURL.openStream(), outputURL);
- }
-
- public void getFileFromURL(String inputURL, String outputURL) throws
IOException {
- getFileFromURL(new URL(inputURL), outputURL);
- }
-
- public void getFileFromTRUDArchive(String trudArchiveName, String
fileName, String outputURL){
-
- logger.info("Now getting file... ");
- if (ftpClient.isConnected())
- {
- logger.info("ftp client is connected... ");
- // now get file specified by inputURL
- try
- {
- ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
- logger.info("Sending NOOP command... ");
- // send NOOP command to see if connection is still active
- if(ftpClient.sendNoOp())
- {
- logger.info("ftpClient.getReplyString() = " +
ftpClient.getReplyString());
- FTPFile[] files = ftpClient.listFiles(getPackPath());
- for(FTPFile file : files)
- {
- logger.info("file.getName() = " + file.getName());
- logger.info("file.getSize() = " + file.getSize());
- if(file.getName().equals(trudArchiveName) &&
file.getSize() > 0)
- {
- InputStream is =
ftpClient.retrieveFileStream(getPackPath() +trudArchiveName);
-
- if (is != null)
- {
- ZipArchiveInputStream
zipArchiveInputStream = new ZipArchiveInputStream(is);
- ZipArchiveEntry zipArchiveEntry =
zipArchiveInputStream.getNextZipEntry();
- while(zipArchiveEntry != null)
- {
- String zippedArchiveEntryName =
zipArchiveEntry.getName();
- logger.info("zippedArchiveEntryName
= " + zippedArchiveEntryName);
- logger.info("fileName = " + fileName);
-
if(zippedArchiveEntryName.equals(fileName))
- {
- logger.info("Extracting: "
+zippedArchiveEntryName);
- File outputLocation = new
File(outputURL);
- boolean canWrite =
outputLocation.exists();
- logger.info("canWrite = " +
canWrite);
- if(! canWrite)
- {
- canWrite =
outputLocation.mkdirs();
- logger.info("canWrite after
mkdirs = " + canWrite);
- }
-
- if (canWrite &&
outputLocation.canWrite())
- {
-
logger.info("outputLocation.getPath() = " + outputLocation.getPath());
- File destinationFile = new
File(outputLocation.getAbsolutePath(), zippedArchiveEntryName);
- OutputStream out = new
FileOutputStream(destinationFile);
-
IOUtils.copy(zipArchiveInputStream, out);
- out.close();
-
- if
(zippedArchiveEntryName.indexOf(".zip") > -1)
- {
- // unpackZip file
-
extractZipFileContents(destinationFile);
- }
- }
- }
- else
- {
- logger.info("Resetting
zipArchiveEntry");
- zipArchiveEntry =
zipArchiveInputStream.getNextZipEntry();
- if (zipArchiveEntry != null) {
-
logger.info("zipArchiveEntry.getName() = " + zipArchiveEntry.getName());
- }
- }
-
- }
-
- zipArchiveInputStream.close();
- is.close();
- }
- break;
- }
- }
-
- // complete pending commands; needed after opening and
closing streams
- ftpClient.completePendingCommand();
- }
- else
- {
- logger.warning("FTP connection might have timed out.");
- ftpClient.disconnect();
- }
- }
- catch (IOException e) {
- logger.warning("FTP connection might have timed
out. "+ERR_MESSAGE + e.fillInStackTrace());
- }
- }
- else
- {
- logger.warning("No connection to TRUD is available. Ensure FTP
connection is open");
- }
- }
-
- private void copyInputStream(InputStream in, OutputStream out)
- throws IOException
- {
- byte[] buffer = new byte[1024];
- int len;
-
- while((len = in.read(buffer)) >= 0)
- out.write(buffer, 0, len);
-
- in.close();
- out.close();
- logger.info("Finished copying inputstream.");
- }
-
- private void extractZipFileContents(File file) {
- Enumeration entries;
-
- try {
- logger.info("Extracting zip file contents...");
- ZipFile zipFile = new ZipFile(file);
-
- entries = zipFile.getEntries();
-
- while(entries.hasMoreElements()) {
- ZipArchiveEntry entry =
(ZipArchiveEntry)entries.nextElement();
-
- if(entry.isDirectory()) {
-
- logger.info("Extracting directory: " +
entry.getName());
- File dir = new File(file.getParent(), entry.getName());
- boolean canWrite = dir.exists();
- if(! canWrite)
- {
- canWrite = dir.mkdir();
- }
-
- if(canWrite){
- continue;
- }
- else{
- logger.warning("Error creating directory during
extraction");
- }
- }
-
- logger.info("Extracting file: " + entry.getName());
- copyInputStream(zipFile.getInputStream(entry),
- new BufferedOutputStream(new FileOutputStream(new
File(file.getParent(), entry.getName()))));
+ public void getFileFromStreamWithProgress(InputStream inputStream,
String outputURL){
+
+ try
+ {
+ File outputFile = new File(outputURL);
+ boolean exists = outputFile.exists();
+ logger.info("exists = " + exists);
+ if(!exists)
+ {
+ exists = outputFile.createNewFile();
+ logger.info("exists after new file create = " + exists);
+ }
+
+ if(exists)
+ {
+ FileOutputStream fos = new FileOutputStream(outputFile);
+ logger.info("fos = " + fos);
+ fos.flush();
+ ProgressMonitorInputStream pmis =
+ new ProgressMonitorInputStream(null, "Getting
file... "+outputFile.getName(), inputStream);
+ pmis.getProgressMonitor().setMillisToDecideToPopup(50);
+ pmis.getProgressMonitor().setMaximum(Math.round(maxBytes));
+ logger.info("Math.round(maxBytes) = " +
Math.round(maxBytes));
+
+ BufferedOutputStream bout = new BufferedOutputStream(fos);
+ bout.flush();
+ logger.info("Getting ready to write bytes...");
+
+ byte[] buffer = new byte[BUFFER];
+ int count = 0;
+ int n = 0;
+
+ while ((n = inputStream.read(buffer)) != -1) {
+ bout.write(buffer, 0, n);
+ count += n;
+ Object[] byteCounts = {count, maxBytes};
+ String message = String.format("Downloaded %d of %d
bytes.\n", byteCounts);
+ pmis.getProgressMonitor().setNote(message);
+ }
+ logger.info("count = " + count);
+ fos.flush();
+ bout.flush();
+
+// byte[] data = new byte[BUFFER];
+// while (true) {
+// int count = pmis.read(data);
+// if (count < 0) break;
+// bout.write(data, 0, count);
+// }
+
+// byte[] b = new byte[BUFFER];
+// int read;
+// while ((read = pmis.read(b)) != -1) {
+// bout.write(b, 0, read);
+// }
+
+// int res;
+// while ((res = pmis.read()) != -1) {
+// bout.write(res);
+// }
+
+// int i = 0;
+// byte[] data = new byte[BUFFER];
+// // write data
+// while((i = inputStream.read(data,0,BUFFER)) >=0)
+// {
+// bout.write(data, 0, i);
+// }
+
+// long bytesCopied = IOUtils.copy(pmis, fos, BUFFER);
+// logger.info("Finished writing bytes : "+bytesCopied);
+
+ // close streams
+ bout.close();
+ fos.close();
+ pmis.close();
}

- zipFile.close();
- logger.info("Closed zip file.");
- } catch (IOException e) {
- logger.warning("Nested exception is : " +
e.fillInStackTrace());
+ // log message
+ logger.info("Successfully downloaded file to : "+outputURL);
+ }
+ catch (FileNotFoundException e) {
+ logger.warning(ERR_MESSAGE+ e.fillInStackTrace());
+ }
+ catch (IOException e) {
+ logger.warning(ERR_MESSAGE+ e.fillInStackTrace());
}
}
+
+ public void getFileFromURL(URL inputURL, String outputURL) throws
IOException {
+ getFileFromStream(inputURL.openStream(), outputURL);
+ }
+
+ public void getFileFromURL(String inputURL, String outputURL) throws
IOException {
+ getFileFromURL(new URL(inputURL), outputURL);
+ }

public void getFileFromTRUD(String fileName, String outputURL){

logger.info("Now getting file... ");
if (ftpClient.isConnected())
{
+ logger.info("ftp client is connected... ");
// now get file specified by inputURL
try
{
+ ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE);
+// ftpClient.setBufferSize(BUFFER);
+ logger.info("Sending NOOP command... ");
// send NOOP command to see if connection is still active
if(ftpClient.sendNoOp())
{
+ logger.info("ftpClient.getReplyString() = " +
ftpClient.getReplyString());
logger.info("Now listing directory... ");
FTPFile[] files = ftpClient.listFiles(getPackPath());
for(FTPFile file : files)
@@ -282,13 +220,34 @@
logger.info("file.getSize() = " + file.getSize());
if(file.getName().equals(fileName) &&
file.getSize() > 0)
{
+// File destinationFile = new File(outputURL);
+// OutputStream out = new
FileOutputStream(destinationFile);
+//
ftpClient.retrieveFile(getPackPath()+fileName, out);
+// out.flush();
+// out.close();
+// logger.info("Done retrieving file from
server");
+
InputStream is =
ftpClient.retrieveFileStream(getPackPath() +fileName);
+ logger.info("is = " + is);
+ // set maxbytes
+ maxBytes = file.getSize();
if (is != null) {
- getFileFromStream(is, outputURL);
+
+ logger.info("is.available() = " +
is.available());
+// File destinationFile = new
File(outputURL);
+// OutputStream out = new
FileOutputStream(destinationFile);
+// IOUtils.copy(is, out);
+// out.close();
+
+ getFileFromStreamWithProgress(is,
outputURL);
+ // close stream
+ is.close();
}
break;
}
}
+ // complete pending commands; needed after opening and
closing streams
+ ftpClient.completePendingCommand();
}
else
{
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/ProcessExecutor.java
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/ProcessExecutor.java
Wed Feb 2 23:53:21 2011
@@ -33,11 +33,12 @@

private static Logger logger =
Logger.getLogger(ProcessExecutor.class.getName());
private final static String SEPARATOR =
System.getProperty("file.separator");
+ private final static String TEMP_FOLDER =
System.getProperty("java.io.tmpdir");

public ProcessExecutor() {
try
{
- logger.addHandler(new
FileHandler(System.getProperty("java.io.tmpdir")+
+ logger.addHandler(new FileHandler(TEMP_FOLDER+
SEPARATOR+"configurator.log", true));
}
catch (IOException e) {
@@ -58,10 +59,10 @@
String packName = args[1];
logger.info("packName = " + packName);
handler.logOutput("PackName = " + packName, true);
- String userName = args[2];
+ String userName = args[2].trim();
logger.info("userName = " + userName);
- handler.logOutput("Skipping username = " + userName, true);
- String pwd = args[3];
+ handler.logOutput("Using username = " + userName, true);
+ String pwd = args[3].trim();
handler.logOutput("Skipping password...", true);
String installType = args[5];
logger.info("installType = " + installType);
@@ -74,39 +75,79 @@
logger.info("downloadURL = " + downloadURL);
handler.logOutput("Opening connection to "+downloadURL, true);

- TRUDLoginService trudLoginService = new TRUDLoginService();
+// TRUDLoginService trudLoginService = new TRUDLoginService();
try
{
File outputDirectory = new File(installPath);

if(outputDirectory.exists() &&
outputDirectory.isDirectory() && outputDirectory.canWrite())
{
- trudLoginService.authenticate(userName,
pwd.toCharArray(), downloadURL);
- logger.info("Finished authenticating to "+downloadURL);
- handler.logOutput("Finished authenticating
to "+downloadURL, true);
-
- fileDownloader.setPackPath(packPath);
- logger.info("fd.getPackPath() = " +
fileDownloader.getPackPath());
- // dont have to validate again, because we checked in
previous installation step
-
fileDownloader.setFtpClient(trudLoginService.getFtpClient());
- logger.info("Got ftp client from login service...");
- handler.logOutput("Got ftp client from login
service...", true);
-
- // set ftp client in fileDownloader
-
fileDownloader.setFtpClient(trudLoginService.getFtpClient());
-
- handler.logOutput("Getting Snofyre DATA", true);
-
fileDownloader.getFileFromTRUDArchive(packName, "snofyre-data.zip",
- installPath);
-
- if("full".equals(installType))
- {
- handler.logOutput("Getting SNOMED CT DATA", true);
-
fileDownloader.getFileFromTRUDArchive(packName, "snomed-data.zip",
- installPath);
- }
-
- handler.logOutput("Finished downloading all packs from
TRUD", true);
+// trudLoginService.authenticate(userName,
pwd.toCharArray(), downloadURL);
+// logger.info("Finished authenticating
to "+downloadURL);
+// handler.logOutput("Finished authenticating
to "+downloadURL, true);
+//
+// fileDownloader.setPackPath(packPath);
+// logger.info("fd.getPackPath() = " +
fileDownloader.getPackPath());
+// // dont have to validate again, because we checked
in previous installation step
+//
fileDownloader.setFtpClient(trudLoginService.getFtpClient());
+// logger.info("Got ftp client from login service...");
+// handler.logOutput("Got ftp client from login
service...", true);
+//
+// // set ftp client in fileDownloader
+//
fileDownloader.setFtpClient(trudLoginService.getFtpClient());
+//
+// handler.logOutput("Getting "+packName, true);
+//// fileDownloader.getFileFromTRUD(packName,
installPath+SEPARATOR+packName);
+// String downloadedPackPath =
installPath+SEPARATOR+packName;
+// fileDownloader.getFileFromTRUD(packName,
downloadedPackPath);
+ handler.logOutput("Finished downloading all packs from
TRUD", true);
+
+ // check downloaded pack exists
+ String downloadedPackPath =
installPath+SEPARATOR+packName;
+ handler.logOutput("Verifying downloaded pack and
starting extraction", true);
+ File downloadedPack = new File(downloadedPackPath);
+ if(downloadedPack.exists() && downloadedPack.canRead())
+ {
+ // extract pack into temp folder
+
ZipArchiveUtils.extractZipFileContents(downloadedPack);
+//
fileDownloader.extractZipFileContents(downloadedPack);
+
+ // extract snofyre data to installation folder
+ handler.logOutput("Extracting SNOFYRE Pack", true);
+// fileDownloader.extractZipFileContents(new
File(TEMP_FOLDER, "snofyre-data.zip"), installPath);
+// if("full".equals(installType))
+// {
+// handler.logOutput("Extracting SNOMED CT
DATA", true);
+// fileDownloader.extractZipFileContents(new
File(TEMP_FOLDER, "snomed-data.zip"), installPath);
+// }
+//
fileDownloader.extractZipFileContents(downloadedPack);
+
ZipArchiveUtils.extractZipFileContents(downloadedPack);
+
+ File snofyrePack = new
File(installPath, "snofyre-data.zip");
+ if(snofyrePack.exists() && snofyrePack.canRead())
+ {
+ handler.logOutput("Extracting SNOFYRE CT
DATA", true);
+//
fileDownloader.extractZipFileContents(snofyrePack);
+
ZipArchiveUtils.extractZipFileContents(snofyrePack);
+ }
+
+ if("full".equals(installType))
+ {
+ File snomedPack = new
File(installPath, "snomed-data.zip");
+ if(snomedPack.exists() && snomedPack.canRead())
+ {
+ handler.logOutput("Extracting SNOMED CT
DATA", true);
+//
fileDownloader.extractZipFileContents(snomedPack);
+
ZipArchiveUtils.extractZipFileContents(snomedPack);
+ }
+ }
+
+ handler.logOutput("Finished downloading all packs
from TRUD", true);
+ }
+ else
+ {
+ handler.logOutput("Error unpacking downloaded
pack. Pack has not been downloaded or is corrupt!", false);
+ }
}
else
{
=======================================
---
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/TRUDConnectionValidator.java
Tue Jan 25 06:33:34 2011
+++
/tags/srth-osgi/srth-osgi-1.8/distribution/src/main/java/uk/nhs/cfh/dsp/srth/distribution/TRUDConnectionValidator.java
Wed Feb 2 23:53:21 2011
@@ -62,9 +62,9 @@

public Status validateData(AutomatedInstallData arg) {

- String userName = arg.getVariable("trud.user.name");
+ String userName = arg.getVariable("trud.user.name").trim();
String serverURL = arg.getVariable("trud.url");
- char[] pwd = arg.getVariable("trud.password").toCharArray();
+ char[] pwd =
arg.getVariable("trud.password").trim().toCharArray();

boolean result = false;
try

Reply all
Reply to author
Forward
0 new messages