Hatch various repairs; setup readme; gitignore
authorBill Erickson <berickxx@gmail.com>
Wed, 3 Dec 2014 20:04:06 +0000 (15:04 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 3 Dec 2014 20:04:06 +0000 (15:04 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
.gitignore [new file with mode: 0644]
README
hatch.xml
run.sh
src/org/evergreen_ils/hatch/Hatch.java
src/org/evergreen_ils/hatch/PrintManager.java

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..2db1c34
--- /dev/null
@@ -0,0 +1,4 @@
+jdk*
+jetty*
+lib/
+
diff --git a/README b/README
index da2faa2..3add0a0 100644 (file)
--- a/README
+++ b/README
@@ -1,3 +1,29 @@
 Hatch - Java Print / Storage / Etc Service
 
-TODO: more info
+** ROUGH SETUP NOTES **
+
+Install Hatch on your desktop -- Linux edition: 
+
+% wget http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-9.2.5.v20141112.tar.gz 
+% tar -zxf jetty-distribution-9.2.5.v20141112.tar.gz 
+% ln -s jetty-distribution-9.2.5.v20141112 jetty
+
+# download jdk1.8 (requires license agreement) -- haven't tested on openjdk yet. 
+# http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
+# and extract in the same directory
+% ln -s jdk1.8.0_25 jdk1.8
+
+% mkdir lib
+% wget -O lib/jetty-util-ajax-9.2.5.v20141112.jar \
+    'http://central.maven.org/maven2/org/eclipse/jetty/jetty-util-ajax/9.2.5.v20141112/jetty-util-ajax-9.2.5.v20141112.jar'
+
+# compile
+% ./run.sh
+
+# compile + run
+% ./run.sh 1
+
+# open https://localhost:8443/ in Chrome and click through the security warning.
+# Then open the browser client.
+# Set "This workstation uses a remote print / storage service ("Hatch")?" under Admin -> Workstation
+# optionally configure / test printing
index ac25f1b..372cba7 100644 (file)
--- a/hatch.xml
+++ b/hatch.xml
        https://<hostname>:8443/ and confirm the cert is trusted -->
   <New id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
     <!-- TODO: make this better -->
-    <Set name="KeyStorePath"><Property name="jetty.home" default="." />/jetty-distribution-9.1.4.v20140401/etc/keystore</Set>
+    <Set name="KeyStorePath"><Property name="jetty.home" default="." />/jetty/etc/keystore</Set>
     <Set name="KeyStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>    
     <Set name="KeyManagerPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>          
-    <Set name="TrustStorePath"><Property name="jetty.home" default="." />/jetty-distribution-9.1.4.v20140401/etc/keystore</Set>
+    <Set name="TrustStorePath"><Property name="jetty.home" default="." />/jetty/etc/keystore</Set>
     <Set name="TrustStorePassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>  
   </New> 
 
diff --git a/run.sh b/run.sh
index 186de4d..91d2dca 100755 (executable)
--- a/run.sh
+++ b/run.sh
@@ -1,5 +1,5 @@
-JAVA_HOME=jdk1.8.0
-JETTY_HOME=jetty-distribution-9.1.4.v20140401
+JAVA_HOME=jdk1.8
+JETTY_HOME=jetty
 
 # compile
 $JAVA_HOME/bin/javac \
index 7e9ad74..716ccae 100644 (file)
@@ -153,6 +153,11 @@ public class Hatch extends Application {
         String content = (String) params.get("content");
         String contentType = (String) params.get("contentType");
 
+        if (content == null) {
+            logger.warn("handlePrint() called with no content");
+            return;
+        }
+
         browser = new BrowserView();
         Scene scene = new Scene(browser);
         primaryStage.setScene(scene);
index 9ecfcef..40a4003 100644 (file)
@@ -393,7 +393,8 @@ public class PrintManager {
             HashMap<String, Object> printerMap = new HashMap<String, Object>();
             printerMaps.add(printerMap);
             printerMap.put("name", printer.getName());
-            if (printer.getName().equals(defaultPrinter.getName())) {
+            if (defaultPrinter != null && 
+                printer.getName().equals(defaultPrinter.getName())) {
                 printerMap.put("is-default", new Boolean(true));
             }
             logger.info("found printer " + printer.getName());