001: /* ParticipantMappingMgrAdminEJBBean.java */
002: package org.enhydra.shark.ws;
003:
004: import javax.naming.InitialContext;
005: import javax.transaction.Status;
006: import javax.transaction.UserTransaction;
007:
008: import org.enhydra.shark.Shark;
009: import org.enhydra.shark.api.admin.ParticipantMappingManagerAdmin;
010: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
011: import org.enhydra.shark.api.common.SharkConstants;
012: import org.enhydra.shark.api.internal.partmappersistence.ParticipantMap;
013: import org.enhydra.shark.api.internal.working.CallbackUtilities;
014: import org.enhydra.shark.ejb.SharkEJBUtilities;
015:
016: /**
017: *
018: * @author V.Puskas
019: * @author S.Bojanic
020: * @author T.Jovanovic
021: * @version 0.1
022: */
023: public class ParticipantMappingMgrAdminWrapper implements
024: ParticipantMappingManagerAdmin {
025:
026: /**
027: * @ejb:interface-method
028: * view-type="all"
029: */
030: public void configure(CallbackUtilities cus) throws Exception {
031: if (SharkEJBUtilities.getEnvType() == 1) {
032: UserTransaction t = null;
033: try {
034: t = (UserTransaction) new InitialContext()
035: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
036: t.begin();
037: getSharkObject().configure(cus);
038: t.commit();
039:
040: } catch (Exception ex) {
041: try {
042: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
043: t.rollback();
044: } catch (Exception ex1) {
045: ex1.printStackTrace();
046: }
047: throw ex;
048: }
049:
050: } else {
051: getSharkObject().configure(cus);
052: }
053: }
054:
055: /**
056: * @ejb:interface-method
057: * view-type="all"
058: */
059: public ParticipantMap[] getParticipantMappings(
060: WMSessionHandle shandle, String packageId,
061: String packageVer, String processDefinitionId,
062: String participantId) throws Exception {
063: if (SharkEJBUtilities.getEnvType() == 1) {
064: UserTransaction t = null;
065: ParticipantMap[] retVal = null;
066: try {
067: t = (UserTransaction) new InitialContext()
068: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
069: t.begin();
070: retVal = getSharkObject().getParticipantMappings(
071: shandle, packageId, packageVer,
072: processDefinitionId, participantId);
073: t.commit();
074:
075: } catch (Exception ex) {
076: try {
077: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
078: t.rollback();
079: } catch (Exception ex1) {
080: ex1.printStackTrace();
081: }
082: throw ex;
083: }
084:
085: return retVal;
086: } else {
087: return getSharkObject().getParticipantMappings(shandle,
088: packageId, packageVer, processDefinitionId,
089: participantId);
090: }
091: }
092:
093: /**
094: * @ejb:interface-method
095: * view-type="all"
096: */
097: public boolean saveParticipantMapping(ParticipantMap pm)
098: throws Exception {
099: if (SharkEJBUtilities.getEnvType() == 1) {
100: UserTransaction t = null;
101: boolean retVal;
102: try {
103: t = (UserTransaction) new InitialContext()
104: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
105: t.begin();
106: retVal = getSharkObject().saveParticipantMapping(pm);
107: t.commit();
108:
109: } catch (Exception ex) {
110: try {
111: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
112: t.rollback();
113: } catch (Exception ex1) {
114: ex1.printStackTrace();
115: }
116: throw ex;
117: }
118:
119: return retVal;
120: } else {
121: return getSharkObject().saveParticipantMapping(pm);
122: }
123: }
124:
125: /**
126: * @ejb:interface-method
127: * view-type="all"
128: */
129: public boolean deleteParticipantMapping(ParticipantMap pm)
130: throws Exception {
131: if (SharkEJBUtilities.getEnvType() == 1) {
132: UserTransaction t = null;
133: boolean retVal;
134: try {
135: t = (UserTransaction) new InitialContext()
136: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
137: t.begin();
138: retVal = getSharkObject().deleteParticipantMapping(pm);
139: t.commit();
140:
141: } catch (Exception ex) {
142: try {
143: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
144: t.rollback();
145: } catch (Exception ex1) {
146: ex1.printStackTrace();
147: }
148: throw ex;
149: }
150:
151: return retVal;
152: } else {
153: return getSharkObject().deleteParticipantMapping(pm);
154: }
155: }
156:
157: /**
158: * @ejb:interface-method
159: * view-type="all"
160: */
161: public ParticipantMap[] getAllParticipantMappings()
162: throws Exception {
163: if (SharkEJBUtilities.getEnvType() == 1) {
164: UserTransaction t = null;
165: ParticipantMap[] retVal = null;
166: try {
167: t = (UserTransaction) new InitialContext()
168: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
169: t.begin();
170: retVal = getSharkObject().getAllParticipantMappings();
171: t.commit();
172:
173: } catch (Exception ex) {
174: try {
175: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
176: t.rollback();
177: } catch (Exception ex1) {
178: ex1.printStackTrace();
179: }
180: throw ex;
181: }
182:
183: return retVal;
184: } else {
185: return getSharkObject().getAllParticipantMappings();
186: }
187: }
188:
189: /**
190: * @ejb:interface-method
191: * view-type="all"
192: */
193: public boolean doesParticipantMappingExist(ParticipantMap pm)
194: throws Exception {
195: if (SharkEJBUtilities.getEnvType() == 1) {
196: UserTransaction t = null;
197: boolean retVal;
198: try {
199: t = (UserTransaction) new InitialContext()
200: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
201: t.begin();
202: retVal = getSharkObject().doesParticipantMappingExist(
203: pm);
204: t.commit();
205:
206: } catch (Exception ex) {
207: try {
208: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
209: t.rollback();
210: } catch (Exception ex1) {
211: ex1.printStackTrace();
212: }
213: throw ex;
214: }
215:
216: return retVal;
217: } else {
218: return getSharkObject().doesParticipantMappingExist(pm);
219: }
220: }
221:
222: /**
223: * @ejb:interface-method
224: * view-type="all"
225: */
226: public ParticipantMap createParticipantMap() throws Exception {
227: if (SharkEJBUtilities.getEnvType() == 1) {
228: UserTransaction t = null;
229: ParticipantMap retVal = null;
230: try {
231: t = (UserTransaction) new InitialContext()
232: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
233: t.begin();
234: retVal = getSharkObject().createParticipantMap();
235: t.commit();
236:
237: } catch (Exception ex) {
238: try {
239: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
240: t.rollback();
241: } catch (Exception ex1) {
242: ex1.printStackTrace();
243: }
244: throw ex;
245: }
246:
247: return retVal;
248: } else {
249: return getSharkObject().createParticipantMap();
250: }
251: }
252:
253: /**
254: * @ejb:interface-method
255: * view-type="all"
256: */
257: public boolean deleteParticipantMappings(String packageId,
258: String packageVersion, String processDefinitionId,
259: String participantId) throws Exception {
260: if (SharkEJBUtilities.getEnvType() == 1) {
261: UserTransaction t = null;
262: boolean retVal;
263: try {
264: t = (UserTransaction) new InitialContext()
265: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
266: t.begin();
267: retVal = getSharkObject().deleteParticipantMappings(
268: packageId, packageVersion, processDefinitionId,
269: participantId);
270: t.commit();
271:
272: } catch (Exception ex) {
273: try {
274: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
275: t.rollback();
276: } catch (Exception ex1) {
277: ex1.printStackTrace();
278: }
279: throw ex;
280: }
281:
282: return retVal;
283: } else {
284: return getSharkObject().deleteParticipantMappings(
285: packageId, packageVersion, processDefinitionId,
286: participantId);
287: }
288: }
289:
290: /**
291: * @ejb:interface-method
292: * view-type="all"
293: */
294: public boolean deleteParticipantMappingsForUserOrGroup(
295: String userOrGroupName) throws Exception {
296: if (SharkEJBUtilities.getEnvType() == 1) {
297: UserTransaction t = null;
298: boolean retVal;
299: try {
300: t = (UserTransaction) new InitialContext()
301: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
302: t.begin();
303: retVal = getSharkObject()
304: .deleteParticipantMappingsForUserOrGroup(
305: userOrGroupName);
306: t.commit();
307:
308: } catch (Exception ex) {
309: try {
310: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
311: t.rollback();
312: } catch (Exception ex1) {
313: ex1.printStackTrace();
314: }
315: throw ex;
316: }
317:
318: return retVal;
319: } else {
320: return getSharkObject()
321: .deleteParticipantMappingsForUserOrGroup(
322: userOrGroupName);
323: }
324: }
325:
326: protected ParticipantMappingManagerAdmin getSharkObject()
327: throws Exception {
328: return (ParticipantMappingManagerAdmin) Shark.getInstance()
329: .getPlugIn(SharkConstants.PLUGIN_PARTICIPANT_MAPPING);
330: }
331: }
|