details: /erp/devel/pi/rev/aee497832258
changeset: 10346:aee497832258
user: Stefan Hühner <stefan.huehner <at> openbravo.com>
date: Wed Feb 02 20:30:31 2011 +0100
summary: Add validation on export to tell devs to use new-style password
references
If a column is defined using one of the old-style boolean properties to define
password fields and does not use one of the new reference types -> add warning
on module validation (during export.database).
diffstat:
src/org/openbravo/service/system/DatabaseValidator.java | 41 ++++++++++++
src/org/openbravo/service/system/SystemValidationResult.java | 2 +-
2 files changed, 42 insertions(+), 1 deletions(-)
diffs (74 lines):
diff -r bf0478c6ef18 -r aee497832258
src/org/openbravo/service/system/DatabaseValidator.java
--- a/src/org/openbravo/service/system/DatabaseValidator.java Wed Feb 02
19:57:04 2011 +0100
+++ b/src/org/openbravo/service/system/DatabaseValidator.java Wed Feb 02
20:30:31 2011 +0100
@@ -35,6 +35,8 @@
import org.apache.ddlutils.model.Unique;
import org.apache.ddlutils.model.View;
import org.hibernate.criterion.Expression;
+import org.hibernate.criterion.LogicalExpression;
+import org.hibernate.criterion.SimpleExpression;
import org.openbravo.base.model.Entity;
import org.openbravo.base.model.ModelProvider;
import org.openbravo.base.model.Property;
@@ -242,10 +244,49 @@
checkDataSetName(result);
+ checkPasswordColumns(result);
+
return result;
}
/**
+ * Checks if old-style password columns exist which should be updated to use
the new references.
+ *
+ */
+ private void checkPasswordColumns(SystemValidationResult result) {
+ org.openbravo.model.ad.domain.Reference hashed = OBDal.getInstance().get(
+ org.openbravo.model.ad.domain.Reference.class,
"C5C21C28B39E4683A91779F16C112E40");
+ org.openbravo.model.ad.domain.Reference encrypted =
OBDal.getInstance().get(
+ org.openbravo.model.ad.domain.Reference.class,
"16EC6DF4A59747749FDF256B7FBBB058");
+
+ // if one of the old-booleans is set, but not using new reference-id's ->
report as warning
+ SimpleExpression enc = Expression.eq(Column.PROPERTY_DISPLAYENCRIPTION,
Boolean.TRUE);
+ LogicalExpression newRefs =
Expression.or(Expression.eq(Column.PROPERTY_REFERENCE, hashed),
+ Expression.eq(Column.PROPERTY_REFERENCE, encrypted));
+ OBCriteria<Column> colQuery =
OBDal.getInstance().createCriteria(Column.class);
+ colQuery.add(Expression.and(enc, Expression.not(newRefs)));
+
+ // only validate given module (if given)
+ if (validateModule != null) {
+ colQuery.add(Expression.eq(Column.PROPERTY_MODULE, validateModule));
+ }
+ if (colQuery.count() > 0) {
+ List<Column> columns = colQuery.list();
+ for (Column column : columns) {
+ result
+ .addWarning(
+ SystemValidationType.OLDSTYLE_PASSWORD_COLUMNS,
+ "The column '"
+ + column.getTable().getName()
+ + "'.'"
+ + column.getName()
+ + "' is using old-style config for password-type columns.
It should be changed to use one of the new references '"
+ + hashed.getName() + "' or '" + encrypted.getName() + "'");
+ }
+ }
+ }
+
+ /**
* Checks dataset name against allowed characters.
*
* Background is that dataset name is directly used to derive the exported
filename for the
diff -r bf0478c6ef18 -r aee497832258
src/org/openbravo/service/system/SystemValidationResult.java
--- a/src/org/openbravo/service/system/SystemValidationResult.java Wed Feb
02 19:57:04 2011 +0100
+++ b/src/org/openbravo/service/system/SystemValidationResult.java Wed Feb
02 20:30:31 2011 +0100
@@ -32,7 +32,7 @@
public class SystemValidationResult {
public enum SystemValidationType {
- NAME_TOO_LONG, MODULE_ERROR, CUSTOMIZATION_ID, INCORRECT_DEFAULT_VALUE,
WRONG_NAME, WRONG_LENGTH, NO_PRIMARY_KEY_COLUMNS,
NOT_NULL_IN_DB_NOT_MANDATORY_IN_AD, MANDATORY_IN_AD_NULLABLE_IN_DB,
NOT_EXIST_IN_AD, NOT_EXIST_IN_DB, NOT_PART_OF_FOREIGN_KEY, WRONG_TYPE,
INCORRECT_CLIENT_ORG_PROPERTY_NAME, UNEQUAL_DEFAULTVALUE, INCORRECT_PK_NAME,
INCORRECT_FK_NAME, INCORRECT_CHECK_NAME, INCORRECT_UNIQUE_NAME,
INCORRECT_INDEX_NAME, INCORRECT_NAME_LENGTH, INCORRECT_DATASET_NAME,
DEPENDENCY_PROBLEM, HAS_PROPERTY_CONFIGURATION;
+ NAME_TOO_LONG, MODULE_ERROR, CUSTOMIZATION_ID, INCORRECT_DEFAULT_VALUE,
WRONG_NAME, WRONG_LENGTH, NO_PRIMARY_KEY_COLUMNS,
NOT_NULL_IN_DB_NOT_MANDATORY_IN_AD, MANDATORY_IN_AD_NULLABLE_IN_DB,
NOT_EXIST_IN_AD, NOT_EXIST_IN_DB, NOT_PART_OF_FOREIGN_KEY, WRONG_TYPE,
INCORRECT_CLIENT_ORG_PROPERTY_NAME, UNEQUAL_DEFAULTVALUE, INCORRECT_PK_NAME,
INCORRECT_FK_NAME, INCORRECT_CHECK_NAME, INCORRECT_UNIQUE_NAME,
INCORRECT_INDEX_NAME, INCORRECT_NAME_LENGTH, INCORRECT_DATASET_NAME,
DEPENDENCY_PROBLEM, HAS_PROPERTY_CONFIGURATION, OLDSTYLE_PASSWORD_COLUMNS;
public String getName() {
return this.getClass().getSimpleName();
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits