You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2013/09/24 16:41:13 UTC

svn commit: r1525904 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils: AlienFile.java FileHelper.java

Author: degenaro
Date: Tue Sep 24 14:41:13 2013
New Revision: 1525904

URL: http://svn.apache.org/r1525904
Log:
UIMA-2726 DUCC support Files tab (log directory contents) for Jobs/Reservations/Services details

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FileHelper.java
Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/AlienFile.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/AlienFile.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/AlienFile.java?rev=1525904&r1=1525903&r2=1525904&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/AlienFile.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/AlienFile.java Tue Sep 24 14:41:13 2013
@@ -1,3 +1,21 @@
+/*
+ * 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.uima.ducc.common.utils;
 
 import java.io.BufferedReader;
@@ -21,16 +39,6 @@ public class AlienFile {
 	private String file_name;
 	private String encoding = "UTF-8";
 	
-	private static String suffix_gz = ".gz";
-	
-	private static boolean isGzFileType(String filename) {
-		boolean retVal = false;
-		if(filename.endsWith(suffix_gz)) {
-			retVal = true;
-		}
-		return retVal;
-	}
-	
 	protected void set_ducc_ling(String value) {
 		ducc_ling = value;
 	}
@@ -135,7 +143,7 @@ public class AlienFile {
 		p.waitFor();
 		InputStream pOut = p.getInputStream();
 		InputStreamReader isr;
-		if(isGzFileType(file_name)) {
+		if(FileHelper.isGzFileType(file_name)) {
 			GZIPInputStream gis = new GZIPInputStream(pOut);
 			isr = new InputStreamReader(gis, encoding);
 		}
@@ -173,7 +181,7 @@ public class AlienFile {
 			Process p = pb.start();
 			p.waitFor();
 			InputStream pOut = p.getInputStream();
-			if(isGzFileType(file_name)) {
+			if(FileHelper.isGzFileType(file_name)) {
 				GZIPInputStream gis = new GZIPInputStream(pOut);
 				isr = new InputStreamReader(gis, encoding);
 			}
@@ -214,7 +222,7 @@ public class AlienFile {
 			Process p = pb.start();
 			//p.waitFor();
 			InputStream pOut = p.getInputStream();
-			if(isGzFileType(file_name)) {
+			if(FileHelper.isGzFileType(file_name)) {
 				GZIPInputStream gis = new GZIPInputStream(pOut);
 				isr = new InputStreamReader(gis, encoding);
 			}

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FileHelper.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FileHelper.java?rev=1525904&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FileHelper.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/FileHelper.java Tue Sep 24 14:41:13 2013
@@ -0,0 +1,40 @@
+/*
+ * 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.uima.ducc.common.utils;
+
+public class FileHelper {
+	
+	private static String suffix_gz = ".gz";
+	
+	public static String encoding = "UTF-8";
+	
+	public static boolean isGzFileType(String filename) {
+		boolean retVal = false;
+		try {
+			String lowercase_filename = filename.toLowerCase();
+			if(lowercase_filename.endsWith(suffix_gz)) {
+				retVal = true;
+			}
+		}
+		catch(Throwable t) {
+			// no worries
+		}
+		return retVal;
+	}
+}