From a2d63fb0c65bec5964f3e25e9f7d9fd511c43b08 Mon Sep 17 00:00:00 2001 From: Laramie Crocker Date: Wed, 15 Dec 2010 21:10:24 +0000 Subject: [PATCH] CSPACE-3332 --- .../IntegrationTests/xmlreplay/Tools.java | 126 ------------------ 1 file changed, 126 deletions(-) delete mode 100755 services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/Tools.java diff --git a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/Tools.java b/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/Tools.java deleted file mode 100755 index bfd7ebf63..000000000 --- a/services/IntegrationTests/src/main/java/org/collectionspace/services/IntegrationTests/xmlreplay/Tools.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * This document is a part of the source code and related artifacts - * for CollectionSpace, an open source collections management system - * for museums and related institutions: - * - * http://www.collectionspace.org - * http://wiki.collectionspace.org - * - * Copyright (c) 2009 Regents of the University of California - * - * Licensed under the Educational Community License (ECL), Version 2.0. - * You may not use this file except in compliance with this License. - * - * You may obtain a copy of the ECL 2.0 License at - * https://source.collectionspace.org/collection-space/LICENSE.txt - * - * 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.collectionspace.services.IntegrationTests.xmlreplay; - -import org.apache.commons.jexl2.Expression; -import org.apache.commons.jexl2.JexlContext; -import org.apache.commons.jexl2.JexlEngine; -import org.apache.commons.jexl2.MapContext; - -import java.io.File; -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -/** General utility methods. - * @author Laramie Crocker - */ -public class Tools { - /** @return first glued to second with the separator string, at most one time - useful for appending paths. - */ - public static String glue(String first, String separator, String second){ - if (first==null) { first = ""; } - if (second==null) { second = ""; } - if (separator==null) { separator = ""; } - if (first.startsWith(separator) && second.startsWith(separator)){ - return first.substring(0, first.length()-separator.length()) + second; - } - if (first.endsWith(separator) || second.startsWith(separator)){ - return first+second; - } - return first+separator+second; - } - - /** Handles null strings as empty. */ - public static boolean isEmpty(String str){ - return !notEmpty(str); - } - - /** Handles null strings as empty. */ - public static boolean notEmpty(String str){ - if (str==null) return false; - if (str.length()==0) return false; - return true; - } - - /** Handles null strings as false. */ - public static boolean isTrue(String test){ - return notEmpty(test) && (new Boolean(test)).booleanValue(); - } - - /* Example usage of searchAndReplace: - for (Map.Entry entry : variablesMap.entrySet()){ - String key = entry.getKey(); - String replace = entry.getValue(); - String find = "\\$\\{"+key+"\\}"; //must add expression escapes - //because $ and braces are "special", and we want to find "${object.CSID}" - uri = Tools.searchAndReplace(uri, find, replace); - System.out.println("---- REPLACE.uri: "+initURI); - System.out.println("---- REPLACE.find: "+find); - System.out.println("---- REPLACE.replace: "+replace); - System.out.println("---- REPLACE.uri result: "+uri); - } - */ - public static String searchAndReplace(String source, String find, String replace){ - Pattern pattern = Pattern.compile(find); - Matcher matcher = pattern.matcher(source); - String output = matcher.replaceAll(replace); - return output; - } - - static boolean m_fileSystemIsDOS = "\\".equals(File.separator); - static boolean m_fileSystemIsMac = ":".equals(File.separator); - - public static boolean fileSystemIsDOS(){return m_fileSystemIsDOS;} - public static boolean fileSystemIsMac(){return m_fileSystemIsMac;} - - public static String fixFilename(String filename){ - if ( m_fileSystemIsDOS ) { - return filename.replace('/', '\\'); - } - if ( m_fileSystemIsMac ) { - String t = filename.replace('/', ':'); - t = t.replace('\\', ':'); - return t; - } - return filename.replace('\\','/'); - } - - public static String join(String dir, String file){ - if ( dir.length() == 0 ) { - return file; - } - dir = Tools.fixFilename(dir); - file = Tools.fixFilename(file); - if ( ! dir.endsWith(File.separator) ) { - dir += File.separator; - } - if ( file.startsWith(File.separator) ) { - file = file.substring(1); - } - return dir + file; - } - - - -} -- 2.47.3