Commit Graph
868 Commits
Author SHA1 Message Date
Adam Heath 8ea51fb77e Fix issues with inventory creation/transfer tests, and with the entity
engine tests, when run with java1.7.  Apparently, the order of methods
returned by reflection varies between runs, so if methods have implicit
requirements on each other, you get spurious errors.

The are 3 types of fixes:

* Combine the separate testCase methods into one
* Add explict method ordering.
* Make use testCase method completely stand-alone.

The product inventory tests were combined, while the entity engine tests
were restructured to be stand-alone.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1605269 13f79535-47bb-0310-9956-ffa450edef68
2014-06-25 05:27:30 +00:00
Adam Heath 1596c224f4 Re-enable hiding of condition parameters in toString calls; this was
accidentally checked in as part of r1604972.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604985 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:45:28 +00:00
Adam Heath c423838342 Remove encryptConditionFields from the condition objects; now, the
encryption/decryption happens at the jdbc layer, when values are set
into a PreparedStatement, or fetched from a ResultSet.

This means that conditions are no longer munged to contain the encrypted
value, and entities are no longer updated to temporarily contain the
encrypted value.  In all cases, the value of a field in memory will be
unecncrypted.

This fixes the following code patterns:

person = delegator.create("Person", [partyId: "my-party"]);
person.socialSecurityNumber = "1234";
person.store();
// this fails, the encrypted value is stored inside entity
assertEquals("1234", person.socialSecurityNumber);
currentValue = person.socialSecurityNumber
person.store();
// this fails, the field is doubly-encrypted
assertEquals(currentValue, person.socialSecurityNumber);

origCondition = EntityCondition.makeCondition(
    "socialSecurityNumber",
    EntityOperator.EQUALS,
    "1234"
);
list = delegator.findList("Person", origCondition);
newCondition = EntityCondition.makeCondition(
    "socialSecurityNumber",
    EntityOperator.EQUALS,
    "1234"
);
// this fails, because the condition is updated in-place, with the
// encrypted field value.
assertEquals(origCondition, newCondition);

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604976 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:24:22 +00:00
Adam Heath eeb2cc31f3 Condition objects are now immutable. This removed more uses of
javolution classes, namely, all the factory support code is now gone.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604975 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:24:08 +00:00
Adam Heath e226c3310b Restructured so that the built-up object is a wrapper around the actual
condition; this allows the wrapped value to be changed, as the builder
api is used, and will make it possible for the actual condition object
to be made final.

To allow for this wrapper to be passed to the delegator, it extends
EntityCondition, and delegates all calls to the contained condition
object.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604974 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:24:01 +00:00
Adam Heath fb157fd4c7 encryptConditionFields now returns a new EntityCondition, if it did
anything.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604973 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:54 +00:00
Adam Heath 40a06ca876 Add EntityConditionValue.encryptConditionFields support to
EntityConditionValue.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604972 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:46 +00:00
Adam Heath b6662d97b3 In EntityExpr.encryptConditionFields. pass the call down to the lhs and
rhs when we are in join mode.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604971 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:38 +00:00
Adam Heath 9d5779c95b This is the first phase at making EntityCondition objects immutable; the
classes/fields not yet finalized are left undone due to there being
side-effects with other parts of the code base.  These side-effects will
be fixed shortly.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604969 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:32 +00:00
Adam Heath 5bc5c4151f Change encrypt=true fields to no longer have a pre-pended salt value.
This is done by just setting the length of salt bytes to 0, but still
having a length byte prepended.

Add a feature to allow for certain fields to actually have a salt
prefix.  This is enabled by setting encrypt=salt in the entity
definition.

This change is slightly incompatible with existing code.  Old database
values will continue to be decrypted correctly.  However, newly
encrypted values will no longer have a salt prepended, while originally
they would.  This shouldn't be a problem in practice.

This change, along with the previous commit, finally allow for direct
lookup of encrypted values.  However, already stored values will not be
found.  To fix those, each database row will have to be read in by
ofbiz, then immediately written back out.

This is part two to completely fix OFBIZ-5959:
Person.socialSecurityNumber can't be used for findByAnd.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604968 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:23 +00:00
Adam Heath 91b11ac4f8 Fix EntityExpr encryptConditionFields; in normal use, lhs would never be
a String, because it would end up being wrapped in an EntityFieldValue
object.  The only way it would be a String is during incorrect
Freemarker lookups(which no longer happen, as the
EntityCondition.makeCondition factory pattern is now in use).

With this fix in place, EntityExpr can finally start encrypting it's
field values, so that direct matching on encrypted fields can work.

