0001: package hero.session;
0002:
0003: /**
0004: *
0005: * Bonita
0006: * Copyright (C) 1999 Bull S.A.
0007: * Bull 68 route de versailles 78434 Louveciennes Cedex France
0008: * Further information: bonita@objectweb.org
0009: *
0010: * This library is free software; you can redistribute it and/or
0011: * modify it under the terms of the GNU Lesser General Public
0012: * License as published by the Free Software Foundation; either
0013: * version 2.1 of the License, or any later version.
0014: *
0015: * This library is distributed in the hope that it will be useful,
0016: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0018: * Lesser General Public License for more details.
0019: *
0020: * You should have received a copy of the GNU Lesser General Public
0021: * License along wit this library; if not, write to the Free Software
0022: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
0023: * USA
0024: *
0025: *
0026: --------------------------------------------------------------------------
0027: * $Id: AdminSessionBean.java,v 1.27 2006/08/30 22:42:02 dparisek Exp $
0028: *
0029: --------------------------------------------------------------------------
0030: */
0031: import hero.hook.NodeHookI;
0032: import hero.hook.ProcessHookI;
0033: import hero.interfaces.BnProjectLocal;
0034: import hero.interfaces.BnProjectLocalHome;
0035: import hero.interfaces.BnProjectPK;
0036: import hero.interfaces.BnNodeLocalHome;
0037: import hero.interfaces.BnNodeLocal;
0038: import hero.interfaces.BnNodePK;
0039: import hero.interfaces.Constants;
0040: import hero.util.EventConstants;
0041: import hero.util.HeroException;
0042: import hero.util.ServerType;
0043:
0044: import java.io.File;
0045: import java.lang.reflect.Method;
0046: import java.util.ArrayList;
0047: import java.util.Arrays;
0048: import java.util.Collection;
0049: import java.util.Iterator;
0050: import java.util.HashMap;
0051:
0052: import javax.ejb.CreateException;
0053: import javax.ejb.SessionBean;
0054: import javax.ejb.SessionContext;
0055:
0056: import org.apache.log4j.Logger;
0057:
0058: /**
0059: *
0060: * The Admin Session Bean, is an stateful session bean that provides the admin API to get information about
0061: * projects and activities in which the user is admin.<br><br>
0062: * <strong>The following lines shows a sample code to use this API in your application:<br><br></strong>
0063: * <br>
0064: * First of all you have to import the Admin Session files:<br>
0065: * <br>
0066: * import hero.interfaces.AdminSessionLocalHome;<br>
0067: * import hero.interfaces.AdminSessionLocal;<br>
0068: * import hero.interfaces.AdminSessionHome;<br>
0069: * import hero.interfaces.AdminSession;<br>
0070: * import hero.interfaces.AdminSessionUtil;<br>
0071: * <br>
0072: * Now, it is time to create the Admin Session instance:<br>
0073: * <br>
0074: * Like this if you want to use local interfaces:<br><br>
0075: * AdminSessionLocalHome adminh = (AdminSessionLocalHome)hero.interfaces.AdminSessionUtil.getLocalHome();<br>
0076: * AdminSessionLocal adminsession = adminh.create();<br>
0077: * <br>
0078: * or like this if you use remote interfaces:<br>
0079: * <br>
0080: * AdminSessionHome adminh = (AdminSessionHome)hero.interfaces.AdminSessionUtil.getHome();<br>
0081: * AdminSession adminsession = adminh.create();<br>
0082: * <br>
0083: * <br>
0084: * Now you can call all Admin Sessions methods...
0085: *
0086: *
0087: * @ejb:bean name="AdminSession"
0088: * display-name="AdminSession Bean"
0089: * type="Stateless"
0090: * transaction-type="Container"
0091: * jndi-name="ejb/hero/AdminSession"
0092: * local-jndi-name="ejb/hero/AdminSession_L"
0093: *
0094: * @ejb:ejb-ref ejb-name="BnProject"
0095: * ref-name="myhero/BnProject"
0096: * @ejb:transaction type="Supports"
0097: * @ejb.permission role-name="BONITAUSER,user,SuperAdmin"
0098: * @jonas.bean
0099: * ejb-name="AdminSession"
0100: * jndi-name="ejb/hero/AdminSession"
0101: *
0102: * @jboss.container-configuration name="Standard Stateless SessionBean for Bonita"
0103: **/
0104:
0105: public class AdminSessionBean implements SessionBean, EventConstants {
0106:
0107: // -------------------------------------------------------------------------
0108: // Static
0109: // -------------------------------------------------------------------------
0110: // Utility variable
0111: private static final Logger trace = Logger
0112: .getLogger(AdminSessionBean.class);
0113:
0114: private static final String SCRIPTS_DIR = ServerType
0115: .getServerBase()
0116: + File.separator + "bonitaScripts";
0117:
0118: // -------------------------------------------------------------------------
0119: // Members
0120: // -------------------------------------------------------------------------
0121:
0122: private SessionContext mContext;
0123:
0124: // -------------------------------------------------------------------------
0125: // Methods
0126: // -------------------------------------------------------------------------
0127:
0128: /**
0129: * Get admin workflow models (admin is the role of the model administrator)
0130: *
0131: * @ejb:interface-method view-type="both"
0132: * @ejb:transaction type="Supports"
0133: *
0134: **/
0135: public Collection getModels() throws HeroException {
0136: trace.debug("start by "
0137: + mContext.getCallerPrincipal().getName());
0138: Collection result = new ArrayList();
0139: BnProjectLocalHome projhome;
0140: try {
0141: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0142: Collection models = projhome.findByAdmin(mContext
0143: .getCallerPrincipal().getName(), Constants.ADMIN,
0144: Constants.Pj.MODEL);
0145: Iterator mdls = models.iterator();
0146: while (mdls.hasNext()) {
0147: BnProjectLocal pj = (BnProjectLocal) mdls.next();
0148: result.add(pj.getBnProjectLightValue());
0149: }
0150: return result;
0151: } catch (javax.naming.NamingException ne) {
0152: trace.error(ne.getMessage());
0153: throw new HeroException(ne.getMessage());
0154: } catch (javax.ejb.FinderException fe) {
0155: trace.error(fe.getMessage());
0156: throw new HeroException(fe.getMessage());
0157: }
0158: }
0159:
0160: /**
0161: * Get instances list for models in which this user is admin (admin is the role of the model administrator)
0162: *
0163: * @ejb:interface-method view-type="both"
0164: * @ejb:transaction type="Supports"
0165: *
0166: **/
0167: public Collection getInstances() throws HeroException {
0168: trace.debug("start by "
0169: + mContext.getCallerPrincipal().getName());
0170: BnProjectLocalHome projhome;
0171: Collection result = new ArrayList();
0172: try {
0173: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0174: Collection instances = projhome.findByAdmin(mContext
0175: .getCallerPrincipal().getName(), Constants.ADMIN,
0176: Constants.Pj.INSTANCE);
0177: Iterator inst = instances.iterator();
0178: while (inst.hasNext()) {
0179: BnProjectLocal pj = (BnProjectLocal) inst.next();
0180: result.add(pj.getBnProjectLightValue());
0181: }
0182: return result;
0183: } catch (javax.naming.NamingException ne) {
0184: trace.error(ne.getMessage());
0185: throw new HeroException(ne.getMessage());
0186: } catch (javax.ejb.FinderException fe) {
0187: trace.error(fe.getMessage());
0188: throw new HeroException(fe.getMessage());
0189: }
0190: }
0191:
0192: /**
0193: * Get filtered instances list for models in which this user is admin (admin is the role of the model administrator)
0194: *
0195: * @ejb:interface-method view-type="both"
0196: * @ejb:transaction type="Supports"
0197: *
0198: **/
0199: public Collection getInstances(HashMap filter) throws HeroException {
0200: trace.debug("start by "
0201: + mContext.getCallerPrincipal().getName());
0202: BnProjectLocalHome projhome;
0203: Collection result = new ArrayList();
0204: try {
0205: Collection instances = null;
0206: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0207: if (filter == null)
0208: instances = projhome.findByAdmin(mContext
0209: .getCallerPrincipal().getName(),
0210: Constants.ADMIN, Constants.Pj.INSTANCE);
0211: else
0212: instances = getFinderByFilter(Constants.Pj.INSTANCE,
0213: filter);
0214:
0215: if (instances == null)
0216: return result;
0217: Iterator inst = instances.iterator();
0218: while (inst.hasNext()) {
0219: BnProjectLocal pj = (BnProjectLocal) inst.next();
0220: result.add(pj.getBnProjectLightValue());
0221: }
0222: return result;
0223: } catch (javax.naming.NamingException ne) {
0224: trace.error(ne.getMessage());
0225: throw new HeroException(ne.getMessage());
0226: } catch (javax.ejb.FinderException fe) {
0227: trace.error(fe.getMessage());
0228: throw new HeroException(fe.getMessage());
0229: }
0230: }
0231:
0232: /**
0233: * Get filtered instances list for models in which this user is admin (admin is the role of the model administrator)
0234: *
0235: * @ejb:interface-method view-type="both"
0236: * @ejb:transaction type="Supports"
0237: *
0238: **/
0239: public Collection getFinderByFilter(String type, HashMap filter)
0240: throws HeroException {
0241: trace.debug("start by "
0242: + mContext.getCallerPrincipal().getName());
0243: Collection results = null;
0244:
0245: String filterS = "";
0246: boolean state = false;
0247: boolean creator = false;
0248: boolean user = false;
0249: boolean role = false;
0250: boolean property = false;
0251: boolean executor = false;
0252: boolean performer = false;
0253: boolean process = false;
0254: int instState = 0;
0255: String instCreator = "";
0256: String instUser = "";
0257: String instRole = "";
0258: String instPropertyKey = "";
0259: String instPropertyVal = "";
0260: int actState = 0;
0261: String actExecutor = "";
0262: String actPerformer = "";
0263: String actProcess = "";
0264: try {
0265: if (type.equals(Constants.Pj.INSTANCE)) {
0266: if (filter.containsKey("state")) {
0267: if (filter.get("state") != null) {
0268: instState = cvStateToNum(filter.get("state")
0269: .toString());
0270: state = true;
0271: }
0272: }
0273: if (filter.containsKey("creator")) {
0274: if (filter.get("creator") != null) {
0275: instCreator = filter.get("creator").toString();
0276: creator = true;
0277: }
0278: }
0279: if (filter.containsKey("user")) {
0280: if (filter.get("user") != null) {
0281: instUser = filter.get("user").toString();
0282: user = true;
0283: }
0284: }
0285: if (filter.containsKey("role")) {
0286: if (filter.get("role") != null) {
0287: instRole = filter.get("role").toString();
0288: role = true;
0289: }
0290: }
0291: if (filter.containsKey("property")) {
0292: if (filter.get("property") != null) {
0293: String instProperty = filter.get("property")
0294: .toString();
0295: int delim = instProperty.indexOf("=");
0296: if (delim >= 0) {
0297: instPropertyKey = instProperty.substring(0,
0298: delim);
0299: instPropertyVal = instProperty
0300: .substring(delim + 1);
0301: if (instPropertyVal.equals("") == false)
0302: property = true;
0303: }
0304: }
0305: }
0306: BnProjectLocalHome projhome;
0307: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0308:
0309: if (state && creator && user && role && property)
0310: results = projhome.findByAdminFiltersAll(instState,
0311: instCreator, instUser, instRole,
0312: instPropertyKey, instPropertyVal, mContext
0313: .getCallerPrincipal().getName(),
0314: Constants.ADMIN, Constants.Pj.INSTANCE);
0315: else if (state && creator && user && role && !property)
0316: results = projhome.findByAdminFiltersNoProp(
0317: instState, instCreator, instUser, instRole,
0318: mContext.getCallerPrincipal().getName(),
0319: Constants.ADMIN, Constants.Pj.INSTANCE);
0320: else if (state && creator && user && !role && property)
0321: results = projhome.findByAdminFiltersNoRole(
0322: instState, instCreator, instUser,
0323: instPropertyKey, instPropertyVal, mContext
0324: .getCallerPrincipal().getName(),
0325: Constants.ADMIN, Constants.Pj.INSTANCE);
0326: else if (state && creator && !user && role && property)
0327: results = projhome.findByAdminFiltersNoUser(
0328: instState, instCreator, instRole,
0329: instPropertyKey, instPropertyVal, mContext
0330: .getCallerPrincipal().getName(),
0331: Constants.ADMIN, Constants.Pj.INSTANCE);
0332: else if (state && !creator && user && role && property)
0333: results = projhome.findByAdminFiltersNoCreator(
0334: instState, instUser, instRole,
0335: instPropertyKey, instPropertyVal, mContext
0336: .getCallerPrincipal().getName(),
0337: Constants.ADMIN, Constants.Pj.INSTANCE);
0338: else if (!state && creator && user && role && property)
0339: results = projhome.findByAdminFiltersNoState(
0340: instCreator, instUser, instRole,
0341: instPropertyKey, instPropertyVal, mContext
0342: .getCallerPrincipal().getName(),
0343: Constants.ADMIN, Constants.Pj.INSTANCE);
0344: else if (state && creator && user && !role && !property)
0345: results = projhome.findByAdminFiltersNoRoleNoProp(
0346: instState, instCreator, instUser, mContext
0347: .getCallerPrincipal().getName(),
0348: Constants.ADMIN, Constants.Pj.INSTANCE);
0349: else if (state && creator && !user && role && !property)
0350: results = projhome.findByAdminFiltersNoUserNoProp(
0351: instState, instCreator, instRole, mContext
0352: .getCallerPrincipal().getName(),
0353: Constants.ADMIN, Constants.Pj.INSTANCE);
0354: else if (state && creator && !user && !role && property)
0355: results = projhome.findByAdminFiltersNoUserNoRole(
0356: instState, instCreator, instPropertyKey,
0357: instPropertyVal, mContext
0358: .getCallerPrincipal().getName(),
0359: Constants.ADMIN, Constants.Pj.INSTANCE);
0360: else if (!state && creator && user && role && !property)
0361: results = projhome.findByAdminFiltersNoStateNoProp(
0362: instCreator, instUser, instRole, mContext
0363: .getCallerPrincipal().getName(),
0364: Constants.ADMIN, Constants.Pj.INSTANCE);
0365: else if (!state && creator && user && !role && property)
0366: results = projhome.findByAdminFiltersNoStateNoRole(
0367: instCreator, instUser, instPropertyKey,
0368: instPropertyVal, mContext
0369: .getCallerPrincipal().getName(),
0370: Constants.ADMIN, Constants.Pj.INSTANCE);
0371: else if (state && !creator && user && !role && property)
0372: results = projhome
0373: .findByAdminFiltersNoCreatorNoRole(
0374: instState, instUser,
0375: instPropertyKey, instPropertyVal,
0376: mContext.getCallerPrincipal()
0377: .getName(),
0378: Constants.ADMIN,
0379: Constants.Pj.INSTANCE);
0380: else if (!state && !creator && user && role && property)
0381: results = projhome
0382: .findByAdminFiltersNoStateNoCreator(
0383: instUser, instRole,
0384: instPropertyKey, instPropertyVal,
0385: mContext.getCallerPrincipal()
0386: .getName(),
0387: Constants.ADMIN,
0388: Constants.Pj.INSTANCE);
0389: else if (state && creator && !user && !role
0390: && !property)
0391: results = projhome
0392: .findByAdminFiltersNoUserNoRoleNoProp(
0393: instState, instCreator, mContext
0394: .getCallerPrincipal()
0395: .getName(),
0396: Constants.ADMIN,
0397: Constants.Pj.INSTANCE);
0398: else if (state && !creator && user && !role
0399: && !property)
0400: results = projhome
0401: .findByAdminFiltersNoCreatorNoRoleNoProp(
0402: instState, instUser, mContext
0403: .getCallerPrincipal()
0404: .getName(),
0405: Constants.ADMIN,
0406: Constants.Pj.INSTANCE);
0407: else if (state && !creator && !user && role
0408: && !property)
0409: results = projhome
0410: .findByAdminFiltersNoCreatorNoUserNoProp(
0411: instState, instRole, mContext
0412: .getCallerPrincipal()
0413: .getName(),
0414: Constants.ADMIN,
0415: Constants.Pj.INSTANCE);
0416: else if (state && !creator && !user && !role
0417: && property)
0418: results = projhome
0419: .findByAdminFiltersNoCreatorNoUserNoRole(
0420: instState, instPropertyKey,
0421: instPropertyVal, mContext
0422: .getCallerPrincipal()
0423: .getName(),
0424: Constants.ADMIN,
0425: Constants.Pj.INSTANCE);
0426: else if (!state && creator && user && !role
0427: && !property)
0428: results = projhome
0429: .findByAdminFiltersNoStateNoRoleNoProp(
0430: instCreator, instUser, mContext
0431: .getCallerPrincipal()
0432: .getName(),
0433: Constants.ADMIN,
0434: Constants.Pj.INSTANCE);
0435: else if (!state && creator && !user && role
0436: && !property)
0437: results = projhome
0438: .findByAdminFiltersNoStateNoUserNoProp(
0439: instCreator, instRole, mContext
0440: .getCallerPrincipal()
0441: .getName(),
0442: Constants.ADMIN,
0443: Constants.Pj.INSTANCE);
0444: else if (!state && creator && !user && !role
0445: && property)
0446: results = projhome
0447: .findByAdminFiltersNoStateNoUserNoRole(
0448: instCreator, instPropertyKey,
0449: instPropertyVal, mContext
0450: .getCallerPrincipal()
0451: .getName(),
0452: Constants.ADMIN,
0453: Constants.Pj.INSTANCE);
0454: else if (!state && !creator && user && role
0455: && !property)
0456: results = projhome
0457: .findByAdminFiltersNoStateNoCreatorNoProp(
0458: instUser, instRole, mContext
0459: .getCallerPrincipal()
0460: .getName(),
0461: Constants.ADMIN,
0462: Constants.Pj.INSTANCE);
0463: else if (!state && !creator && user && !role
0464: && property)
0465: results = projhome
0466: .findByAdminFiltersNoStateNoCreatorNoRole(
0467: instUser, instPropertyKey,
0468: instPropertyVal, mContext
0469: .getCallerPrincipal()
0470: .getName(),
0471: Constants.ADMIN,
0472: Constants.Pj.INSTANCE);
0473: else if (!state && !creator && !user && role
0474: && property)
0475: results = projhome
0476: .findByAdminFiltersNoStateNoCreatorNoUser(
0477: instRole, instPropertyKey,
0478: instPropertyVal, mContext
0479: .getCallerPrincipal()
0480: .getName(),
0481: Constants.ADMIN,
0482: Constants.Pj.INSTANCE);
0483: else if (state && !creator && !user && !role
0484: && !property)
0485: results = projhome
0486: .findByAdminFiltersNoCreatorNoUserNoRoleNoProp(
0487: instState, mContext
0488: .getCallerPrincipal()
0489: .getName(),
0490: Constants.ADMIN,
0491: Constants.Pj.INSTANCE);
0492: else if (!state && creator && !user && !role
0493: && !property)
0494: results = projhome
0495: .findByAdminFiltersNoStateNoUserNoRoleNoProp(
0496: instCreator, mContext
0497: .getCallerPrincipal()
0498: .getName(),
0499: Constants.ADMIN,
0500: Constants.Pj.INSTANCE);
0501: else if (!state && !creator && user && !role
0502: && !property)
0503: results = projhome
0504: .findByAdminFiltersNoStateNoCreatorNoRoleNoProp(
0505: instUser, mContext
0506: .getCallerPrincipal()
0507: .getName(),
0508: Constants.ADMIN,
0509: Constants.Pj.INSTANCE);
0510: else if (!state && !creator && !user && role
0511: && !property)
0512: results = projhome
0513: .findByAdminFiltersNoStateNoCreatorNoUserNoProp(
0514: instRole, mContext
0515: .getCallerPrincipal()
0516: .getName(),
0517: Constants.ADMIN,
0518: Constants.Pj.INSTANCE);
0519: else if (!state && !creator && !user && !role
0520: && property)
0521: results = projhome
0522: .findByAdminFiltersNoStateNoCreatorNoUserNoRole(
0523: instPropertyKey, instPropertyVal,
0524: mContext.getCallerPrincipal()
0525: .getName(),
0526: Constants.ADMIN,
0527: Constants.Pj.INSTANCE);
0528: else if (state && !creator && !user && role && property)
0529: results = projhome
0530: .findByAdminFiltersNoCreatorNoUser(
0531: instState, instRole,
0532: instPropertyKey, instPropertyVal,
0533: mContext.getCallerPrincipal()
0534: .getName(),
0535: Constants.ADMIN,
0536: Constants.Pj.INSTANCE);
0537: else if (state && !creator && user && role && !property)
0538: results = projhome
0539: .findByAdminFiltersNoCreatorNoProp(
0540: instState, instUser, instRole,
0541: mContext.getCallerPrincipal()
0542: .getName(),
0543: Constants.ADMIN,
0544: Constants.Pj.INSTANCE);
0545: else if (!state && creator && !user && role && property)
0546: results = projhome.findByAdminFiltersNoStateNoUser(
0547: instCreator, instRole, instPropertyKey,
0548: instPropertyVal, mContext
0549: .getCallerPrincipal().getName(),
0550: Constants.ADMIN, Constants.Pj.INSTANCE);
0551: else if (!state && !creator && !user && !role
0552: && !property)
0553: results = projhome.findByAdmin(mContext
0554: .getCallerPrincipal().getName(),
0555: Constants.ADMIN, Constants.Pj.INSTANCE);
0556: } else if (type.equals(Constants.Pj.ACTIVITY)) {
0557: if (filter.containsKey("state")) {
0558: if (filter.get("state") != null) {
0559: actState = cvStateToNum(filter.get("state")
0560: .toString());
0561: state = true;
0562: }
0563: }
0564: if (filter.containsKey("executor")) {
0565: if (filter.get("executor") != null) {
0566: actExecutor = filter.get("executor").toString();
0567: executor = true;
0568: }
0569: }
0570: if (filter.containsKey("performer")) {
0571: if (filter.get("performer") != null) {
0572: actPerformer = filter.get("performer")
0573: .toString();
0574: performer = true;
0575: }
0576: }
0577: if (filter.containsKey("process")) {
0578: if (filter.get("process") != null) {
0579: actProcess = filter.get("process").toString()
0580: + "_instance%";
0581: process = true;
0582: }
0583: }
0584: BnNodeLocalHome nodehome;
0585: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
0586:
0587: if (state && executor && performer && process)
0588: results = nodehome.findAdminActivitiesFilterAll(
0589: actState, actExecutor, actPerformer,
0590: actProcess, mContext.getCallerPrincipal()
0591: .getName(), Constants.ADMIN,
0592: Constants.Pj.INSTANCE,
0593: Constants.Pj.COOPERATIVE);
0594: else if (!state && executor && performer && process)
0595: results = nodehome
0596: .findAdminActivitiesFilterNoState(
0597: actExecutor, actPerformer,
0598: actProcess, mContext
0599: .getCallerPrincipal()
0600: .getName(),
0601: Constants.ADMIN,
0602: Constants.Pj.INSTANCE,
0603: Constants.Pj.COOPERATIVE);
0604: else if (!state && !executor && performer && process)
0605: results = nodehome
0606: .findAdminActivitiesFilterNoStateNoExecutor(
0607: actPerformer, actProcess, mContext
0608: .getCallerPrincipal()
0609: .getName(),
0610: Constants.ADMIN,
0611: Constants.Pj.INSTANCE,
0612: Constants.Pj.COOPERATIVE);
0613: else if (!state && !executor && !performer && process)
0614: results = nodehome
0615: .findAdminActivitiesFilterNoStateNoExecutorNoPerformer(
0616: actProcess, mContext
0617: .getCallerPrincipal()
0618: .getName(),
0619: Constants.ADMIN,
0620: Constants.Pj.INSTANCE,
0621: Constants.Pj.COOPERATIVE);
0622: else if (state && executor && performer && !process)
0623: results = nodehome
0624: .findAdminActivitiesFilterNoProcess(
0625: actState, actExecutor,
0626: actPerformer, mContext
0627: .getCallerPrincipal()
0628: .getName(),
0629: Constants.ADMIN,
0630: Constants.Pj.INSTANCE,
0631: Constants.Pj.COOPERATIVE);
0632: else if (!state && executor && performer && !process)
0633: results = nodehome
0634: .findAdminActivitiesFilterNoStateNoProcess(
0635: actExecutor, actPerformer, mContext
0636: .getCallerPrincipal()
0637: .getName(),
0638: Constants.ADMIN,
0639: Constants.Pj.INSTANCE,
0640: Constants.Pj.COOPERATIVE);
0641: else if (state && executor && !performer && process)
0642: results = nodehome
0643: .findAdminActivitiesFilterNoPerformer(
0644: actState, actExecutor, actProcess,
0645: mContext.getCallerPrincipal()
0646: .getName(),
0647: Constants.ADMIN,
0648: Constants.Pj.INSTANCE,
0649: Constants.Pj.COOPERATIVE);
0650: else if (state && !executor && !performer && !process)
0651: results = nodehome
0652: .findAdminActivitiesFilterNoExecutorNoPerformerNoProcess(
0653: actState, mContext
0654: .getCallerPrincipal()
0655: .getName(),
0656: Constants.ADMIN,
0657: Constants.Pj.INSTANCE,
0658: Constants.Pj.COOPERATIVE);
0659: else if (!state && executor && !performer && !process)
0660: results = nodehome
0661: .findAdminActivitiesFilterNoStateNoPerformerNoProcess(
0662: actExecutor, mContext
0663: .getCallerPrincipal()
0664: .getName(),
0665: Constants.ADMIN,
0666: Constants.Pj.INSTANCE,
0667: Constants.Pj.COOPERATIVE);
0668: else if (!state && !executor && performer && !process)
0669: results = nodehome
0670: .findAdminActivitiesFilterNoStateNoExecutorNoProcess(
0671: actPerformer, mContext
0672: .getCallerPrincipal()
0673: .getName(),
0674: Constants.ADMIN,
0675: Constants.Pj.INSTANCE,
0676: Constants.Pj.COOPERATIVE);
0677: else if (!state && executor && !performer && process)
0678: results = nodehome
0679: .findAdminActivitiesFilterNoStateNoPerformer(
0680: actExecutor, actProcess, mContext
0681: .getCallerPrincipal()
0682: .getName(),
0683: Constants.ADMIN,
0684: Constants.Pj.INSTANCE,
0685: Constants.Pj.COOPERATIVE);
0686: else if (state && !executor && performer && !process)
0687: results = nodehome
0688: .findAdminActivitiesFilterNoExecutorNoProcess(
0689: actState, actPerformer, mContext
0690: .getCallerPrincipal()
0691: .getName(),
0692: Constants.ADMIN,
0693: Constants.Pj.INSTANCE,
0694: Constants.Pj.COOPERATIVE);
0695: else if (state && !executor && !performer && process)
0696: results = nodehome
0697: .findAdminActivitiesFilterNoExecutorNoPerformer(
0698: actState, actProcess, mContext
0699: .getCallerPrincipal()
0700: .getName(),
0701: Constants.ADMIN,
0702: Constants.Pj.INSTANCE,
0703: Constants.Pj.COOPERATIVE);
0704: else if (state && executor && !performer && !process)
0705: results = nodehome
0706: .findAdminActivitiesFilterNoPerformerNoProcess(
0707: actState, actExecutor, mContext
0708: .getCallerPrincipal()
0709: .getName(),
0710: Constants.ADMIN,
0711: Constants.Pj.INSTANCE,
0712: Constants.Pj.COOPERATIVE);
0713: else if (state && !executor && performer && process)
0714: results = nodehome
0715: .findAdminActivitiesFilterNoExecutor(
0716: actState, actPerformer, actProcess,
0717: mContext.getCallerPrincipal()
0718: .getName(),
0719: Constants.ADMIN,
0720: Constants.Pj.INSTANCE,
0721: Constants.Pj.COOPERATIVE);
0722: else if (!state && !executor && !performer && !process)
0723: results = nodehome.findAdminActivities(mContext
0724: .getCallerPrincipal().getName(),
0725: Constants.ADMIN, Constants.Pj.INSTANCE,
0726: Constants.Pj.COOPERATIVE);
0727: }
0728: return results;
0729: } catch (javax.naming.NamingException ne) {
0730: trace.error(ne.getMessage());
0731: throw new HeroException(ne.getMessage());
0732: } catch (javax.ejb.FinderException fe) {
0733: trace.error(fe.getMessage());
0734: throw new HeroException(fe.getMessage());
0735: }
0736: }
0737:
0738: /**
0739: * Convert alpha state string to numeric state string as used in DB
0740: *
0741: * @ejb:interface-method view-type="both"
0742: * @ejb:transaction type="Supports"
0743: *
0744: */
0745: public int cvStateToNum(String state) throws HeroException {
0746: trace.debug("start by "
0747: + mContext.getCallerPrincipal().getName());
0748: int result = 0;
0749: if (state.equals("INITIAL"))
0750: result = Constants.Nd.INITIAL;
0751: else if (state.equals("STARTED"))
0752: result = Constants.Nd.READY;
0753: else if (state.equals("READY"))
0754: result = Constants.Nd.READY;
0755: else if (state.equals("DEAD"))
0756: result = Constants.Nd.DEAD;
0757: else if (state.equals("ANTICIPABLE"))
0758: result = Constants.Nd.ANTICIPABLE;
0759: else if (state.equals("EXPIRED"))
0760: result = Constants.Nd.EXPIRED;
0761: else if (state.equals("ANTICIPATING"))
0762: result = Constants.Nd.ANTICIPATING;
0763: else if (state.equals("EXECUTING"))
0764: result = Constants.Nd.EXECUTING;
0765: else if (state.equals("EXECUTED"))
0766: result = Constants.Nd.EXECUTED;
0767: else if (state.equals("INERROR"))
0768: result = Constants.Nd.INERROR;
0769: else if (state.equals("FINISHED"))
0770: result = Constants.Nd.FINISHED;
0771: else if (state.equals("TERMINATED"))
0772: result = Constants.Nd.TERMINATED;
0773: else if (state.equals("CHECKEDOUT"))
0774: result = Constants.Nd.CHECKEDOUT;
0775: else if (state.equals("ANT_SUSPENDED"))
0776: result = Constants.Nd.ANT_SUSPENDED;
0777: else if (state.equals("EXEC_SUSPENDED"))
0778: result = Constants.Nd.EXEC_SUSPENDED;
0779: else if (state.equals("BAD_TRANSITION"))
0780: result = Constants.Nd.BAD_TRANSITION;
0781: return result;
0782: }
0783:
0784: /**
0785: * Get filtered instances list for models for users
0786: *
0787: * @ejb:interface-method view-type="both"
0788: * @ejb:transaction type="Supports"
0789: *
0790: **/
0791: public Collection getInstanceUsers() throws HeroException {
0792: trace.debug("start by "
0793: + mContext.getCallerPrincipal().getName());
0794: BnProjectLocalHome projhome;
0795: Collection result = new ArrayList();
0796: try {
0797: String user = null;
0798: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0799: Collection users = projhome.getModelUserList(mContext
0800: .getCallerPrincipal().getName(), Constants.ADMIN,
0801: Constants.Pj.INSTANCE);
0802: Iterator it = users.iterator();
0803: while (it.hasNext()) {
0804: user = (String) it.next();
0805: result.add(user);
0806: }
0807: return result;
0808: } catch (javax.naming.NamingException ne) {
0809: trace.error(ne.getMessage());
0810: throw new HeroException(ne.getMessage());
0811: }
0812: }
0813:
0814: /**
0815: * Get filtered instances list of models for creators
0816: *
0817: * @ejb:interface-method view-type="both"
0818: * @ejb:transaction type="Supports"
0819: *
0820: **/
0821: public Collection getInstanceCreators() throws HeroException {
0822: trace.debug("start by "
0823: + mContext.getCallerPrincipal().getName());
0824: BnProjectLocalHome projhome;
0825: Collection result = new ArrayList();
0826: try {
0827: String creator = null;
0828: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0829: Collection users = projhome.getModelCreatorList(mContext
0830: .getCallerPrincipal().getName(), Constants.ADMIN,
0831: Constants.Pj.INSTANCE);
0832: Iterator it = users.iterator();
0833: while (it.hasNext()) {
0834: creator = (String) it.next();
0835: result.add(creator);
0836: }
0837: return result;
0838: } catch (javax.naming.NamingException ne) {
0839: trace.error(ne.getMessage());
0840: throw new HeroException(ne.getMessage());
0841: }
0842: }
0843:
0844: /**
0845: * Get filtered instances list of models for creators
0846: *
0847: * @ejb:interface-method view-type="both"
0848: * @ejb:transaction type="Supports"
0849: *
0850: **/
0851: public Collection getInstanceRoles() throws HeroException {
0852: trace.debug("start by "
0853: + mContext.getCallerPrincipal().getName());
0854: BnProjectLocalHome projhome;
0855: Collection result = new ArrayList();
0856: try {
0857: String role = null;
0858: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0859: Collection roles = projhome.getModelRoleList(mContext
0860: .getCallerPrincipal().getName(), Constants.ADMIN,
0861: Constants.Pj.INSTANCE);
0862: Iterator it = roles.iterator();
0863: while (it.hasNext()) {
0864: role = (String) it.next();
0865: if (role.toLowerCase().equals("initialrole") == false)
0866: result.add(role);
0867: }
0868: return result;
0869: } catch (javax.naming.NamingException ne) {
0870: trace.error(ne.getMessage());
0871: throw new HeroException(ne.getMessage());
0872: }
0873: }
0874:
0875: /**
0876: * Get filtered instances list of models for states
0877: *
0878: * @ejb:interface-method view-type="both"
0879: * @ejb:transaction type="Supports"
0880: *
0881: **/
0882: public Collection getInstanceStates() throws HeroException {
0883: trace.debug("start by "
0884: + mContext.getCallerPrincipal().getName());
0885: BnProjectLocalHome projhome;
0886: Collection result = new ArrayList();
0887: try {
0888: String state = null;
0889: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0890: Collection states = projhome.getModelStateList(mContext
0891: .getCallerPrincipal().getName(), Constants.ADMIN,
0892: Constants.Pj.INSTANCE);
0893: Iterator it = states.iterator();
0894: while (it.hasNext()) {
0895: state = it.next().toString();
0896: switch (Integer.parseInt(state)) {
0897: case (0):
0898: state = "INITIAL";
0899: break;
0900: case (1):
0901: state = "STARTED";
0902: break;
0903: case (2):
0904: state = "DEAD";
0905: break;
0906: case (3):
0907: state = "ANTICIPABLE";
0908: break;
0909: case (4):
0910: state = "EXPIRED";
0911: break;
0912: case (5):
0913: state = "ANTICIPATING";
0914: break;
0915: case (6):
0916: state = "EXECUTING";
0917: break;
0918: case (7):
0919: state = "EXECUTED";
0920: break;
0921: case (8):
0922: state = "INERROR";
0923: break;
0924: case (9):
0925: state = "FINISHED";
0926: break;
0927: case (10):
0928: state = "TERMINATED";
0929: break;
0930: case (11):
0931: state = "CHECKEDOUT";
0932: break;
0933: case (12):
0934: state = "ANT_SUSPENDED";
0935: break;
0936: case (13):
0937: state = "EXEC_SUSPENDED";
0938: break;
0939: case (14):
0940: state = "BAD_TRANSITION";
0941: break;
0942: }
0943: result.add(state);
0944: }
0945: return result;
0946: } catch (javax.naming.NamingException ne) {
0947: trace.error(ne.getMessage());
0948: throw new HeroException(ne.getMessage());
0949: }
0950: }
0951:
0952: /**
0953: * Get filtered instances list of models for property Keys
0954: *
0955: * @ejb:interface-method view-type="both"
0956: * @ejb:transaction type="Supports"
0957: *
0958: **/
0959: public Collection getInstancePropertyKeys() throws HeroException {
0960: trace.debug("start by "
0961: + mContext.getCallerPrincipal().getName());
0962: BnProjectLocalHome projhome;
0963: Collection result = new ArrayList();
0964: try {
0965: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0966: Collection keys = projhome.getModelPropertyKeyList(mContext
0967: .getCallerPrincipal().getName(), Constants.ADMIN,
0968: Constants.Pj.MODEL);
0969: Iterator it = keys.iterator();
0970: while (it.hasNext()) {
0971: result.add(it.next());
0972: }
0973: return result;
0974: } catch (javax.naming.NamingException ne) {
0975: trace.error(ne.getMessage());
0976: throw new HeroException(ne.getMessage());
0977: }
0978: }
0979:
0980: /**
0981: * Get subset instances list for models in which this user is admin (admin is the role of the model administrator)
0982: *
0983: * @ejb:interface-method view-type="both"
0984: * @ejb:transaction type="Supports"
0985: *
0986: **/
0987: public Collection getListAsPK(String type, HashMap filter)
0988: throws HeroException {
0989: trace.debug("start by "
0990: + mContext.getCallerPrincipal().getName());
0991: BnProjectLocalHome projhome;
0992: BnNodeLocalHome nodehome;
0993: Collection result = new ArrayList();
0994: Collection list = null;
0995: Iterator it = null;
0996: try {
0997: if (type.equals(Constants.Pj.GETACTIVITIES)) {
0998: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
0999: if (filter == null)
1000: list = nodehome.findAdminActivities(mContext
1001: .getCallerPrincipal().getName(),
1002: Constants.ADMIN, Constants.Pj.INSTANCE,
1003: Constants.Pj.COOPERATIVE);
1004: else
1005: list = getFinderByFilter(Constants.Pj.ACTIVITY,
1006: filter);
1007: it = list.iterator();
1008: while (it.hasNext()) {
1009: BnNodeLocal nd = (BnNodeLocal) it.next();
1010: result.add(nd.getPrimaryKey());
1011: }
1012: } else if (type.equals(Constants.Pj.GETINSTANCES)
1013: || type.equals(Constants.Pj.GETMODELS)) {
1014: if (type.equals(Constants.Pj.GETINSTANCES)) {
1015: if (filter == null) {
1016: projhome = hero.interfaces.BnProjectUtil
1017: .getLocalHome();
1018: list = projhome.findByAdmin(mContext
1019: .getCallerPrincipal().getName(),
1020: Constants.ADMIN, Constants.Pj.INSTANCE);
1021: } else
1022: list = getFinderByFilter(Constants.Pj.INSTANCE,
1023: filter);
1024: } else if (type.equals(Constants.Pj.GETMODELS)) {
1025: projhome = hero.interfaces.BnProjectUtil
1026: .getLocalHome();
1027: list = projhome.findByAdmin(mContext
1028: .getCallerPrincipal().getName(),
1029: Constants.ADMIN, Constants.Pj.MODEL);
1030: }
1031: it = list.iterator();
1032: while (it.hasNext()) {
1033: BnProjectLocal pj = (BnProjectLocal) it.next();
1034: result.add(pj.getPrimaryKey());
1035: }
1036: }
1037: return result;
1038: } catch (javax.naming.NamingException ne) {
1039: trace.error(ne.getMessage());
1040: throw new HeroException(ne.getMessage());
1041: } catch (javax.ejb.FinderException fe) {
1042: trace.error(fe.getMessage());
1043: throw new HeroException(fe.getMessage());
1044: }
1045: }
1046:
1047: /**
1048: * Get subset instances list (by PK)for models in which this user is admin (admin is the role of the model administrator)
1049: *
1050: * @ejb:interface-method view-type="both"
1051: * @ejb:transaction type="Supports"
1052: *
1053: **/
1054: public Collection getListByPK(String type, Collection list,
1055: int offset, int numrows) throws HeroException {
1056: trace.debug("start by "
1057: + mContext.getCallerPrincipal().getName());
1058: BnProjectLocalHome projhome;
1059: BnNodeLocalHome nodehome;
1060: Collection result = new ArrayList();
1061: Iterator it = null;
1062: try {
1063: int add = 0;
1064: int cnt = 0;
1065: if (type.equals(Constants.Pj.GETACTIVITIES)) {
1066: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1067: it = list.iterator();
1068: while (it.hasNext()) {
1069: if (cnt < offset)
1070: it.next();
1071: else {
1072: BnNodeLocal nd = nodehome
1073: .findByPrimaryKey((BnNodePK) it.next());
1074: result.add(nd.getBnNodeValue());
1075: add++;
1076: if (add == numrows)
1077: break;
1078: }
1079: cnt++;
1080: }
1081: } else if (type.equals(Constants.Pj.GETINSTANCES)
1082: || type.equals(Constants.Pj.GETMODELS)) {
1083: projhome = hero.interfaces.BnProjectUtil.getLocalHome();
1084: it = list.iterator();
1085: while (it.hasNext()) {
1086: if (cnt < offset)
1087: it.next();
1088: else {
1089: BnProjectLocal pj = projhome
1090: .findByPrimaryKey((BnProjectPK) it
1091: .next());
1092: result.add(pj.getBnProjectLightValue());
1093: add++;
1094: if (add == numrows)
1095: break;
1096: }
1097: cnt++;
1098: }
1099: }
1100: return result;
1101: } catch (javax.naming.NamingException ne) {
1102: trace.error(ne.getMessage());
1103: throw new HeroException(ne.getMessage());
1104: } catch (javax.ejb.FinderException fe) {
1105: trace.error(fe.getMessage());
1106: throw new HeroException(fe.getMessage());
1107: }
1108: }
1109:
1110: /**
1111: * Get activities for instances/cooperatives projects in which this user is admin (admin is the role of the model administrator)
1112: *
1113: * @ejb:interface-method view-type="both"
1114: * @ejb:transaction type="Supports"
1115: *
1116: **/
1117: public Collection getActivities() throws HeroException {
1118: trace.debug("start by "
1119: + mContext.getCallerPrincipal().getName());
1120: BnNodeLocalHome nodehome;
1121: Collection result = new ArrayList();
1122: try {
1123: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1124: Collection activities = nodehome.findAdminActivities(
1125: mContext.getCallerPrincipal().getName(),
1126: Constants.ADMIN, Constants.Pj.INSTANCE,
1127: Constants.Pj.COOPERATIVE);
1128: Iterator act = activities.iterator();
1129: while (act.hasNext()) {
1130: BnNodeLocal nd = (BnNodeLocal) act.next();
1131: result.add(nd.getBnNodeValue());
1132: }
1133: return result;
1134: } catch (javax.naming.NamingException ne) {
1135: trace.error(ne.getMessage());
1136: throw new HeroException(ne.getMessage());
1137: } catch (javax.ejb.FinderException fe) {
1138: trace.error(fe.getMessage());
1139: throw new HeroException(fe.getMessage());
1140: }
1141: }
1142:
1143: /**
1144: * Get filtered activities for instances/cooperatives projects in which this user is admin (admin is the role of the model administrator)
1145: *
1146: * @ejb:interface-method view-type="both"
1147: * @ejb:transaction type="Supports"
1148: *
1149: **/
1150: public Collection getActivities(HashMap filter)
1151: throws HeroException {
1152: trace.debug("start by "
1153: + mContext.getCallerPrincipal().getName());
1154: BnNodeLocalHome nodehome;
1155: Collection result = new ArrayList();
1156: try {
1157: Collection activities = null;
1158: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1159:
1160: if (filter == null)
1161: activities = nodehome.findAdminActivities(mContext
1162: .getCallerPrincipal().getName(),
1163: Constants.ADMIN, Constants.Pj.INSTANCE,
1164: Constants.Pj.COOPERATIVE);
1165: else
1166: activities = getFinderByFilter(Constants.Pj.ACTIVITY,
1167: filter);
1168:
1169: Iterator act = activities.iterator();
1170: while (act.hasNext()) {
1171: BnNodeLocal nd = (BnNodeLocal) act.next();
1172: result.add(nd.getBnNodeValue());
1173: }
1174: return result;
1175: } catch (javax.naming.NamingException ne) {
1176: trace.error(ne.getMessage());
1177: throw new HeroException(ne.getMessage());
1178: } catch (javax.ejb.FinderException fe) {
1179: trace.error(fe.getMessage());
1180: throw new HeroException(fe.getMessage());
1181: }
1182: }
1183:
1184: /**
1185: * Get filtered activities list for processes
1186: *
1187: * @ejb:interface-method view-type="both"
1188: * @ejb:transaction type="Supports"
1189: *
1190: **/
1191: public Collection getActivityProcesses() throws HeroException {
1192: trace.debug("start by "
1193: + mContext.getCallerPrincipal().getName());
1194: BnNodeLocalHome nodehome;
1195: Collection result = new ArrayList();
1196: try {
1197: String name = null;
1198: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1199: Collection names = nodehome.getAdminActivitiesByProcess(
1200: mContext.getCallerPrincipal().getName(),
1201: Constants.ADMIN, Constants.Pj.MODEL,
1202: Constants.Pj.COOPERATIVE);
1203: Iterator it = names.iterator();
1204: while (it.hasNext()) {
1205: name = (String) it.next();
1206: result.add(name);
1207: }
1208: return result;
1209: } catch (javax.naming.NamingException ne) {
1210: trace.error(ne.getMessage());
1211: throw new HeroException(ne.getMessage());
1212: }
1213: }
1214:
1215: /**
1216: * Get filtered activities list for processes
1217: *
1218: * @ejb:interface-method view-type="both"
1219: * @ejb:transaction type="Supports"
1220: *
1221: **/
1222: public Collection getActivityState() throws HeroException {
1223: trace.debug("start by "
1224: + mContext.getCallerPrincipal().getName());
1225: BnNodeLocalHome nodehome;
1226: Collection result = new ArrayList();
1227: try {
1228: String name = null;
1229: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1230: Collection names = nodehome.getAdminActivitiesByState(
1231: mContext.getCallerPrincipal().getName(),
1232: Constants.ADMIN, Constants.Pj.INSTANCE,
1233: Constants.Pj.COOPERATIVE);
1234: Iterator it = names.iterator();
1235: while (it.hasNext()) {
1236: name = it.next().toString();
1237: switch (Integer.parseInt(name)) {
1238: case (0):
1239: name = "INITIAL";
1240: break;
1241: case (1):
1242: name = "READY";
1243: break;
1244: case (2):
1245: name = "DEAD";
1246: break;
1247: case (3):
1248: name = "ANTICIPABLE";
1249: break;
1250: case (4):
1251: name = "EXPIRED";
1252: break;
1253: case (5):
1254: name = "ANTICIPATING";
1255: break;
1256: case (6):
1257: name = "EXECUTING";
1258: break;
1259: case (7):
1260: name = "EXECUTED";
1261: break;
1262: case (8):
1263: name = "INERROR";
1264: break;
1265: case (9):
1266: name = "FINISHED";
1267: break;
1268: case (10):
1269: name = "TERMINATED";
1270: break;
1271: case (11):
1272: name = "CHECKEDOUT";
1273: break;
1274: case (12):
1275: name = "ANT_SUSPENDED";
1276: break;
1277: case (13):
1278: name = "EXEC_SUSPENDED";
1279: break;
1280: case (14):
1281: name = "BAD_TRANSITION";
1282: break;
1283: }
1284: result.add(name);
1285: }
1286: return result;
1287: } catch (javax.naming.NamingException ne) {
1288: trace.error(ne.getMessage());
1289: throw new HeroException(ne.getMessage());
1290: }
1291: }
1292:
1293: /**
1294: * Get filtered activities list for processes
1295: *
1296: * @ejb:interface-method view-type="both"
1297: * @ejb:transaction type="Supports"
1298: *
1299: **/
1300: public Collection getActivityExecutor() throws HeroException {
1301: trace.debug("start by "
1302: + mContext.getCallerPrincipal().getName());
1303: BnNodeLocalHome nodehome;
1304: Collection result = new ArrayList();
1305: try {
1306: String name = null;
1307: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1308: Collection names = nodehome.getAdminActivitiesByExecutor(
1309: mContext.getCallerPrincipal().getName(),
1310: Constants.ADMIN, Constants.Pj.INSTANCE,
1311: Constants.Pj.COOPERATIVE);
1312: Iterator it = names.iterator();
1313: while (it.hasNext()) {
1314: name = (String) it.next();
1315: result.add(name);
1316: }
1317: return result;
1318: } catch (javax.naming.NamingException ne) {
1319: trace.error(ne.getMessage());
1320: throw new HeroException(ne.getMessage());
1321: }
1322: }
1323:
1324: /**
1325: * Get filtered activities list for processes
1326: *
1327: * @ejb:interface-method view-type="both"
1328: * @ejb:transaction type="Supports"
1329: *
1330: **/
1331: public Collection getActivityPerformer() throws HeroException {
1332: trace.debug("start by "
1333: + mContext.getCallerPrincipal().getName());
1334: BnNodeLocalHome nodehome;
1335: Collection result = new ArrayList();
1336: try {
1337: String name = null;
1338: nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
1339: Collection names = nodehome.getAdminActivitiesByPerformer(
1340: mContext.getCallerPrincipal().getName(),
1341: Constants.ADMIN, Constants.Pj.INSTANCE,
1342: Constants.Pj.COOPERATIVE);
1343: Iterator it = names.iterator();
1344: while (it.hasNext()) {
1345: name = (String) it.next();
1346: result.add(name);
1347: }
1348: return result;
1349: } catch (javax.naming.NamingException ne) {
1350: trace.error(ne.getMessage());
1351: throw new HeroException(ne.getMessage());
1352: }
1353: }
1354:
1355: /**
1356: * This method retrieve the list of hooks deployed on the server
1357: *
1358: * @ejb:interface-method view-type="both"
1359: * @ejb:transaction type="Supports"
1360: *
1361: **/
1362: public Collection getJavaHooks(String eventType) {
1363: trace.debug("start by "
1364: + mContext.getCallerPrincipal().getName());
1365: NodeHookI ndh;
1366: ProcessHookI ph;
1367: String event = "";
1368: try {
1369: ArrayList names = new ArrayList();
1370: String HOOKS_DIR = SCRIPTS_DIR + File.separator + "hero"
1371: + File.separator + "hook";
1372: if ((new File(HOOKS_DIR)).exists()) {
1373: File dir = new File(HOOKS_DIR);
1374: Collection output = Arrays.asList(dir.list());
1375: Iterator i = output.iterator();
1376: while (i.hasNext()) {
1377: String className = (String) i.next();
1378: int index = className.indexOf(".class");
1379: className = className.substring(0, index);
1380: ClassLoader cl = Thread.currentThread()
1381: .getContextClassLoader();
1382: Class clhook = cl.loadClass("hero.hook."
1383: + className);
1384: Class[] param = {};
1385: Object[] o = {};
1386: Method evth = clhook
1387: .getMethod("getMetadata", param);
1388: if (NodeHookI.class.isAssignableFrom(clhook)) {
1389: ndh = (NodeHookI) clhook.newInstance();
1390: event = (String) evth.invoke(ndh, o);
1391: } else if (ProcessHookI.class
1392: .isAssignableFrom(clhook)) {
1393: ph = (ProcessHookI) clhook.newInstance();
1394: event = (String) evth.invoke(ph, o);
1395: }
1396: if (event.equals(eventType))
1397: names.add(className);
1398: }
1399: return names;
1400: } else
1401: return (new ArrayList());
1402:
1403: } catch (Exception e) {
1404: e.printStackTrace();
1405: return new ArrayList();
1406: }
1407: }
1408:
1409: /**
1410: * This method retrieve the list of mappers deployed on the server
1411: *
1412: * @ejb:interface-method view-type="both"
1413: * @ejb:transaction type="Supports"
1414: *
1415: **/
1416: public Collection getCustomMappers() throws HeroException {
1417: trace.debug("start by "
1418: + mContext.getCallerPrincipal().getName());
1419:
1420: try {
1421: ArrayList names = new ArrayList();
1422: String MAPPER_DIR = SCRIPTS_DIR + File.separator + "hero"
1423: + File.separator + "mapper";
1424: if ((new File(MAPPER_DIR)).exists()) {
1425: File dir = new File(MAPPER_DIR);
1426: Collection output = Arrays.asList(dir.list());
1427: Iterator i = output.iterator();
1428: while (i.hasNext()) {
1429: String className = (String) i.next();
1430: int index = className.indexOf(".class");
1431: names.add(className.substring(0, index));
1432: }
1433: return names;
1434: } else
1435: return (new ArrayList());
1436:
1437: } catch (Exception e) {
1438: throw new HeroException(e.getMessage());
1439: }
1440: }
1441:
1442: /**
1443: * This method retrieve the list of performer assignments deployed on the server
1444: *
1445: * @ejb:interface-method view-type="both"
1446: * @ejb:transaction type="Supports"
1447: *
1448: **/
1449: public Collection getCallbackPerformers() throws HeroException {
1450: trace.debug("start by "
1451: + mContext.getCallerPrincipal().getName());
1452:
1453: try {
1454: ArrayList names = new ArrayList();
1455: String PERFORMER_DIR = SCRIPTS_DIR + File.separator
1456: + "hero" + File.separator + "performerAssign";
1457: if ((new File(PERFORMER_DIR)).exists()) {
1458: File dir = new File(PERFORMER_DIR);
1459: Collection output = Arrays.asList(dir.list());
1460: Iterator i = output.iterator();
1461: while (i.hasNext()) {
1462: String className = (String) i.next();
1463: int index = className.indexOf(".class");
1464: names.add(className.substring(0, index));
1465: }
1466: return names;
1467: } else
1468: return (new ArrayList());
1469:
1470: } catch (Exception e) {
1471: throw new HeroException(e.getMessage());
1472: }
1473: }
1474:
1475: /**
1476: * This method retrieve the list of Initiator Mappers deployed on the server
1477: *
1478: * @ejb:interface-method view-type="both"
1479: * @ejb:transaction type="Supports"
1480: *
1481: **/
1482: public Collection getCustomInitiators() throws HeroException {
1483: trace.debug("start by "
1484: + mContext.getCallerPrincipal().getName());
1485:
1486: try {
1487: ArrayList names = new ArrayList();
1488: String INITIATOR_DIR = SCRIPTS_DIR + File.separator
1489: + "hero" + File.separator + "initiatorMapper";
1490: if ((new File(INITIATOR_DIR)).exists()) {
1491: File dir = new File(INITIATOR_DIR);
1492: Collection output = Arrays.asList(dir.list());
1493: Iterator i = output.iterator();
1494: while (i.hasNext()) {
1495: String className = (String) i.next();
1496: int index = className.indexOf(".class");
1497: names.add(className.substring(0, index));
1498: }
1499: return names;
1500: } else
1501: return (new ArrayList());
1502:
1503: } catch (Exception e) {
1504: throw new HeroException(e.getMessage());
1505: }
1506: }
1507:
1508: /**
1509: * Create the AdminSession Bean
1510: *
1511: * @throws CreateException
1512: *
1513: * @ejb.permission unchecked="yes"
1514: * @ejb:create-method view-type="both"
1515: **/
1516:
1517: public void ejbCreate() throws CreateException {
1518: trace.debug("ejbCreate");
1519: }
1520:
1521: public void setSessionContext(final javax.ejb.SessionContext context) {
1522: mContext = context;
1523: }
1524:
1525: public void ejbRemove() {
1526: }
1527:
1528: public void ejbActivate() {
1529: }
1530:
1531: public void ejbPassivate() {
1532: }
1533:
1534: }
|