Author: jleroux
Date: Thu Jun 25 17:24:55 2015
New Revision: 1687589
URL: http://svn.apache.org/r1687589
Log:
OFBIZ-6532 - Adding a new entity-group but no corresponding delegator/group-map
is hard to debug
Adds an error message in log just before crash, so it's easy to debug
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java?rev=1687589&r1=1687588&r2=1687589&view=diff
==============================================================================
---
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
(original)
+++
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/model/ModelGroupReader.java
Thu Jun 25 17:24:55 2015
@@ -72,12 +72,12 @@ public class ModelGroupReader implements
ModelGroupReader reader = readers.get(tempModelName);
if (reader == null) {
- reader = readers.putIfAbsentAndGet(tempModelName, new
ModelGroupReader(tempModelName));
+ reader = readers.putIfAbsentAndGet(tempModelName, new
ModelGroupReader(delegatorName, tempModelName));
}
return reader;
}
- public ModelGroupReader(String modelName) throws
GenericEntityConfException {
+ public ModelGroupReader(String delegatorName, String modelName) throws
GenericEntityConfException {
this.modelName = modelName;
EntityGroupReader entityGroupReaderInfo =
EntityConfig.getInstance().getEntityGroupReader(modelName);
@@ -96,10 +96,10 @@ public class ModelGroupReader implements
}
// preload caches...
- getGroupCache();
+ getGroupCache(delegatorName);
}
- public Map<String, String> getGroupCache() {
+ public Map<String, String> getGroupCache(String delegatorName) {
if (this.groupCache == null) { // don't want to block here
synchronized (ModelGroupReader.class) {
// must check if null again as one of the blocked threads can
still enter
@@ -142,6 +142,13 @@ public class ModelGroupReader implements
String groupName =
UtilXml.checkEmpty(curEntity.getAttribute("group")).intern();
if (groupName == null || entityName ==
null) continue;
+ try {
+ if (null ==
EntityConfig.getInstance().getDelegator(delegatorName).getGroupDataSource(groupName))
{
+ Debug.logError("The declared group
name " + groupName + " has no corresponding group-map in entityengine.xml: ",
module);
+ }
+ } catch (GenericEntityConfException e) {
+ Debug.logWarning(e, "Exception thrown
while getting group name: ", module);
+ }
this.groupNames.add(groupName);
this.groupCache.put(entityName, groupName);
// utilTimer.timerString(" After
entityEntityName -- " + i + " --");
@@ -164,7 +171,7 @@ public class ModelGroupReader implements
* @return A group name
*/
public String getEntityGroupName(String entityName, String
delegatorBaseName) {
- Map<String, String> gc = getGroupCache();
+ Map<String, String> gc = getGroupCache(delegatorBaseName);
if (gc != null) {
String groupName = gc.get(entityName);
@@ -193,7 +200,7 @@ public class ModelGroupReader implements
if (delegatorBaseName.indexOf('#') >= 0) {
delegatorBaseName = delegatorBaseName.substring(0,
delegatorBaseName.indexOf('#'));
}
- getGroupCache();
+ getGroupCache(delegatorBaseName);
if (this.groupNames == null) return null;
Set<String> newSet = new HashSet<String>();
try {
@@ -209,8 +216,8 @@ public class ModelGroupReader implements
* @param groupName
* @return A Set of entityName Strings
*/
- public Set<String> getEntityNamesByGroup(String groupName) {
- Map<String, String> gc = getGroupCache();
+ public Set<String> getEntityNamesByGroup(String delegatorBaseName, String
groupName) {
+ Map<String, String> gc = getGroupCache(delegatorBaseName);
Set<String> enames = new HashSet<String>();
if (groupName == null || groupName.length() <= 0) return enames;