This is part one to fix OFBIZ-5959: Person.socialSecurityNumber can't be
used for findByAnd.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604967 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:11 +00:00
Adam Heath 0aaad002d6 Start creating test cases for the entity engine crypto feature.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604966 13f79535-47bb-0310-9956-ffa450edef68
2014-06-24 00:23:04 +00:00
Adam Heath cf7cfdc544 Remove the last uses of FastList from the entity engine.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1604038 13f79535-47bb-0310-9956-ffa450edef68
2014-06-19 21:38:48 +00:00
Jacques Le Roux a00123d7e7 Closes OFBIZ-5648 - Extend primary keys
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1597239 13f79535-47bb-0310-9956-ffa450edef68
2014-05-24 05:09:39 +00:00
Jacopo Cappellato 1ea8fe79b2 Fixes for a bug reported by Pierre Smits in OFBIZ-4130 (and OFBIZ-5319): a tenant user can access, via the delegator, the meta data information of other tenants; for example a tenant user with grants to use the Webtools application could view/edit the database details of all tenants.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1589589 13f79535-47bb-0310-9956-ffa450edef68
2014-04-24 05:19:13 +00:00
Adrian Crum c63f91c75b GenericEntity.java bug fix, updated the unit tests.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1575589 13f79535-47bb-0310-9956-ffa450edef68
2014-03-08 18:48:35 +00:00
Adrian Crum 7cad5f6af5 A small code cleanup in the entity engine - remove deprecated functionality. Originally, the "blob" field type was used as a catch-all for java.sql.Blob, byte[], and java.lang.Object. Now each Java type has its own field type - so you must specify the correct one.
IMPORTANT: This commit might break some applications. If you get ClassCastExceptions, then you need to change the field type in your entity from blob to either byte-array or object. The change will have no effect on your database - because they are all persisted as BLOB SQL types.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1553890 13f79535-47bb-0310-9956-ffa450edef68
2013-12-28 19:15:58 +00:00
Jacques Le Roux 1276dc8eb8 Removes an useless debug log error, caught around anyway
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1552311 13f79535-47bb-0310-9956-ffa450edef68
2013-12-19 13:17:03 +00:00
Jacques Le Roux c75405ca4a Even if I don't like much never-ending stacks in logs, this adds a log error in case the exception would be swallowed (recommended practice)
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1552249 13f79535-47bb-0310-9956-ffa450edef68
2013-12-19 08:08:16 +00:00
Jacques Le Roux 748770fb6d No functional change. As suggested Adrian on dev ML, creates the AtomicReference update outside the try-catch block.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1552120 13f79535-47bb-0310-9956-ffa450edef68
2013-12-18 21:56:33 +00:00
Jacques Le Roux be880e2c5f No functional automated changes
Add @Override annotations
Fixes comments indentation
Removes trailing blanks


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1552077 13f79535-47bb-0310-9956-ffa450edef68
2013-12-18 20:12:37 +00:00
Jacques Le Roux 60597ea005 Fixes <<FIXME: Replace DCL code with AtomicReference>>
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1552073 13f79535-47bb-0310-9956-ffa450edef68
2013-12-18 19:46:50 +00:00
Jacques Le Roux 3d458932c5 A slightly modified patch from Leon for "sequence-bank-size attributes does not work anymore" https://issues.apache.org/jira/browse/OFBIZ-5429
No matter how I set "sequence-bank-size" for an entity (in my example, its "EntityAuditLog"), the bank size is always default value "10".
It seems that this feature was lost by a serials update of revision 922724 to 922733 submitted by doogie.

