Author: hansbak
Date: Fri Feb 3 07:17:00 2012 New Revision: 1240016 URL: http://svn.apache.org/viewvc?rev=1240016&view=rev Log: make it possible that the applicable system settings in general properties can be overridded by settings in the database. Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml ofbiz/trunk/framework/common/entitydef/entitymodel.xml ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Fri Feb 3 07:17:00 2012 @@ -72,6 +72,7 @@ import org.ofbiz.content.content.UploadC import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.widget.screen.MacroScreenRenderer; @@ -694,7 +695,7 @@ public class DataResourceWorker impleme if (sourceFileLocation != null && sourceFileLocation.exists()) { UtilMisc.copyFile(sourceFileLocation,targetFileLocation); } else { - String defaultVisualThemeId = UtilProperties.getPropertyValue("general", "VISUAL_THEME"); + String defaultVisualThemeId = EntityUtilProperties.getPropertyValue("general", "VISUAL_THEME", delegator); if (defaultVisualThemeId != null) { GenericValue themeValue = delegator.findOne("VisualThemeResource", UtilMisc.toMap("visualThemeId", defaultVisualThemeId, "resourceTypeEnumId", "VT_DOCBOOKSTYLESHEET", "sequenceId", "01"), true); sourceFileLocation = new File(System.getProperty("ofbiz.home") + "/themes" + themeValue.get("resourceValue")); Modified: ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java (original) +++ ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/tracking/TrackingCodeEvents.java Fri Feb 3 07:17:00 2012 @@ -38,6 +38,7 @@ import org.ofbiz.webapp.website.WebSiteW import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.product.category.CategoryWorker; /** @@ -108,7 +109,7 @@ public class TrackingCodeEvents { String dtc = request.getParameter("dtc"); if (UtilValidate.isEmpty(dtc)) { - dtc = UtilProperties.getPropertyValue("general", "partner.trackingCodeId.default"); + dtc = EntityUtilProperties.getPropertyValue("general", "partner.trackingCodeId.default", delegator); } if (UtilValidate.isNotEmpty(dtc)) { GenericValue defaultTrackingCode = null; Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/CompanyHeader.groovy Fri Feb 3 07:17:00 2012 @@ -113,7 +113,7 @@ if (!partyId) { if (fromPartyId) { partyId = fromPartyId; } else { - partyId = UtilProperties.getPropertyValue("general.properties", "ORGANIZATION_PARTY"); + partyId = EntityUtilProperties.getPropertyValue("general.properties", "ORGANIZATION_PARTY", delegator); } } Modified: ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java (original) +++ ofbiz/trunk/applications/party/src/org/ofbiz/party/contact/ContactMechWorker.java Fri Feb 3 07:17:00 2012 @@ -41,6 +41,7 @@ import org.ofbiz.entity.GenericEntityExc import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.util.EntityUtil; +import org.ofbiz.entity.util.EntityUtilProperties; /** * Worker methods for Contact Mechanisms @@ -792,7 +793,7 @@ public class ContactMechWorker { String addr2 = postalAddress.getString("address2"); // get the matching string from general.properties - String matcher = UtilProperties.getPropertyValue("general.properties", "usps.address.match"); + String matcher = EntityUtilProperties.getPropertyValue("general.properties", "usps.address.match", postalAddress.getDelegator()); if (UtilValidate.isNotEmpty(matcher)) { if (addr1 != null && addr1.toLowerCase().matches(matcher)) { return true; Modified: ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml (original) +++ ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml Fri Feb 3 07:17:00 2012 @@ -18,6 +18,20 @@ under the License. --> <entity-engine-xml> - <SystemProperty systemPropertyId="currency.uom.id.default" description="The default currency to use for prices, etc"/> - <SystemProperty systemPropertyId="defaultFromEmailAddress" description="general default 'fromEmailAddress' can be overridden in: EmailTemplateSetting"/> + <SystemProperty systemResourceId="general" systemPropertyId="ORGANIZATION_PARTY" description="the default organizationPartyId for used in dropdowns and reports"/> + <SystemProperty systemResourceId="general" systemPropertyId="VISUAL_THEME" description="ID of the VisualTheme to use if there is no VISUAL_THEME UserPreference record for the current user (ie default value)"/> + <SystemProperty systemResourceId="general" systemPropertyId="currency.uom.id.default" description="The default currency to use for prices, etc"/> + <SystemProperty systemResourceId="general" systemPropertyId="country.geo.id.default" description="the default country for drop downs"/> + <SystemProperty systemResourceId="general" systemPropertyId="partner.trackingCodeId.default" description="the default trackingCodeId to use for Partner Managed Tracking Codes"/> + <SystemProperty systemResourceId="general" systemPropertyId="defaultFromEmailAddress" description="general default 'fromEmailAddress' can be overridden in: EmailTemplateSetting"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.notifications.enabled" description="mail notifications enabled (Y|N)"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.relay.host" description="the default mail server to use"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.auth.user" description="SMTP Auth username setting"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.auth.password" description="SMTP Auth password setting"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.port" description="Gmail smtp port can be either 465 or 587"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.starttls.enable" description="Gmail requires StartTLS"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.socketFactory.port" description="Port needs to be the same as mail.smtp.port"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.socketFactory.class" description="JSSE socket factory"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.socketFactory.fallback" description="Fallback [true|false] determines whether you will allow a non secure connection if you are unable to get a secure one"/> + <SystemProperty systemResourceId="general" systemPropertyId="mail.smtp.sendpartial" description="setting this property to false will abort sending the message"/> </entity-engine-xml> Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Fri Feb 3 07:17:00 2012 @@ -845,9 +845,11 @@ under the License. <!-- ============================ --> <entity entity-name="SystemProperty" package-name="org.ofbiz.common.property" title="Defines a System Property"> + <field name="systemResourceId" type="id-long-ne"></field> <field name="systemPropertyId" type="id-long-ne"></field> <field name="systemPropertyValue" type="value"></field> <field name="description" type="description"></field> + <prim-key field="systemResourceId"/> <prim-key field="systemPropertyId"/> </entity> </entitymodel> Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonWorkers.java Fri Feb 3 07:17:00 2012 @@ -34,6 +34,7 @@ import org.ofbiz.entity.condition.Entity import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.util.EntityTypeUtil; +import org.ofbiz.entity.util.EntityUtilProperties; /** * Common Workers @@ -44,7 +45,7 @@ public class CommonWorkers { public static List<GenericValue> getCountryList(Delegator delegator) { List<GenericValue> geoList = FastList.newInstance(); - String defaultCountry = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); + String defaultCountry = EntityUtilProperties.getPropertyValue("general.properties", "country.geo.id.default", delegator); GenericValue defaultGeo = null; if (UtilValidate.isNotEmpty(defaultCountry)) { try { @@ -110,7 +111,7 @@ public class CommonWorkers { public static List<GenericValue> getAssociatedStateList(Delegator delegator, String country, String listOrderBy) { if (UtilValidate.isEmpty(country)) { // Load the system default country - country = UtilProperties.getPropertyValue("general.properties", "country.geo.id.default"); + country = EntityUtilProperties.getPropertyValue("general.properties", "country.geo.id.default", delegator); } if (UtilValidate.isEmpty(listOrderBy)) { Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java (original) +++ ofbiz/trunk/framework/common/src/org/ofbiz/common/email/EmailServices.java Fri Feb 3 07:17:00 2012 @@ -66,7 +66,9 @@ import org.ofbiz.base.util.UtilPropertie import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.MapStack; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityUtilProperties; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; @@ -98,6 +100,7 @@ public class EmailServices { *@return Map with the result of the service, the output parameters */ public static Map<String, Object> sendMail(DispatchContext ctx, Map<String, ? extends Object> context) { + Delegator delegator = ctx.getDelegator(); String communicationEventId = (String) context.get("communicationEventId"); String orderId = (String) context.get("orderId"); Locale locale = (Locale) context.get("locale"); @@ -162,31 +165,31 @@ public class EmailServices { if (sendType == null || sendType.equals("mail.smtp.host")) { sendType = "mail.smtp.host"; if (UtilValidate.isEmpty(sendVia)) { - sendVia = UtilProperties.getPropertyValue("general.properties", "mail.smtp.relay.host", "localhost"); + sendVia = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.relay.host", "localhost", delegator); } if (UtilValidate.isEmpty(authUser)) { - authUser = UtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.user"); + authUser = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.user", delegator); } if (UtilValidate.isEmpty(authPass)) { - authPass = UtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.password"); + authPass = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.auth.password", delegator); } if (UtilValidate.isNotEmpty(authUser)) { useSmtpAuth = true; } if (UtilValidate.isEmpty(port)) { - port = UtilProperties.getPropertyValue("general.properties", "mail.smtp.port"); + port = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.port", delegator); } if (UtilValidate.isEmpty(socketFactoryPort)) { - socketFactoryPort = UtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.port"); + socketFactoryPort = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.port", delegator); } if (UtilValidate.isEmpty(socketFactoryClass)) { - socketFactoryClass = UtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.class"); + socketFactoryClass = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.class", delegator); } if (UtilValidate.isEmpty(socketFactoryFallback)) { - socketFactoryFallback = UtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.fallback", "false"); + socketFactoryFallback = EntityUtilProperties.getPropertyValue("general.properties", "mail.smtp.socketFactory.fallback", "false", delegator); } if (sendPartial == null) { - sendPartial = UtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.smtp.sendpartial", "true") ? true : false; + sendPartial = EntityUtilProperties.propertyValueEqualsIgnoreCase("general.properties", "mail.smtp.sendpartial", "true", delegator) ? true : false; } } else if (sendVia == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendMissingParameterSendVia", locale)); @@ -298,7 +301,7 @@ public class EmailServices { } // check to see if sending mail is enabled - String mailEnabled = UtilProperties.getPropertyValue("general.properties", "mail.notifications.enabled", "N"); + String mailEnabled = EntityUtilProperties.getPropertyValue("general.properties", "mail.notifications.enabled", "N", delegator); if (!"Y".equalsIgnoreCase(mailEnabled)) { // no error; just return as if we already processed Debug.logImportant("Mail notifications disabled in general.properties; mail with subject [" + subject + "] not sent to addressee [" + sendTo + "]", module); Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java?rev=1240016&r1=1240015&r2=1240016&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java Fri Feb 3 07:17:00 2012 @@ -45,12 +45,12 @@ public class EntityUtilProperties implem public final static String module = EntityUtilProperties.class.getName(); - protected static String getSystemPropertyValue(String name, Delegator delegator) { - if (name == null || name.length() <= 0) return ""; + protected static String getSystemPropertyValue(String resource, String name, Delegator delegator) { + if (name == null || name.length() <= 0) return null; // find system property try { - GenericValue systemProperty = delegator.findOne("SystemProperty", UtilMisc.toMap("systemPropertyId", name), false); + GenericValue systemProperty = delegator.findOne("SystemProperty", UtilMisc.toMap("systemResourceId", resource, "systemPropertyId", name), false); if (UtilValidate.isNotEmpty(systemProperty)) { String systemPropertyValue = systemProperty.getString("systemPropertyValue"); if (UtilValidate.isNotEmpty(systemPropertyValue)) { @@ -67,11 +67,20 @@ public class EntityUtilProperties implem return UtilProperties.propertyValueEquals(resource, name, compareString); } - public static boolean propertyValueEqualsIgnoreCase(String resource, String name, String compareString) { - return UtilProperties.propertyValueEqualsIgnoreCase(resource, name, compareString); + public static boolean propertyValueEqualsIgnoreCase(String resource, String name, String compareString, Delegator delegator) { + String value = getSystemPropertyValue(resource, name, delegator); + if (UtilValidate.isNotEmpty(value)) { + return value.trim().equalsIgnoreCase(compareString); + } else { + return UtilProperties.propertyValueEqualsIgnoreCase(resource, name, compareString); + } } - public static String getPropertyValue(String resource, String name, String defaultValue) { + public static String getPropertyValue(String resource, String name, String defaultValue, Delegator delegator) { + String value = getSystemPropertyValue(resource, name, delegator); + if (UtilValidate.isEmpty(value)) { + value = UtilProperties.getPropertyValue(resource, name); + } return UtilProperties.getPropertyValue(resource, name, defaultValue); } @@ -112,7 +121,7 @@ public class EntityUtilProperties implem } public static String getPropertyValue(String resource, String name, Delegator delegator) { - String value = getSystemPropertyValue(name, delegator); + String value = getSystemPropertyValue(resource, name, delegator); if (UtilValidate.isEmpty(value)) { value = UtilProperties.getPropertyValue(resource, name); } @@ -164,7 +173,7 @@ public class EntityUtilProperties implem } public static String getMessage(String resource, String name, Locale locale, Delegator delegator) { - String value = getSystemPropertyValue(name, delegator); + String value = getSystemPropertyValue(resource, name, delegator); if (UtilValidate.isEmpty(value)) { value = UtilProperties.getMessage(resource, name, locale); } |
Free forum by Nabble | Edit this page |