You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2012/02/01 09:13:22 UTC
svn commit: r1238991 - in /ofbiz/trunk/framework: common/ common/data/
common/entitydef/ entity/entitydef/ entity/script/
entity/src/org/ofbiz/entity/ entity/src/org/ofbiz/entity/connection/
entity/src/org/ofbiz/entity/datasource/ entity/src/org/ofbiz/...
Author: hansbak
Date: Wed Feb 1 08:13:21 2012
New Revision: 1238991
URL: http://svn.apache.org/viewvc?rev=1238991&view=rev
Log:
revert r1238954 some local changes were added
Removed:
ofbiz/trunk/framework/common/data/CommonSystemPropertyData.xml
ofbiz/trunk/framework/entity/script/
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityUtilProperties.java
Modified:
ofbiz/trunk/framework/common/entitydef/entitymodel.xml
ofbiz/trunk/framework/common/ofbiz-component.xml
ofbiz/trunk/framework/entity/entitydef/entitygroup.xml
ofbiz/trunk/framework/entity/entitydef/entitymodel.xml
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java
ofbiz/trunk/framework/entity/testdef/entitytests.xml
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Wed Feb 1 08:13:21 2012
@@ -839,15 +839,4 @@ under the License.
<key-map field-name="portalPageId"/>
</view-link>
</view-entity>
-
- <!-- ============================ -->
- <!-- org.ofbiz.common.property -->
- <!-- ============================ -->
-
- <entity entity-name="SystemProperty" package-name="org.ofbiz.common.property" title="Defines a System Property">
- <field name="systemPropertyId" type="id-long-ne"></field>
- <field name="systemPropertyValue" type="value"></field>
- <field name="description" type="description"></field>
- <prim-key field="systemPropertyId"/>
- </entity>
</entitymodel>
Modified: ofbiz/trunk/framework/common/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/ofbiz-component.xml?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/ofbiz-component.xml (original)
+++ ofbiz/trunk/framework/common/ofbiz-component.xml Wed Feb 1 08:13:21 2012
@@ -28,7 +28,6 @@ under the License.
<entity-resource type="model" reader-name="main" loader="main" location="entitydef/entitymodel_olap.xml"/>
<entity-resource type="group" reader-name="main" loader="main" location="entitydef/entitygroup_olap.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CommonSecurityData.xml"/>
- <entity-resource type="data" reader-name="seed" loader="main" location="data/CommonSystemPropertyData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CommonTypeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CountryCodeData.xml"/>
<entity-resource type="data" reader-name="seed" loader="main" location="data/CurrencyData.xml"/>
Modified: ofbiz/trunk/framework/entity/entitydef/entitygroup.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/entitydef/entitygroup.xml?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/entitydef/entitygroup.xml (original)
+++ ofbiz/trunk/framework/entity/entitydef/entitygroup.xml Wed Feb 1 08:13:21 2012
@@ -29,5 +29,4 @@ under the License.
<!-- <entity-group group="org.ofbiz.tenant" entity="TenantUserLogin"/> -->
<entity-group group="org.ofbiz.tenant" entity="Component"/>
<entity-group group="org.ofbiz.tenant" entity="TenantComponent"/>
- <entity-group group="org.ofbiz.tenant" entity="TenantDomainName"/>
</entitygroup>
Modified: ofbiz/trunk/framework/entity/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/entitydef/entitymodel.xml?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/framework/entity/entitydef/entitymodel.xml Wed Feb 1 08:13:21 2012
@@ -66,6 +66,8 @@ under the License.
<entity entity-name="Tenant" package-name="org.ofbiz.entity.tenant">
<field name="tenantId" type="id-ne"/>
<field name="tenantName" type="name"/>
+ <field name="domainName" type="long-varchar"/>
+ <field name="initialPath" type="value"/>
<field name="disabled" type="indicator"><description>Disabled if 'Y', defaults to 'N' (not disabled).</description></field>
<prim-key field="tenantId"/>
</entity>
@@ -139,14 +141,4 @@ under the License.
<key-map field-name="componentName"/>
</relation>
</entity>
- <entity entity-name="TenantDomainName" package-name="org.ofbiz.entity.tenant">
- <field name="tenantId" type="id-ne"/>
- <field name="domainName" type="long-varchar"/>
- <field name="initialPath" type="value"/>
- <prim-key field="tenantId"/>
- <prim-key field="domainName"/>
- <relation type="one" fk-name="TNTDMN_TNT" rel-entity-name="Tenant">
- <key-map field-name="tenantId"/>
- </relation>
- </entity>
</entitymodel>
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java Wed Feb 1 08:13:21 2012
@@ -56,8 +56,4 @@ public abstract class DelegatorFactory i
delegatorCache.putIfAbsent(delegatorName, delegator);
} while (true);
}
-
- public static void removeDelegator(String delegatorName) {
- delegatorCache.remove(delegatorName);
- }
}
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Wed Feb 1 08:13:21 2012
@@ -18,16 +18,6 @@
*******************************************************************************/
package org.ofbiz.entity.connection;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.transaction.TransactionManager;
-
-import javolution.util.FastMap;
-
import org.apache.commons.dbcp.ConnectionFactory;
import org.apache.commons.dbcp.DriverConnectionFactory;
import org.apache.commons.dbcp.PoolableConnectionFactory;
@@ -42,6 +32,15 @@ import org.ofbiz.entity.datasource.Gener
import org.ofbiz.entity.transaction.TransactionFactory;
import org.w3c.dom.Element;
+import javax.transaction.TransactionManager;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+
+import javolution.util.FastMap;
+
/**
* DBCPConnectionFactory
*/
@@ -49,8 +48,6 @@ public class DBCPConnectionFactory imple
public static final String module = DBCPConnectionFactory.class.getName();
protected static Map<String, ManagedDataSource> dsCache = FastMap.newInstance();
- protected static Map<String, XAConnectionFactory> xacfCache = FastMap.newInstance();
- protected static Map<String, GenericObjectPool> gopCache = FastMap.newInstance();
public Connection getConnection(GenericHelperInfo helperInfo, Element jdbcElement) throws SQLException, GenericEntityException {
ManagedDataSource mds = dsCache.get(helperInfo.getHelperFullName());
@@ -174,27 +171,13 @@ public class DBCPConnectionFactory imple
// cache the pool
dsCache.put(helperInfo.getHelperFullName(), mds);
- xacfCache.put(helperInfo.getHelperFullName(), xacf);
- gopCache.put(helperInfo.getHelperFullName(), pool);
return TransactionFactory.getCursorConnection(helperInfo, mds.getConnection());
}
}
-
- public void removeConnection(GenericHelperInfo helperInfo) {
- dsCache.remove(helperInfo.getHelperFullName());
- }
public void closeAll() {
// no methods on the pool to shutdown; so just clearing for GC
dsCache.clear();
}
-
- public XAConnectionFactory getXAConnectionFactory(GenericHelperInfo helperInfo) {
- return xacfCache.get(helperInfo.getHelperFullName());
- }
-
- public GenericObjectPool getGenericObjectPool(GenericHelperInfo helperInfo) {
- return gopCache.get(helperInfo.getHelperFullName());
- }
}
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Wed Feb 1 08:13:21 2012
@@ -1212,14 +1212,11 @@ public class GenericDAO {
public void checkDb(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) {
DatabaseUtil dbUtil = new DatabaseUtil(this.helperInfo, this.executor);
dbUtil.checkDb(modelEntities, messages, addMissing);
- dbUtil.close();
}
/** Creates a list of ModelEntity objects based on meta data from the database */
public List<ModelEntity> induceModelFromDb(Collection<String> messages) {
DatabaseUtil dbUtil = new DatabaseUtil(this.helperInfo, this.executor);
- List<ModelEntity> modelEntities = dbUtil.induceModelFromDb(messages);
- dbUtil.close();
- return modelEntities;
+ return dbUtil.induceModelFromDb(messages);
}
}
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java Wed Feb 1 08:13:21 2012
@@ -83,7 +83,6 @@ public class DatabaseUtil {
boolean isLegacy = false;
protected ExecutorService executor;
- protected List<Connection> connections = FastList.newInstance();
// OFBiz DatabaseUtil
public DatabaseUtil(GenericHelperInfo helperInfo) {
@@ -146,9 +145,6 @@ public class DatabaseUtil {
throw new GenericEntityException("No connection avaialble for URL [" + connectionUrl + "]");
}
}
-
- connections.add(connection);
-
if (!TransactionUtil.isTransactionInPlace()) {
connection.setAutoCommit(true);
}
@@ -3207,18 +3203,6 @@ public class DatabaseUtil {
}
}
}
-
- public void close() {
- for (Connection connection : connections) {
- try {
- if (!connection.isClosed()) {
- connection.close();
- }
- } catch (SQLException e) {
- Debug.logWarning("Could not close connection: " + connection, module);
- }
- }
- }
/* ====================================================================== */
/* ====================================================================== */
Modified: ofbiz/trunk/framework/entity/testdef/entitytests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/testdef/entitytests.xml?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/testdef/entitytests.xml (original)
+++ ofbiz/trunk/framework/entity/testdef/entitytests.xml Wed Feb 1 08:13:21 2012
@@ -22,7 +22,4 @@ under the License.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
<test-case case-name="entity-tests"><junit-test-suite class-name="org.ofbiz.entity.test.EntityTestSuite"/></test-case>
- <test-case case-name="entity-util-properties-tests">
- <simple-method-test location="component://entity/script/org/ofbiz/entity/test/EntityUtilPropertiesTests.xml"/>
- </test-case>
</test-suite>
Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Wed Feb 1 08:13:21 2012
@@ -564,8 +564,6 @@ public class EntityDataLoadContainer imp
}
}
}
-
- dbUtil.close();
}
/**
* @see org.ofbiz.base.container.Container#stop()
Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java Wed Feb 1 08:13:21 2012
@@ -407,8 +407,6 @@ public class EntityDataServices {
// step 8 - checkdb
Debug.logImportant("Running DB check with add missing enabled", module);
dbUtil.checkDb(modelEntities, messages, true);
-
- dbUtil.close();
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("messages", messages);
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/otherops/PropertyToField.java Wed Feb 1 08:13:21 2012
@@ -24,7 +24,6 @@ import java.util.*;
import org.w3c.dom.*;
import javolution.util.FastMap;
import org.ofbiz.base.util.*;
-import org.ofbiz.entity.util.EntityUtilProperties;
import org.ofbiz.minilang.*;
import org.ofbiz.minilang.method.*;
@@ -72,9 +71,9 @@ public class PropertyToField extends Met
String value = null;
if (noLocale) {
- value = EntityUtilProperties.getPropertyValue(resource, property, methodContext.getDelegator());
+ value = UtilProperties.getPropertyValue(resource, property);
} else {
- value = EntityUtilProperties.getMessage(resource, property, methodContext.getLocale(), methodContext.getDelegator());
+ value = UtilProperties.getMessage(resource, property, methodContext.getLocale());
}
if (UtilValidate.isEmpty(value)) {
value = defaultVal;
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Wed Feb 1 08:13:21 2012
@@ -280,28 +280,16 @@ public class ContextFilter implements Fi
// get tenant delegator by domain name
String serverName = httpRequest.getServerName();
try {
- // first set the delegator to default
- String delegatorName = config.getServletContext().getInitParameter("entityDelegatorName");
-
- if (delegatorName == null || delegatorName.length() <= 0) {
- delegatorName = "default";
- }
- if (Debug.verboseOn()) Debug.logVerbose("Setup Entity Engine Delegator with name " + delegatorName, module);
- Delegator delegator = DelegatorFactory.getDelegator(delegatorName);
- config.getServletContext().setAttribute("delegator", delegator);
- if (delegator == null) {
- Debug.logError("[ContextFilter.init] ERROR: delegator factory returned null for delegatorName \"" + delegatorName + "\"", module);
- }
-
// if tenant was specified, replace delegator with the new per-tenant delegator and set tenantId to session attribute
- List<GenericValue> tenantDomainNames = delegator.findList("TenantDomainName", EntityCondition.makeCondition("domainName", serverName), null, UtilMisc.toList("-createdStamp"), null, false);
- if (UtilValidate.isNotEmpty(tenantDomainNames)) {
- GenericValue tenantDomainName = EntityUtil.getFirst(tenantDomainNames);
- String tenantId = tenantDomainName.getString("tenantId");
+ Delegator delegator = getDelegator(config.getServletContext());
+ List<GenericValue> tenants = delegator.findList("Tenant", EntityCondition.makeCondition("domainName", serverName), null, UtilMisc.toList("-createdStamp"), null, false);
+ if (UtilValidate.isNotEmpty(tenants)) {
+ GenericValue tenant = EntityUtil.getFirst(tenants);
+ String tenantId = tenant.getString("tenantId");
// if the request path is a root mount then redirect to the initial path
if (UtilValidate.isNotEmpty(requestPath) && requestPath.equals(contextUri)) {
- String initialPath = tenantDomainName.getString("initialPath");
+ String initialPath = tenant.getString("initialPath");
if (UtilValidate.isNotEmpty(initialPath) && !"/".equals(initialPath)) {
((HttpServletResponse)response).sendRedirect(initialPath);
return;
@@ -309,33 +297,32 @@ public class ContextFilter implements Fi
}
// make that tenant active, setup a new delegator and a new dispatcher
- delegatorName = delegator.getDelegatorBaseName() + "#" + tenantId;
- httpRequest.getSession().setAttribute("delegatorName", delegatorName);
+ String tenantDelegatorName = delegator.getDelegatorBaseName() + "#" + tenantId;
+ httpRequest.getSession().setAttribute("delegatorName", tenantDelegatorName);
// after this line the delegator is replaced with the new per-tenant delegator
- delegator = DelegatorFactory.getDelegator(delegatorName);
+ delegator = DelegatorFactory.getDelegator(tenantDelegatorName);
+ config.getServletContext().setAttribute("delegator", delegator);
+
+ // clear web context objects
+ config.getServletContext().setAttribute("authorization", null);
+ config.getServletContext().setAttribute("security", null);
+ config.getServletContext().setAttribute("dispatcher", null);
+
+ // initialize authorizer
+ getAuthz();
+ // initialize security
+ Security security = getSecurity();
+ // initialize the services dispatcher
+ LocalDispatcher dispatcher = getDispatcher(config.getServletContext());
+
+ // set web context objects
+ httpRequest.getSession().setAttribute("dispatcher", dispatcher);
+ httpRequest.getSession().setAttribute("security", security);
httpRequest.setAttribute("tenantId", tenantId);
}
- config.getServletContext().setAttribute("delegator", delegator);
-
- // clear web context objects
- config.getServletContext().setAttribute("authorization", null);
- config.getServletContext().setAttribute("security", null);
- config.getServletContext().setAttribute("dispatcher", null);
-
- // initialize authorizer
- getAuthz();
- // initialize security
- Security security = getSecurity();
- // initialize the services dispatcher
- LocalDispatcher dispatcher = getDispatcher(config.getServletContext());
-
- // set web context objects
- httpRequest.getSession().setAttribute("dispatcher", dispatcher);
- httpRequest.getSession().setAttribute("security", security);
-
// NOTE DEJ20101130: do NOT always put the delegator name in the user's session because the user may
// have logged in and specified a tenant, and even if no Tenant record with a matching domainName field
// is found this will change the user's delegator back to the base one instead of the one for the
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=1238991&r1=1238990&r2=1238991&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Wed Feb 1 08:13:21 2012
@@ -645,11 +645,9 @@ public class LoginWorker {
if (currCatalog != null) session.setAttribute("CURRENT_CATALOG_ID", currCatalog);
if (delegatorName != null) {
// if there is a tenantId in the delegatorName remove it now so that tenant selection doesn't last beyond logout
- /*
if (delegatorName.indexOf('#') > 0) {
delegatorName = delegatorName.substring(0, delegatorName.indexOf('#'));
}
- */
session.setAttribute("delegatorName", delegatorName);
delegator = DelegatorFactory.getDelegator(delegatorName);