jleroux: This thread http://markmail.org/message/ifosqek74gqtv7fz trace the root cause
Leon's fix is safe from a concurrency perspective. I just added a check on SequenceBank.maxBankSize and put some doc in the XSD

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1551744 13f79535-47bb-0310-9956-ffa450edef68
2013-12-17 22:45:20 +00:00
Adrian Crum fb23ff7e09 Improved error message in GenericEntity.java - no functional change. The improved message should help developers solve the problem causing the exception.
This has been discussed before, but I will mention it again for instruction: GenericEntity instances that are kept in the entity cache are shared among multiple threads. Therefore, they must be immutable. If you get a GenericEntity instance from the cache and you want to modify it, you must clone it first.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1547790 13f79535-47bb-0310-9956-ffa450edef68
2013-12-04 12:43:24 +00:00
Adrian Crum 3afb5a5c06 Fixed a regression in ModelEntity.java caused by the recent thread-safety refactoring. Patch provided by Leon - https://issues.apache.org/jira/browse/OFBIZ-5399.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1543994 13f79535-47bb-0310-9956-ffa450edef68
2013-11-21 00:37:08 +00:00
Jacques Le Roux a38a21fc0a This closes "Introduce Tomcat's JreMemoryLeakPreventionListener and why" https://issues.apache.org/jira/browse/OFBIZ-5395
The idea is to avoid ThreadLocal with custom classes, this can lead to memory leaks when an external application server is used.
Reverts r1075322 (commit for OFBIZ-4107) hence removes CompilerMatcher 
Uses PatternFactory instead of CompilerMatcher class (from CompilerMatcher keeps the compiled patterns cache idea)
In UtilHttp.java
  Removes dead code
  Removes useless "UtilHttp." for class methods and constants calls (moot point, have we conventions on this?).


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1542960 13f79535-47bb-0310-9956-ffa450edef68
2013-11-18 09:46:35 +00:00
Adrian Crum a2c1465efd Fixed a bug in the entity tests - JUnit expected and actual arguments were reversed in the testTransactionUtilRollback test.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1533542 13f79535-47bb-0310-9956-ffa450edef68
2013-10-18 16:34:09 +00:00
Adrian Crum 4b75f74431 Fixed some flaws in the JDBC password handling code. Improved JavaDocs in updated code.
The original code would provide a null or empty password (depending on code branching) if no password was configured, so I wasn't able to determine what the desired behavior was. Now an exception is thrown if there is no JDBC password, and datasource connection attempts fail gracefully.

If we want to support 'authenticationless' JDBC connections, then this will need to be looked at again.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1533202 13f79535-47bb-0310-9956-ffa450edef68
2013-10-17 18:33:49 +00:00
Adrian Crum 047036654c Added some convenience methods to GenericHelperInfo.java that will help simplify client code.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1533171 13f79535-47bb-0310-9956-ffa450edef68
2013-10-17 17:27:51 +00:00
Adrian Crum 4dd795cb50 Code cleanup and small optimization in GenericHelperInfo.java.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1533147 13f79535-47bb-0310-9956-ffa450edef68
2013-10-17 16:42:42 +00:00
Jacques Le Roux c8ce55ecc9 A patch from Anahita Goljahani for Fixed mispelling of "occurred" https://issues.apache.org/jira/browse/OFBIZ-5342
jleroux: this includes a safe change in jquery.validate.js and jquery.validate.min.js

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1530341 13f79535-47bb-0310-9956-ffa450edef68
2013-10-08 16:35:40 +00:00
Adrian Crum 91294728c2 Fixed a problem with bad try-catch-finally nesting and transaction handling in GenericDelegator.
1. The only exception caught was GenericEntityException, so any other thrown exception was missed - meaning the transaction was committed and GenericDelegator acted as if nothing was wrong.

2. The commit was performed in the finally block, so it was ALWAYS performed - even after an exception was thrown and the transaction was rolled back.

