0001: /* AdminMiscEJBBean.java */
0002: package org.enhydra.shark.ws;
0003:
0004: import javax.naming.InitialContext;
0005: import javax.transaction.Status;
0006: import javax.transaction.UserTransaction;
0007:
0008: import org.enhydra.shark.Shark;
0009: import org.enhydra.shark.api.client.wfmc.audit.WMAAuditEntryIterator;
0010: import org.enhydra.shark.api.client.wfmc.wapi.WMActivityInstance;
0011: import org.enhydra.shark.api.client.wfmc.wapi.WMAttributeIterator;
0012: import org.enhydra.shark.api.client.wfmc.wapi.WMFilter;
0013: import org.enhydra.shark.api.client.wfmc.wapi.WMSessionHandle;
0014: import org.enhydra.shark.api.client.wfservice.AdminMisc;
0015: import org.enhydra.shark.api.client.wfservice.WMEntity;
0016: import org.enhydra.shark.api.common.DeadlineInfo;
0017: import org.enhydra.shark.ejb.SharkEJBUtilities;
0018:
0019: /**
0020: * @author V.Puskas
0021: * @author S.Bojanic
0022: * @author T.Jovanovic
0023: * @version 0.1
0024: */
0025: public class AdminMiscWrapper implements AdminMisc {
0026:
0027: /**
0028: * @ejb:interface-method view-type="all" Returns string representing the XPDL
0029: * definition Id of activity instance that has the given Id.
0030: * @param procId activity's process Id.
0031: * @param actId Id of activity instance.
0032: * @return XPDL activity definition Id for the given activity instance.
0033: * @throws Exception If something unexpected happens.
0034: */
0035: public WMEntity getActivityDefinitionInfo(WMSessionHandle shandle,
0036: String procId, String actId) throws Exception {
0037: if (SharkEJBUtilities.getEnvType() == 1) {
0038: UserTransaction t = null;
0039: WMEntity retVal = null;
0040: try {
0041: t = (UserTransaction) new InitialContext()
0042: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0043: t.begin();
0044: retVal = getSharkObject().getActivityDefinitionInfo(
0045: shandle, procId, actId);
0046: t.commit();
0047:
0048: } catch (Exception ex) {
0049: try {
0050: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0051: t.rollback();
0052: } catch (Exception ex1) {
0053: ex1.printStackTrace();
0054: }
0055: throw ex;
0056: }
0057:
0058: return retVal;
0059: } else {
0060: return getSharkObject().getActivityDefinitionInfo(shandle,
0061: procId, actId);
0062: }
0063: }
0064:
0065: /**
0066: * @ejb:interface-method view-type="all" Returns string representing the XPDL
0067: * definition Id of process instance that has the given Id.
0068: * @param procId Id of process instance.
0069: * @return XPDL process definition Id for the given process instance.
0070: * @throws Exception If something unexpected happens.
0071: */
0072: public WMEntity getProcessDefinitionInfo(WMSessionHandle shandle,
0073: String procId) throws Exception {
0074: if (SharkEJBUtilities.getEnvType() == 1) {
0075: UserTransaction t = null;
0076: WMEntity retVal = null;
0077: try {
0078: t = (UserTransaction) new InitialContext()
0079: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0080: t.begin();
0081: retVal = getSharkObject().getProcessDefinitionInfo(
0082: shandle, procId);
0083: t.commit();
0084:
0085: } catch (Exception ex) {
0086: try {
0087: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0088: t.rollback();
0089: } catch (Exception ex1) {
0090: ex1.printStackTrace();
0091: }
0092: throw ex;
0093: }
0094:
0095: return retVal;
0096: } else {
0097: return getSharkObject().getProcessDefinitionInfo(shandle,
0098: procId);
0099: }
0100: }
0101:
0102: /**
0103: * @ejb:interface-method view-type="all" Returns string representing the XPDL
0104: * definition Id of process instance that has the given Id.
0105: * @param shandle
0106: * @return XPDL process definition Id for the given process instance.
0107: * @throws Exception If something unexpected happens.
0108: */
0109: public WMEntity getProcessDefinitionInfoByUniqueProcessDefinitionName(
0110: WMSessionHandle shandle, String procDefUniqueName)
0111: throws Exception {
0112: if (SharkEJBUtilities.getEnvType() == 1) {
0113: UserTransaction t = null;
0114: WMEntity retVal = null;
0115: try {
0116: t = (UserTransaction) new InitialContext()
0117: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0118: t.begin();
0119: retVal = getSharkObject()
0120: .getProcessDefinitionInfoByUniqueProcessDefinitionName(
0121: shandle, procDefUniqueName);
0122: t.commit();
0123:
0124: } catch (Exception ex) {
0125: try {
0126: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0127: t.rollback();
0128: } catch (Exception ex1) {
0129: ex1.printStackTrace();
0130: }
0131: throw ex;
0132: }
0133:
0134: return retVal;
0135: } else {
0136: return getSharkObject()
0137: .getProcessDefinitionInfoByUniqueProcessDefinitionName(
0138: shandle, procDefUniqueName);
0139: }
0140: }
0141:
0142: /**
0143: * @ejb:interface-method view-type="all" Returns string representing the XPDL
0144: * definition Id of process instance that has the given Id.
0145: * @param shandle
0146: * @param procId Id of process instance.
0147: * @return XPDL process definition Id for the given process instance.
0148: * @throws Exception If something unexpected happens.
0149: */
0150: public WMEntity getVariableDefinitionInfo(WMSessionHandle shandle,
0151: String procId, String variableId) throws Exception {
0152: if (SharkEJBUtilities.getEnvType() == 1) {
0153: UserTransaction t = null;
0154: WMEntity retVal = null;
0155: try {
0156: t = (UserTransaction) new InitialContext()
0157: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0158: t.begin();
0159: retVal = getSharkObject().getVariableDefinitionInfo(
0160: shandle, procId, variableId);
0161: t.commit();
0162:
0163: } catch (Exception ex) {
0164: try {
0165: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0166: t.rollback();
0167: } catch (Exception ex1) {
0168: ex1.printStackTrace();
0169: }
0170: throw ex;
0171: }
0172:
0173: return retVal;
0174: } else {
0175: return getSharkObject().getVariableDefinitionInfo(shandle,
0176: procId, variableId);
0177: }
0178: }
0179:
0180: /**
0181: * @ejb:interface-method view-type="all" Returns string representing the XPDL
0182: * definition Id of process instance that has the given Id.
0183: * @param shandle
0184: * @return XPDL process definition Id for the given process instance.
0185: * @throws Exception If something unexpected happens.
0186: */
0187: public WMEntity getVariableDefinitionInfoByUniqueProcessDefinitionName(
0188: WMSessionHandle shandle, String procDefUniqueName,
0189: String variableId) throws Exception {
0190: if (SharkEJBUtilities.getEnvType() == 1) {
0191: UserTransaction t = null;
0192: WMEntity retVal = null;
0193: try {
0194: t = (UserTransaction) new InitialContext()
0195: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0196: t.begin();
0197: retVal = getSharkObject()
0198: .getVariableDefinitionInfoByUniqueProcessDefinitionName(
0199: shandle, procDefUniqueName, variableId);
0200: t.commit();
0201:
0202: } catch (Exception ex) {
0203: try {
0204: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0205: t.rollback();
0206: } catch (Exception ex1) {
0207: ex1.printStackTrace();
0208: }
0209: throw ex;
0210: }
0211:
0212: return retVal;
0213: } else {
0214: return getSharkObject()
0215: .getVariableDefinitionInfoByUniqueProcessDefinitionName(
0216: shandle, procDefUniqueName, variableId);
0217: }
0218: }
0219:
0220: /**
0221: * @ejb:interface-method view-type="all" Returns string representing the class name of
0222: * the instance of variable that can be determined by the given
0223: * parameters. If there is no such variable, Exception will be
0224: * thrown.
0225: * @param procId Id of process instance.
0226: * @param variableId Id of XPDL variable definition.
0227: * @return Java class name of variable instance.
0228: * @throws Exception If something unexpected happens.
0229: */
0230: public String getVariableJavaClassName(WMSessionHandle shandle,
0231: String procId, String variableId) throws Exception {
0232: if (SharkEJBUtilities.getEnvType() == 1) {
0233: UserTransaction t = null;
0234: String retVal = null;
0235: try {
0236: t = (UserTransaction) new InitialContext()
0237: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0238: t.begin();
0239: retVal = getSharkObject().getVariableJavaClassName(
0240: shandle, procId, variableId);
0241: t.commit();
0242:
0243: } catch (Exception ex) {
0244: try {
0245: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0246: t.rollback();
0247: } catch (Exception ex1) {
0248: ex1.printStackTrace();
0249: }
0250: throw ex;
0251: }
0252:
0253: return retVal;
0254: } else {
0255: return getSharkObject().getVariableJavaClassName(shandle,
0256: procId, variableId);
0257: }
0258: }
0259:
0260: /**
0261: * @ejb:interface-method view-type="all" Returns string representing the class name of
0262: * the instance of variable that can be determined by the given
0263: * parameters. If there is no such variable, Exception will be
0264: * thrown.
0265: * @param shandle
0266: * @param variableId Id of XPDL variable definition.
0267: * @return Java class name of variable instance.
0268: * @throws Exception If something unexpected happens.
0269: */
0270: public String getVariableJavaClassNameByUniqueProcessDefinitionName(
0271: WMSessionHandle shandle, String procDefUniqueName,
0272: String variableId) throws Exception {
0273: if (SharkEJBUtilities.getEnvType() == 1) {
0274: UserTransaction t = null;
0275: String retVal = null;
0276: try {
0277: t = (UserTransaction) new InitialContext()
0278: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0279: t.begin();
0280: retVal = getSharkObject()
0281: .getVariableJavaClassNameByUniqueProcessDefinitionName(
0282: shandle, procDefUniqueName, variableId);
0283: t.commit();
0284:
0285: } catch (Exception ex) {
0286: try {
0287: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0288: t.rollback();
0289: } catch (Exception ex1) {
0290: ex1.printStackTrace();
0291: }
0292: throw ex;
0293: }
0294:
0295: return retVal;
0296: } else {
0297: return getSharkObject()
0298: .getVariableJavaClassNameByUniqueProcessDefinitionName(
0299: shandle, procDefUniqueName, variableId);
0300: }
0301: }
0302:
0303: /**
0304: * @ejb:interface-method view-type="all" Returns the name of the resource that
0305: * requested (created) the proces. If the process was requested
0306: * by subflow activity, it returns the name of the resource that
0307: * created the process that this activity is belonging to, and if
0308: * this process is also created by another activity, it searches
0309: * for the one created by resource.
0310: * @param procId The id of the process instance.
0311: * @return String representing resource name which is unique in the system.
0312: * @throws Exception If something unexpected happens.
0313: */
0314: public String getProcessRequesterUsername(WMSessionHandle shandle,
0315: String procId) throws Exception {
0316: if (SharkEJBUtilities.getEnvType() == 1) {
0317: UserTransaction t = null;
0318: String retVal = null;
0319: try {
0320: t = (UserTransaction) new InitialContext()
0321: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0322: t.begin();
0323: retVal = getSharkObject().getProcessRequesterUsername(
0324: shandle, procId);
0325: t.commit();
0326:
0327: } catch (Exception ex) {
0328: try {
0329: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0330: t.rollback();
0331: } catch (Exception ex1) {
0332: ex1.printStackTrace();
0333: }
0334: throw ex;
0335: }
0336:
0337: return retVal;
0338: } else {
0339: return getSharkObject().getProcessRequesterUsername(
0340: shandle, procId);
0341: }
0342: }
0343:
0344: /**
0345: * @ejb:interface-method view-type="all" If process with given id is a subflow, it
0346: * returns the subflow activity instance which instantiated this
0347: * process. Otherwise, it returns null.
0348: * @param procId The id of the process instance.
0349: * @return WMActivityInstance representing activity that instantiated process or null
0350: * if process is not subflow.
0351: * @throws Exception If something unexpected happens.
0352: */
0353: public WMActivityInstance getProcessActivityRequester(
0354: WMSessionHandle shandle, String procId) throws Exception {
0355: if (SharkEJBUtilities.getEnvType() == 1) {
0356: UserTransaction t = null;
0357: WMActivityInstance retVal = null;
0358: try {
0359: t = (UserTransaction) new InitialContext()
0360: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0361: t.begin();
0362: retVal = getSharkObject().getProcessActivityRequester(
0363: shandle, procId);
0364: t.commit();
0365:
0366: } catch (Exception ex) {
0367: try {
0368: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0369: t.rollback();
0370: } catch (Exception ex1) {
0371: ex1.printStackTrace();
0372: }
0373: throw ex;
0374: }
0375:
0376: return retVal;
0377: } else {
0378: return getSharkObject().getProcessActivityRequester(
0379: shandle, procId);
0380: }
0381: }
0382:
0383: /**
0384: * @ejb:interface-method view-type="all" Returns the name of the resource that
0385: * accepted/completed activity. If there is no such (i.e.
0386: * activity is still not accepted by any resource, or this is an
0387: * "automatic" activity executed by shark itself), it returns
0388: * null.
0389: * @param procId activity's process Id.
0390: * @param actId Id of activity instance that we search block activity instance Id for.
0391: * @return String representing resource name which is unique in the system.
0392: * @throws Exception If something unexpected happens.
0393: */
0394: public String getActivityResourceUsername(WMSessionHandle shandle,
0395: String procId, String actId) throws Exception {
0396: if (SharkEJBUtilities.getEnvType() == 1) {
0397: UserTransaction t = null;
0398: String retVal = null;
0399: try {
0400: t = (UserTransaction) new InitialContext()
0401: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0402: t.begin();
0403: retVal = getSharkObject().getActivityResourceUsername(
0404: shandle, procId, actId);
0405: t.commit();
0406:
0407: } catch (Exception ex) {
0408: try {
0409: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0410: t.rollback();
0411: } catch (Exception ex1) {
0412: ex1.printStackTrace();
0413: }
0414: throw ex;
0415: }
0416:
0417: return retVal;
0418: } else {
0419: return getSharkObject().getActivityResourceUsername(
0420: shandle, procId, actId);
0421: }
0422: }
0423:
0424: /**
0425: * @ejb:interface-method view-type="all" Returns string representing the Id of block
0426: * activity instance of activity instance that has the given Id.
0427: * @param procId activity's process Id.
0428: * @param actId Id of activity instance that we search block activity instance Id for.
0429: * @return block activity instance Id if there is one for the given activity instance,
0430: * or null if given activity does not belong to the block.
0431: * @throws Exception If something unexpected happens.
0432: */
0433: public String getBlockActivityId(WMSessionHandle shandle,
0434: String procId, String actId) throws Exception {
0435: if (SharkEJBUtilities.getEnvType() == 1) {
0436: UserTransaction t = null;
0437: String retVal = null;
0438: try {
0439: t = (UserTransaction) new InitialContext()
0440: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0441: t.begin();
0442: retVal = getSharkObject().getBlockActivityId(shandle,
0443: procId, actId);
0444: t.commit();
0445:
0446: } catch (Exception ex) {
0447: try {
0448: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0449: t.rollback();
0450: } catch (Exception ex1) {
0451: ex1.printStackTrace();
0452: }
0453: throw ex;
0454: }
0455:
0456: return retVal;
0457: } else {
0458: return getSharkObject().getBlockActivityId(shandle, procId,
0459: actId);
0460: }
0461: }
0462:
0463: /**
0464: * @ejb:interface-method view-type="all" Returns string representing the activity Id of
0465: * activity instance that relates to the assignment determined by
0466: * given parameters.
0467: * @param procId assignment's process Id.
0468: * @param assId Id of assignment instance.
0469: * @return activity instance Id for the given assignment.
0470: * @throws Exception If something unexpected happens.
0471: */
0472: public String getAssignmentActivityId(WMSessionHandle shandle,
0473: String procId, String assId) throws Exception {
0474: if (SharkEJBUtilities.getEnvType() == 1) {
0475: UserTransaction t = null;
0476: String retVal = null;
0477: try {
0478: t = (UserTransaction) new InitialContext()
0479: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0480: t.begin();
0481: retVal = getSharkObject().getAssignmentActivityId(
0482: shandle, procId, assId);
0483: t.commit();
0484:
0485: } catch (Exception ex) {
0486: try {
0487: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0488: t.rollback();
0489: } catch (Exception ex1) {
0490: ex1.printStackTrace();
0491: }
0492: throw ex;
0493: }
0494:
0495: return retVal;
0496: } else {
0497: return getSharkObject().getAssignmentActivityId(shandle,
0498: procId, assId);
0499: }
0500: }
0501:
0502: /**
0503: * @ejb:interface-method view-type="all" Returns string representing username of
0504: * resource instance that relates to assignment determined by
0505: * given parameters.
0506: * @param procId assignment's process Id.
0507: * @param assId Id of assignment instance.
0508: * @return resource username for the given assignment.
0509: * @throws Exception If something unexpected happens.
0510: */
0511: public String getAssignmentResourceUsername(
0512: WMSessionHandle shandle, String procId, String assId)
0513: throws Exception {
0514: if (SharkEJBUtilities.getEnvType() == 1) {
0515: UserTransaction t = null;
0516: String retVal = null;
0517: try {
0518: t = (UserTransaction) new InitialContext()
0519: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0520: t.begin();
0521: retVal = getSharkObject()
0522: .getAssignmentResourceUsername(shandle, procId,
0523: assId);
0524: t.commit();
0525:
0526: } catch (Exception ex) {
0527: try {
0528: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0529: t.rollback();
0530: } catch (Exception ex1) {
0531: ex1.printStackTrace();
0532: }
0533: throw ex;
0534: }
0535:
0536: return retVal;
0537: } else {
0538: return getSharkObject().getAssignmentResourceUsername(
0539: shandle, procId, assId);
0540: }
0541: }
0542:
0543: /**
0544: * @ejb:interface-method view-type="all" Returns the time when process is created in
0545: * number of milliseconds that have passed since January 1, 1970
0546: * 00:00:00.000 GMT.
0547: * @param procId Id of process instance
0548: * @throws Exception If process does not exist, it is locked too long or if something
0549: * unexpected happens.
0550: */
0551: public long getProcessCreatedTime(WMSessionHandle shandle,
0552: String procId) throws Exception {
0553: if (SharkEJBUtilities.getEnvType() == 1) {
0554: UserTransaction t = null;
0555: long retVal;
0556: try {
0557: t = (UserTransaction) new InitialContext()
0558: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0559: t.begin();
0560: retVal = getSharkObject().getProcessCreatedTime(
0561: shandle, procId);
0562: t.commit();
0563:
0564: } catch (Exception ex) {
0565: try {
0566: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0567: t.rollback();
0568: } catch (Exception ex1) {
0569: ex1.printStackTrace();
0570: }
0571: throw ex;
0572: }
0573:
0574: return retVal;
0575: } else {
0576: return getSharkObject().getProcessCreatedTime(shandle,
0577: procId);
0578: }
0579: }
0580:
0581: /**
0582: * @ejb:interface-method view-type="all" Returns the time when process is started in
0583: * number of milliseconds that have passed since January 1, 1970
0584: * 00:00:00.000 GMT. If process is not started returns
0585: * Long.MAX_VALUE/2.
0586: * @param procId Id of process instance
0587: * @throws Exception If process does not exist, it is locked too long or if something
0588: * unexpected happens.
0589: */
0590: public long getProcessStartedTime(WMSessionHandle shandle,
0591: String procId) throws Exception {
0592: if (SharkEJBUtilities.getEnvType() == 1) {
0593: UserTransaction t = null;
0594: long retVal;
0595: try {
0596: t = (UserTransaction) new InitialContext()
0597: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0598: t.begin();
0599: retVal = getSharkObject().getProcessStartedTime(
0600: shandle, procId);
0601: t.commit();
0602:
0603: } catch (Exception ex) {
0604: try {
0605: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0606: t.rollback();
0607: } catch (Exception ex1) {
0608: ex1.printStackTrace();
0609: }
0610: throw ex;
0611: }
0612:
0613: return retVal;
0614: } else {
0615: return getSharkObject().getProcessStartedTime(shandle,
0616: procId);
0617: }
0618: }
0619:
0620: /**
0621: * @ejb:interface-method view-type="all" Returns the time when process is finished in
0622: * number of milliseconds that have passed since January 1, 1970
0623: * 00:00:00.000 GMT. If process is not finished returns
0624: * Long.MAX_VALUE/2.
0625: * @param procId Id of process instance
0626: * @throws Exception If process does not exist, it is locked too long or if something
0627: * unexpected happens.
0628: */
0629: public long getProcessFinishTime(WMSessionHandle shandle,
0630: String procId) throws Exception {
0631: if (SharkEJBUtilities.getEnvType() == 1) {
0632: UserTransaction t = null;
0633: long retVal;
0634: try {
0635: t = (UserTransaction) new InitialContext()
0636: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0637: t.begin();
0638: retVal = getSharkObject().getProcessFinishTime(shandle,
0639: procId);
0640: t.commit();
0641:
0642: } catch (Exception ex) {
0643: try {
0644: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0645: t.rollback();
0646: } catch (Exception ex1) {
0647: ex1.printStackTrace();
0648: }
0649: throw ex;
0650: }
0651:
0652: return retVal;
0653: } else {
0654: return getSharkObject().getProcessFinishTime(shandle,
0655: procId);
0656: }
0657: }
0658:
0659: /**
0660: * @ejb:interface-method view-type="all" Returns the time when activity is created in
0661: * number of milliseconds that have passed since January 1, 1970
0662: * 00:00:00.000 GMT.
0663: * @param procId Id of process instance
0664: * @throws Exception If activity does not exist, its process is locked too long or if
0665: * something unexpected happens.
0666: */
0667: public long getActivityCreatedTime(WMSessionHandle shandle,
0668: String procId, String actId) throws Exception {
0669: if (SharkEJBUtilities.getEnvType() == 1) {
0670: UserTransaction t = null;
0671: long retVal;
0672: try {
0673: t = (UserTransaction) new InitialContext()
0674: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0675: t.begin();
0676: retVal = getSharkObject().getActivityCreatedTime(
0677: shandle, procId, actId);
0678: t.commit();
0679:
0680: } catch (Exception ex) {
0681: try {
0682: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0683: t.rollback();
0684: } catch (Exception ex1) {
0685: ex1.printStackTrace();
0686: }
0687: throw ex;
0688: }
0689:
0690: return retVal;
0691: } else {
0692: return getSharkObject().getActivityCreatedTime(shandle,
0693: procId, actId);
0694: }
0695: }
0696:
0697: /**
0698: * @ejb:interface-method view-type="all" Returns the time when activity is last time
0699: * accepted in number of milliseconds that have passed since
0700: * January 1, 1970 00:00:00.000 GMT. If activity is not accepted
0701: * (it is not in open.running state) returns Long.MAX_VALUE/2.
0702: * @param procId Id of process instance
0703: * @throws Exception If activity does not exist, its process is locked too long or if
0704: * something unexpected happens.
0705: */
0706: public long getActivityStartedTime(WMSessionHandle shandle,
0707: String procId, String actId) throws Exception {
0708: if (SharkEJBUtilities.getEnvType() == 1) {
0709: UserTransaction t = null;
0710: long retVal;
0711: try {
0712: t = (UserTransaction) new InitialContext()
0713: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0714: t.begin();
0715: retVal = getSharkObject().getActivityStartedTime(
0716: shandle, procId, actId);
0717: t.commit();
0718:
0719: } catch (Exception ex) {
0720: try {
0721: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0722: t.rollback();
0723: } catch (Exception ex1) {
0724: ex1.printStackTrace();
0725: }
0726: throw ex;
0727: }
0728:
0729: return retVal;
0730: } else {
0731: return getSharkObject().getActivityStartedTime(shandle,
0732: procId, actId);
0733: }
0734: }
0735:
0736: /**
0737: * @ejb:interface-method view-type="all" Returns the time when activity is finished in
0738: * number of milliseconds that have passed since January 1, 1970
0739: * 00:00:00.000 GMT. If activity is not finished returns
0740: * Long.MAX_VALUE/2.
0741: * @param procId Id of process instance
0742: * @throws Exception If activity does not exist, its process is locked too long or if
0743: * something unexpected happens.
0744: */
0745: public long getActivityFinishTime(WMSessionHandle shandle,
0746: String procId, String actId) throws Exception {
0747: if (SharkEJBUtilities.getEnvType() == 1) {
0748: UserTransaction t = null;
0749: long retVal;
0750: try {
0751: t = (UserTransaction) new InitialContext()
0752: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0753: t.begin();
0754: retVal = getSharkObject().getActivityFinishTime(
0755: shandle, procId, actId);
0756: t.commit();
0757:
0758: } catch (Exception ex) {
0759: try {
0760: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0761: t.rollback();
0762: } catch (Exception ex1) {
0763: ex1.printStackTrace();
0764: }
0765: throw ex;
0766: }
0767:
0768: return retVal;
0769: } else {
0770: return getSharkObject().getActivityFinishTime(shandle,
0771: procId, actId);
0772: }
0773: }
0774:
0775: /**
0776: * @ejb:interface-method view-type="all" Returns a list of all shark usernames.
0777: * @param shandle
0778: * @return
0779: * @throws Exception
0780: */
0781: public String[] getAllUsers(WMSessionHandle shandle)
0782: throws Exception {
0783: if (SharkEJBUtilities.getEnvType() == 1) {
0784: UserTransaction t = null;
0785: String[] retVal = null;
0786: try {
0787: t = (UserTransaction) new InitialContext()
0788: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0789: t.begin();
0790: retVal = getSharkObject().getAllUsers(shandle);
0791: t.commit();
0792:
0793: } catch (Exception ex) {
0794: try {
0795: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0796: t.rollback();
0797: } catch (Exception ex1) {
0798: ex1.printStackTrace();
0799: }
0800: throw ex;
0801: }
0802:
0803: return retVal;
0804: } else {
0805: return getSharkObject().getAllUsers(shandle);
0806: }
0807: }
0808:
0809: /**
0810: * @ejb:interface-method view-type="all"
0811: */
0812: public WMAttributeIterator listActivityInstanceResultAttributes(
0813: WMSessionHandle shandle, String procInstId,
0814: String actInstId, WMFilter filter, boolean countFlag)
0815: throws Exception {
0816: if (SharkEJBUtilities.getEnvType() == 1) {
0817: UserTransaction t = null;
0818: WMAttributeIterator retVal = null;
0819: try {
0820: t = (UserTransaction) new InitialContext()
0821: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0822: t.begin();
0823: retVal = getSharkObject()
0824: .listActivityInstanceResultAttributes(shandle,
0825: procInstId, actInstId, filter,
0826: countFlag);
0827: t.commit();
0828:
0829: } catch (Exception ex) {
0830: try {
0831: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0832: t.rollback();
0833: } catch (Exception ex1) {
0834: ex1.printStackTrace();
0835: }
0836: throw ex;
0837: }
0838:
0839: return retVal;
0840: } else {
0841: return getSharkObject()
0842: .listActivityInstanceResultAttributes(shandle,
0843: procInstId, actInstId, filter, countFlag);
0844: }
0845: }
0846:
0847: // /////////////////////// EA
0848:
0849: /**
0850: * @ejb:interface-method view-type="all" Returns input signature for the XPDL process
0851: * definition defined by package Id, package version and
0852: * definition Id. The input signature is meta information that
0853: * defines how to set the context of of a process instance.
0854: * <p>
0855: * The Map entry identifies the name and the data type
0856: * (represented by its string name) of the data item. Map
0857: * contains an entry for only those variables which are in XPDL
0858: * represented as FormalParameters with IN or INOUT type.
0859: */
0860: public String[][] getProcessDefinitionInputSignature(
0861: WMSessionHandle shandle, WMEntity procDef) throws Exception {
0862: if (SharkEJBUtilities.getEnvType() == 1) {
0863: UserTransaction t = null;
0864: String[][] retVal = null;
0865: try {
0866: t = (UserTransaction) new InitialContext()
0867: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0868: t.begin();
0869: retVal = getSharkObject()
0870: .getProcessDefinitionInputSignature(shandle,
0871: procDef);
0872: t.commit();
0873:
0874: } catch (Exception ex) {
0875: try {
0876: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0877: t.rollback();
0878: } catch (Exception ex1) {
0879: ex1.printStackTrace();
0880: }
0881: throw ex;
0882: }
0883:
0884: return retVal;
0885: } else {
0886: return getSharkObject().getProcessDefinitionInputSignature(
0887: shandle, procDef);
0888: }
0889: }
0890:
0891: // ///////////////////////
0892:
0893: // /////////////////////// CACHEADMIN
0894:
0895: /**
0896: * @ejb:interface-method view-type="all" Returns process cache size.
0897: */
0898: public int getProcessCacheSize(WMSessionHandle sessionHandle)
0899: throws Exception {
0900: if (SharkEJBUtilities.getEnvType() == 1) {
0901: UserTransaction t = null;
0902: int retVal;
0903: try {
0904: t = (UserTransaction) new InitialContext()
0905: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0906: t.begin();
0907: retVal = getSharkObject().getProcessCacheSize(
0908: sessionHandle);
0909: t.commit();
0910:
0911: } catch (Exception ex) {
0912: try {
0913: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0914: t.rollback();
0915: } catch (Exception ex1) {
0916: ex1.printStackTrace();
0917: }
0918: throw ex;
0919: }
0920:
0921: return retVal;
0922: } else {
0923: return getSharkObject().getProcessCacheSize(sessionHandle);
0924: }
0925: }
0926:
0927: /**
0928: * @ejb:interface-method view-type="all" Returns the number of currently cached process
0929: * objects.
0930: */
0931: public int howManyCachedProcesses(WMSessionHandle sessionHandle)
0932: throws Exception {
0933: if (SharkEJBUtilities.getEnvType() == 1) {
0934: UserTransaction t = null;
0935: int retVal;
0936: try {
0937: t = (UserTransaction) new InitialContext()
0938: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0939: t.begin();
0940: retVal = getSharkObject().howManyCachedProcesses(
0941: sessionHandle);
0942: t.commit();
0943:
0944: } catch (Exception ex) {
0945: try {
0946: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0947: t.rollback();
0948: } catch (Exception ex1) {
0949: ex1.printStackTrace();
0950: }
0951: throw ex;
0952: }
0953:
0954: return retVal;
0955: } else {
0956: return getSharkObject().howManyCachedProcesses(
0957: sessionHandle);
0958: }
0959: }
0960:
0961: /**
0962: * @ejb:interface-method view-type="all" Returns resource cache size.
0963: */
0964: public int getResourceCacheSize(WMSessionHandle sessionHandle)
0965: throws Exception {
0966: if (SharkEJBUtilities.getEnvType() == 1) {
0967: UserTransaction t = null;
0968: int retVal;
0969: try {
0970: t = (UserTransaction) new InitialContext()
0971: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
0972: t.begin();
0973: retVal = getSharkObject().getResourceCacheSize(
0974: sessionHandle);
0975: t.commit();
0976:
0977: } catch (Exception ex) {
0978: try {
0979: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
0980: t.rollback();
0981: } catch (Exception ex1) {
0982: ex1.printStackTrace();
0983: }
0984: throw ex;
0985: }
0986:
0987: return retVal;
0988: } else {
0989: return getSharkObject().getResourceCacheSize(sessionHandle);
0990: }
0991: }
0992:
0993: /**
0994: * @ejb:interface-method view-type="all" Returns the number of currently cached
0995: * resource objects.
0996: */
0997: public int howManyCachedResources(WMSessionHandle sessionHandle)
0998: throws Exception {
0999: if (SharkEJBUtilities.getEnvType() == 1) {
1000: UserTransaction t = null;
1001: int retVal;
1002: try {
1003: t = (UserTransaction) new InitialContext()
1004: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1005: t.begin();
1006: retVal = getSharkObject().howManyCachedResources(
1007: sessionHandle);
1008: t.commit();
1009:
1010: } catch (Exception ex) {
1011: try {
1012: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1013: t.rollback();
1014: } catch (Exception ex1) {
1015: ex1.printStackTrace();
1016: }
1017: throw ex;
1018: }
1019:
1020: return retVal;
1021: } else {
1022: return getSharkObject().howManyCachedResources(
1023: sessionHandle);
1024: }
1025: }
1026:
1027: // ///////////////////////
1028:
1029: // /////////////////////// DEADLINE
1030:
1031: /**
1032: * @ejb:interface-method view-type="all" Returns information on all deadlines of a
1033: * given process's active activities.
1034: * @param procId Id of process instance
1035: */
1036: public DeadlineInfo[] getDeadlineInfoForProcess(
1037: WMSessionHandle session, String procId) throws Exception {
1038: if (SharkEJBUtilities.getEnvType() == 1) {
1039: UserTransaction t = null;
1040: DeadlineInfo[] retVal = null;
1041: try {
1042: t = (UserTransaction) new InitialContext()
1043: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1044: t.begin();
1045: retVal = getSharkObject().getDeadlineInfoForProcess(
1046: session, procId);
1047: t.commit();
1048:
1049: } catch (Exception ex) {
1050: try {
1051: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1052: t.rollback();
1053: } catch (Exception ex1) {
1054: ex1.printStackTrace();
1055: }
1056: throw ex;
1057: }
1058:
1059: return retVal;
1060: } else {
1061: return getSharkObject().getDeadlineInfoForProcess(session,
1062: procId);
1063: }
1064: }
1065:
1066: /**
1067: * @ejb:interface-method view-type="all" Returns information on all deadlines of a
1068: * given activity.
1069: * @param procId Id of process instance
1070: * @param actId Id of activity instance
1071: */
1072: public DeadlineInfo[] getDeadlineInfoForActivity(
1073: WMSessionHandle session, String procId, String actId)
1074: throws Exception {
1075: if (SharkEJBUtilities.getEnvType() == 1) {
1076: UserTransaction t = null;
1077: DeadlineInfo[] retVal = null;
1078: try {
1079: t = (UserTransaction) new InitialContext()
1080: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1081: t.begin();
1082: retVal = getSharkObject().getDeadlineInfoForActivity(
1083: session, procId, actId);
1084: t.commit();
1085:
1086: } catch (Exception ex) {
1087: try {
1088: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1089: t.rollback();
1090: } catch (Exception ex1) {
1091: ex1.printStackTrace();
1092: }
1093: throw ex;
1094: }
1095:
1096: return retVal;
1097: } else {
1098: return getSharkObject().getDeadlineInfoForActivity(session,
1099: procId, actId);
1100: }
1101: }
1102:
1103: /**
1104: * @ejb:interface-method view-type="all"
1105: */
1106: public String[][] getToolAgentsInfo(WMSessionHandle shandle)
1107: throws Exception {
1108: if (SharkEJBUtilities.getEnvType() == 1) {
1109: UserTransaction t = null;
1110: String[][] retVal = null;
1111: try {
1112: t = (UserTransaction) new InitialContext()
1113: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1114: t.begin();
1115: retVal = getSharkObject().getToolAgentsInfo(shandle);
1116: t.commit();
1117:
1118: } catch (Exception ex) {
1119: try {
1120: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1121: t.rollback();
1122: } catch (Exception ex1) {
1123: ex1.printStackTrace();
1124: }
1125: throw ex;
1126: }
1127:
1128: return retVal;
1129: } else {
1130: return getSharkObject().getToolAgentsInfo(shandle);
1131: }
1132: }
1133:
1134: // EVENT AUDITs
1135: /**
1136: * @ejb:interface-method view-type="all"
1137: */
1138: public WMAAuditEntryIterator listProcessAuditEntries(
1139: WMSessionHandle shandle, String procId) throws Exception {
1140: if (SharkEJBUtilities.getEnvType() == 1) {
1141: UserTransaction t = null;
1142: WMAAuditEntryIterator retVal = null;
1143: try {
1144: t = (UserTransaction) new InitialContext()
1145: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1146: t.begin();
1147: retVal = getSharkObject().listProcessAuditEntries(
1148: shandle, procId);
1149: t.commit();
1150:
1151: } catch (Exception ex) {
1152: try {
1153: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1154: t.rollback();
1155: } catch (Exception ex1) {
1156: ex1.printStackTrace();
1157: }
1158: throw ex;
1159: }
1160:
1161: return retVal;
1162: } else {
1163: return getSharkObject().listProcessAuditEntries(shandle,
1164: procId);
1165: }
1166: }
1167:
1168: /**
1169: * @ejb:interface-method view-type="all"
1170: */
1171: public WMAAuditEntryIterator listActivityAuditEntries(
1172: WMSessionHandle shandle, String procId, String actId)
1173: throws Exception {
1174: if (SharkEJBUtilities.getEnvType() == 1) {
1175: UserTransaction t = null;
1176: WMAAuditEntryIterator retVal = null;
1177: try {
1178: t = (UserTransaction) new InitialContext()
1179: .lookup(SharkEJBUtilities.TOMCAT_USER_TRANS_JNDI_NAME);
1180: t.begin();
1181: retVal = getSharkObject().listActivityAuditEntries(
1182: shandle, procId, actId);
1183: t.commit();
1184:
1185: } catch (Exception ex) {
1186: try {
1187: if (t.getStatus() != Status.STATUS_NO_TRANSACTION)
1188: t.rollback();
1189: } catch (Exception ex1) {
1190: ex1.printStackTrace();
1191: }
1192: throw ex;
1193: }
1194:
1195: return retVal;
1196: } else {
1197: return getSharkObject().listActivityAuditEntries(shandle,
1198: procId, actId);
1199: }
1200: }
1201:
1202: protected AdminMisc getSharkObject() throws Exception {
1203: return (AdminMisc) Shark.getInstance().getAdminMisc();
1204: }
1205: }
|