use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method commit.
public static void commit(ModelContext context, int remoteHandle, String dataSourceName, com.genexus.db.IDataStoreProvider dataStore, String objName) {
boolean doCommit = true;
if (// Si estoy en el contexto de un EJB
context.getSessionContext() != null) {
try {
javax.naming.Context initCtx = new javax.naming.InitialContext();
String trnType = (String) initCtx.lookup("java:comp/env/GX/TrnType");
if (// Si la TRN en el EJB es manejada por el contenedor
trnType.equals("CONTAINER"))
doCommit = false;
} catch (javax.naming.NamingException e) {
throw new RuntimeException(e.getMessage());
}
}
if (usingQueue)
GXQueue.commitAll();
if (doCommit) {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
if (!context.inBeforeCommit) {
context.inBeforeCommit = true;
executeEvent(context, info, objName, "before_commit", dataSourceName);
context.inBeforeCommit = false;
}
try {
if (dataStore != null && !context.inErrorHandler) {
// Commit con mecanismo de error_handler
dataStore.commit(dataSourceName);
} else {
// commit desde reorg por ejemplo, en donde no debe entrar al mencaismo de error_handler.
getConnectionManager(context).commit(context, remoteHandle, dataSourceName);
}
if (!context.inAfterCommit) {
context.inAfterCommit = true;
executeEvent(context, info, objName, "after_commit", dataSourceName);
context.inAfterCommit = false;
}
} catch (SQLException e) {
Application.GXLocalException(context, remoteHandle, "Application.commit", e);
}
}
if (useSmartCache && !ApplicationContext.getInstance().getReorganization())
getSmartCacheProvider(remoteHandle).recordUpdates();
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method getDBMSUser.
/**
* Si estoy en el cliente:
*
* - GXDB++ del Namespace Remotas -> User del server
* - GXDB++ del Namespace Locales -> User del cliente
*/
/**
* @deprecated use com.genexus.db.IDataStoreProvider.getDBMSUser();
*/
public static String getDBMSUser(ModelContext context, int handle, String dataSource) {
UserInformation info = getConnectionManager().getUserInformation(handle);
String dbmsUser = null;
try {
dbmsUser = getConnectionManager(context).getUserName(context, handle, dataSource);
} catch (SQLException ex) {
PrivateUtilities.errorHandler("getDBMSUser()" + ex.getErrorCode() + " SQLState " + ex.getSQLState() + " Statement", ex);
}
return dbmsUser;
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method canConnect.
public static boolean canConnect(ModelContext context, int remoteHandle, String location) {
try {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
getConnectionManager(context).getServerDateTime(context, remoteHandle, "DEFAULT");
} catch (Exception e) {
return false;
}
return true;
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method getServerDateTime.
public static Date getServerDateTime(ModelContext context, int handle, String dataSource) {
UserInformation info = getConnectionManager().getUserInformation(handle);
Date dateTime = null;
try {
dateTime = getConnectionManager(context).getServerDateTime(context, handle, dataSource);
} catch (SQLException ex) {
PrivateUtilities.errorHandler("getDBMSUser()" + ex.getErrorCode() + " SQLState " + ex.getSQLState() + " Statement", ex);
dateTime = CommonUtil.resetTime(CommonUtil.nullDate());
}
return dateTime;
}
use of com.genexus.db.UserInformation in project JavaClasses by genexuslabs.
the class Application method rollback.
public static void rollback(ModelContext context, int remoteHandle, String dataSourceName, com.genexus.db.IDataStoreProvider dataStore, String objName) {
boolean doRollback = true;
if (// Si estoy en el contexto de un EJB
context.getSessionContext() != null) {
try {
javax.naming.Context initCtx = new javax.naming.InitialContext();
String trnType = (String) initCtx.lookup("java:comp/env/GX/TrnType");
if (// Si la TRN en el EJB es manejada por el contenedor
trnType.equals("CONTAINER"))
doRollback = false;
} catch (javax.naming.NamingException e) {
throw new RuntimeException(e.getMessage());
}
}
if (usingQueue)
GXQueue.rollbackAll();
if (doRollback) {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
if (!context.inBeforeRollback) {
context.inBeforeRollback = true;
executeEvent(context, info, objName, "before_rollback", dataSourceName);
context.inBeforeRollback = false;
}
try {
if (dataStore != null && !context.inErrorHandler) {
// Rollback con mecanismo de error_handler
dataStore.rollback(dataSourceName);
} else {
// rollback desde error_handler por ejemplo, en donde no debe entrar al mencaismo de error_handler.
getConnectionManager(context).rollback(context, remoteHandle, dataSourceName);
}
if (!context.inAfterRollback) {
context.inAfterRollback = true;
executeEvent(context, info, objName, "after_rollback", dataSourceName);
context.inAfterRollback = false;
}
} catch (SQLException e) {
Application.GXLocalException(context, remoteHandle, "Application.commit", e);
}
} else {
UserInformation info = getConnectionManager().getUserInformation(remoteHandle);
if (!context.inBeforeRollback) {
context.inBeforeRollback = true;
executeEvent(context, info, objName, "before_rollback", dataSourceName);
context.inBeforeRollback = false;
}
((GxEjbContext) context.getSessionContext()).setRollback();
if (!context.inAfterRollback) {
context.inAfterRollback = true;
executeEvent(context, info, objName, "after_rollback", dataSourceName);
context.inAfterRollback = false;
}
}
if (useSmartCache)
getSmartCacheProvider(remoteHandle).discardUpdates();
}
Aggregations