private int saveRecord(VariablesSecureApp vars, OBError myError, char type) throws IOException, ServletException { BusinessPartnerCategoryData data = null; int total = 0; if (org.openbravo.erpCommon.utility.WindowAccessData.hasReadOnlyAccess( this, vars.getRole(), tabId)) { OBError newError = Utility.translateError( this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage())); myError.setError(newError); vars.setMessage(tabId, myError); } else { Connection con = null; try { con = this.getTransactionConnection(); data = getEditVariables(con, vars); data.dateTimeFormat = vars.getSessionValue("#AD_SqlDateTimeFormat"); String strSequence = ""; if (type == 'I') { strSequence = SequenceIdData.getUUID(); if (log4j.isDebugEnabled()) log4j.debug("Sequence: " + strSequence); data.cBpGroupId = strSequence; } if (Utility.isElementInList( Utility.getContext(this, vars, "#User_Client", windowId, accesslevel), data.adClientId) && Utility.isElementInList( Utility.getContext(this, vars, "#User_Org", windowId, accesslevel), data.adOrgId)) { if (type == 'I') { total = data.insert(con, this); } else { // Check the version of the record we are saving is the one in DB if (BusinessPartnerCategoryData.getCurrentDBTimestamp(this, data.cBpGroupId) .equals(vars.getStringParameter("updatedTimestamp"))) { total = data.update(con, this); } else { myError.setMessage( Replace.replace( Replace.replace( Utility.messageBD(this, "SavingModifiedRecord", vars.getLanguage()), "\\n", "<br/>"), """, "\"")); myError.setType("Error"); vars.setSessionValue(tabId + "|concurrentSave", "true"); } } } else { OBError newError = Utility.translateError( this, vars, vars.getLanguage(), Utility.messageBD(this, "NoWriteAccess", vars.getLanguage())); myError.setError(newError); } releaseCommitConnection(con); } catch (Exception ex) { OBError newError = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage()); myError.setError(newError); try { releaseRollbackConnection(con); } catch (final Exception e) { // do nothing } } if (myError.isEmpty() && total == 0) { OBError newError = Utility.translateError(this, vars, vars.getLanguage(), "@CODE=DBExecuteError"); myError.setError(newError); } vars.setMessage(tabId, myError); if (!myError.isEmpty()) { if (data != null) { if (type == 'I') { data.cBpGroupId = ""; } else { } vars.setEditionData(tabId, data); } } else { vars.setSessionValue(windowId + "|C_BP_Group_ID", data.cBpGroupId); } } return total; }