details: /erp/devel/pi/rev/dfce65e76a7e
changeset: 9085:dfce65e76a7e
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Fri Nov 26 08:32:02 2010 +0100
summary: Added messages related to FeatureRestrictions
details: /erp/devel/pi/rev/3b01cfe8e73f
changeset: 9086:3b01cfe8e73f
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Mon Nov 29 15:05:38 2010 +0100
summary: Usage audit is done in a public UsageAudit class to allow it to be
called from
other places, not only HSAS.
details: /erp/devel/pi/rev/3b9922cebaef
changeset: 9087:3b9922cebaef
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Tue Nov 30 15:39:41 2010 +0100
summary: realated to issue 15331: Some DAL connection do not have
AD_Context_Info
Workaround for this issue: when setting the session information for DAL,
force creation of temporary table if the connection doesn't already have
it.
details: /erp/devel/pi/rev/3ce069393956
changeset: 9088:3ce069393956
user: Asier Lostalé <asier.lostale <at> openbravo.com>
date: Mon Dec 06 11:34:53 2010 +0100
summary: Close popup sets message and closes when calling from new windows
diffstat:
src-core/src/org/openbravo/database/SessionInfo.java | 16 +
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java | 45 +---
src/org/openbravo/base/secureApp/PopUp_Response.html | 14 +-
src/org/openbravo/base/secureApp/PopUp_Response.xml | 6 +
src/org/openbravo/erpCommon/obps/ActivationKey.java | 14 +-
src/org/openbravo/erpCommon/security/UsageAudit.java | 115 +++++++++++++
6 files changed, 177 insertions(+), 33 deletions(-)
diffs (truncated from 301 to 300 lines):
diff -r 6225aaa81a40 -r 3ce069393956
src-core/src/org/openbravo/database/SessionInfo.java
--- a/src-core/src/org/openbravo/database/SessionInfo.java Mon Dec 13
08:29:00 2010 +0100
+++ b/src-core/src/org/openbravo/database/SessionInfo.java Mon Dec 06
11:34:53 2010 +0100
@@ -177,6 +177,22 @@
}
/**
+ * Initialized DB with temporary table and sets session information on it.
+ *
+ * @param conn
+ * Connection where the session information will be stored in
+ * @param rdbms
+ * Database type
+ */
+ public static void setDBSessionInfo(Connection conn, String rdbms) {
+ if (!isAuditActive) {
+ return;
+ }
+ initDB(conn, rdbms);
+ setDBSessionInfo(conn);
+ }
+
+ /**
* Return the connection associated with the current session, if there is
one.
*/
static Connection getSessionConnection() {
diff -r 6225aaa81a40 -r 3ce069393956
src/org/openbravo/base/secureApp/HttpSecureAppServlet.java
--- a/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java Mon Dec
13 08:29:00 2010 +0100
+++ b/src/org/openbravo/base/secureApp/HttpSecureAppServlet.java Mon Dec
06 11:34:53 2010 +0100
@@ -55,7 +55,6 @@
import org.openbravo.authentication.basic.DefaultAuthenticationManager;
import org.openbravo.base.HttpBaseServlet;
import org.openbravo.base.exception.OBException;
-import org.openbravo.base.provider.OBProvider;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
@@ -65,13 +64,12 @@
import org.openbravo.erpCommon.obps.ActivationKey.FeatureRestriction;
import org.openbravo.erpCommon.obps.ActivationKey.LicenseRestriction;
import org.openbravo.erpCommon.security.SessionLogin;
+import org.openbravo.erpCommon.security.UsageAudit;
import org.openbravo.erpCommon.utility.JRFieldProviderDataSource;
import org.openbravo.erpCommon.utility.JRFormatFactory;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.PrintJRData;
import org.openbravo.erpCommon.utility.Utility;
-import org.openbravo.model.ad.access.SessionUsageAudit;
-import org.openbravo.model.ad.system.Client;
import org.openbravo.model.ad.system.SystemInformation;
import org.openbravo.model.ad.ui.Form;
import org.openbravo.model.ad.ui.FormTrl;
@@ -79,7 +77,6 @@
import org.openbravo.model.ad.ui.ProcessTrl;
import org.openbravo.model.ad.ui.Tab;
import org.openbravo.model.ad.ui.WindowTrl;
-import org.openbravo.model.common.enterprise.Organization;
import org.openbravo.utils.FileUtility;
import org.openbravo.utils.Replace;
import org.openbravo.xmlEngine.XmlDocument;
@@ -388,33 +385,7 @@
SessionInfo.setModuleId(classInfo.adModuleId);
}
- OBContext.setAdminMode();
- try {
- boolean usageAuditEnabled =
OBDal.getInstance().get(SystemInformation.class, "0")
- .isUsageauditenabled();
- if (SessionInfo.getProcessId() != null &&
SessionInfo.getProcessType() != null
- && usageAuditEnabled && vars1.getSessionValue("#AD_Session_ID")
!= null
- && !"".equals(vars1.getSessionValue("#AD_Session_ID"))) {
- // Session Usage Audit
- SessionUsageAudit usageAudit =
OBProvider.getInstance().get(SessionUsageAudit.class);
- usageAudit.setClient(OBDal.getInstance().get(Client.class, "0"));
-
usageAudit.setOrganization(OBDal.getInstance().get(Organization.class, "0"));
- usageAudit.setJavaClassName(this.getClass().getName());
- usageAudit.setModule(OBDal.getInstance().get(
- org.openbravo.model.ad.module.Module.class,
SessionInfo.getModuleId()));
- usageAudit.setSession(OBDal.getInstance().get(
- org.openbravo.model.ad.access.Session.class,
- vars1.getSessionValue("#AD_Session_ID")));
- usageAudit.setObject(SessionInfo.getProcessId());
- usageAudit.setCommand(vars1.getCommand());
- usageAudit.setObjectType(SessionInfo.getProcessType());
- OBDal.getInstance().save(usageAudit);
- }
- } finally {
- OBContext.restorePreviousMode();
- OBDal.getInstance().flush();
- OBDal.getInstance().getConnection().commit();
- }
+ UsageAudit.auditAction(vars1, this.getClass().getName());
// Autosave logic
final Boolean saveRequest = (Boolean) request.getAttribute("autosave");
@@ -1053,6 +1024,18 @@
log4j.debug("Output: PopUp Response");
final XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
"org/openbravo/base/secureApp/PopUp_Response").createXmlDocument();
+
+ if ("W".equals(classInfo.type)) {
+ OBError myMessage = vars.getMessage(classInfo.id);
+ // vars.removeMessage(classInfo.id);
+ // TODO: Remove message only in case the window was called in 3.0 new
layout mode
+ if (myMessage != null) {
+ xmlDocument.setParameter("messageType", myMessage.getType());
+ xmlDocument.setParameter("messageTitle", myMessage.getTitle());
+ xmlDocument.setParameter("messageMessage", myMessage.getMessage());
+ }
+ }
+
xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage()
+ "\";");
xmlDocument.setParameter("href", path.equals("") ? "null" : "'" + path +
"'");
response.setContentType("text/html; charset=UTF-8");
diff -r 6225aaa81a40 -r 3ce069393956
src/org/openbravo/base/secureApp/PopUp_Response.html
--- a/src/org/openbravo/base/secureApp/PopUp_Response.html Mon Dec 13
08:29:00 2010 +0100
+++ b/src/org/openbravo/base/secureApp/PopUp_Response.html Mon Dec 06
11:34:53 2010 +0100
@@ -24,7 +24,14 @@
}
function submitThisPage(ref) {
- top.opener.submitCommandForm("DEFAULT", false, null, ref, '_self');
+ if (top.opener.submitCommandForm) {
+ top.opener.submitCommandForm("DEFAULT", false, null, ref,
'_self');
+ } else {
+ var msgText = document.getElementById('messageMessage').value;
+ if (msgText) {
+ top.opener.isc.say(msgText);
+ }
+ }
top.close();
return true;
}
@@ -32,5 +39,10 @@
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
onload="submitThisPage(xx);" id="paramHref">
<h1>Complementing the operation ?</h1>
+<form>
+ <input type="hidden" name="messageType" id="messageType" value=""/>
+ <input type="hidden" name="messageTitle" id="messageTitle" value=""/>
+ <input type="hidden" name="messageMessage" id="messageMessage"
value=""/>
+</form>
</body>
</html>
diff -r 6225aaa81a40 -r 3ce069393956
src/org/openbravo/base/secureApp/PopUp_Response.xml
--- a/src/org/openbravo/base/secureApp/PopUp_Response.xml Mon Dec 13
08:29:00 2010 +0100
+++ b/src/org/openbravo/base/secureApp/PopUp_Response.xml Mon Dec 06
11:34:53 2010 +0100
@@ -14,4 +14,10 @@
<template file="PopUp_Response.html"/>
<PARAMETER id="paramLanguage" name="language"/>
<PARAMETER id="paramHref" name="href" attribute="onload" replace="xx"/>
+ <PARAMETER id="paramHref" name="href" attribute="onload" replace="xx"/>
+
+ <PARAMETER id="messageType" name="messageType" default =""
attribute="value"/>
+ <PARAMETER id="messageTitle" name="messageTitle" default =""
attribute="value"/>
+ <PARAMETER id="messageMessage" name="messageMessage" default =""
attribute="value"/>
+
</REPORT>
diff -r 6225aaa81a40 -r 3ce069393956
src/org/openbravo/erpCommon/obps/ActivationKey.java
--- a/src/org/openbravo/erpCommon/obps/ActivationKey.java Mon Dec 13
08:29:00 2010 +0100
+++ b/src/org/openbravo/erpCommon/obps/ActivationKey.java Mon Dec 06
11:34:53 2010 +0100
@@ -102,7 +102,19 @@
}
public enum FeatureRestriction {
- NO_RESTRICTION, DISABLED_MODULE_RESTRICTION, TIER1_RESTRICTION,
TIER2_RESTRICTION, UNKNOWN_RESTRICTION;
+ NO_RESTRICTION(""),
DISABLED_MODULE_RESTRICTION("FeatureInDisabledModule"), TIER1_RESTRICTION(
+ "FEATURE_OBPS_ONLY"), TIER2_RESTRICTION("FEATURE_OBPS_ONLY"),
UNKNOWN_RESTRICTION("");
+
+ private String msg;
+
+ private FeatureRestriction(String msg) {
+ this.msg = msg;
+ }
+
+ @Override
+ public String toString() {
+ return msg;
+ }
}
public enum LicenseClass {
diff -r 6225aaa81a40 -r 3ce069393956
src/org/openbravo/erpCommon/security/UsageAudit.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/security/UsageAudit.java Mon Dec 06
11:34:53 2010 +0100
@@ -0,0 +1,115 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2009 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.erpCommon.security;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.openbravo.base.provider.OBProvider;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.database.SessionInfo;
+import org.openbravo.model.ad.access.SessionUsageAudit;
+import org.openbravo.model.ad.system.Client;
+import org.openbravo.model.ad.system.SystemInformation;
+import org.openbravo.model.common.enterprise.Organization;
+
+/**
+ * Inserts usage auditory in database.
+ *
+ * @author alostale
+ *
+ */
+public class UsageAudit {
+ private static final Logger log4j = Logger.getLogger(UsageAudit.class);
+
+ private static final String SESSION_ID_ATTR = "#AD_SESSION_ID";
+ // OPERATION_TYPE_PARAM is defined in DataSourceConstants, copied here not
to create a
+ // core->org.openbravo.service.datasource dependency by now
+ private static final String OPERATION_TYPE_PARAM = "_operationType";
+
+ /**
+ * Inserts a new record in usage audit in case auditory is enabled.
Information is obtained from
+ * vars parameter and SessionInfo.
+ *
+ */
+ public static void auditAction(VariablesSecureApp vars, String
javaClassName) {
+ auditAction(vars.getSessionValue(SESSION_ID_ATTR), vars.getCommand(),
SessionInfo
+ .getProcessType(), SessionInfo.getModuleId(),
SessionInfo.getProcessId(), javaClassName);
+ }
+
+ /**
+ * Inserts a new record in usage audit in case auditory is enabled.
Information is obtained from
+ * request and parameters.
+ *
+ */
+ public static void auditAction(HttpServletRequest request, Map<String,
String> parameters) {
+ HttpSession session = request.getSession(false);
+ if (session == null) {
+ return;
+ }
+ auditAction((String) session.getAttribute(SESSION_ID_ATTR), parameters
+ .get(OPERATION_TYPE_PARAM), "W", parameters.get("moduleId"),
parameters.get("tabId"), null);
+ }
+
+ private static void auditAction(String sessionId, String action, String
objectType,
+ String moduleId, String objectId, String javaClassName) {
+ try {
+ OBContext.setAdminMode();
+
+ final boolean usageAuditEnabled =
OBDal.getInstance().get(SystemInformation.class, "0")
+ .isUsageauditenabled();
+ final boolean auditAction = usageAuditEnabled && sessionId != null &&
!sessionId.isEmpty()
+ && objectType != null && !objectType.isEmpty() && moduleId != null
&& !moduleId.isEmpty();
+
+ if (!auditAction) {
+ return;
+ }
+ log4j.debug("Auditing sessionId: " + sessionId + " - action:" + action
+ " - objectType:"
+ + objectType + " - moduleId:" + moduleId + " - objectId:" + objectId
+ + " - javaClassName:" + javaClassName);
+ SessionUsageAudit usageAudit =
OBProvider.getInstance().get(SessionUsageAudit.class);
+ usageAudit.setClient(OBDal.getInstance().get(Client.class, "0"));
+ usageAudit.setOrganization(OBDal.getInstance().get(Organization.class,
"0"));
+ usageAudit.setJavaClassName(javaClassName);
+
usageAudit.setModule(OBDal.getInstance().get(org.openbravo.model.ad.module.Module.class,
+ moduleId));
+
usageAudit.setSession(OBDal.getInstance().get(org.openbravo.model.ad.access.Session.class,
+ sessionId));
+ usageAudit.setCommand(action);
+ usageAudit.setObjectType(objectType);
+ usageAudit.setObject(objectId);
+ OBDal.getInstance().save(usageAudit);
+ } finally {
+ OBContext.restorePreviousMode();
+ OBDal.getInstance().flush();
+ try {
+ OBDal.getInstance().getConnection().commit();
+ } catch (SQLException e) {
+ log4j.error("Error commiting usage audit", e);
+ }
+ }
+ }
------------------------------------------------------------------------------
Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL,
new data types, scalar functions, improved concurrency, built-in packages,
OCI, SQL*Plus, data movement tools, best practices and more.
http://p.sf.net/sfu/oracle-sfdev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits