details: /erp/erp/devel/pi/rev/1d0013f170bf changeset: 4689:1d0013f170bf user: Stefan Hühner <stefan.huehner <at> openbravo.com> date: Thu Aug 20 20:36:30 2009 +0200 summary: Fixed 10343: Fix info popup for non system administrator users. - Move out setInAdministratorMode from ActivationKey constructor - Instead put it into the caller about constructor and other method calls
diffstat: src/org/openbravo/erpCommon/ad_forms/About.java | 79 ++++++++++++++------------ src/org/openbravo/erpCommon/obps/ActivationKey.java | 3 - 2 files changed, 43 insertions(+), 39 deletions(-) diffs (122 lines): diff -r 4bf2d28936f9 -r 1d0013f170bf src/org/openbravo/erpCommon/ad_forms/About.java --- a/src/org/openbravo/erpCommon/ad_forms/About.java Thu Aug 20 19:47:22 2009 +0200 +++ b/src/org/openbravo/erpCommon/ad_forms/About.java Thu Aug 20 20:36:30 2009 +0200 @@ -28,6 +28,7 @@ import org.openbravo.base.secureApp.HttpSecureAppServlet; import org.openbravo.base.secureApp.VariablesSecureApp; +import org.openbravo.dal.core.OBContext; import org.openbravo.erpCommon.obps.ActivationKey; import org.openbravo.erpCommon.utility.Utility; import org.openbravo.xmlEngine.XmlDocument; @@ -51,48 +52,54 @@ if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); - ActivationKey ak = new ActivationKey(); - response.setContentType("text/html; charset=UTF-8"); - PrintWriter out = response.getWriter(); - String discard[] = { "", "" }; - AboutData[] data = AboutData.selectTranslators(this); - AboutData ver = AboutData.select(this); - XmlDocument xmlDocument = null; - if (data.length == 0) { - discard[0] = "discard"; - data = AboutData.set(); - } - String licenseInfo = ""; - if (ak.isActiveInstance()) { - licenseInfo = Utility.messageBD(this, "OPSLicensedTo", vars.getLanguage()) + " " - + ak.getProperty("customer"); - } else { - licenseInfo = Utility.messageBD(this, "OPSCommunityEdition", vars.getLanguage()); + boolean adminMode = OBContext.getOBContext().setInAdministratorMode(true); + try { + ActivationKey ak = new ActivationKey(); + response.setContentType("text/html; charset=UTF-8"); + PrintWriter out = response.getWriter(); + String discard[] = { "", "" }; + AboutData[] data = AboutData.selectTranslators(this); + AboutData ver = AboutData.select(this); + XmlDocument xmlDocument = null; + if (data.length == 0) { + discard[0] = "discard"; + data = AboutData.set(); + } + String licenseInfo = ""; + if (ak.isActiveInstance()) { + licenseInfo = Utility.messageBD(this, "OPSLicensedTo", vars.getLanguage()) + " " + + ak.getProperty("customer"); + } else { + licenseInfo = Utility.messageBD(this, "OPSCommunityEdition", vars.getLanguage()); - discard[1] = "paramOPSInfo"; - } - xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_forms/About", discard) - .createXmlDocument(); + discard[1] = "paramOPSInfo"; + } + xmlDocument = xmlEngine.readXmlTemplate("org/openbravo/erpCommon/ad_forms/About", discard) + .createXmlDocument(); - String version = ver.version.substring(0, ver.version.lastIndexOf(".")) + " " - + ver.versionLabel; + String version = ver.version.substring(0, ver.version.lastIndexOf(".")) + " " + + ver.versionLabel; - xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n"); - xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";"); - xmlDocument.setParameter("theme", vars.getTheme()); - xmlDocument.setParameter("paramLicensedTo", licenseInfo); - xmlDocument.setData("structure1", data); - xmlDocument.setParameter("ver", version); - xmlDocument.setParameter("versionId", ver.versionId); - xmlDocument.setParameter("versionNo", ver.version); + xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n"); + xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";"); + xmlDocument.setParameter("theme", vars.getTheme()); + xmlDocument.setParameter("paramLicensedTo", licenseInfo); + xmlDocument.setData("structure1", data); + xmlDocument.setParameter("ver", version); + xmlDocument.setParameter("versionId", ver.versionId); + xmlDocument.setParameter("versionNo", ver.version); - if (ak.isActiveInstance()) { - xmlDocument.setParameter("paraOPSPurpose", ak.getPurpose(vars.getLanguage())); - xmlDocument.setParameter("paraOPSType", ak.getLicenseExplanation(this, vars.getLanguage())); + if (ak.isActiveInstance()) { + xmlDocument.setParameter("paraOPSPurpose", ak.getPurpose(vars.getLanguage())); + xmlDocument.setParameter("paraOPSType", ak.getLicenseExplanation(this, vars.getLanguage())); + } + + out.println(xmlDocument.print()); + out.close(); + } finally { + OBContext.getOBContext().setInAdministratorMode(adminMode); } - out.println(xmlDocument.print()); - out.close(); } public String getServletInfo() { diff -r 4bf2d28936f9 -r 1d0013f170bf src/org/openbravo/erpCommon/obps/ActivationKey.java --- a/src/org/openbravo/erpCommon/obps/ActivationKey.java Thu Aug 20 19:47:22 2009 +0200 +++ b/src/org/openbravo/erpCommon/obps/ActivationKey.java Thu Aug 20 20:36:30 2009 +0200 @@ -73,8 +73,6 @@ private static final int MILLSECS_PER_DAY = 24 * 60 * 60 * 1000; public ActivationKey() { - boolean adminMode = OBContext.getOBContext().isInAdministratorMode(); - OBContext.getOBContext().setInAdministratorMode(true); org.openbravo.model.ad.system.System sys = OBDal.getInstance().get( org.openbravo.model.ad.system.System.class, "0"); strPublicKey = sys.getInstanceKey(); @@ -196,7 +194,6 @@ } isActive = true; setLogger(); - OBContext.getOBContext().setInAdministratorMode(adminMode); } @SuppressWarnings( { "static-access", "unchecked" }) ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits