ModelEntity model = entity.getModelEntity();
String entityName = model.getEntityName();
Iterator<ModelField> i = model.getFieldsIterator();
while (i.hasNext()) {
ModelField field = i.next();
if (field.getEncrypt()) {
String keyName = entityName;
if (model instanceof ModelViewEntity) {
ModelViewEntity modelView = (ModelViewEntity) model;
keyName = modelView.getAliasedEntity(modelView.getAlias(field.getName()).getEntityAlias(), modelReader).getEntityName();
}
String encHex = (String) entity.get(field.getName());
if (UtilValidate.isNotEmpty(encHex)) {
try {
entity.dangerousSetNoCheckButFast(field, crypto.decrypt(keyName, encHex));
} catch (EntityCryptoException e) {
// not fatal -- allow returning of the encrypted value
Debug.logWarning(e, "Problem decrypting field [" + entityName + " / " + field.getName() + "]", module);
}
}
}
}
}