details: http://code.openbravo.com/erp/devel/pi/rev/89977713b8fd changeset: 3548:89977713b8fd user: Martin Taal <martin.taal <at> openbravo.com> date: Wed Apr 08 10:00:26 2009 +0200 summary: Backed out of changeset 3547:92d129f93321
diffstat: src/org/openbravo/base/model/NamingUtil.java | 1 - src/org/openbravo/dal/core/DalThreadHandler.java | 3 + src/org/openbravo/dal/core/TriggerHandler.java | 5 +- src/org/openbravo/dal/xml/EntityResolver.java | 86 +++++++---------- src/org/openbravo/dal/xml/EntityXMLConverter.java | 5 +- src/org/openbravo/service/dataset/DataSetService.java | 76 ++++++-------- src/org/openbravo/service/db/ClientImportEntityResolver.java | 1 - src/org/openbravo/service/db/DataImportService.java | 4 +- src/org/openbravo/service/rest/DalWebService.java | 5 +- 9 files changed, 77 insertions(+), 109 deletions(-) diffs (truncated from 329 to 300 lines): diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/base/model/NamingUtil.java --- a/src/org/openbravo/base/model/NamingUtil.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/base/model/NamingUtil.java Wed Apr 08 10:00:26 2009 +0200 @@ -50,7 +50,6 @@ reservedNames.put("transient", "trnsnt"); reservedNames.put("case", "cse"); reservedNames.put("char", "chr"); - reservedNames.put("public", "pblic"); } /** diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/dal/core/DalThreadHandler.java --- a/src/org/openbravo/dal/core/DalThreadHandler.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/dal/core/DalThreadHandler.java Wed Apr 08 10:00:26 2009 +0200 @@ -52,6 +52,9 @@ } } finally { SessionHandler.deleteSessionHandler(); + if (OBContext.getOBContext() != null) { + OBContext.getOBContext().setInAdministratorMode(false); + } OBContext.setOBContext((OBContext) null); } } diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/dal/core/TriggerHandler.java --- a/src/org/openbravo/dal/core/TriggerHandler.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/dal/core/TriggerHandler.java Wed Apr 08 10:00:26 2009 +0200 @@ -59,7 +59,6 @@ log.debug("Disabling triggers"); Check.isNull(sessionStatus.get(), "There is already a ADSessionStatus present in this thread, " + "call enable before calling disable again"); - final boolean adminMode = OBContext.getOBContext().isInAdministratorMode(); try { OBContext.getOBContext().setInAdministratorMode(true); final SessionStatus localSessionStatus = OBProvider.getInstance().get(SessionStatus.class); @@ -71,9 +70,7 @@ Check.isNotNull(localSessionStatus.getId(), "The id is not set after insert"); sessionStatus.set(localSessionStatus); } finally { - if (!adminMode) { - OBContext.getOBContext().restorePreviousAdminMode(); - } + OBContext.getOBContext().restorePreviousAdminMode(); } } diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/dal/xml/EntityResolver.java --- a/src/org/openbravo/dal/xml/EntityResolver.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/dal/xml/EntityResolver.java Wed Apr 08 10:00:26 2009 +0200 @@ -163,55 +163,45 @@ data.put(getKey(entityName, id), result); } - setClientOrganization(result); + // TODO: add warning if the entity is created in a different + // client/organization than the inputted ones + // Set the client and organization on the most detailed level + // looking at the accesslevel of the entity + Client setClient; + Organization setOrg; + if (entity.getAccessLevel() == AccessLevel.SYSTEM) { + setClient = clientZero; + setOrg = organizationZero; + } else if (entity.getAccessLevel() == AccessLevel.SYSTEM_CLIENT) { + setClient = client; + setOrg = organizationZero; + } else if (entity.getAccessLevel() == AccessLevel.CLIENT) { + setClient = client; + setOrg = organizationZero; + } else if (entity.getAccessLevel() == AccessLevel.CLIENT_ORGANIZATION) { + setClient = client; + setOrg = organization; + } else if (entity.getAccessLevel() == AccessLevel.ORGANIZATION) { + // TODO: is this correct? That it is the same as the previous + // one? + setClient = client; + setOrg = organization; + } else if (entity.getAccessLevel() == AccessLevel.ALL) { + setClient = client; + setOrg = organization; + } else { + throw new EntityXMLException("Access level " + entity.getAccessLevel() + " not supported"); + } + if (entity.isClientEnabled()) { + result.setValue(PROPERTY_CLIENT, setClient); + } + if (entity.isOrganizationEnabled()) { + result.setValue(PROPERTY_ORGANIZATION, setOrg); + } } return result; } - protected void setClientOrganization(BaseOBObject bob) { - - setClientOrganizationZero(); - - final Entity entity = bob.getEntity(); - - // TODO: add warning if the entity is created in a different - // client/organization than the inputted ones - // Set the client and organization on the most detailed level - // looking at the accesslevel of the entity - Client setClient; - Organization setOrg; - if (entity.getAccessLevel() == AccessLevel.SYSTEM) { - setClient = clientZero; - setOrg = organizationZero; - } else if (entity.getAccessLevel() == AccessLevel.SYSTEM_CLIENT) { - setClient = client; - setOrg = organizationZero; - } else if (entity.getAccessLevel() == AccessLevel.CLIENT) { - setClient = client; - setOrg = organizationZero; - } else if (entity.getAccessLevel() == AccessLevel.CLIENT_ORGANIZATION) { - setClient = client; - setOrg = organization; - } else if (entity.getAccessLevel() == AccessLevel.ORGANIZATION) { - // TODO: is this correct? That it is the same as the previous - // one? - setClient = client; - setOrg = organization; - } else if (entity.getAccessLevel() == AccessLevel.ALL) { - setClient = client; - setOrg = organization; - } else { - throw new EntityXMLException("Access level " + entity.getAccessLevel() + " not supported"); - } - if (entity.isClientEnabled()) { - bob.setValue(PROPERTY_CLIENT, setClient); - } - if (entity.isOrganizationEnabled()) { - bob.setValue(PROPERTY_ORGANIZATION, setOrg); - } - - } - // search on the basis of the access level of the entity protected BaseOBObject searchInstance(Entity entity, String id) { final AccessLevel al = entity.getAccessLevel(); @@ -307,7 +297,6 @@ // and then re-imported that it occurs multiple times. private List<String> getId(String id, Entity entity, String orgId) { final String[] searchOrgIds = getOrgIds(orgId); - final boolean adminMode = OBContext.getOBContext().isInAdministratorMode(); try { OBContext.getOBContext().setInAdministratorMode(true); final OBCriteria<ReferenceDataStore> rdlCriteria = OBDal.getInstance().createCriteria( @@ -330,10 +319,7 @@ } return result; } finally { - // only set back if the previous was false - if (!adminMode) { - OBContext.getOBContext().restorePreviousAdminMode(); - } + OBContext.getOBContext().restorePreviousAdminMode(); } } diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/dal/xml/EntityXMLConverter.java --- a/src/org/openbravo/dal/xml/EntityXMLConverter.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/dal/xml/EntityXMLConverter.java Wed Apr 08 10:00:26 2009 +0200 @@ -504,10 +504,7 @@ .getCodeRevision() + ""); } finally { - // only set back if the previous was false - if (!adminMode) { - OBContext.getOBContext().setInAdministratorMode(adminMode); - } + OBContext.getOBContext().setInAdministratorMode(adminMode); } } diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/service/dataset/DataSetService.java --- a/src/org/openbravo/service/dataset/DataSetService.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/service/dataset/DataSetService.java Wed Apr 08 10:00:26 2009 +0200 @@ -228,58 +228,50 @@ // do the part which can be done as super user separately from the // actual read of the db - final boolean adminMode = OBContext.getOBContext().isInAdministratorMode(); - try { - OBContext.getOBContext().setInAdministratorMode(true); - final String entityName = dataSetTable.getTable().getName(); - final Entity entity = ModelProvider.getInstance().getEntity(entityName); + OBContext.getOBContext().setInAdministratorMode(true); + final String entityName = dataSetTable.getTable().getName(); + final Entity entity = ModelProvider.getInstance().getEntity(entityName); - if (entity == null) { - log.error("Entity not found using table name " + entityName); - return new ArrayList<BaseOBObject>(); - } + if (entity == null) { + log.error("Entity not found using table name " + entityName); + return new ArrayList<BaseOBObject>(); + } - String whereClause = dataSetTable.getSQLWhereClause(); + String whereClause = dataSetTable.getSQLWhereClause(); - final Map<String, Object> existingParams = new HashMap<String, Object>(); - if (whereClause != null) { - if (parameters != null) { - for (final String name : parameters.keySet()) { - if (whereClause.indexOf(":" + name) != -1) { - existingParams.put(name, parameters.get(name)); - } + final Map<String, Object> existingParams = new HashMap<String, Object>(); + if (whereClause != null) { + if (parameters != null) { + for (final String name : parameters.keySet()) { + if (whereClause.indexOf(":" + name) != -1) { + existingParams.put(name, parameters.get(name)); } } } + } - if (moduleId != null && whereClause != null) { - while (whereClause.indexOf("@moduleid@") != -1) { - whereClause = whereClause.replace("@moduleid@", "'" + moduleId + "'"); - } - if (whereClause.indexOf(":moduleid") != -1 && parameters.get("moduleid") == null) { - existingParams.put("moduleid", moduleId); - } + if (moduleId != null && whereClause != null) { + while (whereClause.indexOf("@moduleid@") != -1) { + whereClause = whereClause.replace("@moduleid@", "'" + moduleId + "'"); } - - final OBQuery<BaseOBObject> oq = OBDal.getInstance().createQuery(entity.getName(), - whereClause); - oq.setFilterOnActive(false); - oq.setNamedParameters(existingParams); - - if (OBContext.getOBContext().getRole().getId().equals("0") - && OBContext.getOBContext().getCurrentClient().getId().equals("0")) { - oq.setFilterOnReadableOrganization(false); - oq.setFilterOnReadableClients(false); - } - - final List<?> list = oq.list(); - Collections.sort(list, new BaseOBIDHexComparator()); - return (List<BaseOBObject>) list; - } finally { - if (!adminMode) { - OBContext.getOBContext().restorePreviousAdminMode(); + if (whereClause.indexOf(":moduleid") != -1 && parameters.get("moduleid") == null) { + existingParams.put("moduleid", moduleId); } } + + final OBQuery<BaseOBObject> oq = OBDal.getInstance().createQuery(entity.getName(), whereClause); + oq.setFilterOnActive(false); + oq.setNamedParameters(existingParams); + + if (OBContext.getOBContext().getRole().getId().equals("0") + && OBContext.getOBContext().getCurrentClient().getId().equals("0")) { + oq.setFilterOnReadableOrganization(false); + oq.setFilterOnReadableClients(false); + } + + final List<?> list = oq.list(); + Collections.sort(list, new BaseOBIDHexComparator()); + return (List<BaseOBObject>) list; } /** diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/service/db/ClientImportEntityResolver.java --- a/src/org/openbravo/service/db/ClientImportEntityResolver.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/service/db/ClientImportEntityResolver.java Wed Apr 08 10:00:26 2009 +0200 @@ -104,7 +104,6 @@ // keep it here so it can be found later getData().put(getKey(entityName, id), result); } - setClientOrganization(result); } return result; } diff -r 92d129f93321 -r 89977713b8fd src/org/openbravo/service/db/DataImportService.java --- a/src/org/openbravo/service/db/DataImportService.java Tue Apr 07 22:35:32 2009 +0200 +++ b/src/org/openbravo/service/db/DataImportService.java Wed Apr 08 10:00:26 2009 +0200 @@ -141,11 +141,11 @@ public ImportResult importClientData(EntityXMLProcessor importProcessor, boolean importAuditInfo, Reader reader) { try { - OBContext.getOBContext().setInAdministratorMode(true); final ImportResult ir = new ImportResult(); boolean rolledBack = false; + OBContext.getOBContext().setInAdministratorMode(true); try { // disable the triggers to prevent unexpected extra db actions // during import @@ -279,8 +279,6 @@ return ir; ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits