/* ParticipantMappingMgrAdminEJBBean.java */
package org.enhydra.shark.ws;
import javax.naming.InitialContext;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.enhydra.shark.Shark;
import org.enhydra.shark.api.admin.ParticipantMappingManagerAdmin;
import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
import org.enhydra.shark.api.common.SharkConstants;
import org.enhydra.shark.api.internal.partmappersistence.ParticipantMap;
import org.enhydra.shark.api.internal.working.CallbackUtilities;
import org.enhydra.shark.ejb.SharkEJBUtilities;
/**
*
* @author V.Puskas
* @author S.Bojanic
* @author T.Jovanovic
* @version 0.1
*/
public class ParticipantMappingMgrAdminWrapper implements ParticipantMappingManagerAdmin {
/**
* @ejb:interface-method
* view-type="all"
*/
public void configure(CallbackUtilities cus) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
getSharkObject().configure(cus);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
}
else {
getSharkObject().configure(cus);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public ParticipantMap[] getParticipantMappings(WMSessionHandle shandle,
String packageId,
String packageVer,
String processDefinitionId,
String participantId) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
ParticipantMap[] retVal = null;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().getParticipantMappings(shandle, packageId, packageVer, processDefinitionId, participantId);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().getParticipantMappings(shandle, packageId, packageVer, processDefinitionId, participantId);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public boolean saveParticipantMapping(ParticipantMap pm) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
boolean retVal;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().saveParticipantMapping(pm);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().saveParticipantMapping(pm);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public boolean deleteParticipantMapping(ParticipantMap pm) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
boolean retVal;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().deleteParticipantMapping(pm);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().deleteParticipantMapping(pm);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public ParticipantMap[] getAllParticipantMappings() throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
ParticipantMap[] retVal = null;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().getAllParticipantMappings();
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().getAllParticipantMappings();
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public boolean doesParticipantMappingExist(ParticipantMap pm) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
boolean retVal;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().doesParticipantMappingExist(pm);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().doesParticipantMappingExist(pm);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public ParticipantMap createParticipantMap() throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
ParticipantMap retVal = null;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().createParticipantMap();
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().createParticipantMap();
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public boolean deleteParticipantMappings(String packageId,
String packageVersion,
String processDefinitionId,
String participantId) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
boolean retVal;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().deleteParticipantMappings(packageId, packageVersion, processDefinitionId, participantId);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().deleteParticipantMappings(packageId, packageVersion, processDefinitionId, participantId);
}
}
/**
* @ejb:interface-method
* view-type="all"
*/
public boolean deleteParticipantMappingsForUserOrGroup(String userOrGroupName) throws Exception {
if (SharkEJBUtilities.getEnvType() == 1) {
UserTransaction t = null;
boolean retVal;
try {
t = (UserTransaction)new InitialContext().lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
t.begin();
retVal = getSharkObject().deleteParticipantMappingsForUserOrGroup(userOrGroupName);
t.commit();
}
catch (Exception ex) {
try {
if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
t.rollback();
}
catch (Exception ex1) {
ex1.printStackTrace();
}
throw ex;
}
return retVal;
}
else {
return getSharkObject().deleteParticipantMappingsForUserOrGroup(userOrGroupName);
}
}
protected ParticipantMappingManagerAdmin getSharkObject() throws Exception {
return (ParticipantMappingManagerAdmin) Shark.getInstance().
getPlugIn(SharkConstants.PLUGIN_PARTICIPANT_MAPPING);
}
}
|