Add fuctions to encode/decode zipped base64 strings

Change-Id: Iab3f3bbae66921097d3d35fca7c0fd289ef1bb35
diff --git a/src/com/mirantis/mcp/Common.groovy b/src/com/mirantis/mcp/Common.groovy
index b501b04..7a29432 100644
--- a/src/com/mirantis/mcp/Common.groovy
+++ b/src/com/mirantis/mcp/Common.groovy
@@ -1,5 +1,8 @@
 package com.mirantis.mcp
 
+import java.util.zip.GZIPInputStream
+import java.util.zip.GZIPOutputStream
+
 @Grab(group='org.yaml', module='snakeyaml', version='1.17')
 import org.yaml.snakeyaml.Yaml
 
@@ -200,3 +203,19 @@
   } //else
 
 }
+
+def zipBase64(String s){
+    def targetStream = new ByteArrayOutputStream()
+    def zipStream = new GZIPOutputStream(targetStream)
+    zipStream.write(s.getBytes('UTF-8'))
+    zipStream.close()
+    def zippedBytes = targetStream.toByteArray()
+    targetStream.close()
+    return zippedBytes.encodeBase64()
+}
+
+def unzipBase64(String compressed){
+    def inflaterStream = new GZIPInputStream(new ByteArrayInputStream(compressed.decodeBase64()))
+    def uncompressedStr = inflaterStream.getText('UTF-8')
+    return uncompressedStr
+}