We managed to get away with this all along because typically there is a wrapping transaction that clears it all up. But still, the Delegator code needs to handle transactions correctly.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1527810 13f79535-47bb-0310-9956-ffa450edef68
2013-09-30 22:43:02 +00:00
Adrian Crum d64e8c0c7c Fixed a subtle flaw in the GenericDelegator.findOne method. When a database query returns no result, GenericValue.NULL_VALUE is put in the pk cache - so future findOne calls will know the entity value doesn't exist. But the findOne method never checked for GenericValue.NULL_VALUE in cache gets, so the database was queried again for an entity value we already know doesn't exist.
https://issues.apache.org/jira/browse/OFBIZ-5332


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1527626 13f79535-47bb-0310-9956-ffa450edef68
2013-09-30 16:13:03 +00:00
Adrian Crum 8117cb5756 Small change to GenericDelegator.findOne method - moved the primary key validation check to the beginning of the method.
I believe the original intention was to perform the validation check after the EV_VALIDATE ECAs were run, but the primary key was being used in three method calls before that happened - so those methods could have been passed an invalid primary key.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1527609 13f79535-47bb-0310-9956-ffa450edef68
2013-09-30 15:15:35 +00:00
Adrian Crum d5511e39cd Small code cleanup and optimization in ModelEntityChecker.java.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1526226 13f79535-47bb-0310-9956-ffa450edef68
2013-09-25 16:44:16 +00:00
Jacques Le Roux ff5f0a5096 A patch for "Deprecate doCacheClear in Delegator interface and class and related minilang classes" https://issues.apache.org/jira/browse/OFBIZ-5325
* Deprecates methods in Delegator interface and class
* Deprecates cache clear related variable and methods in EntitySaxReader class
* Deprecates cache clear related variables in minilang related delegator classes
* In simple-method schema annotations, marks do-cache-clear attribute as deprecated 


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1524704 13f79535-47bb-0310-9956-ffa450edef68
2013-09-19 12:03:47 +00:00
Adrian Crum 572ac66d16 Minor change to GenericDelegator - Put some logging calls inside if blocks.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1524183 13f79535-47bb-0310-9956-ffa450edef68
2013-09-17 19:17:49 +00:00
Adrian Crum 8004ad04c2 JavaDoc fix - no functional change.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1524134 13f79535-47bb-0310-9956-ffa450edef68
2013-09-17 17:17:56 +00:00
Jacques Le Roux 53343461e0 Since we decided to keep findAll, no reasons to deprecate
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1523645 13f79535-47bb-0310-9956-ffa450edef68
2013-09-16 13:38:08 +00:00
Jacques Le Roux ca73e7694e As suggested on dev ML, reintroduces findAll("EntityName") but uses the new pattern with a cache variable rather than a signature with "Cache" in method name (thanks to Adrian's comment on dev ML)
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1523507 13f79535-47bb-0310-9956-ffa450edef68
2013-09-15 21:58:38 +00:00
Jacques Le Roux d54e2f098c As suggested on dev ML, reintroduce findAll("EntityName"), I decided that findAllCache("EntityName") could be also. If you disagree on findAllCache, just remove it...
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1523466 13f79535-47bb-0310-9956-ffa450edef68
2013-09-15 17:53:43 +00:00
Jacopo Cappellato 3fd7d250d9 Fixed bug introduced in rev 1490678 (removal of cached DOM tree code and refactoring for thread-safety): after that commit it was not possible to define entity data readers at runtime, this fix re-enables the feature.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1516094 13f79535-47bb-0310-9956-ffa450edef68
2013-08-21 06:20:42 +00:00
Jacques Le Roux 1956e731a3 No functional changes, only formatting.
While looking for other cases like r1459222 and r1509164 introduced by r1300812 and r1305309. I noticed there were a lot of wrong for loops formatting (miss a white space after for), this changes it

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1511742 13f79535-47bb-0310-9956-ffa450edef68
2013-08-08 12:28:01 +00:00
Adam Heath d950b6fb05 FEATURE: Allow constant numbers to be directly added to a query, instead
of having to deal with some kind of map/generic value.  This makes it
simpler to use full-text-search queries thru the entity
engine(postgresql and oracle).

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1497893 13f79535-47bb-0310-9956-ffa450edef68
2013-06-28 19:08:39 +00:00
Adam Heath 8a497262d9 FIX: If using <extend-entity> to change the type of a pre-existing
field, then we need to be certain to remove the existing defined field
from the list of available fields.  Otherwise, you'll end up with the
same field being queried in SELECT, and the same field being updated in
INSERT or UPDATE.

This issue was discovered when changing the type of a pre-existing
field(so that the length of the field could be increased).

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1497889 13f79535-47bb-0310-9956-ffa450edef68
2013-06-28 19:08:09 +00:00
Adrian Crum c60b808b92 Reverting rev 1486552:
https://issues.apache.org/jira/browse/OFBIZ-5214


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1491170 13f79535-47bb-0310-9956-ffa450edef68
2013-06-09 10:04:15 +00:00
Adrian Crum c1c2028fd4 Fixed a thread deadlock issue that seems to be specific to loading the MS SQL JDBC driver.
https://issues.apache.org/jira/browse/OFBIZ-5216


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1491165 13f79535-47bb-0310-9956-ffa450edef68
2013-06-09 09:24:49 +00:00
Adrian Crum 06ec6b5eaf Removed some code I introduced in recent commits where I was hoping to support reloading the entityengine.xml file in a controlled manor, but it seems to be causing thread deadlocks.
https://issues.apache.org/jira/browse/OFBIZ-5216


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1490965 13f79535-47bb-0310-9956-ffa450edef68
2013-06-08 11:55:12 +00:00
Adrian Crum 91949082c1 Cleaned up the auto-generated code in the entity config models.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1490940 13f79535-47bb-0310-9956-ffa450edef68
2013-06-08 10:00:45 +00:00
Adrian Crum 18b5135a31 Third pass at removing cached DOM tree code from EntityConfigUtil.java. I converted some of the code to use the new thread-safe models.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1490938 13f79535-47bb-0310-9956-ffa450edef68
2013-06-08 09:34:47 +00:00