|
Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/lang/SourceMonitored.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/lang/SourceMonitored.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/lang/SourceMonitored.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/lang/SourceMonitored.java Wed Aug 11 13:22:40 2010 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.base.lang; -import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java Wed Aug 11 13:22:40 2010 @@ -241,6 +241,56 @@ OUTER: assertFalse(msg + "too many items", i < Array.getLength(got)); } + public static <V, I extends Iterable<V>> void assertEqualsIterable(String label, List<? extends V> wanted, I got) { + assertEqualsIterable(label, wanted, 0, got, 0); + } + + public static <V, I extends Iterable<V>> void assertEqualsIterable(String label, List<? extends V> wanted, int wantedExtra, I got, int gotExtra) { + Iterator<? extends V> wantedIt = wanted.iterator(); + Iterator<V> gotIt = got.iterator(); + while (wantedIt.hasNext() && gotIt.hasNext()) { + assertEquals(label + ":iterate", wantedIt.next(), gotIt.next()); + } + while (wantedExtra > 0) { + assertTrue(label + ":wanted-extra(" + wantedExtra + ")", wantedIt.hasNext()); + wantedExtra--; + } + assertFalse(label + ":wanted-done", wantedIt.hasNext()); + while (gotExtra > 0) { + assertTrue(label + ":got-extra(" + gotExtra + ")", gotIt.hasNext()); + gotExtra--; + } + assertFalse(label + ":got-done", gotIt.hasNext()); + } + + public static <V, I extends Iterable<V>> void assertEqualsIterable(String label, List<? extends V> wanted, List<? extends V> wantedExtra, I got, List<? extends V> gotExtra) { + assertEqualsIterable(label, wanted, wantedExtra, false, got, gotExtra, false); + } + + public static <V, I extends Iterable<V>> void assertEqualsIterable(String label, List<? extends V> wanted, List<? extends V> wantedExtra, boolean removeWanted, I got, List<? extends V> gotExtra, boolean removeGot) { + Iterator<? extends V> wantedIt = wanted.iterator(); + Iterator<V> gotIt = got.iterator(); + while (wantedIt.hasNext() && gotIt.hasNext()) { + assertEquals(label + ":iterate", wantedIt.next(), gotIt.next()); + } + while (wantedExtra.size() > 0) { + assertTrue(label + ":wanted-extra(" + wantedExtra + ")-hasNext", wantedIt.hasNext()); + assertEquals(label + ":wanted-extra(" + wantedExtra + ")", wantedExtra.remove(0), wantedIt.next()); + if (removeWanted) { + wantedIt.remove(); + } + } + assertFalse(label + ":wanted-done", wantedIt.hasNext()); + while (gotExtra.size() > 0) { + assertTrue(label + ":got-extra(" + gotExtra + ")-hasNext", gotIt.hasNext()); + assertEquals(label + ":got-extra(" + gotExtra + ")", gotExtra.remove(0), gotIt.next()); + if (removeGot) { + gotIt.remove(); + } + } + assertFalse(label + ":got-done", gotIt.hasNext()); + } + public static <T> void assertEquals(Map<T, ?> wanted, Object got) { assertEquals(null, wanted, got); } Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/Assert.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/Assert.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/Assert.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/Assert.java Wed Aug 11 13:22:40 2010 @@ -20,9 +20,14 @@ package org.ofbiz.base.util; import java.util.Collection; import java.util.Map; -/** Basic assertions. +import org.ofbiz.base.lang.ThreadSafe; + +/** Basic assertions. The static methods in this class provide a convenient way + * to test method arguments. All of the methods in this class throw <code> + * IllegalArgumentException</code> if the method arguments are invalid. * */ +@ThreadSafe public class Assert { /** @@ -58,7 +63,7 @@ public class Assert { } /** - * Tests if an argument is not null and is an instance of a specified class. + * Tests if an argument is not null and is an instance of one of the specified classes. * <p><code>Assert.isInstanceOf("foo", foo, Foo.class, Bar.class, ...);</code></p> * * @param argumentName @@ -101,7 +106,7 @@ public class Assert { } /** - * Tests if an argument is not null and is not an instance of a specified class. + * Tests if an argument is not null and is not an instance of one of the specified classes. * <p><code>Assert.isNotInstanceOf("foo", foo, Foo.class, Bar.class, ...);</code></p> * * @param argumentName Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/BshUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/BshUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/BshUtil.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/BshUtil.java Wed Aug 11 13:22:40 2010 @@ -24,10 +24,10 @@ import java.io.Reader; import java.io.StringReader; import java.net.MalformedURLException; import java.net.URL; -import java.util.HashMap; import java.util.Map; import javolution.util.FastMap; + import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.cache.UtilCache; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/KeyStoreUtil.java Wed Aug 11 13:22:40 2010 @@ -66,7 +66,11 @@ public class KeyStoreUtil { ComponentConfig.KeystoreInfo ks = ComponentConfig.getKeystoreInfo(componentName, keyStoreName); File file = FileUtil.getFile(ks.createResourceHandler().getFullLocation()); FileOutputStream out = new FileOutputStream(file); - store.store(out, ks.getPassword().toCharArray()); + try { + store.store(out, ks.getPassword().toCharArray()); + } finally { + out.close(); + } } public static KeyStore getComponentKeyStore(String componentName, String keyStoreName) throws IOException, GeneralSecurityException, GenericConfigException { @@ -83,7 +87,12 @@ public class KeyStoreUtil { throw new IOException("Invalid keystore type; null"); } KeyStore ks = KeyStore.getInstance(type); - ks.load(url.openStream(), password.toCharArray()); + InputStream in = url.openStream(); + try { + ks.load(in, password.toCharArray()); + } finally { + in.close(); + } return ks; } @@ -107,7 +116,12 @@ public class KeyStoreUtil { } if (keyFile.exists() && keyFile.canRead()) { - ks.load(new FileInputStream(keyFile), password.toCharArray()); + InputStream in = new FileInputStream(keyFile); + try { + ks.load(in, password.toCharArray()); + } finally { + in.close(); + } } else { ks.load(null, "changeit".toCharArray()); } Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/ReferenceCleaner.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/ReferenceCleaner.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/ReferenceCleaner.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/ReferenceCleaner.java Wed Aug 11 13:22:40 2010 @@ -18,9 +18,8 @@ *******************************************************************************/ package org.ofbiz.base.util; -import java.lang.ref.Reference; -import java.lang.ref.ReferenceQueue; import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/StringUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/StringUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/StringUtil.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/StringUtil.java Wed Aug 11 13:22:40 2010 @@ -46,7 +46,7 @@ import org.owasp.esapi.Validator; import org.owasp.esapi.codecs.Codec; import org.owasp.esapi.codecs.HTMLEntityCodec; import org.owasp.esapi.codecs.PercentCodec; -import org.owasp.esapi.errors.EncodingException; +import org.owasp.esapi.errors.IntrusionException; import org.owasp.esapi.reference.DefaultEncoder; import org.owasp.esapi.reference.DefaultValidator; @@ -56,12 +56,13 @@ import org.owasp.esapi.reference.Default */ public class StringUtil { + public static final StringUtil INSTANCE = new StringUtil(); public static final String module = StringUtil.class.getName(); protected static final Map<String, Pattern> substitutionPatternMap; /** OWASP ESAPI canonicalize strict flag; setting false so we only get warnings about double encoding, etc; can be set to true for exceptions and more security */ public static final boolean esapiCanonicalizeStrict = false; - public static final Encoder defaultWebEncoder; + public static final DefaultEncoder defaultWebEncoder; public static final Validator defaultWebValidator; static { // possible codecs: CSSCodec, HTMLEntityCodec, JavaScriptCodec, MySQLCodec, OracleCodec, PercentCodec, UnixCodec, VBScriptCodec, WindowsCodec @@ -81,6 +82,9 @@ public class StringUtil { public static final SimpleEncoder xmlEncoder = new XmlEncoder(); public static final SimpleEncoder stringEncoder = new StringEncoder(); + private StringUtil() { + } + public static interface SimpleEncoder { public String encode(String original); } @@ -536,10 +540,10 @@ public class StringUtil { // canonicalize, strict (error on double-encoding) try { value = defaultWebEncoder.canonicalize(value, true); - } catch (EncodingException e) { + } catch (IntrusionException e) { // NOTE: using different log and user targeted error messages to allow the end-user message to be less technical Debug.logError("Canonicalization (format consistency, character escaping that is mixed or double, etc) error for attribute named [" + valueName + "], String [" + value + "]: " + e.toString(), module); - errorMessageList.add("In field [" + valueName + "] found character espacing (mixed or double) that is not allowed or other format consistency error: " + e.toString()); + errorMessageList.add("In field [" + valueName + "] found character escaping (mixed or double) that is not allowed or other format consistency error: " + e.toString()); } // check for "<", ">" @@ -647,23 +651,39 @@ public class StringUtil { } public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sep) { + return appendTo(sb, iterable, prefix, suffix, null, sep, null); + } + + public static StringBuilder appendTo(StringBuilder sb, Iterable<? extends Appender<StringBuilder>> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) { Iterator<? extends Appender<StringBuilder>> it = iterable.iterator(); while (it.hasNext()) { if (prefix != null) sb.append(prefix); it.next().appendTo(sb); if (suffix != null) sb.append(suffix); - if (it.hasNext() && sep != null) sb.append(sep); + if (it.hasNext() && sep != null) { + if (sepPrefix != null) sb.append(sepPrefix); + sb.append(sep); + if (sepSuffix != null) sb.append(sepSuffix); + } } return sb; } public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sep) { + return append(sb, iterable, prefix, suffix, null, sep, null); + } + + public static StringBuilder append(StringBuilder sb, Iterable<? extends Object> iterable, String prefix, String suffix, String sepPrefix, String sep, String sepSuffix) { Iterator<? extends Object> it = iterable.iterator(); while (it.hasNext()) { if (prefix != null) sb.append(prefix); sb.append(it.next()); if (suffix != null) sb.append(suffix); - if (it.hasNext() && sep != null) sb.append(sep); + if (it.hasNext() && sep != null) { + if (sepPrefix != null) sb.append(sepPrefix); + sb.append(sep); + if (sepSuffix != null) sb.append(sepSuffix); + } } return sb; } Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/TimeDuration.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/TimeDuration.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/TimeDuration.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/TimeDuration.java Wed Aug 11 13:22:40 2010 @@ -19,12 +19,15 @@ package org.ofbiz.base.util; import java.io.Serializable; -import com.ibm.icu.util.Calendar; import org.ofbiz.base.lang.SourceMonitored; +import org.ofbiz.base.lang.ThreadSafe; + +import com.ibm.icu.util.Calendar; /** An immutable representation of a period of time. */ @SourceMonitored +@ThreadSafe @SuppressWarnings("serial") public class TimeDuration implements Serializable, Comparable<TimeDuration> { /** A <code>TimeDuration</code> instance that represents a zero time duration. */ Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilFormatOut.java Wed Aug 11 13:22:40 2010 @@ -99,7 +99,7 @@ public class UtilFormatOut { } /** Formats a BigDecimal into a properly formatted currency string based on isoCode and Locale - * @param price The price double to be formatted + * @param price The price BigDecimal to be formatted * @param isoCode the currency ISO code * @param locale The Locale used to format the number * @param maximumFractionDigits The maximum number of fraction digits used; if set to -1 than the default value for the locale is used @@ -124,8 +124,8 @@ public class UtilFormatOut { return nbParsing; } - /** Formats a double into a properly formatted currency string based on isoCode and Locale - * @param price The price double to be formatted + /** Formats a BigDecimal into a properly formatted currency string based on isoCode and Locale + * @param price The price BigDecimal to be formatted * @param isoCode the currency ISO code * @param locale The Locale used to format the number * @return A String with the formatted price @@ -462,11 +462,11 @@ public class UtilFormatOut { return retString; } - /** Replaces all occurances of oldString in mainString with newString + /** Replaces all occurrences of oldString in mainString with newString * @param mainString The original string * @param oldString The string to replace * @param newString The string to insert in place of the old - * @return mainString with all occurances of oldString replaced by newString + * @return mainString with all occurrences of oldString replaced by newString */ public static String replaceString(String mainString, String oldString, String newString) { return StringUtil.replaceString(mainString, oldString, newString); Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilHttp.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilHttp.java Wed Aug 11 13:22:40 2010 @@ -55,6 +55,7 @@ import javolution.util.FastMap; import org.apache.commons.lang.RandomStringUtils; import org.owasp.esapi.errors.EncodingException; +import org.owasp.esapi.errors.IntrusionException; /** * HttpUtil - Misc HTTP Utility Functions @@ -260,7 +261,7 @@ public class UtilHttp { String cannedStr = StringUtil.defaultWebEncoder.canonicalize(paramValue, StringUtil.esapiCanonicalizeStrict); if (Debug.verboseOn()) Debug.logVerbose("Canonicalized parameter with " + (cannedStr.equals(paramValue) ? "no " : "") + "change: original [" + paramValue + "] canned [" + cannedStr + "]", module); return cannedStr; - } catch (EncodingException e) { + } catch (IntrusionException e) { Debug.logError(e, "Error in canonicalize parameter value [" + paramValue + "]: " + e.toString(), module); return paramValue; } @@ -1312,6 +1313,9 @@ public class UtilHttp { int rowDelimiterIndex = (parameterName != null? parameterName.indexOf(UtilHttp.MULTI_ROW_DELIMITER): -1); if (rowDelimiterIndex > 0) { String thisRowIndex = parameterName.substring(rowDelimiterIndex + rowDelimiterLength); + if (thisRowIndex.indexOf("_") > -1) { + thisRowIndex = thisRowIndex.substring(0, thisRowIndex.indexOf("_")); + } if (maxRowIndex.length() < thisRowIndex.length()) { maxRowIndex = thisRowIndex; } else if (maxRowIndex.length() == thisRowIndex.length() && maxRowIndex.compareTo(thisRowIndex) < 0) { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilIO.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilIO.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilIO.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilIO.java Wed Aug 11 13:22:40 2010 @@ -19,21 +19,20 @@ package org.ofbiz.base.util; import java.io.BufferedInputStream; -import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.Reader; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.io.Reader; import java.io.Serializable; import java.io.StringReader; import java.io.StringWriter; @@ -43,7 +42,6 @@ import java.nio.charset.Charset; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; - import org.ofbiz.base.container.ClassLoaderContainer; import org.ofbiz.base.conversion.Converter; import org.ofbiz.base.conversion.Converters; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilXml.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilXml.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilXml.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/UtilXml.java Wed Aug 11 13:22:40 2010 @@ -855,6 +855,20 @@ public class UtilXml { return elementValue; } + /** Return a named attribute of a named child node or a default if null. */ + public static String childElementAttribute(Element element, String childElementName, String attributeName, String defaultValue) { + if (element == null) return defaultValue; + // get the value of the first element with the given name + Element childElement = firstChildElement(element, childElementName); + String elementAttribute = elementAttribute(childElement, attributeName, defaultValue); + + if (UtilValidate.isEmpty(elementAttribute)) + return defaultValue; + else + return elementAttribute; + } + + /** Return the text (node value) of the first node under this, works best if normalized. */ public static String elementValue(Element element) { if (element == null) return null; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/CacheLine.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/CacheLine.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/CacheLine.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/CacheLine.java Wed Aug 11 13:22:40 2010 @@ -18,8 +18,6 @@ *******************************************************************************/ package org.ofbiz.base.util.cache; -import java.util.concurrent.TimeUnit; - import org.ofbiz.base.concurrent.ExecutionPool; public abstract class CacheLine<V> extends ExecutionPool.Pulse { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/cache/test/UtilCacheTests.java Wed Aug 11 13:22:40 2010 @@ -18,26 +18,21 @@ *******************************************************************************/ package org.ofbiz.base.util.cache.test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; + import java.io.Serializable; -import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; +import java.util.HashSet; import java.util.Map; import java.util.Set; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; - -import org.ofbiz.base.util.Debug; +import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.cache.CacheListener; import org.ofbiz.base.util.cache.UtilCache; -import org.ofbiz.base.test.GenericTestCaseBase; public class UtilCacheTests extends GenericTestCaseBase implements Serializable { public static final String module = UtilCacheTests.class.getName(); Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapEntrySet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapEntrySet.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapEntrySet.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapEntrySet.java Wed Aug 11 13:22:40 2010 @@ -19,7 +19,6 @@ package org.ofbiz.base.util.collections; import java.util.Map; -import java.util.Set; public abstract class GenericMapEntrySet<K, V, M extends GenericMap<K, V>> extends GenericMapSet<K, V, M, Map.Entry<K, V>> { public GenericMapEntrySet(M source) { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapKeySet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapKeySet.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapKeySet.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/GenericMapKeySet.java Wed Aug 11 13:22:40 2010 @@ -19,7 +19,6 @@ package org.ofbiz.base.util.collections; import java.util.Map; -import java.util.Set; public abstract class GenericMapKeySet<K, V, M extends Map<K, V>> extends GenericMapSet<K, V, M, K> { public GenericMapKeySet(M source) { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapContext.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapContext.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapContext.java Wed Aug 11 13:22:40 2010 @@ -25,13 +25,12 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import javolution.lang.Reusable; import javolution.context.ObjectFactory; +import javolution.lang.Reusable; import javolution.util.FastList; import javolution.util.FastMap; import javolution.util.FastSet; -import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapStack.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapStack.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapStack.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/MapStack.java Wed Aug 11 13:22:40 2010 @@ -21,10 +21,7 @@ package org.ofbiz.base.util.collections; import java.util.Locale; import java.util.Map; -import javolution.lang.Reusable; import javolution.context.ObjectFactory; -import javolution.util.FastMap; -import javolution.util.FastSet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/test/GenericMapTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/test/GenericMapTest.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/test/GenericMapTest.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/collections/test/GenericMapTest.java Wed Aug 11 13:22:40 2010 @@ -21,14 +21,13 @@ package org.ofbiz.base.util.collections. import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.collections.GenericMap; import org.ofbiz.base.util.collections.GenericMapEntry; import org.ofbiz.base.util.collections.IteratorWrapper; -import org.ofbiz.base.test.GenericTestCaseBase; public class GenericMapTest extends GenericTestCaseBase { public static class TestGenericMap<K, V> extends GenericMap<K, V> { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Wed Aug 11 13:22:40 2010 @@ -86,7 +86,7 @@ public class FreeMarkerWorker { newConfig.setObjectWrapper(wrapper); newConfig.setSharedVariable("Static", wrapper.getStaticModels()); newConfig.setLocalizedLookup(false); - newConfig.setSharedVariable("StringUtil", new BeanModel(new StringUtil(), wrapper)); + newConfig.setSharedVariable("StringUtil", new BeanModel(StringUtil.INSTANCE, wrapper)); newConfig.setTemplateLoader(new FlexibleTemplateLoader()); newConfig.setAutoImports(UtilProperties.getProperties("freemarkerImports")); newConfig.setTemplateExceptionHandler(new FreeMarkerWorker.OFBizTemplateExceptionHandler()); Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ObjectTypeTests.java Wed Aug 11 13:22:40 2010 @@ -19,8 +19,7 @@ package org.ofbiz.base.util.test; import java.math.BigDecimal; -import java.nio.CharBuffer; -import java.nio.Buffer; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -29,21 +28,15 @@ import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TimeZone; -import java.sql.Timestamp; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Attr; import org.ofbiz.base.lang.SourceMonitored; -import org.ofbiz.base.util.Debug; +import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.TimeDuration; -import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilXml; -import org.ofbiz.base.test.GenericTestCaseBase; +import org.w3c.dom.Document; @SourceMonitored public class ObjectTypeTests extends GenericTestCaseBase { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ReferenceCleanerTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ReferenceCleanerTests.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ReferenceCleanerTests.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/ReferenceCleanerTests.java Wed Aug 11 13:22:40 2010 @@ -19,15 +19,13 @@ package org.ofbiz.base.util.test; import java.util.HashSet; -import java.util.LinkedList; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Exchanger; -import java.util.concurrent.TimeUnit; import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.TimeUnit; -import org.ofbiz.base.util.ReferenceCleaner; import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.test.GenericTestCaseBase; +import org.ofbiz.base.util.ReferenceCleaner; @SourceMonitored public class ReferenceCleanerTests extends GenericTestCaseBase { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilIOTests.java Wed Aug 11 13:22:40 2010 @@ -26,7 +26,6 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.InetAddress; import java.sql.Time; -import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Locale; @@ -34,9 +33,9 @@ import java.util.TimeZone; import java.util.UUID; import org.ofbiz.base.lang.SourceMonitored; +import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.UtilIO; import org.ofbiz.base.util.UtilMisc; -import org.ofbiz.base.test.GenericTestCaseBase; @SourceMonitored public class UtilIOTests extends GenericTestCaseBase { Modified: ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java (original) +++ ofbiz/branches/jquery/framework/base/src/org/ofbiz/base/util/test/UtilObjectTests.java Wed Aug 11 13:22:40 2010 @@ -19,10 +19,9 @@ package org.ofbiz.base.util.test; import java.io.ByteArrayInputStream; -import java.io.Externalizable; import java.io.FilterInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; @@ -31,10 +30,10 @@ import java.util.Set; import org.ofbiz.base.lang.Factory; import org.ofbiz.base.lang.SourceMonitored; +import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GroovyUtil; import org.ofbiz.base.util.UtilObject; -import org.ofbiz.base.test.GenericTestCaseBase; @SourceMonitored public class UtilObjectTests extends GenericTestCaseBase { Modified: ofbiz/branches/jquery/framework/bi/widget/BiForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/bi/widget/BiForms.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/bi/widget/BiForms.xml (original) +++ ofbiz/branches/jquery/framework/bi/widget/BiForms.xml Wed Aug 11 13:22:40 2010 @@ -35,4 +35,4 @@ under the License. <submit button-type="button"/> </field> </form> -</forms> \ No newline at end of file +</forms> Modified: ofbiz/branches/jquery/framework/bi/widget/BiMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/bi/widget/BiMenus.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/bi/widget/BiMenus.xml (original) +++ ofbiz/branches/jquery/framework/bi/widget/BiMenus.xml Wed Aug 11 13:22:40 2010 @@ -21,4 +21,4 @@ under the License. <menu name="BiAppBar" title="${uiLabelMap.BusinessIntelligenceApplication}" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml"> <menu-item name="reportbuilder" title="${uiLabelMap.BusinessIntelligenceReportBuilder}"><link target="ReportBuilderSelectStarSchema"/></menu-item> </menu> -</menus> \ No newline at end of file +</menus> Modified: ofbiz/branches/jquery/framework/birt/lib/platform/plugins/com.lowagie.text/plugin.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/birt/lib/platform/plugins/com.lowagie.text/plugin.properties?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/birt/lib/platform/plugins/com.lowagie.text/plugin.properties (original) +++ ofbiz/branches/jquery/framework/birt/lib/platform/plugins/com.lowagie.text/plugin.properties Wed Aug 11 13:22:40 2010 @@ -14,4 +14,4 @@ # under the License. ##################################################################### pluginName = Lowagie iText -providerName = Apache Open For Business Project \ No newline at end of file +providerName = Apache Open For Business Project Modified: ofbiz/branches/jquery/framework/birt/ofbiz-component.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/birt/ofbiz-component.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/birt/ofbiz-component.xml (original) +++ ofbiz/branches/jquery/framework/birt/ofbiz-component.xml Wed Aug 11 13:22:40 2010 @@ -23,9 +23,9 @@ under the License. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd"> <resource-loader name="main" type="component"/> <classpath type="jar" location="lib/*"/> - <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.common_2.5.0.v200906151043.jar"/> - <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.ecore_2.5.0.v200906151043.jar"/> - <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar"/> + <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.common_2.6.0.v20100607-0756.jar"/> + <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.ecore_2.6.0.v20100607-0756.jar"/> + <classpath type="jar" location="lib/platform/plugins/org.eclipse.emf.ecore.xmi_2.5.0.v20100521-1846.jar"/> <classpath type="jar" location="lib/platform/plugins/org.w3c.css.sac_1.3.0.v200805290154.jar"/> <classpath type="jar" location="lib/platform/plugins/org.mozilla.rhino_1.7.1.v20090608/lib/js.jar"/> <classpath type="jar" location="lib/platform/plugins/org.w3c.sac_1.3.0.v20070710/lib/flute.jar"/> Modified: ofbiz/branches/jquery/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java (original) +++ ofbiz/branches/jquery/framework/birt/src/org/ofbiz/birt/report/service/OFBizBirtViewerReportService.java Wed Aug 11 13:22:40 2010 @@ -21,8 +21,6 @@ package org.ofbiz.birt.report.service; import java.io.File; import java.io.OutputStream; import java.rmi.RemoteException; -import java.sql.Connection; -import java.sql.SQLException; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -51,9 +49,6 @@ import org.eclipse.birt.report.utility.P import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.birt.container.BirtContainer; -import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.entity.jdbc.ConnectionFactory; public class OFBizBirtViewerReportService extends BirtViewerReportService { Modified: ofbiz/branches/jquery/framework/catalina/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/catalina/entitydef/entitymodel.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/catalina/entitydef/entitymodel.xml (original) +++ ofbiz/branches/jquery/framework/catalina/entitydef/entitymodel.xml Wed Aug 11 13:22:40 2010 @@ -49,4 +49,4 @@ under the License. <field name="lastAccessed" type="numeric"></field> <prim-key field="sessionId"/> </entity> -</entitymodel> \ No newline at end of file +</entitymodel> Modified: ofbiz/branches/jquery/framework/common/config/general.properties URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/config/general.properties?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/config/general.properties (original) +++ ofbiz/branches/jquery/framework/common/config/general.properties Wed Aug 11 13:22:40 2010 @@ -129,4 +129,4 @@ https.localhost=ABQIAAAAtt0d8djaYFkk8N5L http.localhost=ABQIAAAAtt0d8djaYFkk8N5LJVcDSBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxR3euHYk9bpwvdF2Qg1EYO1LQitHA # -- Y if you want to display the multi-tenant textbox in the login page -multitenant=N \ No newline at end of file +multitenant=N Modified: ofbiz/branches/jquery/framework/common/script/org/ofbiz/common/test/UserLoginTests.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/script/org/ofbiz/common/test/UserLoginTests.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/script/org/ofbiz/common/test/UserLoginTests.xml (original) +++ ofbiz/branches/jquery/framework/common/script/org/ofbiz/common/test/UserLoginTests.xml Wed Aug 11 13:22:40 2010 @@ -35,4 +35,4 @@ </assert> <check-errors/> </simple-method> -</simple-methods> \ No newline at end of file +</simple-methods> Modified: ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/Captcha.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/Captcha.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/Captcha.java (original) +++ ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/Captcha.java Wed Aug 11 13:22:40 2010 @@ -21,12 +21,6 @@ package org.ofbiz.common; -import javax.imageio.ImageIO; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.ofbiz.base.util.UtilHttp; - import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; @@ -35,8 +29,11 @@ import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.util.Date; -import org.ofbiz.base.util.Debug; + +import javax.imageio.ImageIO; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.ofbiz.base.util.UtilDateTime; public class Captcha { Modified: ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/CommonWorkers.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++ ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/CommonWorkers.java Wed Aug 11 13:22:40 2010 @@ -33,6 +33,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; +import org.ofbiz.entity.util.EntityTypeUtil; /** * Common Workers @@ -146,26 +147,11 @@ public class CommonWorkers { * @param parentTypeField Field in Type entity which stores the parent type. * @param parentType Value of the parent type against which check is performed. * @return boolean value based on the check results. + * + * @deprecated Moved to {@link org.ofbiz.entity.util.EntityTypeUtil#hasParentType(Delegator, String, String, String, String, String) EntityTypeUtil} */ + @Deprecated public static boolean hasParentType(Delegator delegator, String entityName, String primaryKey, String childType, String parentTypeField, String parentType) { - GenericValue childTypeValue = null; - try { - childTypeValue = delegator.findOne(entityName, UtilMisc.toMap(primaryKey, childType), true); - } catch (GenericEntityException e) { - Debug.logError("Error finding "+entityName+" record for type "+childType, module); - } - if (childTypeValue != null) { - if (parentType.equals(childTypeValue.getString(primaryKey))) return true; - - if (childTypeValue.getString(parentTypeField) != null) { - if (parentType.equals(childTypeValue.getString(parentTypeField))) { - return true; - } else { - return hasParentType(delegator, entityName, primaryKey, childTypeValue.getString(parentTypeField), parentTypeField, parentType); - } - } - } - - return false; + return EntityTypeUtil.hasParentType(delegator, entityName, primaryKey, childType, parentTypeField, parentType); } } Modified: ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java (original) +++ ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/KeywordSearchUtil.java Wed Aug 11 13:22:40 2010 @@ -19,7 +19,6 @@ package org.ofbiz.common; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -27,6 +26,7 @@ import java.util.StringTokenizer; import java.util.TreeSet; import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; Modified: ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/olap/CommonDimensionServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/olap/CommonDimensionServices.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/olap/CommonDimensionServices.java (original) +++ ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/olap/CommonDimensionServices.java Wed Aug 11 13:22:40 2010 @@ -18,38 +18,19 @@ *******************************************************************************/ package org.ofbiz.common.olap; -import java.nio.ByteBuffer; -import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Map; -import javax.mail.internet.MimeMessage; -import javax.transaction.xa.XAException; - -import javolution.util.FastMap; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilDateTime; -import static org.ofbiz.base.util.UtilGenerics.checkList; -import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.model.ModelEntity; -import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; -import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; -import org.ofbiz.service.ServiceXaWrapper; -import org.ofbiz.service.mail.MimeMessageWrapper; /** * Common Services Modified: ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/uom/UomWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/uom/UomWorker.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/uom/UomWorker.java (original) +++ ofbiz/branches/jquery/framework/common/src/org/ofbiz/common/uom/UomWorker.java Wed Aug 11 13:22:40 2010 @@ -19,20 +19,19 @@ package org.ofbiz.common.uom; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.util.Map; + +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; -import org.ofbiz.entity.Delegator; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; import com.ibm.icu.util.Calendar; -import java.math.BigDecimal; -import java.sql.Timestamp; -import java.util.Map; - -import javolution.util.FastMap; - /** * UomWorker */ Modified: ofbiz/branches/jquery/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy (original) +++ ofbiz/branches/jquery/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy Wed Aug 11 13:22:40 2010 @@ -27,15 +27,21 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityFunction; import org.ofbiz.entity.condition.EntityOperator; -def andExprs = []; +def mainAndConds = []; +def orExprs = []; def entityName = context.entityName; def searchFields = context.searchFields; def displayFields = context.displayFields ?: searchFields; + def searchValueFieldName = parameters.term; +def fieldValue = null; if (searchValueFieldName) fieldValue = searchValueFieldName; + def searchType = context.searchType; +def displayFieldsSet = null; + if (searchFields && fieldValue) { - searchFieldsList = StringUtil.toList(searchFields); + def searchFieldsList = StringUtil.toList(searchFields); displayFieldsSet = StringUtil.toSet(displayFields); returnField = searchFieldsList[0]; //default to first element of searchFields displayFieldsSet.add(returnField); //add it to select fields, in case it is missing @@ -50,10 +56,10 @@ if (searchFields && fieldValue) { } searchFieldsList.each { fieldName -> if ("EQUALS".equals(searchType)) { - andExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(returnField), EntityOperator.EQUALS, searchValue)); + orExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(returnField), EntityOperator.EQUALS, searchValue)); return;//in case of EQUALS, we search only a match for the returned field } else { - andExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)), EntityOperator.LIKE, searchValue)); + orExprs.add(EntityCondition.makeCondition(EntityFunction.UPPER(EntityFieldValue.makeFieldValue(fieldName)), EntityOperator.LIKE, searchValue)); } } } @@ -66,17 +72,19 @@ def conditionFields = context.conditionF if (conditionFields) { // these fields are for additonal conditions, this is a Map of name/value pairs for (conditionFieldEntry in conditionFields.entrySet()) { - andExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(conditionFieldEntry.getKey()), EntityOperator.EQUALS, conditionFieldEntry.getValue())); + mainAndConds.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(conditionFieldEntry.getKey()), EntityOperator.EQUALS, conditionFieldEntry.getValue())); } } -if (andExprs && entityName && displayFieldsSet) { - entityConditionList = EntityCondition.makeCondition(andExprs, EntityOperator.OR); +if (orExprs && entityName && displayFieldsSet) { + mainAndConds.add(EntityCondition.makeCondition(orExprs, EntityOperator.OR)); - //if there is an extra condition, add it to main condition - if (context.andCondition && context.andCondition instanceof EntityCondition) { - entityConditionList = EntityCondition.makeCondition(context.andCondition, entityConditionList); + //if there is an extra condition, add it to main condition list + if (context.andCondition && context.andCondition instanceof EntityCondition) { + mainAndConds.add(context.andCondition); } + + def entityConditionList = EntityCondition.makeCondition(mainAndConds, EntityOperator.AND); Integer autocompleterViewSize = Integer.valueOf(context.autocompleterViewSize ?: 10); EntityFindOptions findOptions = new EntityFindOptions(); Modified: ofbiz/branches/jquery/framework/common/webcommon/includes/htmlTemplate.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/common/webcommon/includes/htmlTemplate.ftl?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/common/webcommon/includes/htmlTemplate.ftl (original) +++ ofbiz/branches/jquery/framework/common/webcommon/includes/htmlTemplate.ftl Wed Aug 11 13:22:40 2010 @@ -19,7 +19,7 @@ under the License. <#include "component://widget/templates/htmlFormMacroLibrary.ftl"/> -<#macro lookupField className="" alert="" name="" value="" size="20" maxlength="20" id="" event="" action="" disabled="" autocomplete="" descriptionFieldName="" formName="" fieldFormName="" targetParameterIter="" imgSrc="" ajaxUrl="" ajaxEnabled="" presentation="" width="620" height="500" position="topleft" fadeBackground="" clearText="" showDescription="" initiallyCollapsed=""> +<#macro lookupField className="" alert="" name="" value="" size="20" maxlength="20" id="" event="" action="" disabled="" autocomplete="" descriptionFieldName="" formName="" fieldFormName="" targetParameterIter="" imgSrc="" ajaxUrl="" ajaxEnabled="" presentation="" width="20" height="20" position="topleft" fadeBackground="true" clearText="" showDescription="" initiallyCollapsed=""> <#if (!ajaxEnabled?has_content)> <#assign javascriptEnabled = Static["org.ofbiz.base.util.UtilHttp"].isJavaScriptEnabled(request) /> <#if (javascriptEnabled)> @@ -41,6 +41,11 @@ under the License. <#local showDescription = "false" /> </#if> </#if> + <#if "true" == disabled> + <#local disabled = true/> + <#else> + <#local disabled = false /> + </#if> <@renderLookupField className alert name value size maxlength id event action disabled autocomplete descriptionFieldName formName fieldFormName targetParameterIter imgSrc ajaxUrl ajaxEnabled presentation width height position fadeBackground clearText showDescription initiallyCollapsed/> </#macro> Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/GenericDelegator.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Wed Aug 11 13:22:40 2010 @@ -21,7 +21,6 @@ package org.ofbiz.entity; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; -import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -47,9 +46,6 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.entity.cache.Cache; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionList; -import org.ofbiz.entity.condition.EntityExpr; -import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.config.DatasourceInfo; import org.ofbiz.entity.config.DelegatorInfo; import org.ofbiz.entity.config.EntityConfigUtil; @@ -251,6 +247,7 @@ public class GenericDelegator implements } // initialize helpers by group + TreeSet<String> helpersDone = new TreeSet<String>(); Set<String> groupNames = getModelGroupReader().getGroupNames(delegatorBaseName); for (String groupName: groupNames) { GenericHelperInfo helperInfo = this.getGroupHelperInfo(groupName); @@ -258,7 +255,6 @@ public class GenericDelegator implements if (Debug.infoOn()) Debug.logInfo("Delegator \"" + delegatorFullName + "\" initializing helper \"" + helperBaseName + "\" for entity group \"" + groupName + "\".", module); - TreeSet<String> helpersDone = new TreeSet<String>(); if (UtilValidate.isNotEmpty(helperInfo.getHelperFullName())) { // make sure each helper is only loaded once if (helpersDone.contains(helperInfo.getHelperFullName())) { Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/cache/AbstractEntityConditionCache.java Wed Aug 11 13:22:40 2010 @@ -33,7 +33,6 @@ import org.ofbiz.entity.GenericPK; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.model.ModelEntity; -import org.ofbiz.entity.model.ModelViewEntity; public abstract class AbstractEntityConditionCache<K, V> extends AbstractCache<EntityCondition, Map<K, V>> { Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityDateFilterCondition.java Wed Aug 11 13:22:40 2010 @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import javolution.context.ObjectFactory; +import javolution.util.FastList; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.entity.Delegator; @@ -133,4 +134,66 @@ public class EntityDateFilterCondition e ) ); } + + /** + * Creates an EntityCondition representing a date range filter query to be used against + * entities that themselves represent a date range. When used the resulting entities + * will meet at least one of the following criteria: + * - fromDate is equal to or after rangeStart but before rangeEnd + * - thruDate is equal to or after rangeStart but before rangeEnd + * - fromDate is null and thruDate is equal to or after rangeStart + * - thruDate is null and fromDate is before rangeEnd + * - fromDate is null and thruDate is null + * + * @param rangeStart The start of the range to filter against + * @param rangeEnd The end of the range to filter against + * @param fromDateName The name of the field containing the entity's "fromDate" + * @param thruDateName The name of the field containing the entity's "thruDate" + * @return EntityCondition representing the date range filter + */ + public static EntityCondition makeRangeCondition(Timestamp rangeStart, Timestamp rangeEnd, String fromDateName, String thruDateName) { + List<EntityCondition> criteria = FastList.newInstance(); + // fromDate is equal to or after rangeStart but before rangeEnd + criteria.add( + EntityCondition.makeCondition( + EntityCondition.makeCondition(fromDateName, EntityOperator.GREATER_THAN_EQUAL_TO, rangeStart), + EntityOperator.AND, + EntityCondition.makeCondition(fromDateName, EntityOperator.LESS_THAN, rangeEnd) + ) + ); + // thruDate is equal to or after rangeStart but before rangeEnd + criteria.add( + EntityCondition.makeCondition( + EntityCondition.makeCondition(thruDateName, EntityOperator.GREATER_THAN_EQUAL_TO, rangeStart), + EntityOperator.AND, + EntityCondition.makeCondition(thruDateName, EntityOperator.LESS_THAN, rangeEnd) + ) + ); + // fromDate is null and thruDate is equal to or after rangeStart + criteria.add( + EntityCondition.makeCondition( + EntityCondition.makeCondition(fromDateName, EntityOperator.EQUALS, null), + EntityOperator.AND, + EntityCondition.makeCondition(thruDateName, EntityOperator.GREATER_THAN_EQUAL_TO, rangeStart) + ) + ); + // thruDate is null and fromDate is before rangeEnd + criteria.add( + EntityCondition.makeCondition( + EntityCondition.makeCondition(thruDateName, EntityOperator.EQUALS, null), + EntityOperator.AND, + EntityCondition.makeCondition(fromDateName, EntityOperator.LESS_THAN, rangeEnd) + ) + ); + // fromDate is null and thruDate is null + criteria.add( + EntityCondition.makeCondition( + EntityCondition.makeCondition(thruDateName, EntityOperator.EQUALS, null), + EntityOperator.AND, + EntityCondition.makeCondition(fromDateName, EntityOperator.EQUALS, null) + ) + ); + // require at least one of the above to be true + return EntityCondition.makeCondition(criteria, EntityOperator.OR); + } } Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/condition/EntityExpr.java Wed Aug 11 13:22:40 2010 @@ -249,11 +249,41 @@ public class EntityExpr extends EntityCo Debug.logWarning(e, module); } // make sure the type of keyFieldName of EntityConditionSubSelect matches the field Java type - if (!ObjectType.instanceOf(valueType.getJavaType(), type.getJavaType())) { - String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type of keyFieldName : [" + valueType.getJavaType()+ "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; + try { + if (!ObjectType.instanceOf(ObjectType.loadClass(valueType.getJavaType()), type.getJavaType())) { + String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type of keyFieldName : [" + valueType.getJavaType()+ "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; + // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); + Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + } + } catch (ClassNotFoundException e) { + String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type of keyFieldName : [" + valueType.getJavaType()+ "] could not be found]"; // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); - Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + Debug.logWarning(e, "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); } + } else if (value instanceof EntityFieldValue) { + EntityFieldValue efv = (EntityFieldValue) this.lhs; + String rhsFieldName = efv.getFieldName(); + ModelField rhsField = modelEntity.getField(fieldName); + if (rhsField == null) { + throw new IllegalArgumentException("FieldName " + rhsFieldName + " not found for entity: " + modelEntity.getEntityName()); + } + ModelFieldType rhsType = null; + try { + rhsType = delegator.getEntityFieldType(modelEntity, rhsField.getType()); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); + } + try { + if (!ObjectType.instanceOf(ObjectType.loadClass(rhsType.getJavaType()), type.getJavaType())) { + String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type [" + rhsType.getJavaType() + "] of rhsFieldName : [" + rhsFieldName + "] is not compatible with the Java type of the field [" + type.getJavaType() + "]"; + // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); + Debug.logWarning(new Exception("Location of database type warning"), "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=- " + errMsg, module); + } + } catch (ClassNotFoundException e) { + String errMsg = "Warning using ["+ value.getClass().getName() + "] and entity field [" + modelEntity.getEntityName() + "." + curField.getName() + "]. The Java type [" + rhsType.getJavaType() + "] of rhsFieldName : [" + rhsFieldName + "] could not be found]"; + // eventually we should do this, but for now we'll do a "soft" failure: throw new IllegalArgumentException(errMsg); + Debug.logWarning(e, "=-=-=-=-=-=-=-=-= Database type warning in EntityExpr =-=-=-=-=-=-=-=-= " + errMsg, module); + } } else { // make sure the type matches the field Java type if (!ObjectType.instanceOf(value, type.getJavaType())) { |
| Free forum by Nabble | Edit this page |
