1 package hero.session; 2 23 24 import hero.entity.EdgeState; 25 import hero.entity.NodeState; 26 import hero.interfaces.BnAgentEdgeLocal; 27 import hero.interfaces.BnAgentEdgeLocalHome; 28 import hero.interfaces.BnAgentEdgeValue; 29 import hero.interfaces.BnAgentLocal; 30 import hero.interfaces.BnAgentLocalHome; 31 import hero.interfaces.BnAgentValue; 32 import hero.interfaces.BnEdgeLocal; 33 import hero.interfaces.BnEdgeLocalHome; 34 import hero.interfaces.BnEdgeUtil; 35 import hero.interfaces.BnEdgeValue; 36 import hero.interfaces.BnNodeHookLocal; 37 import hero.interfaces.BnNodeHookLocalHome; 38 import hero.interfaces.BnNodeHookUtil; 39 import hero.interfaces.BnNodeInterHookLocal; 40 import hero.interfaces.BnNodeInterHookValue; 41 import hero.interfaces.BnNodeInterHookLocalHome; 42 import hero.interfaces.BnNodeInterHookUtil; 43 import hero.interfaces.BnNodeLightValue; 44 import hero.interfaces.BnNodeLocal; 45 import hero.interfaces.BnNodeLocalHome; 46 import hero.interfaces.BnNodePropertyLocal; 47 import hero.interfaces.BnNodePropertyValue; 48 import hero.interfaces.BnNodePropertyLocalHome; 49 import hero.interfaces.BnNodePropertyUtil; 50 import hero.interfaces.BnNodeUtil; 51 import hero.interfaces.BnNodeValue; 52 import hero.interfaces.BnIterationLocal; 53 import hero.interfaces.BnIterationLocalHome; 54 import hero.interfaces.BnIterationUtil; 55 import hero.interfaces.BnIterationLightValue; 56 import hero.interfaces.BnProjectHookLocal; 57 import hero.interfaces.BnProjectHookLocalHome; 58 import hero.interfaces.BnProjectHookUtil; 59 import hero.interfaces.BnProjectInterHookLocal; 60 import hero.interfaces.BnProjectInterHookLocalHome; 61 import hero.interfaces.BnProjectInterHookUtil; 62 import hero.interfaces.BnProjectLocal; 63 import hero.interfaces.BnProjectLocalHome; 64 import hero.interfaces.BnProjectPropertyLocal; 65 import hero.interfaces.BnProjectPropertyLocalHome; 66 import hero.interfaces.BnProjectPropertyUtil; 67 import hero.interfaces.BnProjectPropertyValue; 68 import hero.interfaces.BnProjectValue; 69 import hero.interfaces.BnProjectConfigLocalHome; 70 import hero.interfaces.BnRoleLocal; 71 import hero.interfaces.BnRoleLocalHome; 72 import hero.interfaces.BnRoleUtil; 73 import hero.interfaces.BnRoleValue; 74 import hero.interfaces.BnUserLightValue; 75 import hero.interfaces.BnUserLocal; 76 import hero.interfaces.BnUserLocalHome; 77 import hero.interfaces.BnUserUtil; 78 import hero.interfaces.EngineLocal; 79 import hero.interfaces.EngineLocalHome; 80 import hero.interfaces.InvalidValueException; 81 import hero.interfaces.Constants; 82 import hero.interfaces.ProjectSessionLocal; 83 84 import hero.interfaces.UserServiceLocal; 85 import hero.interfaces.UserServiceLocalHome; 86 87 import hero.util.BonitaConfig; 88 import hero.util.BonitaDeadline; 89 import hero.util.BonitaProjectLocator; 90 import hero.util.BonitaServiceException; 91 import hero.util.DeleteEdgeException; 92 import hero.util.EventConstants; 93 import hero.util.HeroException; 94 import hero.util.AdminException; 95 import hero.util.HiddenException; 96 import hero.util.AccessException; 97 import hero.util.NodeExecutingException; 98 import hero.util.StrutsEdgeValue; 99 import hero.util.StrutsNodeValue; 100 import hero.util.values.BonitaEdgeValue; 101 import hero.util.values.BonitaIterationValue; 102 import hero.util.values.BonitaNodeValue; 103 import hero.util.values.BonitaProjectValue; 104 import hero.util.values.BonitaPropertyValue; 105 import hero.util.values.BonitaRoleValue; 106 import hero.util.values.BonitaUserValue; 107 import hero.interfaces.JMSServicesSessionUtil; 108 import hero.interfaces.JMSServicesSessionLocalHome; 109 import hero.interfaces.JMSServicesSessionLocal; 110 111 import hero.interfaces.BnRoleMapperLocal; 112 import hero.interfaces.BnRoleMapperLocalHome; 113 import hero.interfaces.BnRoleMapperUtil; 114 115 import hero.interfaces.BnNodePerformerAssignLocal; 116 import hero.interfaces.BnNodePerformerAssignLocalHome; 117 import hero.interfaces.BnNodePerformerAssignUtil; 118 import hero.interfaces.BnNodePerformerAssignValue; 119 120 import java.rmi.RemoteException ; 121 import java.util.ArrayList ; 122 123 import java.util.Collection ; 124 import java.util.Date ; 125 import java.util.Iterator ; 126 import java.util.Map ; 127 128 import javax.ejb.CreateException ; 129 import javax.ejb.FinderException ; 130 import javax.ejb.RemoveException ; 131 import javax.ejb.SessionBean ; 132 import javax.ejb.SessionContext ; 133 import javax.ejb.EJBException ; 134 import javax.naming.Context ; 135 136 import org.apache.log4j.Logger; 137 import org.apache.log4j.Level; 138 139 219 220 public class ProjectSessionBean implements SessionBean , EventConstants{ 221 222 private static final Logger trace = Logger.getLogger(ProjectSessionBean.class); 227 private static final Logger thelog = Logger.getLogger("log"); 228 229 233 private SessionContext mContext; 234 235 private BnProjectLocalHome pHome; 236 private BnProjectLocal mProject=null; 237 private Collection subProjects = new ArrayList (); 238 private JMSServicesSessionLocal jms = null; 239 private ArrayList visited = new ArrayList (); 240 private String caller=null; 241 private BonitaConfig bonitaConfig; 242 243 247 251 261 public void addUser(String userName) throws HeroException { 262 if (this.getProjectConfigTrace()) 263 trace.info(" Parameter: name=" + userName + " process name = "+this.getName()+ " started by " + this.getCaller()); 264 UserServiceLocalHome ushome; 265 UserServiceLocal ul; 266 if (!isAdminOfProject(this.getCaller())) 267 { 268 if (this.getProjectConfigTrace()) 269 trace.error("Only the Admin of the project is allowed to do this operation... "); 270 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 271 } 272 BnUserLocalHome uHome; 273 BnRoleLocalHome rHome; 274 BnRoleLocal mRole; 275 BnUserLocal mUser; 276 try { 277 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 278 uHome = hero.interfaces.BnUserUtil.getLocalHome(); 279 rHome = hero.interfaces.BnRoleUtil.getLocalHome(); 280 } catch (javax.naming.NamingException be) { 281 if (this.getProjectConfigTrace()) 282 trace.error(be.getMessage()); 283 throw new HeroException(be.getMessage()); 284 } 285 try { 286 ul = ushome.create(); 287 mUser = ul.findUser(userName); 288 } catch (Exception fe) { 289 if (this.getProjectConfigTrace()) 290 trace.error("User does not exist " + fe.getMessage()); 291 throw new HeroException("User does not exist"); 292 } 293 Collection cUsers = mProject.getBnUsers(); 294 if (!cUsers.contains(mUser)) 295 { 296 cUsers.add(mUser); 297 if (!userName.equals(Constants.ADMIN)) 298 this.addRole(userName, "BnUser BnRole"); 299 this.setUserRole(userName, userName); 300 jms.sendProjectEvent(ADDUSERPROJECT,this.getName(),userName); 301 } 302 } 303 304 323 324 public void addNode(String name, int nodeType) throws HeroException { 325 if (this.getProjectConfigTrace()) 326 trace.info("parameter: name= " + name + " nodeType= " + name + " process name = "+this.getName()+ " started by " + this.getCaller()); 327 BnNodeLocalHome nHome; 328 BnNodeLocal mNode; 329 if (!isAdminOfProject(this.getCaller())) 330 { 331 if (this.getProjectConfigTrace()) 332 trace.error("Only the Admin of the project is allowed to do this operation... "); 333 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 334 } 335 336 try { 337 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 338 } catch (javax.naming.NamingException be) { 339 if (this.getProjectConfigTrace()) 340 trace.error(be.getMessage()); 341 throw new HeroException(be.getMessage()); 342 } 343 344 try { 345 BnNodeLocal nf = nHome.findByName(name, mProject.getId()); 346 throw new HeroException("Node "+ name+ " already exist in project "+ mProject.getName()); 347 } catch (javax.ejb.FinderException nn) { 348 if (this.getProjectConfigTrace()) 349 if (this.getProjectConfigTrace()) 350 trace.error(nn.getMessage()); 351 try { 352 if (name.equals("")) 353 throw new HeroException("Node name can not be empty..."); 354 BnNodeLocal nd = nHome.create(name, nodeType); 355 if (mProject.getType().equals(Constants.Pj.MODEL)) 357 nd.setState(Constants.Nd.INITIAL); 358 BnNodeValue ndata = nd.getBnNodeValue(); 359 ndata.setCreationDate(new java.util.Date ()); 360 nd.setBnNodeValue(ndata); 361 362 Collection cNodes = mProject.getBnNodes(); 363 cNodes.add(nd); 364 366 String creator = this.getCaller(); 367 nd.setCreator(creator); 368 nd.setExecutor(creator); BnRoleLocalHome rHome = BnRoleUtil.getLocalHome(); 370 BnRoleLocal role = rHome.findByName(hero.interfaces.Constants.INITIALROLE,mProject.getId()); 371 nd.setBnRole(role); 372 373 if (nodeType == Constants.Nd.SUB_PROCESS_NODE) 374 { 375 try { 376 BnProjectLocal pl = pHome.findByName(name); 377 pl.setParent(mProject.getName()); 378 } catch (javax.ejb.FinderException pe) { 379 if (this.getProjectConfigTrace()) 380 trace.error("Project "+ name+ " does not exist " + pe.getMessage()); 381 throw new HeroException("Project "+ name+ " does not exist");} 382 } 383 384 jms.sendNodeEvent(ADDNODE,this.getName(),name,nodeType,ndata.getState(),this.getCaller()); 386 } catch (InvalidValueException ie) { 387 if (this.getProjectConfigTrace()) 388 trace.error(ie.getMessage()); 389 throw new HeroException(ie.getMessage()); 390 } catch (CreateException ce) { 391 if (this.getProjectConfigTrace()) 392 trace.error(ce.getMessage()); 393 throw new HeroException(ce.getMessage()); 394 } catch (FinderException fe) {fe.printStackTrace(); 395 if (this.getProjectConfigTrace()) 396 trace.error(fe.getMessage()); 397 throw new HeroException(fe.getMessage()); 398 } catch (javax.naming.NamingException ne) { 399 if (this.getProjectConfigTrace()) 400 trace.error(ne.getMessage()); 401 throw new HeroException(ne.getMessage()); 402 } 403 } 404 } 405 406 419 420 public void addNodeSubProcess(String name, String projectName) throws HeroException { 421 if (this.getProjectConfigTrace()) 422 trace.info("parameters : name=" + name + "project=" + projectName + " process name = " + this.getName()+ " started by " + this.getCaller()); 423 if (!isAdminOfProject(this.getCaller())) 424 { 425 if (this.getProjectConfigTrace()) 426 trace.error("Only the Admin of the project is allowed to do this operation... "); 427 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 428 } 429 try{ 430 String aP = mProject.getName(); 431 this.initProject(projectName,name); 432 Collection nodes = mProject.getBnNodes(); 433 Iterator nds = nodes.iterator(); 434 while (nds.hasNext()) { 436 BnNodeLocal subNode = (BnNodeLocal)nds.next(); 437 if (subNode.getState()==Constants.Nd.READY) 438 this.setNodeState(subNode,Constants.Nd.INITIAL); 439 } 440 if (mProject.getType().equals(Constants.Pj.MODEL)) 441 this.initModel(aP); 442 else 443 this.initProject(aP); 444 this.addNode(name,Constants.Nd.SUB_PROCESS_NODE); 445 subProjects.clear(); 446 }catch (Exception ans){ 447 if (this.getProjectConfigTrace()) 448 trace.error("Error in addNodeSubProcess " + ans.getMessage()); 449 throw new HeroException("Error in addNodeSubProcess"); 450 } 451 } 452 453 463 public void addAgent(String name) throws HeroException { 464 if (this.getProjectConfigTrace()) 465 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 466 BnAgentLocalHome nHome; 467 BnAgentLocal mAgent; 468 if (!isAdminOfProject(this.getCaller())) 469 { 470 if (this.getProjectConfigTrace()) 471 trace.error("Only the Admin of the project is allowed to do this operation... "); 472 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 473 } 474 try { 475 nHome = hero.interfaces.BnAgentUtil.getLocalHome(); 476 } catch (javax.naming.NamingException be) { 477 if (this.getProjectConfigTrace()) 478 trace.error(be.getMessage()); 479 throw new HeroException(be.getMessage()); 480 } 481 482 try { 483 BnAgentLocal nf = nHome.findByName(name, mProject.getId()); 484 throw new HeroException("BnAgent "+ name+ " already exist in project "+ mProject.getName()); 485 } catch (javax.ejb.FinderException nn) { 486 if (this.getProjectConfigTrace()) 487 trace.error(nn.getMessage()); 488 489 try { 490 BnAgentLocal ag = nHome.create(name); 491 BnAgentValue adata = ag.getBnAgentValue(); 492 adata.setCreationDate(new java.util.Date ()); 493 ag.setBnAgentValue(adata); 494 Collection cAgents = mProject.getBnAgents(); 495 cAgents.add(ag); 496 String creator = this.getCaller(); 497 BnUserLocalHome uHome = hero.interfaces.BnUserUtil.getLocalHome(); 498 BnUserLocal user = uHome.findByName(creator); 499 ag.setCreator(user); 500 501 } catch (InvalidValueException ie) { 504 if (this.getProjectConfigTrace()) 505 trace.error(ie.getMessage()); 506 throw new HeroException(ie.getMessage()); 507 } catch (CreateException ce) { 508 if (this.getProjectConfigTrace()) 509 trace.error(ce.getMessage()); 510 throw new HeroException(ce.getMessage()); 511 } catch (FinderException fe) { 512 if (this.getProjectConfigTrace()) 513 trace.error(fe.getMessage()); 514 throw new HeroException(fe.getMessage()); 515 } catch (javax.naming.NamingException ne) { 516 if (this.getProjectConfigTrace()) 517 trace.error(ne.getMessage()); 518 throw new HeroException(ne.getMessage()); 519 } 520 } 521 } 522 523 534 public void addEdge(String name, String in, String out) 535 throws HeroException { 536 if (this.getProjectConfigTrace()) 537 trace.error("parameters: name=" + name + " in=" + in + " out=" + out + " process name = " + this.getName()+ " started by " + this.getCaller()); 538 throw new HeroException("no more implemented"); 539 } 540 541 554 public String addEdge(String in, String out) throws HeroException { 555 if (this.getProjectConfigTrace()) 556 trace.info("parameters: in=" + in + " out:" + out + " process name = " + this.getName()+ " started by " + this.getCaller()); 557 BnEdgeLocalHome eHome; 558 BnNodeLocalHome nHome; 559 BnNodeLocal mInNode; 560 BnNodeLocal mOutNode; 561 BnEdgeLocal mEdge; 562 if (!isAdminOfProject(this.getCaller())) 563 { 564 if (this.getProjectConfigTrace()) 565 trace.error("Only the Admin of the project is allowed to do this operation... "); 566 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 567 } 568 try { 569 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 570 } catch (javax.naming.NamingException be) { 571 if (this.getProjectConfigTrace()) 572 trace.error(be.getMessage()); 573 throw new HeroException(be.getMessage()); 574 } 575 try { 576 mInNode = nHome.findByName(in, mProject.getId()); 577 } catch (FinderException fe) { 578 if (this.getProjectConfigTrace()) 579 trace.error("In Node does not exist " + fe.getMessage()); 580 throw new HeroException("In Node does not exist"); 581 } 582 try { 583 mOutNode = nHome.findByName(out, mProject.getId()); 584 } catch (FinderException fe) { 585 if (this.getProjectConfigTrace()) 586 trace.error("Out Node does not exist " + fe.getMessage()); 587 throw new HeroException("Out Node does not exist"); 588 } 589 try { 590 eHome = hero.interfaces.BnEdgeUtil.getLocalHome(); 591 } catch (javax.naming.NamingException be) { 592 if (this.getProjectConfigTrace()) 593 trace.error(be.getMessage()); 594 throw new HeroException(be.getMessage()); 595 } 596 visited.clear(); 597 if (!checkStructuralConstraints(in, out)) 598 throw new hero.util.EdgeCycleException("This edge add a cycle"); 599 600 if (checkDynamics(out)) { if (checkDuplicateEdge(in, out)) { 602 try { 603 mEdge = eHome.create(); 604 mEdge.setBnProject(mProject); 605 mEdge.setInBnNode(mInNode); 606 mEdge.setOutBnNode(mOutNode); 607 608 jms.sendEdgeEvent(ADDEDGE,this.getName(),mEdge.getName(),mInNode.getName(),mOutNode.getName(),this.getCaller()); 609 610 } catch (InvalidValueException ie) { 611 if (this.getProjectConfigTrace()) 612 trace.error(ie.getMessage()); 613 throw new HeroException(ie.getMessage()); 614 } catch (CreateException ce) { 615 if (this.getProjectConfigTrace()) 616 trace.error(ce.getMessage()); 617 throw new HeroException(ce.getMessage()); 618 } 619 } else { 620 throw new hero.util.DuplicatedEdgeException("Cannot add edge. BnEdge between nodes already exist"); 621 } 622 } else { 623 throw new hero.util.NodeStartedException("Cannot add edge. " + out + " is already started"); 624 } 625 628 629 int edgeState = hero.interfaces.Constants.edgeTransition[Constants.CONDITION_TRUE][mInNode.getState()]; 631 this.setEdgeState(mEdge, edgeState); 632 634 635 int newOperation = mOutNode.getActivation().state(mOutNode); 636 int newState = mOutNode.getTransition().computeState(mOutNode, newOperation); 637 if (newState == hero.interfaces.Constants.Nd.BAD_TRANSITION) { 638 throw new HeroException("AddEdge generated a bad Node transition"); 639 } 640 this.setNodeState(mOutNode, newState); 641 return mEdge.getName(); 643 } 644 645 657 public String addAgentEdge(String in, String out) throws HeroException { 658 if (this.getProjectConfigTrace()) 659 trace.info("parameters: in=" + in + " out:" + out + " process name = " + this.getName()+ " started by " + this.getCaller()); 660 BnAgentEdgeLocalHome eHome; 661 BnNodeLocalHome nHome; 662 BnAgentLocalHome aHome; 663 BnAgentLocal mInAgent; 664 BnNodeLocal mOutNode; 665 BnAgentEdgeLocal mEdge; 666 if (!isAdminOfProject(this.getCaller())) 667 { 668 if (this.getProjectConfigTrace()) 669 trace.error("Only the Admin of the project is allowed to do this operation... "); 670 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 671 } 672 try { 673 aHome = hero.interfaces.BnAgentUtil.getLocalHome(); 674 } catch (javax.naming.NamingException be) { 675 if (this.getProjectConfigTrace()) 676 trace.error(be.getMessage()); 677 throw new HeroException(be.getMessage()); 678 } 679 try { 680 mInAgent = aHome.findByName(in, mProject.getId()); 681 } catch (FinderException fe) { 682 if (this.getProjectConfigTrace()) 683 trace.error("In Agent does not exist " + fe.getMessage()); 684 throw new HeroException("In Agent does not exist"); 685 } 686 try { 687 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 688 } catch (javax.naming.NamingException be) { 689 if (this.getProjectConfigTrace()) 690 trace.error(be.getMessage()); 691 throw new HeroException(be.getMessage()); 692 } 693 try { 694 mOutNode = nHome.findByName(out, mProject.getId()); 695 } catch (FinderException fe) { 696 if (this.getProjectConfigTrace()) 697 trace.error("Out Node does not exist " + fe.getMessage()); 698 throw new HeroException("Out Node does not exist"); 699 } 700 try { 701 eHome = hero.interfaces.BnAgentEdgeUtil.getLocalHome(); 702 } catch (javax.naming.NamingException be) { 703 if (this.getProjectConfigTrace()) 704 trace.error(be.getMessage()); 705 throw new HeroException(be.getMessage()); 706 } 707 if (checkDynamics(out)) { if (checkDuplicateAgentEdge(in, out)) { 709 try { 710 mEdge = eHome.create(); 711 mEdge.setBnProject(mProject); 712 mEdge.setInBnAgent(mInAgent); 713 mEdge.setOutBnNode(mOutNode); 714 715 717 } catch (InvalidValueException ie) { 718 if (this.getProjectConfigTrace()) 719 trace.error(ie.getMessage()); 720 throw new HeroException(ie.getMessage()); 721 } catch (CreateException ce) { 722 if (this.getProjectConfigTrace()) 723 trace.error(ce.getMessage()); 724 throw new HeroException(ce.getMessage()); 725 } 726 } else { 727 throw new hero.util.DuplicatedEdgeException("Cannot add agentEdge. AgentEdge between nodes already exist"); 728 } 729 } else { 730 throw new hero.util.NodeStartedException( 731 "Cannot add agentEdge. " + out + " is already started"); 732 } 733 734 this.setAgentEdgeState(mEdge, hero.interfaces.Constants.Ed.INITIAL); 736 737 int newOperation = mOutNode.getActivation().state(mOutNode); 738 int newState = mOutNode.getTransition().computeState(mOutNode, newOperation); 739 if (newState == hero.interfaces.Constants.Nd.BAD_TRANSITION) { 740 throw new HeroException("AddEdge generated a bad Node transition"); 741 } 742 this.setNodeState(mOutNode, newState); 743 return mEdge.getName(); 745 } 746 747 759 public void addRole(String roleName, String description) 760 throws HeroException { 761 BnRoleLocalHome roleh; 762 if (this.getProjectConfigTrace()) 763 trace.info("parameters: roleName=" + roleName + " description=" + description + " process name = " + this.getName()+ " started by " + this.getCaller()); 764 if (!isAdminOfProject(this.getCaller())) 765 { 766 if (this.getProjectConfigTrace()) 767 trace.error("Only the Admin of the project is allowed to do this operation... "); 768 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 769 } 770 try { 771 roleh = BnRoleUtil.getLocalHome(); 772 } catch (javax.naming.NamingException ne) { 773 if (this.getProjectConfigTrace()) 774 trace.error(ne.getMessage()); 775 throw new HeroException(ne.getMessage()); 776 } 777 778 try { 779 BnRoleLocal nf = roleh.findByName(roleName, mProject.getId()); 780 throw new HeroException("BnRole "+ roleName+ " already exist in project "+ mProject.getName()); 781 } catch (javax.ejb.FinderException nn) { 782 if (this.getProjectConfigTrace()) 783 trace.error(nn.getMessage()); 784 785 BnRoleValue rv = new BnRoleValue(); 786 rv.setName(roleName); 787 rv.setDescription(description); 788 try { 789 BnRoleLocal rl = roleh.create(rv); 790 mProject.getBnRoles().add(rl); 791 jms.sendRoleEvent(ADDROLE,this.getName(),roleName); 793 } catch (javax.ejb.CreateException ce) { 794 if (this.getProjectConfigTrace()) 795 trace.error(ce.getMessage()); 796 throw new HeroException(ce.getMessage()); 797 } 798 } 799 } 800 801 814 public void addIteration(String from, String to, String condition) throws HeroException { 815 if (this.getProjectConfigTrace()) 816 trace.info("parameters: from=" + from + " to=" + to + " condition=" + condition + " process name = " + this.getName()+ " started by " + this.getCaller()); 817 BnIterationLocalHome iteh; 818 if (!isAdminOfProject(this.getCaller())) 819 { 820 if (this.getProjectConfigTrace()) 821 trace.error("Only the Admin of the project is allowed to do this operation... "); 822 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 823 } 824 if (!this.checkStructuralConstraints(from,to)) 825 { 826 try { 827 iteh = BnIterationUtil.getLocalHome(); 828 } catch (javax.naming.NamingException ne) { 829 if (this.getProjectConfigTrace()) 830 trace.error(ne.getMessage()); 831 throw new HeroException(ne.getMessage()); 832 } 833 834 try { 835 BnIterationLocal it = iteh.findByFromTo(from, to, mProject.getId()); 836 throw new HeroException("Iteration already exist between: "+ from +" and "+to+" nodes, in project "+ mProject.getName()); 837 } catch (javax.ejb.FinderException nn) { 838 839 BnIterationLightValue iv = new BnIterationLightValue(); 840 iv.setFromNode(from); 841 iv.setToNode(to); 842 iv.setCondition(condition); 843 try { 844 BnIterationLocal il = iteh.create(iv); 845 mProject.getBnIterations().add(il); 846 jms.sendIterationEvent(ADDITERATION,this.getName(), from, to); 847 } catch (Exception ce) { 848 if (this.getProjectConfigTrace()) 849 trace.error(ce.getMessage()); 850 throw new HeroException(ce.getMessage()); 851 } 852 } 853 } 854 else 855 throw new HeroException("This iteration is not possible..."); 856 } 857 858 870 public void deleteIteration(String from, String to) throws HeroException { 871 if (this.getProjectConfigTrace()) 872 trace.info("parameters: from=" + from + " to=" + to +" process name = " + this.getName()+ " started by " + this.getCaller()); 873 BnIterationLocalHome iteh; 874 if (!isAdminOfProject(this.getCaller())) 875 { 876 if (this.getProjectConfigTrace()) 877 trace.error("Only the Admin of the project is allowed to do this operation... "); 878 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 879 } 880 try { 881 iteh = BnIterationUtil.getLocalHome(); 882 } catch (javax.naming.NamingException ne) { 883 if (this.getProjectConfigTrace()) 884 trace.error(ne.getMessage()); 885 throw new HeroException(ne.getMessage()); 886 } 887 try { 888 BnIterationLocal it = iteh.findByFromTo(from, to, mProject.getId()); 889 it.remove(); 890 } catch (javax.ejb.FinderException nn) { 891 if (this.getProjectConfigTrace()) 892 trace.error("Iteration does not exist: "+ from +" and "+to+" nodes, in project "+ mProject.getName()); 893 throw new HeroException("Iteration does not exist: "+ from +" and "+to+" nodes, in project "+ mProject.getName()); 894 } catch (javax.ejb.RemoveException rn) { 895 if (this.getProjectConfigTrace()) 896 trace.error("Error when deleting activity iteration: "+ from +" and "+to+" nodes, in project "+ mProject.getName()); 897 throw new HeroException("Error when deleting activity iteration: "+ from +" and "+to+" nodes, in project "+ mProject.getName()); 898 } 899 } 900 901 915 public void addHook(String hookName, String eventName, int hookType) 916 throws HeroException { 917 if (this.getProjectConfigTrace()) 918 trace.info("parameters: hookName=" + hookName + " eventName=" + eventName + " process name = " + this.getName()+ " started by " + this.getCaller()); 919 BnProjectHookLocalHome pHome; 920 BnProjectHookLocal ppLocal; 921 if (!isAdminOfProject(this.getCaller())) 922 { 923 if (this.getProjectConfigTrace()) 924 trace.error("Only the Admin of the project is allowed to do this operation... "); 925 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 926 } 927 try { 928 pHome = BnProjectHookUtil.getLocalHome(); 929 } catch (javax.naming.NamingException ne) { 930 if (this.getProjectConfigTrace()) 931 trace.error(ne.getMessage()); 932 throw new HeroException(ne.getMessage()); 933 } 934 935 try { 936 BnProjectHookLocal pf = pHome.findByName(mProject.getId(), hookName); 937 throw new HeroException("BnProject hook "+ hookName + " already exist in project "+ mProject.getName()); 938 } catch (javax.ejb.FinderException pn) { 939 if (this.getProjectConfigTrace()) 940 trace.error(pn.getMessage()); 941 try { 942 BnProjectHookLocal h = pHome.create(hookName, eventName, hookType); 943 h.setBnProject(mProject); 944 } catch (CreateException fe) { 945 if (this.getProjectConfigTrace()) 946 trace.error(fe.getMessage()); 947 throw new HeroException(fe.getMessage()); 948 } catch (InvalidValueException ie) { 949 if (this.getProjectConfigTrace()) 950 trace.error(ie.getMessage()); 951 throw new HeroException(ie.getMessage()); 952 } 953 } 954 } 955 956 971 public void addNodeHook(String nodeName,String hookName,String eventName,int hookType) throws HeroException { 972 if (this.getProjectConfigTrace()) 973 trace.info("parameters: node="+ nodeName+ " hookName="+ hookName+ " eventName=" + eventName + " process name = " + this.getName()+ " started by " + this.getCaller()); 974 BnNodeHookLocalHome pHome; 975 BnNodeHookLocal ppLocal; 976 if (!isAdminOfProject(this.getCaller())) 977 { 978 if (this.getProjectConfigTrace()) 979 trace.error("Only the Admin of the project is allowed to do this operation... "); 980 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 981 } 982 BnNodeLocal nd = mProject.getBnNode(nodeName); 983 try { 984 pHome = BnNodeHookUtil.getLocalHome(); 985 } catch (javax.naming.NamingException ne) { 986 if (this.getProjectConfigTrace()) 987 trace.error(ne.getMessage()); 988 throw new HeroException(ne.getMessage()); 989 } 990 991 try { 992 BnNodeHookLocal nf = pHome.findByName(nd.getId(), hookName); 993 throw new HeroException("BnNode hook "+ hookName+ " already exist in node "+ nodeName); 994 } catch (javax.ejb.FinderException nn) { 995 if (this.getProjectConfigTrace()) 996 trace.error(nn.getMessage()); 997 try { 998 BnNodeHookLocal h = pHome.create(hookName, eventName, hookType); 999 h.setBnNode(nd); 1000 } catch (CreateException fe) { 1001 if (this.getProjectConfigTrace()) 1002 trace.error(fe.getMessage()); 1003 throw new HeroException(fe.getMessage()); 1004 } catch (InvalidValueException ie) { 1005 if (this.getProjectConfigTrace()) 1006 trace.error(ie.getMessage()); 1007 throw new HeroException(ie.getMessage()); 1008 } 1009 } 1010 } 1011 1012 1024 public void addRoleMapper(String roleName,String mapperName,int mapperType) throws HeroException { 1025 if (this.getProjectConfigTrace()) 1027 trace.info("parameters: roleName="+ roleName+ " mapperName="+ mapperName+ " mapperType="+ mapperType+ " process name = " + this.getName()+ " started by " + this.getCaller()); 1028 1029 BnRoleMapperLocalHome mapperh; 1030 BnRoleLocalHome roleh; 1031 BnRoleMapperLocal ppLocal = null; 1032 BnRoleLocal role = null; 1033 if (!isAdminOfProject(this.getCaller())) 1034 { 1035 if (this.getProjectConfigTrace()) 1036 trace.error("Only the Admin of the project is allowed to do this operation... "); 1037 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1038 } 1039 try { 1040 mapperh = BnRoleMapperUtil.getLocalHome(); 1041 roleh = BnRoleUtil.getLocalHome(); 1042 } catch (javax.naming.NamingException ne) { 1043 if (this.getProjectConfigTrace()) 1044 trace.error(ne.getMessage()); 1045 throw new HeroException(ne.getMessage()); 1046 } 1047 try { 1049 role = roleh.findByName(roleName, mProject.getId()); 1050 } catch (FinderException pfe) { 1051 if (this.getProjectConfigTrace()) 1052 trace.error(pfe.getMessage()); 1053 throw new HeroException("The bnRole does not exist for role : " + roleName); 1054 } 1055 ppLocal = role.getBnRoleMapper(); 1057 if (ppLocal != null){ 1058 ppLocal.setName(mapperName); 1059 ppLocal.setType(mapperType); 1060 } 1061 else { 1062 try { 1063 ppLocal = mapperh.create(mapperName, mapperType); 1064 ppLocal.setBnRole(role); 1065 } catch (CreateException fe) { 1066 if (this.getProjectConfigTrace()) 1067 trace.error(fe.getMessage()); 1068 throw new HeroException(fe.getMessage()); 1069 } catch (InvalidValueException ie) { 1070 if (this.getProjectConfigTrace()) 1071 trace.error(ie.getMessage()); 1072 throw new HeroException(ie.getMessage()); 1073 } 1074 } 1075 } 1076 1077 1089 public void addNodePerformerAssign(String nodeName,String performerAssignName,int performerAssignType, String propertyName) throws HeroException { 1090 if (this.getProjectConfigTrace()) 1092 trace.debug("addNodePerformerAssign: node = "+ nodeName+ " performerAssignName = "+ performerAssignName); 1093 1094 BnNodePerformerAssignLocalHome performerAssignh; 1095 BnNodeLocalHome nodeh; 1096 BnNodePerformerAssignLocal ppLocal = null; 1097 BnNodeLocal node = null; 1098 if (!isAdminOfProject(this.getCaller())) 1099 { 1100 if (this.getProjectConfigTrace()) 1101 trace.error("Only the Admin of the project is allowed to do this operation... "); 1102 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1103 } 1104 try { 1105 performerAssignh = BnNodePerformerAssignUtil.getLocalHome(); 1106 nodeh = BnNodeUtil.getLocalHome(); 1107 } catch (javax.naming.NamingException ne) { 1108 throw new HeroException(ne.getMessage()); 1109 } 1110 try { 1112 node = nodeh.findByName(nodeName, mProject.getId()); 1113 } catch (FinderException pfe) { 1114 throw new HeroException("The bnNode does not exist for node : " + nodeName); 1115 } 1116 ppLocal = node.getBnNodePerformerAssign(); 1118 if (ppLocal != null){ 1119 ppLocal.setName(performerAssignName); 1120 ppLocal.setType(performerAssignType); 1121 ppLocal.setPropertyName(propertyName); 1122 } 1123 else { 1124 try { 1125 ppLocal = performerAssignh.create(performerAssignName, performerAssignType, propertyName); 1126 ppLocal.setBnNode(node); 1127 } catch (CreateException fe) { 1128 throw new HeroException(fe.getMessage()); 1129 } catch (InvalidValueException ie) { 1130 throw new HeroException(ie.getMessage()); 1131 } 1132 } 1133 } 1134 1135 1175 public void addNodeInterHook(String nodeName,String hookName,String eventName,int hookType,String value) 1176 throws HeroException { 1177 if (this.getProjectConfigTrace()) 1178 trace.info("parameters: node="+ nodeName+ " hookName="+ hookName+ " eventName="+ eventName+ " value="+ value + " process name = " + this.getName()+ " started by " + this.getCaller()); 1179 BnNodeInterHookLocalHome pHome; 1180 BnNodeInterHookLocal ppLocal; 1181 if (!isAdminOfProject(this.getCaller())) 1182 { 1183 if (this.getProjectConfigTrace()) 1184 trace.error("Only the Admin of the project is allowed to do this operation... "); 1185 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1186 } 1187 1188 BnNodeLocal nd = mProject.getBnNode(nodeName); 1189 try { 1190 pHome = BnNodeInterHookUtil.getLocalHome(); 1191 } catch (javax.naming.NamingException ne) { 1192 if (this.getProjectConfigTrace()) 1193 trace.error(ne.getMessage()); 1194 throw new HeroException(ne.getMessage()); 1195 } 1196 1197 try { 1198 BnNodeInterHookLocal nf = pHome.findByName(nd.getId(), hookName); 1199 throw new HeroException("Interactive node hook "+ hookName+ " already exist in node "+ nodeName); 1200 } catch (javax.ejb.FinderException nn) { 1201 if (this.getProjectConfigTrace()) 1202 trace.error(nn.getMessage()); 1203 try { 1204 BnNodeInterHookLocal h = pHome.create(hookName, eventName, hookType, value); 1205 h.setBnNode(nd); 1206 } catch (CreateException fe) { 1207 if (this.getProjectConfigTrace()) 1208 trace.error(fe.getMessage()); 1209 throw new HeroException(fe.getMessage()); 1210 } catch (InvalidValueException ie) { 1211 if (this.getProjectConfigTrace()) 1212 trace.error(ie.getMessage()); 1213 throw new HeroException(ie.getMessage()); 1214 } 1215 } 1216 } 1217 1218 1232 public void addInterHook(String hookName,String eventName,int hookType,String value) 1233 throws HeroException { 1234 if (this.getProjectConfigTrace()) 1235 trace.info("parameters: hookName="+ hookName+ " eventName="+ eventName+ " value="+ value + " process name = " + this.getName()+ " started by " + this.getCaller()); 1236 BnProjectInterHookLocalHome pHome; 1237 BnProjectInterHookLocal ppLocal; 1238 if (!isAdminOfProject(this.getCaller())) 1239 { 1240 if (this.getProjectConfigTrace()) 1241 trace.error("Only the Admin of the project is allowed to do this operation... "); 1242 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1243 } 1244 try { 1245 pHome = BnProjectInterHookUtil.getLocalHome(); 1246 } catch (javax.naming.NamingException ne) { 1247 if (this.getProjectConfigTrace()) 1248 trace.error(ne.getMessage()); 1249 throw new HeroException(ne.getMessage()); 1250 } 1251 1252 try { 1253 BnProjectInterHookLocal nf = pHome.findByName(mProject.getId(), hookName); 1254 throw new HeroException("Interactive hook "+ hookName+ " already exist in project "+ mProject.getName()); 1255 } catch (javax.ejb.FinderException nn) { 1256 if (this.getProjectConfigTrace()) 1257 trace.error(nn.getMessage()); 1258 try { 1259 BnProjectInterHookLocal h = pHome.create(hookName, eventName, hookType, value); 1260 h.setBnProject(mProject); 1261 } catch (CreateException fe) { 1262 if (this.getProjectConfigTrace()) 1263 trace.error(fe.getMessage()); 1264 throw new HeroException(fe.getMessage()); 1265 } catch (InvalidValueException ie) { 1266 if (this.getProjectConfigTrace()) 1267 trace.error(ie.getMessage()); 1268 throw new HeroException(ie.getMessage()); 1269 } 1270 } 1271 } 1272 1273 1283 public void activeProcess() throws HeroException { 1284 if (!isAdminOfProject(this.getCaller())) 1285 { 1286 if (this.getProjectConfigTrace()) 1287 trace.error("Only the Admin of the project is allowed to do this operation... "); 1288 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1289 } 1290 if (mProject.getStatus().equals(Constants.Pj.HIDDEN)) 1291 { 1292 mProject.setStatus(Constants.Pj.ACTIVE); 1293 try { 1294 mProject.setModel(BonitaProjectLocator.generateProjectValue(mProject.getName())); 1296 } catch (BonitaServiceException e) {e.printStackTrace(); 1297 throw new HeroException(e.getMessage()); 1298 } 1299 } 1300 else 1301 throw new HeroException("This project is already ACTIVE..."); 1302 } 1303 1304 1314 public void hideProcess() throws HeroException { 1315 if (!isAdminOfProject(this.getCaller())) 1316 { 1317 if (this.getProjectConfigTrace()) 1318 trace.error("Only the Admin of the project is allowed to do this operation... "); 1319 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1320 } 1321 if (mProject.getStatus().equals(Constants.Pj.ACTIVE)) 1322 { 1323 mProject.setStatus(Constants.Pj.HIDDEN); 1324 try { 1325 mProject.setModel(BonitaProjectLocator.generateProjectValue(mProject.getName())); 1327 } catch (BonitaServiceException e) {e.printStackTrace(); 1328 throw new HeroException(e.getMessage()); 1329 } 1330 } 1331 else 1332 throw new HeroException("This projects is already HIDDEN..."); 1333 } 1334 1335 1339 1350 public void deleteNode(String name) throws HeroException { 1351 if (this.getProjectConfigTrace()) 1353 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 1354 if (!isAdminOfProject(this.getCaller())) 1355 { 1356 if (this.getProjectConfigTrace()) 1357 trace.error("Only the Admin of the project is allowed to do this operation... "); 1358 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1359 } 1360 BnNodeLocal nd = mProject.getBnNode(name); 1361 if (nd.isExecuting()) { 1362 throw new NodeExecutingException("Cannot delete node. It is executing"); 1363 } 1364 1370 if (this.getNodeType(name)==Constants.Nd.SUB_PROCESS_NODE) 1371 { 1372 try { 1373 BnProjectLocal plocal = pHome.findByName(name); 1374 Collection nodes = plocal.getBnNodes(); 1375 Iterator nds = nodes.iterator(); 1376 while (nds.hasNext()) { 1378 BnNodeLocal nod = (BnNodeLocal)nds.next(); 1379 if (nod.getType()==Constants.Nd.SUB_PROCESS_NODE) 1380 throw new HeroException("Error in delete project: You have to delete subProcesses first !!"); 1381 } 1382 plocal.remove(); 1383 jms.sendProjectEvent(DELETEPROJECT, name); 1384 } catch (RemoveException pre) { 1385 if (this.getProjectConfigTrace()) 1386 trace.error("Cannot remove project " + pre.getMessage()); 1387 throw new HeroException("Cannot remove project " + pre.getMessage()); 1388 } catch (FinderException pfe) { 1389 if (this.getProjectConfigTrace()) 1390 trace.error("Cannot find project " + pfe.getMessage()); 1391 throw new HeroException("Cannot find project " + pfe.getMessage()); 1392 } 1393 } 1394 1395 Collection edgesIn = nd.getInBnEdges(); 1396 Object [] edai = edgesIn.toArray(); 1397 for (int i = 0; i < edai.length; i++) { 1398 edgeDeletion((BnEdgeLocal) edai[i]); 1399 } 1400 Collection edgesOut = nd.getOutBnEdges(); 1401 Object [] edao = edgesOut.toArray(); 1402 for (int i = 0; i < edao.length; i++) { 1403 edgeDeletion((BnEdgeLocal) edao[i]); 1404 } 1405 try { 1406 int state = nd.getState(); 1407 int type = nd.getType(); 1408 nd.remove(); 1409 jms.sendNodeEvent(DELETENODE,this.getName(),name,type,state,this.getCaller()); 1410 } catch (RemoveException re) { 1411 if (this.getProjectConfigTrace()) 1412 trace.error("Cannot remove node " + re.getMessage()); 1413 throw new HeroException("Cannot remove node " + re.getMessage()); 1414 } 1415 } 1416 1417 1428 public void deleteEdge(String name) throws HeroException { 1429 if (this.getProjectConfigTrace()) 1431 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 1432 BnEdgeLocalHome eh; 1433 BnEdgeLocal ed; 1434 if (!isAdminOfProject(this.getCaller())) 1435 { 1436 if (this.getProjectConfigTrace()) 1437 trace.error("Only the Admin of the project is allowed to do this operation... "); 1438 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1439 } 1440 try { 1441 eh = BnEdgeUtil.getLocalHome(); 1442 } catch (javax.naming.NamingException ne) { 1443 if (this.getProjectConfigTrace()) 1444 trace.error(ne.getMessage()); 1445 throw new HeroException(ne.getMessage()); 1446 } 1447 try { 1448 ed = eh.findByName(name, mProject.getId()); 1449 } catch (FinderException fe) { 1450 if (this.getProjectConfigTrace()) 1451 trace.error("edge does not exists " + fe.getMessage()); 1452 throw new HeroException("edge does not exists " + name); 1453 } 1454 String nodeIn = ed.getInBnNode().getName(); 1455 String nodeOut = ed.getOutBnNode().getName(); 1456 edgeDeletion(ed); 1457 jms.sendEdgeEvent(DELETEEDGE,this.getName(),name,nodeIn,nodeOut,this.getCaller()); 1458 } 1459 1460 1463 1464 public void edgeDeletion(BnEdgeLocal ed) throws HeroException { 1465 BnNodeLocal nd = ed.getOutBnNode(); 1466 if (this.getProjectConfigTrace()) 1467 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 1468 if (!isAdminOfProject(this.getCaller())) 1469 { 1470 if (this.getProjectConfigTrace()) 1471 trace.error("Only the Admin of the project is allowed to do this operation... "); 1472 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1473 } 1474 if (nd.isExecuting()) { 1475 throw new DeleteEdgeException("Cannot delete edge. Out node executing"); 1476 } 1477 1483 try { 1484 ed.remove(); 1485 int newOperation = nd.getActivation().state(nd); 1486 int newState = nd.getTransition().computeState(nd, newOperation); 1487 if (newState == hero.interfaces.Constants.Nd.BAD_TRANSITION) { 1488 throw new HeroException("AddEdge generated a bad BnNode transition"); 1489 } 1490 if (!mProject.getType().equals(Constants.Pj.MODEL)) 1491 this.setNodeState(nd, newState); 1492 } catch (RemoveException e) { 1493 if (this.getProjectConfigTrace()) 1494 trace.error("deleteNode failed " + e.getMessage()); 1495 throw new HeroException("deleteNode failed " + e.getMessage()); 1496 } 1497 } 1498 1499 1500 1509 public void deleteHook(String hookName) throws HeroException { 1510 if (this.getProjectConfigTrace()) 1511 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 1512 BnProjectHookLocalHome pHome; 1513 BnProjectHookLocal ppLocal; 1514 if (!isAdminOfProject(this.getCaller())) 1515 { 1516 if (this.getProjectConfigTrace()) 1517 trace.error("Only the Admin of the project is allowed to do this operation... "); 1518 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1519 } 1520 try { 1521 pHome = BnProjectHookUtil.getLocalHome(); 1522 } catch (javax.naming.NamingException ne) { 1523 if (this.getProjectConfigTrace()) 1524 trace.error(ne.getMessage()); 1525 throw new HeroException(ne.getMessage()); 1526 } 1527 1528 try { 1529 BnProjectHookLocal ph = pHome.findByName(mProject.getId(), hookName); 1530 ph.remove(); 1531 } catch (FinderException fe) { 1532 if (this.getProjectConfigTrace()) 1533 trace.error(fe.getMessage()); 1534 throw new HeroException(fe.getMessage()); 1535 } catch (RemoveException rm) { 1536 if (this.getProjectConfigTrace()) 1537 trace.error(rm.getMessage()); 1538 throw new HeroException(rm.getMessage()); 1539 } 1540 } 1541 1542 1552 public void deleteNodeHook(String nodeName, String hookName) 1553 throws HeroException { 1554 if (this.getProjectConfigTrace()) 1555 trace.info("parameters: nodename=" + nodeName + "Hookname=" + hookName + " process name = " + this.getName()+ " started by " + this.getCaller()); 1556 BnNodeHookLocalHome pHome; 1557 BnNodeHookLocal ppLocal; 1558 BnNodeLocal nd = mProject.getBnNode(nodeName); 1559 if (!isAdminOfProject(this.getCaller())) 1560 { 1561 if (this.getProjectConfigTrace()) 1562 trace.error("Only the Admin of the project is allowed to do this operation... "); 1563 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1564 } 1565 try { 1566 pHome = BnNodeHookUtil.getLocalHome(); 1567 } catch (javax.naming.NamingException ne) { 1568 if (this.getProjectConfigTrace()) 1569 trace.error(ne.getMessage()); 1570 throw new HeroException(ne.getMessage()); 1571 } 1572 try { 1573 BnNodeHookLocal nh = pHome.findByName(nd.getId(), hookName); 1574 nh.remove(); 1575 } catch (FinderException fe) { 1576 if (this.getProjectConfigTrace()) 1577 trace.error(fe.getMessage()); 1578 throw new HeroException(fe.getMessage()); 1579 } catch (RemoveException rm) { 1580 if (this.getProjectConfigTrace()) 1581 trace.error(rm.getMessage()); 1582 throw new HeroException(rm.getMessage()); 1583 } 1584 } 1585 1586 1596 public void deleteNodeInterHook(String nodeName, String interHookName) 1597 throws HeroException { 1598 if (this.getProjectConfigTrace()) 1599 trace.info("parameters: nodename=" + nodeName + "InerhookName=" + interHookName + " process name = " + this.getName()+ " started by " + this.getCaller()); 1600 BnNodeInterHookLocalHome pHome; 1601 BnNodeInterHookLocal ppLocal; 1602 BnNodeLocal nd = mProject.getBnNode(nodeName); 1603 if (!isAdminOfProject(this.getCaller())) 1604 { 1605 if (this.getProjectConfigTrace()) 1606 trace.error("Only the Admin of the project is allowed to do this operation... "); 1607 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1608 } 1609 try { 1610 pHome = BnNodeInterHookUtil.getLocalHome(); 1611 } catch (javax.naming.NamingException ne) { 1612 if (this.getProjectConfigTrace()) 1613 trace.error(ne.getMessage()); 1614 throw new HeroException(ne.getMessage()); 1615 } 1616 try { 1617 BnNodeInterHookLocal nh = 1618 pHome.findByName(nd.getId(), interHookName); 1619 nh.remove(); 1620 } catch (FinderException fe) { 1621 if (this.getProjectConfigTrace()) 1622 trace.error(fe.getMessage()); 1623 throw new HeroException(fe.getMessage()); 1624 } catch (RemoveException rm) { 1625 if (this.getProjectConfigTrace()) 1626 trace.error(rm.getMessage()); 1627 throw new HeroException(rm.getMessage()); 1628 } 1629 } 1630 1631 1640 public void deleteInterHook(String interHookName) throws HeroException { 1641 BnProjectInterHookLocalHome pHome; 1642 BnProjectInterHookLocal ppLocal; 1643 if (this.getProjectConfigTrace()) 1644 trace.info("parameter: interhookName=" + interHookName + " process name = " + this.getName()+ " started by " + this.getCaller()); 1645 if (!isAdminOfProject(this.getCaller())) 1646 { 1647 if (this.getProjectConfigTrace()) 1648 trace.error("Only the Admin of the project is allowed to do this operation... "); 1649 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1650 } 1651 try { 1652 pHome = BnProjectInterHookUtil.getLocalHome(); 1653 } catch (javax.naming.NamingException ne) { 1654 if (this.getProjectConfigTrace()) 1655 trace.error(ne.getMessage()); 1656 throw new HeroException(ne.getMessage()); 1657 } 1658 1659 try { 1660 BnProjectInterHookLocal ph = 1661 pHome.findByName(mProject.getId(), interHookName); 1662 ph.remove(); 1663 } catch (FinderException fe) { 1664 if (this.getProjectConfigTrace()) 1665 trace.error(fe.getMessage()); 1666 throw new HeroException(fe.getMessage()); 1667 } catch (RemoveException rm) { 1668 if (this.getProjectConfigTrace()) 1669 trace.error(rm.getMessage()); 1670 throw new HeroException(rm.getMessage()); 1671 } 1672 } 1673 1674 1684 public void deleteRoleMapper(String roleName) throws HeroException { 1685 if (this.getProjectConfigTrace()) 1686 trace.info("parameter: roleName=" + roleName + " process name = " + this.getName()+ " started by " + this.getCaller()); 1687 BnRoleLocalHome pHome; 1688 BnRoleMapperLocal mapperL; 1689 BnRoleLocal roleL; 1690 if (!isAdminOfProject(this.getCaller())) 1691 { 1692 if (this.getProjectConfigTrace()) 1693 trace.error("Only the Admin of the project is allowed to do this operation... "); 1694 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1695 } 1696 try { 1697 pHome = BnRoleUtil.getLocalHome(); 1698 } catch (javax.naming.NamingException ne) { 1699 if (this.getProjectConfigTrace()) 1700 trace.error(ne.getMessage()); 1701 throw new HeroException(ne.getMessage()); 1702 } 1703 1704 try { 1705 roleL = pHome.findByName(roleName, mProject.getId()); 1706 mapperL = roleL.getBnRoleMapper(); 1707 } catch (FinderException fe) { 1708 if (this.getProjectConfigTrace()) 1709 trace.error(fe.getMessage()); 1710 throw new HeroException(fe.getMessage()); 1711 } 1712 1713 try { 1714 mapperL.remove(); 1715 } catch (RemoveException rm) { 1716 if (this.getProjectConfigTrace()) 1717 trace.error(rm.getMessage()); 1718 throw new HeroException(rm.getMessage()); 1719 } 1720 } 1721 1722 1731 public void deleteProperty(String key) throws HeroException { 1732 if (this.getProjectConfigTrace()) 1733 trace.info("parameter: key=" + key + " process name = " + this.getName()+ " started by " + this.getCaller()); 1734 1735 BnProjectPropertyLocalHome pHome; 1736 BnProjectPropertyLocal ppLocal; 1737 if (!isAdminOfProject(this.getCaller())) 1738 { 1739 if (this.getProjectConfigTrace()) 1740 trace.error("Only the Admin of the project is allowed to do this operation... "); 1741 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1742 } 1743 try { 1744 pHome = BnProjectPropertyUtil.getLocalHome(); 1745 } catch (javax.naming.NamingException ne) { 1746 if (this.getProjectConfigTrace()) 1747 trace.error(ne.getMessage()); 1748 throw new HeroException(ne.getMessage()); 1749 } 1750 Collection c = null; 1751 try { 1752 c = pHome.findByTheKey(mProject.getId(), key); 1753 } catch (FinderException fe) { 1754 if (this.getProjectConfigTrace()) 1755 trace.error(fe.getMessage()); 1756 throw new HeroException(fe.getMessage()); 1757 } 1758 1759 if (!c.isEmpty()) { 1760 try { 1761 ppLocal = (BnProjectPropertyLocal) (c.toArray())[0]; 1762 ppLocal.remove(); 1763 } catch (RemoveException rm) { 1764 if (this.getProjectConfigTrace()) 1765 trace.error(rm.getMessage()); 1766 throw new HeroException(rm.getMessage()); 1767 } 1768 1769 } else { 1770 throw new HeroException("Property not found :" + key); 1771 } 1772 } 1773 1774 1784 public void deleteNodeProperty(String nodeName, String key) 1785 throws HeroException { 1786 if (this.getProjectConfigTrace()) 1787 trace.info("parameters: node=" + nodeName + " key=" + key + " process name = " + this.getName()+ " started by " + this.getCaller()); 1788 1789 BnNodePropertyLocalHome pHome; 1790 BnNodePropertyLocal propertyLocal = null; 1791 if (!isAdminOfProject(this.getCaller())) 1792 { 1793 if (this.getProjectConfigTrace()) 1794 trace.error("Only the Admin of the project is allowed to do this operation... "); 1795 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1796 } 1797 BnNodeLocal nd = mProject.getBnNode(nodeName); 1798 1799 try { 1800 pHome = BnNodePropertyUtil.getLocalHome(); 1801 } catch (javax.naming.NamingException ne) { 1802 if (this.getProjectConfigTrace()) 1803 trace.error(ne.getMessage()); 1804 throw new HeroException(ne.getMessage()); 1805 } 1806 Collection c = null; 1807 try { 1808 c = pHome.findByTheKey(nd.getId(), key); 1809 } catch (FinderException fe) { 1810 if (this.getProjectConfigTrace()) 1811 trace.error(fe.getMessage()); 1812 throw new HeroException(fe.getMessage()); 1813 } 1814 1815 if (!c.isEmpty()) { 1816 try { 1817 propertyLocal = (BnNodePropertyLocal) (c.toArray())[0]; 1818 propertyLocal.remove(); 1819 } catch (RemoveException rm) { 1820 if (this.getProjectConfigTrace()) 1821 trace.error(rm.getMessage()); 1822 throw new HeroException(rm.getMessage()); 1823 } 1824 1825 } else { 1826 throw new HeroException("Property not found :" + key); 1827 } 1828 } 1829 1830 1834 1844 public void setTraceLevel(String level) throws HeroException { 1845 if (this.getProjectConfigTrace()) 1846 trace.info("parameters: level=" + level + " process name = " + this.getName()+ " started by " + this.getCaller()); 1847 if (!isAdminOfProject(this.getCaller())) 1848 { 1849 if (this.getProjectConfigTrace()) 1850 trace.error("Only the Admin of the project is allowed to do this operation... "); 1851 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1852 } 1853 if (level.equals(Constants.INFO)) 1854 trace.setLevel(Level.INFO); 1855 else if (level.equals(Constants.DEBUG)) 1856 trace.setLevel(Level.DEBUG); 1857 else if (level.equals(Constants.ERROR)) 1858 trace.setLevel(Level.ERROR); 1859 } 1860 1861 1871 public void setLogLevel(String level) throws HeroException { 1872 if (this.getProjectConfigTrace()) 1873 trace.info("parameters: level=" + level + " process name = " + this.getName()+ " started by " + this.getCaller()); 1874 if (!isAdminOfProject(this.getCaller())) 1875 { 1876 if (this.getProjectConfigTrace()) 1877 trace.error("Only the Admin of the project is allowed to do this operation... "); 1878 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1879 } 1880 if (level.equals(Constants.INFO)) 1881 thelog.setLevel(Level.INFO); 1882 else if (level.equals(Constants.DEBUG)) 1883 thelog.setLevel(Level.DEBUG); 1884 else if (level.equals(Constants.ERROR)) 1885 thelog.setLevel(Level.ERROR); 1886 } 1887 1888 1889 1901 public void setUserRole(String userName, String roleName) 1902 throws HeroException { 1903 if (this.getProjectConfigTrace()) 1904 trace.info("parameters: user=" + userName + " role=" + roleName + " process name = " + this.getName()+ " started by " + this.getCaller()); 1905 BnRoleLocalHome roleh; 1906 BnUserLocalHome userh; 1907 UserServiceLocalHome ushome; 1908 UserServiceLocal ul; 1909 if (!isAdminOfProject(this.getCaller())) 1910 { 1911 if (this.getProjectConfigTrace()) 1912 trace.error("Only the Admin of the project is allowed to do this operation... "); 1913 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1914 } 1915 try { 1916 roleh = BnRoleUtil.getLocalHome(); 1917 userh = BnUserUtil.getLocalHome(); 1918 ushome= hero.interfaces.UserServiceUtil.getLocalHome(); 1919 } catch (javax.naming.NamingException ne) { 1920 if (this.getProjectConfigTrace()) 1921 trace.error(ne.getMessage()); 1922 throw new HeroException(ne.getMessage()); 1923 } 1924 try { 1925 ul = ushome.create(); 1926 BnUserLocal user = ul.findUser(userName); 1927 1928 BnRoleLocal role = roleh.findByName(roleName, mProject.getId()); 1929 user.getBnRoles().add(role); 1930 jms.sendUserRoleEvent(SETUSERROLE,this.getName(),userName,roleName); 1931 } catch (Exception fe) { 1932 if (this.getProjectConfigTrace()) 1933 trace.error(fe.getMessage()); 1934 throw new HeroException(fe.getMessage()); 1935 } 1936 } 1937 1938 1949 public void setNodeRole(String name, String role) throws HeroException { 1950 if (this.getProjectConfigTrace()) 1951 trace.info("parameters: name=" + name + " role=" + role + " process name = " + this.getName()+ " started by " + this.getCaller()); 1952 BnRoleLocalHome rh; 1953 BnNodeLocalHome nh; 1954 BnNodeLocal nl; 1955 BnRoleLocal rl; 1956 if (!isAdminOfProject(this.getCaller())) 1957 { 1958 if (this.getProjectConfigTrace()) 1959 trace.error("Only the Admin of the project is allowed to do this operation... "); 1960 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 1961 } 1962 try { 1963 rh = BnRoleUtil.getLocalHome(); 1964 nh = BnNodeUtil.getLocalHome(); 1965 } catch (javax.naming.NamingException ne) { 1966 if (this.getProjectConfigTrace()) 1967 trace.error(ne.getMessage()); 1968 throw new HeroException(ne.getMessage()); 1969 } 1970 try { 1971 nl = nh.findByName(name, mProject.getId()); 1972 } catch (FinderException fe) { 1973 if (this.getProjectConfigTrace()) 1974 trace.error("BnNode does not exists " + fe.getMessage()); 1975 throw new HeroException("BnNode does not exists " + name); 1976 } 1977 try { 1978 rl = rh.findByName(role, mProject.getId()); 1979 } catch (FinderException fe) { 1980 if (this.getProjectConfigTrace()) 1981 trace.error("BnRole does not exists " + fe.getMessage()); 1982 throw new HeroException("BnRole does not exists " + role); 1983 } 1984 nl.setBnRole(rl); 1985 jms.sendProjectEvent(CHANGEROLE, this.getName()); 1986 } 1987 1988 1999 public void setEditNode(String node, String role, String description, long deadline) throws HeroException { 2000 if (this.getProjectConfigTrace()) 2001 trace.debug("setEditNode: node=" + node + " role=" + role +" description=" + description + " deadline=" + deadline); 2002 if (!isAdminOfProject(this.getCaller())) 2003 { 2004 if (this.getProjectConfigTrace()) 2005 trace.error("Only the Admin of the project is allowed to do this operation... "); 2006 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2007 } 2008 this.setNodeDeadline(node,deadline); 2009 this.setNodeDescription(node,description); 2010 this.setNodeRole(node,role); 2011 } 2012 2013 2032 public void setEdgeCondition(String edge, String condition) 2033 throws HeroException { 2034 if (this.getProjectConfigTrace()) 2035 trace.info("parameters: name=" + edge + " condition=" + condition + " process name = " + this.getName()+ " started by " + this.getCaller()); 2036 if (!isAdminOfProject(this.getCaller())) 2037 { 2038 if (this.getProjectConfigTrace()) 2039 trace.error("Only the Admin of the project is allowed to do this operation... "); 2040 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2041 } 2042 BnEdgeLocal e = mProject.getBnEdge(edge); 2043 e.setCondition(condition); 2044 } 2045 2046 2057 public void setNodeDeadline(String name, long date) throws HeroException { 2058 if (this.getProjectConfigTrace()) 2059 trace.info("parameters: name=" + name + " deadline=" + date + " process name = " + this.getName()+ " started by " + this.getCaller()); 2060 if (!isAdminOfProject(this.getCaller())) 2061 { 2062 if (this.getProjectConfigTrace()) 2063 trace.error("Only the Admin of the project is allowed to do this operation... "); 2064 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2065 } 2066 if (new java.sql.Date (date).before(new Date ())) 2067 throw new HeroException("This date is before the current date !!"); 2068 2069 ArrayList ar = new ArrayList (); 2071 ar.add(new Long (date)); 2072 setNodeDeadlines(name, ar); 2073 } 2074 2075 2086 public void setNodeDeadlines(String name, Collection co) throws HeroException { 2087 Iterator it = co.iterator(); 2088 2089 if (this.getProjectConfigTrace()) 2090 trace.info("parameters: name=" + name + " collection of deadlines " + " process name = " + this.getName()+ " started by " + this.getCaller()); 2091 while (it.hasNext()){ 2092 trace.info("deadline = " + ((Long )it.next()).longValue() ); 2093 } 2094 if (!isAdminOfProject(this.getCaller())) 2095 { 2096 if (this.getProjectConfigTrace()) 2097 trace.error("Only the Admin of the project is allowed to do this operation... "); 2098 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2099 } 2100 it = co.iterator(); 2102 ArrayList ar = new ArrayList (); 2103 BnNodeLocal nd = mProject.getBnNode(name); 2104 while (it.hasNext()){ 2105 long d = ((Long )it.next()).longValue(); 2106 if (new java.sql.Date (d).before(new Date ())) 2107 throw new HeroException("The date of the deadline : " + d + " is before the current date !!"); 2108 Date date = new java.sql.Date (d); 2109 ar.add(date); 2110 } 2111 nd.setDeadlines(ar); 2112 2113 if (nd.getState()== Constants.Nd.READY && nd.getBnProject().getType().equals(Constants.Pj.COOPERATIVE)) 2114 BonitaDeadline.getInstance().startDeadlines(name, mProject.getId()); 2115 2116 String projectName = this.getName(); 2117 jms.sendNodeEvent(SETNODEDEADLINES,projectName,name,nd.getType(),nd.getState(),this.getCaller()); 2118 2119 } 2120 2121 2131 public void setNodeRelativeDeadlines(String name, Collection co) throws HeroException { 2132 Iterator it = co.iterator(); 2133 2134 if (this.getProjectConfigTrace()) 2135 trace.info("parameters: name=" + name + " collection of relativeDeadlines " + " process name = " + this.getName()+ " started by " + this.getCaller()); 2136 while (it.hasNext()){ 2137 trace.info("deadline = " + ((Long )it.next()).longValue() ); 2138 } 2139 if (!isAdminOfProject(this.getCaller())) 2140 { 2141 if (this.getProjectConfigTrace()) 2142 trace.error("Only the Admin of the project is allowed to do this operation... "); 2143 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2144 } 2145 it = co.iterator(); 2147 ArrayList ar = new ArrayList (); 2148 BnNodeLocal nd = mProject.getBnNode(name); 2149 while (it.hasNext()){ 2150 long d = ((Long )it.next()).longValue(); 2151 Date date = new java.sql.Date (d); 2152 ar.add(date); 2153 } 2154 nd.setRelativeDeadlines(ar); 2155 2156 if (nd.getState()== Constants.Nd.READY && nd.getBnProject().getType().equals(Constants.Pj.COOPERATIVE)) 2157 BonitaDeadline.getInstance().startDeadlines(name, mProject.getId()); 2158 2159 String projectName = this.getName(); 2160 jms.sendNodeEvent(SETNODEDEADLINES,projectName,name,nd.getType(),nd.getState(),this.getCaller()); 2161 2162 } 2163 2164 2175 public void setNodeRelativeDeadline(String name, long date) throws HeroException { 2176 if (this.getProjectConfigTrace()) 2177 trace.info("parameters: name=" + name + " deadline=" + date + " process name = " + this.getName()+ " started by " + this.getCaller()); 2178 if (!isAdminOfProject(this.getCaller())) 2179 { 2180 if (this.getProjectConfigTrace()) 2181 trace.error("Only the Admin of the project is allowed to do this operation... "); 2182 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2183 } 2184 ArrayList ar = new ArrayList (); 2186 ar.add(new Long (date)); 2187 setNodeRelativeDeadlines(name, ar); 2188 } 2189 2190 2201 public void setNodeDescription(String name, String description) 2202 throws HeroException { 2203 if (this.getProjectConfigTrace()) 2204 trace.info("parameters: name="+ name+ " description="+ description + " process name = " + this.getName()+ " started by " + this.getCaller()); 2205 if (!isAdminOfProject(this.getCaller())) 2206 { 2207 if (this.getProjectConfigTrace()) 2208 trace.error("Only the Admin of the project is allowed to do this operation... "); 2209 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2210 } 2211 BnNodeLocal nd = mProject.getBnNode(name); 2212 nd.setDescription(description); 2213 } 2214 2215 2226 public void setNodeInterHookValue(String node, String hook, String value) 2227 throws HeroException { 2228 if (this.getProjectConfigTrace()) 2229 trace.info("parameters: node="+ node+ " hook="+ hook+ " value="+ value+ " process name = " + this.getName()+ " started by " + this.getCaller()); 2230 if (!isAdminOfProject(this.getCaller())) 2231 { 2232 if (this.getProjectConfigTrace()) 2233 trace.error("Only the Admin of the project is allowed to do this operation... "); 2234 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2235 } 2236 BnNodeLocal nd = mProject.getBnNode(node); 2237 Collection hooks = nd.getBnInterHooks(); 2238 for (Iterator ih = hooks.iterator(); ih.hasNext();) { 2239 BnNodeInterHookLocal hk = (BnNodeInterHookLocal) ih.next(); 2240 if (hk.getName().equals(hook)) { 2241 hk.setScript(value); 2242 } 2243 } 2244 } 2245 2246 2256 public void setInterHookValue(String hook, String value) 2257 throws HeroException { 2258 if (this.getProjectConfigTrace()) 2259 trace.info("parameters: hook=" + hook + " value=" + value+ " process name = " + this.getName()+ " started by " + this.getCaller()); 2260 if (!isAdminOfProject(this.getCaller())) 2261 { 2262 if (this.getProjectConfigTrace()) 2263 trace.error("Only the Admin of the project is allowed to do this operation... "); 2264 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2265 } 2266 Collection hooks = mProject.getBnInterHooks(); 2267 for (Iterator ih = hooks.iterator(); ih.hasNext();) { 2268 BnProjectInterHookLocal hk = (BnProjectInterHookLocal) ih.next(); 2269 if (hk.getName().equals(hook)) { 2270 hk.setScript(value); 2271 } 2272 } 2273 } 2274 2275 2285 2286 public void unsetUserRole(String userName, String roleName) throws HeroException{ 2287 if (this.getProjectConfigTrace()) 2288 trace.info("parameters: userName=" + userName + " roleName=" + roleName + " process name = " + this.getName()+ " started by " + this.getCaller()); 2289 BnUserLocal mUser; 2290 BnUserLocalHome uHome; 2291 BnRoleLocalHome rHome; 2292 BnRoleLocal mRole; 2293 UserServiceLocalHome ushome; 2294 UserServiceLocal ul; 2295 if (!isAdminOfProject(this.getCaller())) 2296 { 2297 if (this.getProjectConfigTrace()) 2298 trace.error("Only the Admin of the project is allowed to do this operation... "); 2299 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2300 } 2301 try { 2302 uHome = hero.interfaces.BnUserUtil.getLocalHome(); 2303 rHome = hero.interfaces.BnRoleUtil.getLocalHome(); 2304 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 2305 } catch (javax.naming.NamingException be) { 2306 if (this.getProjectConfigTrace()) 2307 trace.error(be.getMessage()); 2308 throw new HeroException(be.getMessage()); 2309 } 2310 try { 2311 ul = ushome.create(); 2312 mUser = ul.findUser(userName); 2313 } catch (Exception fe) { 2314 if (this.getProjectConfigTrace()) 2315 trace.error("User does not exist " + fe.getMessage()); 2316 throw new HeroException("User does not exist"); 2317 } 2318 2319 Collection userRoles = this.getUserRolesInProject(userName); 2320 Iterator i = userRoles.iterator(); 2321 while (i.hasNext()) 2322 { 2323 BnRoleValue role = (BnRoleValue)i.next(); 2324 if (role.getName().equals(roleName)) 2325 { 2326 try { 2327 mRole = rHome.findByName(role.getName(),mProject.getId()); 2328 mUser.getBnRoles().remove(mRole); 2329 } catch (javax.ejb.FinderException fe) { 2330 if (this.getProjectConfigTrace()) 2331 trace.error("Role does not exist " + fe.getMessage()); 2332 throw new HeroException("Role does not exist"); 2333 } 2334 } 2335 } 2336 2337 jms.sendUserRoleEvent(UNSETUSERROLE,this.getName(),userName,roleName); 2338 } 2339 2340 2350 public void unsetUser(String userName) throws HeroException { 2351 if (this.getProjectConfigTrace()) 2352 trace.info(" Parameter: name=" + userName + " process name = "+this.getName()+ " started by " + this.getCaller()); 2353 UserServiceLocalHome ushome; 2354 UserServiceLocal ul; 2355 if (!isAdminOfProject(this.getCaller())) 2356 { 2357 if (this.getProjectConfigTrace()) 2358 trace.error("Only the Admin of the project is allowed to do this operation... "); 2359 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2360 } 2361 BnUserLocalHome uHome; 2362 BnRoleLocalHome rHome; 2363 BnUserLocal mUser; 2364 try { 2365 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 2366 uHome = hero.interfaces.BnUserUtil.getLocalHome(); 2367 rHome = hero.interfaces.BnRoleUtil.getLocalHome(); 2368 } catch (javax.naming.NamingException be) { 2369 if (this.getProjectConfigTrace()) 2370 trace.error(be.getMessage()); 2371 throw new HeroException(be.getMessage()); 2372 } 2373 try { 2374 ul = ushome.create(); 2375 mUser = ul.findUser(userName); 2376 } catch (Exception fe) { 2377 if (this.getProjectConfigTrace()) 2378 trace.error("User does not exist " + fe.getMessage()); 2379 throw new HeroException("User does not exist"); 2380 } 2381 Collection cUsers = mProject.getBnUsers(); 2382 if (cUsers.contains(mUser)) 2383 mProject.getBnUsers().remove(mUser); 2384 else 2385 { 2386 if (this.getProjectConfigTrace()) 2387 trace.error("User does not exist in the project..."); 2388 throw new HeroException("User does not exist in the project"); 2389 } 2390 2391 } 2392 2393 2403 public void setNodeTraditional(String name) throws HeroException { 2404 if (this.getProjectConfigTrace()) 2405 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 2406 if (!isAdminOfProject(this.getCaller())) 2407 { 2408 if (this.getProjectConfigTrace()) 2409 trace.error("Only the Admin of the project is allowed to do this operation... "); 2410 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2411 } 2412 BnNodeLocal nd = mProject.getBnNode(name); 2413 nd.setAnticipable(false); 2414 nd.setTransition(NodeState.make(nd.getType(), false)); 2415 } 2416 2417 2426 public void setNodeAnticipable(String name) throws HeroException { 2427 if (this.getProjectConfigTrace()) 2428 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 2429 if (!isAdminOfProject(this.getCaller())) 2430 { 2431 if (this.getProjectConfigTrace()) 2432 trace.error("Only the Admin of the project is allowed to do this operation... "); 2433 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2434 } 2435 BnNodeLocal nd = mProject.getBnNode(name); 2436 nd.setAnticipable(true); 2437 nd.setTransition(NodeState.make(nd.getType(), true)); 2438 } 2439 2440 2449 public void setNodeAutomatic(String name) throws HeroException { 2450 if (this.getProjectConfigTrace()) 2451 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 2452 if (!isAdminOfProject(this.getCaller())) 2453 { 2454 if (this.getProjectConfigTrace()) 2455 trace.error("Only the Admin of the project is allowed to do this operation... "); 2456 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2457 } 2458 BnNodeLocal nd = mProject.getBnNode(name); 2459 nd.setTransition(NodeState.make(5, true)); 2461 } 2464 2465 2480 public void setNodeType(String name, int type) throws HeroException { 2481 if (this.getProjectConfigTrace()) 2482 trace.info("parameters: name=" + name + " type" + type + " process name = " + this.getName()+ " started by " + this.getCaller()); 2483 if (!isAdminOfProject(this.getCaller())) 2484 { 2485 if (this.getProjectConfigTrace()) 2486 trace.error("Only the Admin of the project is allowed to do this operation... "); 2487 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2488 } 2489 BnNodeLocal nd = mProject.getBnNode(name); 2490 nd.setType(type); 2491 nd.setTransition(NodeState.make(nd.getType(), true)); 2492 nd.setActivation(EdgeState.make(nd.getType())); 2493 } 2494 2495 2508 public void setNodeProperty(String nodeName,String key,String value,boolean propagate) 2509 throws HeroException { 2510 BnNodePropertyLocalHome pHome; 2511 BnNodePropertyLocal propertyLocal; 2512 if (!isAdminOfProject(this.getCaller())) 2513 { 2514 if (mProject.getName().matches(".*_instance.*") && !isUserInNodeRole(nodeName)) 2515 { 2516 if (this.getProjectConfigTrace()) 2517 trace.error("You are not allowed to set/update properties of this node... "); 2518 throw new HeroException("You are not allowed to set/update properties of this node... "); 2519 } 2520 } 2521 if (this.getProjectConfigTrace()) 2522 trace.info("parameters: node="+ nodeName+ " key="+ key+ " value="+ value + " process name = " + this.getName()+ " started by " + this.getCaller()); 2523 2524 BnNodeLocal nd = mProject.getBnNode(nodeName); 2525 2526 try { 2527 pHome = BnNodePropertyUtil.getLocalHome(); 2528 } catch (javax.naming.NamingException ne) { 2529 if (this.getProjectConfigTrace()) 2530 trace.error(ne.getMessage()); 2531 throw new HeroException(ne.getMessage()); 2532 } 2533 Collection c = null; 2534 try { 2535 c = pHome.findByTheKey(nd.getId(), key); 2536 } catch (FinderException fe) { 2537 if (this.getProjectConfigTrace()) 2538 trace.error(fe.getMessage()); 2539 throw new HeroException(fe.getMessage()); 2540 } 2541 if (!c.isEmpty()) { 2542 propertyLocal = (BnNodePropertyLocal) (c.toArray())[0]; 2543 propertyLocal.setTheValue(value); 2544 propertyLocal.setPropagate(propagate); 2545 } else { 2546 try { 2547 propertyLocal = pHome.create(key, value); 2548 propertyLocal.setBnNode(nd); 2549 propertyLocal.setPropagate(propagate); 2550 } catch (InvalidValueException ie) { 2551 if (this.getProjectConfigTrace()) 2552 trace.error(ie.getMessage()); 2553 throw new HeroException(ie.getMessage()); 2554 } catch (javax.ejb.CreateException ce) { 2555 if (this.getProjectConfigTrace()) 2556 trace.error(ce.getMessage()); 2557 throw new HeroException(ce.getMessage()); 2558 } 2559 } 2560 } 2561 2562 2574 2575 public void setNodeProperty(String nodeName, String key, String value) 2576 throws HeroException { 2577 BnNodePropertyLocalHome pHome; 2578 BnNodePropertyLocal propertyLocal = null; 2579 2580 if (!isAdminOfProject(this.getCaller())) 2581 { 2582 if (mProject.getName().matches(".*_instance.*") && !isUserInNodeRole(nodeName)) 2583 { 2584 if (this.getProjectConfigTrace()) 2585 trace.error("You are not allowed to set/update properties of this node... "); 2586 throw new HeroException("You are not allowed to set/update properties of this node... "); 2587 } 2588 } 2589 if (this.getProjectConfigTrace()) 2590 trace.info("parameters: node="+ nodeName+ " key="+ key+ " value="+ value + " process name = " + this.getName()+ " started by " + this.getCaller()); 2591 BnNodeLocal nd = mProject.getBnNode(nodeName); 2592 2593 try { 2594 pHome = BnNodePropertyUtil.getLocalHome(); 2595 } catch (javax.naming.NamingException ne) { 2596 if (this.getProjectConfigTrace()) 2597 trace.error(ne.getMessage()); 2598 throw new HeroException(ne.getMessage()); 2599 } 2600 Collection c = null; 2601 try { 2602 c = pHome.findByTheKey(nd.getId(), key); 2603 } catch (FinderException fe) { 2604 if (this.getProjectConfigTrace()) 2605 trace.error(fe.getMessage()); 2606 throw new HeroException(fe.getMessage()); 2607 } 2608 2609 if (!c.isEmpty()) { 2610 2611 propertyLocal = (BnNodePropertyLocal) (c.toArray())[0]; 2612 if (propertyLocal.getPossibleValues() == null || propertyLocal.getPossibleValues().contains(value)) 2613 propertyLocal.setTheValue(value); 2614 else 2615 throw new HeroException("This value is not one of possibles values defined for the property..."); 2616 2617 2618 } else { 2619 try { 2620 propertyLocal = pHome.create(key, value); 2621 propertyLocal.setBnNode(nd); 2622 2623 } catch (InvalidValueException ie) { 2624 if (this.getProjectConfigTrace()) 2625 trace.error(ie.getMessage()); 2626 throw new HeroException(ie.getMessage()); 2627 } catch (javax.ejb.CreateException ce) { 2628 if (this.getProjectConfigTrace()) 2629 trace.error(ce.getMessage()); 2630 throw new HeroException(ce.getMessage()); 2631 } 2632 } 2633 } 2634 2635 2646 public void setProperty(String key, String value) throws HeroException { 2647 if (this.getProjectConfigTrace()) 2648 trace.info("parameters: key=" + key + " value=" + value + " process name = " + this.getName()+ " started by " + this.getCaller()); 2649 if (!isAdminOfProject(this.getCaller())) 2650 { 2651 if (this.getProjectConfigTrace()) 2652 trace.error("Only the Admin of the project is allowed to do this operation... "); 2653 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2654 } 2655 BnProjectPropertyLocalHome pHome; 2656 BnProjectPropertyLocal ppLocal = null; 2657 2658 try { 2659 pHome = BnProjectPropertyUtil.getLocalHome(); 2660 } catch (javax.naming.NamingException ne) { 2661 if (this.getProjectConfigTrace()) 2662 trace.error(ne.getMessage()); 2663 throw new HeroException(ne.getMessage()); 2664 } 2665 Collection c = null; 2666 try { 2667 c = pHome.findByTheKey(mProject.getId(), key); 2668 } catch (FinderException fe) { 2669 if (this.getProjectConfigTrace()) 2670 trace.error(fe.getMessage()); 2671 throw new HeroException(fe.getMessage()); 2672 } 2673 2674 if (!c.isEmpty()) { 2675 2676 ppLocal = (BnProjectPropertyLocal) (c.toArray())[0]; 2677 if (ppLocal.getPossibleValues() == null || ppLocal.getPossibleValues().contains(value)) 2678 ppLocal.setTheValue(value); 2679 else 2680 throw new HeroException("This value is not one of possibles values defined for the property..."); 2681 2682 } else { 2683 try { 2684 ppLocal = pHome.create(key, value); 2685 ppLocal.setBnProject(mProject); 2686 2687 } catch (InvalidValueException ie) { 2688 if (this.getProjectConfigTrace()) 2689 trace.error(ie.getMessage()); 2690 throw new HeroException(ie.getMessage()); 2691 } catch (javax.ejb.CreateException ce) { 2692 if (this.getProjectConfigTrace()) 2693 trace.error(ce.getMessage()); 2694 throw new HeroException(ce.getMessage()); 2695 } 2696 } 2697 } 2698 2699 2711 public void setNodePropertyPossibleValues(String nodeName, String key, Collection values) 2712 throws HeroException { 2713 BnNodePropertyLocalHome pHome; 2714 BnNodePropertyLocal propertyLocal; 2715 if (!isAdminOfProject(this.getCaller())) 2716 { 2717 if (mProject.getName().matches(".*_instance.*") && !isUserInNodeRole(nodeName)) 2718 { 2719 if (this.getProjectConfigTrace()) 2720 trace.error("You are not allowed to set/update properties of this node... "); 2721 throw new HeroException("You are not allowed to set/update properties of this node... "); 2722 } 2723 } 2724 if (this.getProjectConfigTrace()) 2725 trace.info("parameters: node="+ nodeName+ " key="+ key+ " values="+ values + " process name = " + this.getName()+ " started by " + this.getCaller()); 2726 2727 BnNodeLocal nd = mProject.getBnNode(nodeName); 2728 2729 try { 2730 pHome = BnNodePropertyUtil.getLocalHome(); 2731 } catch (javax.naming.NamingException ne) { 2732 if (this.getProjectConfigTrace()) 2733 trace.error(ne.getMessage()); 2734 throw new HeroException(ne.getMessage()); 2735 } 2736 Collection c = null; 2737 try { 2738 c = pHome.findByTheKey(nd.getId(), key); 2739 } catch (FinderException fe) { 2740 if (this.getProjectConfigTrace()) 2741 trace.error(fe.getMessage()); 2742 throw new HeroException(fe.getMessage()); 2743 } 2744 if (c.isEmpty()) { 2745 try { 2746 propertyLocal = pHome.create(key, values); 2747 propertyLocal.setBnNode(nd); 2748 } catch (InvalidValueException ie) { 2749 if (this.getProjectConfigTrace()) 2750 trace.error(ie.getMessage()); 2751 throw new HeroException(ie.getMessage()); 2752 } catch (javax.ejb.CreateException ce) { 2753 if (this.getProjectConfigTrace()) 2754 trace.error(ce.getMessage()); 2755 throw new HeroException(ce.getMessage()); 2756 } 2757 } 2758 } 2759 2760 2771 public void setPropertyPossibleValues(String key, Collection values) 2772 throws HeroException { 2773 BnProjectPropertyLocalHome pHome; 2774 BnProjectPropertyLocal propertyLocal; 2775 if (!isAdminOfProject(this.getCaller())) 2776 { 2777 if (this.getProjectConfigTrace()) 2778 trace.error("Only the Admin of the project is allowed to do this operation... "); 2779 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2780 } 2781 if (this.getProjectConfigTrace()) 2782 trace.info("parameters: key="+ key+ " values="+ values + " process name = " + this.getName()+ " started by " + this.getCaller()); 2783 2784 try { 2785 pHome = BnProjectPropertyUtil.getLocalHome(); 2786 } catch (javax.naming.NamingException ne) { 2787 if (this.getProjectConfigTrace()) 2788 trace.error(ne.getMessage()); 2789 throw new HeroException(ne.getMessage()); 2790 } 2791 Collection c = null; 2792 try { 2793 c = pHome.findByTheKey(mProject.getId(),key); 2794 } catch (FinderException fe) { 2795 if (this.getProjectConfigTrace()) 2796 trace.error(fe.getMessage()); 2797 throw new HeroException(fe.getMessage()); 2798 } 2799 if (c.isEmpty()) { 2800 try { 2801 propertyLocal = pHome.create(key, values); 2802 propertyLocal.setBnProject(mProject); 2803 } catch (InvalidValueException ie) { 2804 if (this.getProjectConfigTrace()) 2805 trace.error(ie.getMessage()); 2806 throw new HeroException(ie.getMessage()); 2807 } catch (javax.ejb.CreateException ce) { 2808 if (this.getProjectConfigTrace()) 2809 trace.error(ce.getMessage()); 2810 throw new HeroException(ce.getMessage()); 2811 } 2812 } 2813 } 2814 2815 2819 2829 public void hookEvent(String nodeName, String event) throws HeroException { 2830 if (this.getProjectConfigTrace()) 2831 trace.info("parameters: node=" + nodeName + " event=" + event + " process name = " + this.getName()+ " started by " + this.getCaller()); 2832 if (!isAdminOfProject(this.getCaller())) 2833 { 2834 if (this.getProjectConfigTrace()) 2835 trace.error("Only the Admin of the project is allowed to do this operation... "); 2836 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 2837 } 2838 Collection hooks; 2839 BnNodeLocal node; 2840 2841 node = mProject.getBnNode(nodeName); 2842 hooks = node.getBnHooks(); 2843 for (Iterator i = hooks.iterator(); i.hasNext();) { 2844 BnNodeHookLocal hk = (BnNodeHookLocal) i.next(); 2845 if (hk.getEvent().equalsIgnoreCase(event)) { 2846 hero.hook.Hook h = 2847 hero.hook.Hook.make(hk.getName(), event, hk.getType()); 2848 h.execute(this, event, node); 2849 } 2850 } 2851 } 2852 2853 2854 2862 public void propagateNodeProperties(String nodeName) throws HeroException { 2863 if (this.getProjectConfigTrace()) 2864 trace.info("parameter: name=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 2865 2866 BnNodePropertyLocalHome pHome; 2867 BnNodePropertyLocal propertyLocal = null; 2868 2869 BnNodeLocal nd = mProject.getBnNode(nodeName); 2870 2871 Collection c = nd.getBnProperties(); 2872 Collection c2 = nd.getOutBnEdges(); 2873 2874 if ((!c.isEmpty()) && (!c2.isEmpty())) { 2875 BnNodePropertyLocal p; 2876 BnEdgeLocal ed; 2877 for (Iterator i = c.iterator(); i.hasNext();) { 2878 p = (BnNodePropertyLocal) i.next(); 2879 for (Iterator i2 = c2.iterator(); i2.hasNext();) { 2880 ed = (BnEdgeLocal) i2.next(); 2881 if (p.getPropagate()) 2882 { 2883 this.setNodePropertyPossibleValues((ed.getOutBnNode()).getName(),p.getTheKey(),p.getPossibleValues()); 2884 if (p.getTheValue()!=null || p.getPossibleValues().size()==0) 2885 this.setNodeProperty((ed.getOutBnNode()).getName(),p.getTheKey(),p.getTheValue(),true); 2886 } 2887 } 2888 } 2889 } 2890 } 2891 2892 2893 2904 public void setNodeState(BnNodeLocal node, int state) throws HeroException { 2905 if (this.getProjectConfigTrace()) 2906 trace.info("parameters: name=" + node.getName() + " state=" + state + " process name = " + this.getName()+ " started by " + this.getCaller()); 2907 2908 node.setState(state); 2909 if (state == hero.interfaces.Constants.Nd.EXECUTING || state == hero.interfaces.Constants.Nd.ANTICIPATING) { 2910 node.setStartDate(new java.util.Date ()); 2911 } 2912 else if (state == hero.interfaces.Constants.Nd.TERMINATED) { 2913 if (!(node.getStartDate() !=null)) 2914 node.setStartDate(new java.util.Date ()); 2915 node.setEndDate(new java.util.Date ()); 2916 } 2918 else if (state == hero.interfaces.Constants.Nd.DEAD) 2919 { 2920 if (!(node.getStartDate() !=null)) 2921 node.setStartDate(new java.util.Date ()); 2922 node.setEndDate(new java.util.Date ()); 2923 } 2924 jms.sendNodeEvent(SETNODESTATE,this.getName(),node.getName(),node.getType(),state,this.getCaller()); 2925 } 2926 2927 2935 public void setNodesReady() throws HeroException { 2936 if (this.getProjectConfigTrace()) 2937 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 2938 try{ 2939 Collection nodes = mProject.getBnNodes(); 2940 Iterator nds = nodes.iterator(); 2941 while (nds.hasNext()) { 2943 BnNodeLocal subNode = (BnNodeLocal)nds.next(); 2944 if (this.getNodeInEdges(subNode.getName()).size()==0 && subNode.getState()==Constants.Nd.INITIAL 2945 && (subNode.getType()==Constants.Nd.AND_JOIN_AUTOMATIC_NODE || subNode.getType()==Constants.Nd.OR_JOIN_AUTOMATIC_NODE)) 2946 { 2947 this.setNodeState(subNode,Constants.Nd.READY); 2948 EngineLocalHome enghome; 2949 try { 2950 enghome = hero.interfaces.EngineUtil.getLocalHome(); 2951 EngineLocal engine = enghome.create(); 2952 engine.startActivity(mProject.getName(), subNode.getName()); 2953 } catch (javax.naming.NamingException ne) { 2954 throw new HeroException(ne.getMessage()); 2955 } 2956 } 2957 else if (this.getNodeInEdges(subNode.getName()).size()==0 && subNode.getState()==Constants.Nd.INITIAL) 2958 this.setNodeState(subNode,Constants.Nd.READY); 2959 } 2960 }catch (Exception ans){ 2961 if (this.getProjectConfigTrace()) 2962 trace.error("Error in setNodeReady " + ans.getMessage()); 2963 throw new HeroException("Error in setNodeReady"); 2964 } 2965 } 2966 2967 2976 2977 public void propagatesParentProperties(String node) throws HeroException { 2978 if (this.getProjectConfigTrace()) 2979 trace.info("parameter: nodeName=" + node + " process name = " + this.getName()+ " started by " + this.getCaller()); 2980 BnProjectLocal pl = mProject; 2981 try{ 2982 Collection props = mProject.getBnNode(node).getBnProperties(); 2983 this.initProject(node); 2984 Iterator i = props.iterator(); 2985 while (i.hasNext()) 2986 { 2987 BnNodePropertyLocal prop = (BnNodePropertyLocal)i.next(); 2988 this.setPropertyPossibleValues(prop.getTheKey(),prop.getPossibleValues()); 2989 if (prop.getTheValue()!=null || prop.getPossibleValues().size()==0) 2990 this.setProperty(prop.getTheKey(),prop.getTheValue()); 2991 } 2992 this.setNodesReady(); 2993 mProject=pl; 2994 }catch (Exception ans){ans.printStackTrace(); 2995 mProject=pl; 2996 if (this.getProjectConfigTrace()) 2997 trace.error("Error in propagatesParentProperties " + ans.getMessage()); 2998 throw new HeroException("Error in propagatesParentProperties");} 2999 } 3000 3001 3010 3011 public void propagatesSubProcessProperties(String node) throws HeroException { 3012 if (this.getProjectConfigTrace()) 3013 trace.info("parameter: nodeName=" + node + " process name = " + this.getName()+ " started by " + this.getCaller()); 3014 BnProjectLocal pl = mProject; 3015 try{ 3016 this.initProject(node); 3017 Collection props = this.getProperties(); 3018 mProject = pl; 3019 Iterator i = props.iterator(); 3020 while (i.hasNext()) 3021 { 3022 BnProjectPropertyValue prop = (BnProjectPropertyValue)i.next(); 3023 this.setNodePropertyPossibleValues(node,prop.getTheKey(),prop.getPossibleValues()); 3024 if (prop.getTheValue()!=null || prop.getPossibleValues().size()==0) 3025 this.setNodeProperty(node,prop.getTheKey(),prop.getTheValue(),true); 3026 } 3027 }catch (Exception ans){ans.printStackTrace(); 3028 mProject=pl; 3029 if (this.getProjectConfigTrace()) 3030 trace.error("Error in propagatesSubProcessProperties " + ans.getMessage()); 3031 throw new HeroException("Error in propagatesSubProcessProperties ");} 3032 } 3033 3034 3044 public void setEdgeState(BnEdgeLocal edge, int state) 3045 throws HeroException { 3046 if (this.getProjectConfigTrace()) 3047 trace.info("parameters: name=" + edge.getName() + " state=" + state + " process name = " + this.getName()+ " started by " + this.getCaller()); 3048 edge.setState(state); 3049 jms.sendEdgeEvent(SETEDGESTATE,this.getName(),edge.getName(),edge.getInBnNode().getName(),edge.getOutBnNode().getName(),this.getCaller()); 3050 } 3051 3052 3062 public void setAgentState(BnAgentLocal agent, int state) 3063 throws HeroException { 3064 if (this.getProjectConfigTrace()) 3065 trace.info("parameters: name=" + agent.getName() + " state=" + state + " state=" + state + " process name = " + this.getName()+ " started by " + this.getCaller()); 3066 agent.setState(state); 3067 } 3069 3070 3080 public void setAgentEdgeState(BnAgentEdgeLocal agentEdge, int state) 3081 throws HeroException { 3082 if (this.getProjectConfigTrace()) 3083 trace.info("parameters: name="+ agentEdge.getName()+ " state="+ state + " state=" + state + " process name = " + this.getName()+ " started by " + this.getCaller()); 3084 agentEdge.setState(state); 3085 } 3087 3088 3097 public void setNodeExecutor(String name) throws HeroException { 3098 if (this.getProjectConfigTrace()) 3099 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3100 3101 BnUserLocalHome uHome; 3102 BnUserLocal user; 3103 try { 3104 uHome = BnUserUtil.getLocalHome(); 3105 } catch (javax.naming.NamingException ne) { 3106 if (this.getProjectConfigTrace()) 3107 trace.error(ne.getMessage()); 3108 throw new HeroException(ne.getMessage()); 3109 } 3110 BnNodeLocal nd = mProject.getBnNode(name); 3111 String executor = this.getCaller(); 3112 Collection users = mProject.getBnUsers(); 3113 Iterator i = users.iterator(); 3114 while (i.hasNext()) 3115 { 3116 BnUserLocal ul = (BnUserLocal)i.next(); 3117 if (ul.getName().equals(executor)) 3118 { 3119 nd.setExecutor(executor); 3120 break; 3121 } 3122 } 3123 3131 jms.sendNodeEvent(SETNODEEXECUTOR,this.getName(),name,nd.getType(),nd.getState(),this.getCaller()); 3132 } 3133 3134 3135 3139 3150 public String getNodeDescription(String name) throws HeroException { 3151 if (this.getProjectConfigTrace()) 3152 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3153 BnNodeLocal nd = mProject.getBnNode(name); 3154 return (nd.getDescription()); 3155 } 3156 3157 3168 public String getNodeInterHookValue(String node, String hook) 3169 throws HeroException { 3170 if (!isAdminOfProject(this.getCaller())) 3171 { 3172 if (this.getProjectConfigTrace()) 3173 trace.error("Only the Admin of the project is allowed to do this operation... "); 3174 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 3175 } 3176 String value = null; 3177 if (this.getProjectConfigTrace()) 3178 trace.info("parameters: node=" + node + " hook=" + hook + " process name = " + this.getName()+ " started by " + this.getCaller()); 3179 BnNodeLocal nd = mProject.getBnNode(node); 3180 Collection hooks = nd.getBnInterHooks(); 3181 for (Iterator ih = hooks.iterator(); ih.hasNext();) { 3182 BnNodeInterHookLocal hk = (BnNodeInterHookLocal) ih.next(); 3183 if (hk.getName().equals(hook)) { 3184 value = hk.getScript(); 3185 } 3186 } 3187 return value; 3188 } 3189 3190 3200 public String getInterHookValue(String hook) throws HeroException { 3201 String value = null; 3202 if (!isAdminOfProject(this.getCaller())) 3203 { 3204 if (this.getProjectConfigTrace()) 3205 trace.error("Only the Admin of the project is allowed to do this operation... "); 3206 throw new AdminException("Only the Admin of the project is allowed to do this operation... "); 3207 } 3208 if (this.getProjectConfigTrace()) 3209 trace.info("parameter: hook=" + hook + " process name = " + this.getName()+ " started by " + this.getCaller()); 3210 Collection hooks = mProject.getBnInterHooks(); 3211 for (Iterator ih = hooks.iterator(); ih.hasNext();) { 3212 BnProjectInterHookLocal hk = (BnProjectInterHookLocal) ih.next(); 3213 if (hk.getName().equals(hook)) { 3214 value = hk.getScript(); 3215 } 3216 } 3217 return value; 3218 } 3219 3220 3230 public BnProjectValue getDetails() throws HeroException { 3231 if (this.getProjectConfigTrace()) 3232 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3233 return mProject.getBnProjectValue(); 3234 } 3235 3236 3245 public String getName() throws HeroException { 3246 if (mProject!=null) 3247 { 3248 trace.info(" process name = " + mProject.getName()+ " started by " + this.getCaller()); 3249 return mProject.getName(); 3250 } 3251 return null; 3252 } 3253 3254 3263 3264 public String getCreator() throws HeroException { 3265 if (this.getProjectConfigTrace()) 3266 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3267 return mProject.getCreator(); 3268 } 3269 3270 3279 3280 public String getStatus() throws HeroException { 3281 if (this.getProjectConfigTrace()) 3282 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3283 return mProject.getStatus(); 3284 } 3285 3286 3295 3296 public String getType() throws HeroException { 3297 if (this.getProjectConfigTrace()) 3298 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3299 return mProject.getType(); 3300 } 3301 3302 3303 3312 public Collection getRoles() throws HeroException { 3313 if (this.getProjectConfigTrace()) 3314 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3315 Collection roles = mProject.getBnRoles(); 3316 ArrayList result = new ArrayList (); 3317 for (Iterator i = roles.iterator(); i.hasNext();) { 3318 result.add((BnRoleLocal) i.next()); 3319 } 3320 return result; 3321 } 3322 3323 3332 public Collection getRolesValue() throws HeroException { 3333 if (this.getProjectConfigTrace()) 3334 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3335 Collection roles = mProject.getBnRoles(); 3336 ArrayList result = new ArrayList (); 3337 for (Iterator i = roles.iterator(); i.hasNext();) { 3338 BnRoleLocal rl =(BnRoleLocal) i.next(); 3339 result.add(rl.getBnRoleValue()); 3340 } 3341 return result; 3342 } 3343 3344 3353 public BnRoleValue getRoleValue(String roleName) throws HeroException { 3354 if (this.getProjectConfigTrace()) 3355 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3356 try { 3357 BnRoleLocalHome roleh = (BnRoleLocalHome)BnRoleUtil.getLocalHome(); 3358 BnRoleLocal rolel = roleh.findByName(roleName, mProject.getId()); 3359 return (rolel.getBnRoleValue()); 3360 } catch (Exception pfe) { 3361 throw new HeroException("This Role does not exist in this project : " + roleName); 3362 } 3363 } 3364 3365 3376 public BnNodePerformerAssignValue getNodePerformerAssign(String nodeName) throws HeroException { 3377 if (this.getProjectConfigTrace()) 3379 trace.debug("parameter: nodeName=" + nodeName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3380 3381 BnNodeLocal node = null; 3382 3383 try { 3385 BnNodeLocalHome nodeh = (BnNodeLocalHome)BnNodeUtil.getLocalHome(); 3386 node = nodeh.findByName(nodeName, mProject.getId()); 3387 } catch (Exception pfe) { 3388 throw new HeroException("The bnNode does not exist for node : " + nodeName); 3389 } 3390 if (node.getBnNodePerformerAssign()!=null) 3391 return (node.getBnNodePerformerAssign().getBnNodePerformerAssignValue()); 3392 else 3393 return null; 3394 } 3395 3396 3405 public Collection getRolesNames() throws HeroException { 3406 if (this.getProjectConfigTrace()) 3407 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3408 Collection roles = mProject.getBnRoles(); 3409 ArrayList result = new ArrayList (); 3410 for (Iterator i = roles.iterator(); i.hasNext();) { 3411 result.add(((BnRoleLocal) i.next()).getName()); 3412 } 3413 return result; 3414 } 3415 3416 3417 3428 public Collection getUserRoles(String userName) throws HeroException { 3429 if (this.getProjectConfigTrace()) 3430 trace.info("parameter: userName=" + userName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3431 BnUserLocalHome uHome; 3432 BnUserLocal user; 3433 try { 3434 uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome(); 3435 } catch (javax.naming.NamingException be) { 3436 if (this.getProjectConfigTrace()) 3437 trace.error(be.getMessage()); 3438 throw new HeroException(be.getMessage()); 3439 } 3440 try { 3441 user = uHome.findByName(userName); 3442 } catch (FinderException f) { 3443 if (this.getProjectConfigTrace()) 3444 trace.error("FinderException " + f.getMessage()); 3445 throw new HeroException("FinderException"); 3446 } 3447 Collection roles = user.getBnRoles(); 3448 ArrayList result = new ArrayList (); 3449 for (Iterator i = roles.iterator(); i.hasNext();) { 3450 result.add((BnRoleLocal) i.next()); 3451 } 3452 return result; 3453 } 3454 3455 3466 public Collection getUserRolesInProject(String userName) 3467 throws HeroException { 3468 if (this.getProjectConfigTrace()) 3469 trace.info("parameter: userName=" + userName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3470 BnUserLocalHome uHome; 3471 BnUserLocal user; 3472 ArrayList result = new ArrayList (); 3473 try { 3474 uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome(); 3475 } catch (javax.naming.NamingException be) { 3476 if (this.getProjectConfigTrace()) 3477 trace.error(be.getMessage()); 3478 throw new HeroException(be.getMessage()); 3479 } 3480 try { 3481 user = uHome.findByName(userName); 3482 } catch (FinderException f) { 3483 if (this.getProjectConfigTrace()) 3484 trace.error("FinderException " + f.getMessage()); 3485 throw new HeroException("FinderException"); 3486 } 3487 Collection userRoles = user.getBnRoles(); 3488 Collection projectRoles = mProject.getBnRoles(); 3489 for (Iterator i = userRoles.iterator(); i.hasNext();) { 3490 BnRoleLocal ur = (BnRoleLocal) i.next(); 3491 for (Iterator j = projectRoles.iterator(); j.hasNext();) { 3492 BnRoleLocal up = (BnRoleLocal) j.next(); 3493 if (ur.getId() == up.getId()) 3494 result.add(ur.getBnRoleValue()); 3495 } 3496 } 3497 return result; 3498 } 3499 3500 3511 public Collection getUsersRole(String roleName) 3512 throws HeroException { 3513 if (this.getProjectConfigTrace()) 3514 trace.info("parameter: roleName=" + roleName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3515 BnRoleLocalHome rHome; 3516 BnRoleLocal role; 3517 ArrayList result = new ArrayList (); 3518 try { 3519 rHome = (BnRoleLocalHome) hero.interfaces.BnRoleUtil.getLocalHome(); 3520 } catch (javax.naming.NamingException be) { 3521 if (this.getProjectConfigTrace()) 3522 trace.error(be.getMessage()); 3523 throw new HeroException(be.getMessage()); 3524 } 3525 try { 3526 role = rHome.findByName(roleName,mProject.getId()); 3527 } catch (FinderException f) { 3528 if (this.getProjectConfigTrace()) 3529 trace.error("FinderException " + f.getMessage()); 3530 throw new HeroException("FinderException"); 3531 } 3532 Collection usersR = role.getBnUsers(); 3533 Iterator users = usersR.iterator(); 3534 while (users.hasNext()) 3535 { 3536 BnUserLocal user = (BnUserLocal) users.next(); 3537 result.add(user.getName()); 3538 } 3539 return result; 3540 } 3541 3542 3553 public Collection getUserRolesInProjectNames(String userName) 3554 throws HeroException { 3555 if (this.getProjectConfigTrace()) 3556 trace.info("parameter: userName=" + userName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3557 BnUserLocalHome uHome; 3558 BnUserLocal user; 3559 ArrayList result = new ArrayList (); 3560 try { 3561 uHome = (BnUserLocalHome) hero.interfaces.BnUserUtil.getLocalHome(); 3562 } catch (javax.naming.NamingException be) { 3563 if (this.getProjectConfigTrace()) 3564 trace.error(be.getMessage()); 3565 throw new HeroException(be.getMessage()); 3566 } 3567 try { 3568 user = uHome.findByName(userName); 3569 } catch (FinderException f) { 3570 if (this.getProjectConfigTrace()) 3571 trace.error("FinderException " + f.getMessage()); 3572 throw new HeroException("FinderException"); 3573 } 3574 3575 Collection userRoles = user.getBnRoles(); 3576 Collection projectRoles = mProject.getBnRoles(); 3577 for (Iterator i = userRoles.iterator(); i.hasNext();) { 3578 BnRoleLocal ur = (BnRoleLocal) i.next(); 3579 for (Iterator j = projectRoles.iterator(); j.hasNext();) { 3580 BnRoleLocal up = (BnRoleLocal) j.next(); 3581 if (ur.getId().equals(up.getId())) 3582 result.add(ur.getBnRoleValue().getName()); 3583 } 3584 } 3585 return result; 3586 } 3587 3588 3598 public BnRoleLocal getNodeRole(String nodeName) throws HeroException { 3599 if (this.getProjectConfigTrace()) 3600 trace.info("parameter: nodeName=" + nodeName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3601 BnNodeLocal nd = mProject.getBnNode(nodeName); 3602 return ((BnRoleLocal) nd.getBnRole()); 3603 } 3604 3605 3616 public String getEdgeCondition(String edge) 3617 throws HeroException { 3618 if (this.getProjectConfigTrace()) 3619 trace.info("parameter: name=" + edge+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3620 BnEdgeLocal e = mProject.getBnEdge(edge); 3621 return(e.getCondition()); 3622 } 3623 3624 3634 public boolean getNodeAnticipable(String name) throws HeroException { 3635 if (this.getProjectConfigTrace()) 3636 trace.info("parameter: name=" + name+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3637 BnNodeLocal nd = mProject.getBnNode(name); 3638 return (nd.getAnticipable()); 3639 } 3640 3641 3652 public String getNodeRoleName(String nodeName) throws HeroException { 3653 if (this.getProjectConfigTrace()) 3654 trace.info("parameter: nodeName=" + nodeName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3655 BnNodeLocal nd = mProject.getBnNode(nodeName); 3656 return (((BnRoleLocal) nd.getBnRole()).getName()); 3657 } 3658 3659 3671 public String getNodeDeadline(String nodeName) throws HeroException { 3672 if (this.getProjectConfigTrace()) 3673 trace.info("parameter: nodeName=" + nodeName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3674 BnNodeLocal nd = mProject.getBnNode(nodeName); 3675 if (nd.getDeadlines().size() != 0) { 3676 Collection co = nd.getDeadlines(); 3677 Iterator it = co.iterator(); 3678 Date date = null; 3679 while (it.hasNext()){ 3680 date = (Date )it.next(); 3681 } 3682 return (date.toString()); 3683 } 3684 else 3685 return (null); 3686 3692 } 3693 3694 3705 public Collection getNodeDeadlines(String nodeName) throws HeroException { 3706 if (this.getProjectConfigTrace()) 3707 trace.info("parameter: nodeName=" + nodeName+ " process name = " + this.getName()+ " started by " + this.getCaller()); 3708 BnNodeLocal nd = mProject.getBnNode(nodeName); 3709 if (nd.getDeadlines() != null) 3710 return (nd.getDeadlines()); 3711 else 3712 return (null); 3713 } 3714 3715 3716 3727 public BnNodeValue getNodeValue(String name) throws HeroException { 3728 if (this.getProjectConfigTrace()) 3729 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3730 BnNodeLocalHome nHome; 3731 BnNodeLocal mNode; 3732 BnNodeValue nv; 3733 try { 3734 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 3735 } catch (javax.naming.NamingException be) { 3736 if (this.getProjectConfigTrace()) 3737 trace.error(be.getMessage()); 3738 throw new HeroException(be.getMessage()); 3739 } 3740 try { 3741 mNode = nHome.findByName(name, mProject.getId()); 3742 } catch (FinderException fe) { 3743 if (this.getProjectConfigTrace()) 3744 trace.error("In Node does not exist " + fe.getMessage()); 3745 throw new HeroException("In Node does not exist"); 3746 } 3747 nv = mNode.getBnNodeValue(); 3748 return nv; 3749 } 3750 3751 3762 public BnAgentValue getAgentValue(String name) throws HeroException { 3763 if (this.getProjectConfigTrace()) 3764 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3765 BnAgentLocalHome nHome; 3766 BnAgentLocal mAgent; 3767 BnAgentValue av; 3768 try { 3769 nHome = hero.interfaces.BnAgentUtil.getLocalHome(); 3770 } catch (javax.naming.NamingException be) { 3771 if (this.getProjectConfigTrace()) 3772 trace.error(be.getMessage()); 3773 throw new HeroException(be.getMessage()); 3774 } 3775 try { 3776 mAgent = nHome.findByName(name, mProject.getId()); 3777 } catch (FinderException fe) { 3778 if (this.getProjectConfigTrace()) 3779 trace.error("In BnAgent does not exist " + fe.getMessage()); 3780 throw new HeroException("In BnAgent does not exist"); 3781 } 3782 av = mAgent.getBnAgentValue(); 3783 return av; 3784 } 3785 3786 3797 public BnAgentEdgeValue getAgentEdgeValue(String name) 3798 throws HeroException { 3799 if (this.getProjectConfigTrace()) 3800 trace.info("parameter: name=" + name); 3801 BnAgentEdgeLocalHome nHome; 3802 BnAgentEdgeLocal mAgentEdge; 3803 BnAgentEdgeValue av; 3804 try { 3805 nHome = hero.interfaces.BnAgentEdgeUtil.getLocalHome(); 3806 } catch (javax.naming.NamingException be) { 3807 if (this.getProjectConfigTrace()) 3808 trace.error(be.getMessage()); 3809 throw new HeroException(be.getMessage()); 3810 } 3811 try { 3812 mAgentEdge = nHome.findByName(name, mProject.getId()); 3813 } catch (FinderException fe) { 3814 if (this.getProjectConfigTrace()) 3815 trace.error("In BnAgentEdge does not exist " + fe.getMessage()); 3816 throw new HeroException("In BnAgentEdge does not exist"); 3817 } 3818 av = mAgentEdge.getBnAgentEdgeValue(); 3819 if (this.getProjectConfigTrace()) 3820 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3821 return av; 3822 } 3823 3824 3835 public BnNodeLightValue getNodeLightValue(String name) 3836 throws HeroException { 3837 if (this.getProjectConfigTrace()) 3838 trace.info("parameter: name=" + name); 3839 BnNodeLocalHome nHome; 3840 BnNodeLocal mNode; 3841 BnNodeLightValue nv; 3842 try { 3843 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 3844 } catch (javax.naming.NamingException be) { 3845 if (this.getProjectConfigTrace()) 3846 trace.error(be.getMessage()); 3847 throw new HeroException(be.getMessage()); 3848 } 3849 try { 3850 mNode = nHome.findByName(name, mProject.getId()); 3851 } catch (FinderException fe) { 3852 if (this.getProjectConfigTrace()) 3853 trace.error("In Node does not exist " + fe.getMessage()); 3854 throw new HeroException("In Node does not exist"); 3855 } 3856 nv = mNode.getBnNodeLightValue(); 3857 return nv; 3858 } 3859 3860 3861 3872 public BnEdgeValue getEdgeValue(String name) throws HeroException { 3873 if (this.getProjectConfigTrace()) 3874 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3875 BnEdgeLocalHome eHome; 3876 BnEdgeLocal mEdge; 3877 BnEdgeValue ev; 3878 try { 3879 eHome = hero.interfaces.BnEdgeUtil.getLocalHome(); 3880 } catch (javax.naming.NamingException be) { 3881 if (this.getProjectConfigTrace()) 3882 trace.error(be.getMessage()); 3883 throw new HeroException(be.getMessage()); 3884 } 3885 try { 3886 mEdge = eHome.findByName(name, mProject.getId()); 3887 } catch (FinderException fe) { 3888 if (this.getProjectConfigTrace()) 3889 trace.error("BnEdge does not exist " + fe.getMessage()); 3890 throw new HeroException("BnEdge does not exist"); 3891 } 3892 ev = mEdge.getBnEdgeValue(); 3893 return ev; 3894 } 3895 3896 3906 public String getNodeExecutor(String name) throws HeroException { 3907 if (this.getProjectConfigTrace()) 3908 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3909 BnNodeLocal nd = mProject.getBnNode(name); 3910 return nd.getExecutor(); 3913 } 3914 3915 3933 public int getNodeState(String name) throws HeroException { 3934 if (this.getProjectConfigTrace()) 3935 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3936 BnNodeLocal nd = mProject.getBnNode(name); 3937 return (nd.getState()); 3938 } 3939 3940 3955 public int getNodeType(String name) throws HeroException { 3956 if (this.getProjectConfigTrace()) 3957 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 3958 BnNodeLocal nd = mProject.getBnNode(name); 3959 return (nd.getType()); 3960 } 3961 3962 3971 public Collection getUsers() throws HeroException { 3972 if (this.getProjectConfigTrace()) 3973 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3974 Collection users = mProject.getBnUsers(); 3975 ArrayList result = new ArrayList (); 3976 for (Iterator i = users.iterator(); i.hasNext();) { 3977 result.add(((BnUserLocal) i.next()).getName()); 3978 } 3979 return result; 3980 } 3981 3982 3991 public Collection getAllUsers() throws HeroException { 3992 if (this.getProjectConfigTrace()) 3993 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 3994 UserServiceLocalHome ushome; 3995 UserServiceLocal ul; 3996 Collection users; 3997 try { 3998 ushome = (UserServiceLocalHome) hero.interfaces.UserServiceUtil.getLocalHome(); 3999 } catch (javax.naming.NamingException be) { 4000 if (this.getProjectConfigTrace()) 4001 trace.error(be.getMessage()); 4002 throw new HeroException(be.getMessage()); 4003 } 4004 try { 4005 ul = ushome.create(); 4006 users = ul.findUsers(); 4007 } catch (Exception fe) { 4008 if (this.getProjectConfigTrace()) 4009 trace.error("Error in find users " + fe.getMessage()); 4010 throw new HeroException("Error in find users "); 4011 } 4012 ArrayList result = new ArrayList (); 4013 for (Iterator i = users.iterator(); i.hasNext();) { 4014 Map user = (Map )i.next(); 4015 result.add(user.get("name")); 4016 } 4017 return result; 4018 } 4019 4020 4029 public Collection getNodesNames() throws HeroException { 4030 if (this.getProjectConfigTrace()) 4031 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4032 4033 ArrayList names = new ArrayList (); 4035 Collection nodes = mProject.getBnNodes(); 4036 Iterator i = nodes.iterator(); 4037 while (i.hasNext()) { 4038 BnNodeLocal n = (BnNodeLocal) i.next(); 4039 names.add(n.getName()); 4040 } 4041 return ((Collection ) names); 4042 } 4043 4044 4053 public Collection getEdgesNames() throws HeroException { 4054 if (this.getProjectConfigTrace()) 4055 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4056 ArrayList names = new ArrayList (); 4058 Collection edges = mProject.getBnEdges(); 4059 Iterator i = edges.iterator(); 4060 while (i.hasNext()) { 4061 BnEdgeLocal n = (BnEdgeLocal) i.next(); 4062 names.add(n.getName()); 4063 } 4064 return ((Collection ) names); 4065 } 4066 4067 4077 public String getEdgeInNode(String edgeName) throws HeroException { 4078 if (this.getProjectConfigTrace()) 4079 trace.info("parameter: edgeName" + edgeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4080 BnEdgeLocal e = mProject.getBnEdge(edgeName); 4081 return (((BnNodeLocal) e.getInBnNode()).getName()); 4082 } 4083 4084 4094 public String getEdgeOutNode(String edgeName) throws HeroException { 4095 if (this.getProjectConfigTrace()) 4096 trace.info("parameter: edgeName" + edgeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4097 BnEdgeLocal e = mProject.getBnEdge(edgeName); 4098 return (((BnNodeLocal) e.getOutBnNode()).getName()); 4099 } 4100 4101 4112 public Collection getNodeInEdges(String name) throws HeroException { 4113 if (this.getProjectConfigTrace()) 4114 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 4115 4116 Collection in = new ArrayList (); 4117 BnNodeLocal nd = mProject.getBnNode(name); 4118 4119 Collection edgesIn = nd.getInBnEdges(); 4120 Iterator i = edgesIn.iterator(); 4121 while (i.hasNext()) 4122 in.add(((BnEdgeLocal) i.next()).getName()); 4123 return (in); 4124 } 4125 4126 4137 public Collection getNodeOutEdges(String name) throws HeroException { 4138 if (this.getProjectConfigTrace()) 4139 trace.info("parameter: name=" + name + " process name = " + this.getName()+ " started by " + this.getCaller()); 4140 4141 Collection out = new ArrayList (); 4142 BnNodeLocal nd = mProject.getBnNode(name); 4143 4144 Collection edgesOut = nd.getOutBnEdges(); 4145 Iterator i = edgesOut.iterator(); 4146 while (i.hasNext()) 4147 out.add(((BnEdgeLocal) i.next()).getName()); 4148 return (out); 4149 } 4150 4151 4161 public Collection getNodeProperties(String nodeName) throws HeroException { 4162 if (this.getProjectConfigTrace()) 4163 trace.info("parameter: name=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4164 Collection prp = new ArrayList (); 4165 BnNodePropertyLocal pl; 4166 4167 BnNodeLocal nd = mProject.getBnNode(nodeName); 4168 4169 Collection pls = nd.getBnProperties(); 4170 4171 for (Iterator i = pls.iterator(); i.hasNext();) { 4172 pl = (BnNodePropertyLocal) i.next(); 4173 prp.add(pl.getBnNodePropertyValue()); 4174 } 4175 return (prp); 4176 } 4177 4178 4189 public BnNodePropertyValue getNodeProperty(String nodeName, String key) throws HeroException { 4190 if (this.getProjectConfigTrace()) 4191 trace.info("parameters: node=" + nodeName + " key=" + key + " process name = " + this.getName()+ " started by " + this.getCaller()); 4192 BnNodePropertyLocal pl; 4193 BnNodeLocal nd = mProject.getBnNode(nodeName); 4194 Collection pls = nd.getBnProperties(); 4195 4196 for (Iterator i = pls.iterator(); i.hasNext();) { 4197 pl = (BnNodePropertyLocal) i.next(); 4198 if (pl.getTheKey().equals(key)) 4199 return (pl.getBnNodePropertyValue()); 4200 4201 } 4202 return (null); 4203 } 4204 4205 4215 public BnProjectPropertyValue getProperty(String key) throws HeroException { 4216 if (this.getProjectConfigTrace()) 4217 trace.info("parameter: key=" + key + " process name = " + this.getName()+ " started by " + this.getCaller()); 4218 BnProjectPropertyLocal pl; 4219 Collection pls = mProject.getBnProperties(); 4220 4221 for (Iterator i = pls.iterator(); i.hasNext();) { 4222 pl = (BnProjectPropertyLocal) i.next(); 4223 if (pl.getTheKey().equals(key)) 4224 return (pl.getBnProjectPropertyValue()); 4225 } 4226 return (null); 4227 } 4228 4229 4239 public Collection getNodeHooks(String nodeName) throws HeroException { 4240 if (this.getProjectConfigTrace()) 4241 trace.info("parameter: node=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4242 Collection hk = new ArrayList (); 4243 BnNodeHookLocal pl; 4244 4245 BnNodeLocal nd = mProject.getBnNode(nodeName); 4246 4247 Collection pls = nd.getBnHooks(); 4248 4249 for (Iterator i = pls.iterator(); i.hasNext();) { 4250 pl = (BnNodeHookLocal) i.next(); 4251 hk.add(pl.getBnNodeHookValue()); 4252 } 4253 return (hk); 4254 } 4255 4256 4266 public Collection getNodeInterHooks(String nodeName) throws HeroException { 4267 if (this.getProjectConfigTrace()) 4268 trace.info("parameter: node=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4269 4270 Collection hk = new ArrayList (); 4271 BnNodeInterHookLocal pl; 4272 4273 BnNodeLocal nd = mProject.getBnNode(nodeName); 4274 4275 Collection pls = nd.getBnInterHooks(); 4276 4277 for (Iterator i = pls.iterator(); i.hasNext();) { 4278 pl = (BnNodeInterHookLocal) i.next(); 4279 hk.add(pl.getBnNodeInterHookValue()); 4280 } 4281 return (hk); 4282 } 4283 4284 4293 public Collection getRoleMappers() throws HeroException { 4294 if (this.getProjectConfigTrace()) 4295 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4296 4297 Collection cm = new ArrayList (); 4298 BnRoleMapperLocal mapperL = null; 4299 BnRoleLocal roleL = null; 4300 Collection cr = mProject.getBnRoles(); 4301 4302 for (Iterator i = cr.iterator(); i.hasNext();) { 4303 roleL = (BnRoleLocal) i.next(); 4304 mapperL = roleL.getBnRoleMapper(); 4306 if ( mapperL != null){ 4307 cm.add(mapperL.getBnRoleMapperValue()); 4308 } 4309 } 4310 return (cm); 4311 } 4312 4313 4322 public Collection getInterHooks() throws HeroException { 4323 if (this.getProjectConfigTrace()) 4324 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4325 4326 Collection hk = new ArrayList (); 4327 BnProjectInterHookLocal pl; 4328 Collection pls = mProject.getBnInterHooks(); 4329 4330 for (Iterator i = pls.iterator(); i.hasNext();) { 4331 pl = (BnProjectInterHookLocal) i.next(); 4332 hk.add(pl.getBnProjectInterHookValue()); 4333 } 4334 return (hk); 4335 } 4336 4337 4338 4349 public BnNodeInterHookValue getNodeInterHook(String nodeName, String interHook) throws HeroException { 4350 if (this.getProjectConfigTrace()) 4351 trace.info("parameters: node=" + nodeName + " key=" + interHook + " process name = " + this.getName()+ " started by " + this.getCaller()); 4352 BnNodeInterHookLocal hl; 4353 BnNodeLocal nd = mProject.getBnNode(nodeName); 4354 Collection hls = nd.getBnInterHooks(); 4355 4356 for (Iterator i = hls.iterator(); i.hasNext();) { 4357 hl = (BnNodeInterHookLocal) i.next(); 4358 if (hl.getName().equals(interHook)) 4359 return (hl.getBnNodeInterHookValue()); 4360 } 4361 return (null); 4362 } 4363 4364 4373 public Collection getPropertiesKey() throws HeroException { 4374 if (this.getProjectConfigTrace()) 4375 trace.info("started by " + this.getCaller()); 4376 Collection prp = new ArrayList (); 4377 BnProjectPropertyLocal ppl; 4378 4379 Collection pls = mProject.getBnProperties(); 4380 for (Iterator i = pls.iterator(); i.hasNext();) { 4381 ppl = (BnProjectPropertyLocal) i.next(); 4382 prp.add(ppl.getBnProjectPropertyValue().getTheKey()); 4383 } 4384 return (prp); 4385 } 4386 4387 4395 public Object [] getIterations() throws HeroException { 4396 if (this.getProjectConfigTrace()) 4397 trace.info("started by " + this.getCaller()); 4398 Collection ite = new ArrayList (); 4399 BnIterationLocal itel; 4400 4401 Collection itls = mProject.getBnIterations(); 4402 for (Iterator i = itls.iterator(); i.hasNext();) { 4403 itel = (BnIterationLocal) i.next(); 4404 BnIterationLightValue iv = (BnIterationLightValue)itel.getBnIterationLightValue(); 4405 ite.add(iv); 4406 } 4407 return (ite.toArray()); 4408 } 4409 4410 4418 public String getToIteration(String from) throws HeroException { 4419 if (this.getProjectConfigTrace()) 4420 trace.info("parameters: from=" + from+"started by " + this.getCaller()); 4421 BnIterationLocalHome iteh; 4422 4423 try { 4424 iteh = BnIterationUtil.getLocalHome(); 4425 } catch (javax.naming.NamingException ne) { 4426 if (this.getProjectConfigTrace()) 4427 trace.error(ne.getMessage()); 4428 throw new HeroException(ne.getMessage()); 4429 } 4430 try { 4431 BnIterationLocal it = iteh.findByFrom(mProject.getId(),from); 4432 return(it.getToNode()); 4433 } catch (FinderException fe) { 4434 if (this.getProjectConfigTrace()) 4435 trace.error(fe.getMessage()); 4436 return (null); 4437 } 4438 } 4439 4440 4448 public boolean getIterationExist(String from) throws HeroException { 4449 if (this.getProjectConfigTrace()) 4450 trace.info("parameters: from=" + from+"started by " + this.getCaller()); 4451 BnIterationLocalHome iteh; 4452 4453 try { 4454 iteh = BnIterationUtil.getLocalHome(); 4455 } catch (javax.naming.NamingException ne) { 4456 if (this.getProjectConfigTrace()) 4457 trace.error(ne.getMessage()); 4458 throw new HeroException(ne.getMessage()); 4459 } 4460 try { 4461 BnIterationLocal it = iteh.findByFrom(mProject.getId(),from); 4462 return(true); 4463 } catch (FinderException fe) { 4464 return (false); 4465 } 4466 } 4467 4468 4476 public String getIterationCondition(String from) throws HeroException { 4477 if (this.getProjectConfigTrace()) 4478 trace.info("parameters: from=" + from+"started by " + this.getCaller()); 4479 BnIterationLocalHome iteh; 4480 4481 try { 4482 iteh = BnIterationUtil.getLocalHome(); 4483 } catch (javax.naming.NamingException ne) { 4484 if (this.getProjectConfigTrace()) 4485 trace.error(ne.getMessage()); 4486 throw new HeroException(ne.getMessage()); 4487 } 4488 try { 4489 BnIterationLocal it = iteh.findByFrom(mProject.getId(),from); 4490 return(it.getCondition()); 4491 } catch (FinderException fe) { 4492 if (this.getProjectConfigTrace()) 4493 trace.error(fe.getMessage()); 4494 return (null); 4495 } 4496 } 4497 4498 4507 public Collection getProperties() throws HeroException { 4508 if (this.getProjectConfigTrace()) 4509 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4510 Collection prp = new ArrayList (); 4511 BnProjectPropertyLocal ppl; 4512 4513 Collection pls = mProject.getBnProperties(); 4514 for (Iterator i = pls.iterator(); i.hasNext();) { 4515 ppl = (BnProjectPropertyLocal) i.next(); 4516 prp.add(ppl.getBnProjectPropertyValue()); 4517 } 4518 return (prp); 4519 } 4520 4521 4530 public Collection getHooks() throws HeroException { 4531 if (this.getProjectConfigTrace()) 4532 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4533 Collection hooks = new ArrayList (); 4534 BnProjectHookLocal phl; 4535 4536 Collection hks = mProject.getBnHooks(); 4537 for (Iterator i = hks.iterator(); i.hasNext();) { 4538 phl = (BnProjectHookLocal) i.next(); 4539 hooks.add(phl.getBnProjectHookValue()); 4540 } 4541 return (hooks); 4542 } 4543 4544 4545 4555 public String getProjectNameOfInstance(String instanceName) throws HeroException { 4556 if (this.getProjectConfigTrace()) 4557 trace.info("parameters: instanceName=" + instanceName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4558 if (instanceName.matches(".*"+"_instance"+".*")){ 4559 int i = instanceName.indexOf("_instance"); 4560 return(instanceName.substring(0,i)); 4561 } 4562 else { 4563 throw new HeroException(instanceName+" is not a project instance..."); 4564 } 4565 } 4566 4567 4576 public String getParent() throws HeroException { 4577 if (this.getProjectConfigTrace()) 4578 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4579 return(mProject.getParent()); 4580 } 4581 4582 4591 public boolean isTerminated() { 4592 Collection nodes = mProject.getBnNodes(); 4593 Iterator i = nodes.iterator(); 4594 while (i.hasNext()) { 4595 BnNodeLocal node = (BnNodeLocal) i.next(); 4596 int state = node.getState(); 4597 if (state != hero.interfaces.Constants.Nd.TERMINATED 4598 && state != hero.interfaces.Constants.Nd.EXPIRED 4599 && state != hero.interfaces.Constants.Nd.DEAD) 4600 return false; 4601 } 4602 return true; 4603 } 4604 4605 4609 4620 public StrutsNodeValue getStrutsNode(String nodeName) 4621 throws HeroException { 4622 if (this.getProjectConfigTrace()) 4623 trace.info("parameter: nodeName=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4624 4625 BnNodeLocalHome nHome; 4626 BnNodeLocal n; 4627 try { 4628 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 4629 } catch (javax.naming.NamingException be) { 4630 if (this.getProjectConfigTrace()) 4631 trace.error(be.getMessage()); 4632 throw new HeroException(be.getMessage()); 4633 } 4634 try { 4635 if (this.getProjectConfigTrace()) 4636 trace.info("getStrutsNode: nodeName=" + nodeName); 4637 n = nHome.findByName(nodeName, mProject.getId()); 4638 4639 StrutsNodeValue snv = new StrutsNodeValue(); 4640 snv.setProjectName(mProject.getName()); 4641 snv.setName(n.getName()); 4642 snv.setCreator(n.getCreator()); 4643 snv.setRole(n.getBnRole().getName()); 4644 snv.setState( 4645 hero.interfaces.Constants.Nd.nodeStateName[n.getState()]); 4646 snv.setType(hero.interfaces.Constants.Nd.nodeTypeName[n.getType()]); 4647 if (n.getDescription() != null) 4648 snv.setDescription(n.getDescription()); 4649 if (n.getExecutor() != null) 4650 snv.setExecutor(n.getExecutor()); 4651 snv.setAnticipable(n.getAnticipable()); 4652 4656 4657 if (n.getDeadlines().size() != 0) { 4658 Collection co = n.getDeadlines(); 4659 Iterator it = co.iterator(); 4660 Date date = null; 4661 while (it.hasNext()){ 4662 date = (Date )it.next(); 4663 } 4664 snv.setDeadline(date.toString()); 4665 } 4666 return (snv); 4667 } catch (FinderException fe) { 4668 if (this.getProjectConfigTrace()) 4669 trace.error("In BnNode does not exist " + fe.getMessage()); 4670 throw new HeroException("In BnNode does not exist"); 4671 } 4672 } 4673 4674 4675 4684 public Object [] getNodes() throws HeroException { 4685 if (this.getProjectConfigTrace()) 4686 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4687 ArrayList ns = new ArrayList (); 4689 Collection nodes = new ArrayList (); 4690 4691 nodes = mProject.getBnNodes(); 4692 Iterator i = nodes.iterator(); 4693 while (i.hasNext()) { 4694 BnNodeLocal n = (BnNodeLocal) i.next(); 4695 StrutsNodeValue snv = new StrutsNodeValue(); 4696 snv.setProjectName(mProject.getName()); 4697 snv.setName(n.getName()); 4698 snv.setCreator(n.getCreator()); 4699 snv.setRole(n.getBnRole().getName()); 4700 snv.setState(Constants.Nd.nodeStateName[n.getState()]); 4701 snv.setType(Constants.Nd.nodeTypeName[n.getType()]); 4702 if (n.getDescription() != null) 4703 snv.setDescription(n.getDescription()); 4704 if (n.getExecutor() != null) 4705 snv.setExecutor(n.getExecutor()); 4706 snv.setAnticipable(n.getAnticipable()); 4707 4711 if (n.getDeadlines().size() != 0) { 4712 Collection co = n.getDeadlines(); 4713 Iterator it = co.iterator(); 4714 Date date = null; 4715 while (it.hasNext()){ 4716 date = (Date )it.next(); 4717 } 4718 snv.setDeadline(date.toString()); 4719 } 4720 4721 ns.add(snv); 4722 } 4723 return (ns.toArray()); 4724 } 4725 4726 4736 public Collection getStrutsNodes() throws HeroException { 4737 if (this.getProjectConfigTrace()) 4738 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4739 4740 ArrayList strutsNodes = new ArrayList (); 4742 Collection nodes = mProject.getBnNodes(); 4743 Iterator i = nodes.iterator(); 4744 while (i.hasNext()) { 4745 BnNodeLocal n = (BnNodeLocal) i.next(); 4746 StrutsNodeValue snv = new StrutsNodeValue(); 4747 snv.setName(n.getName()); 4748 snv.setCreator(n.getCreator()); 4749 snv.setRole(n.getBnRole().getName()); 4750 snv.setState( 4751 hero.interfaces.Constants.Nd.nodeStateName[n.getState()]); 4752 snv.setType(hero.interfaces.Constants.Nd.nodeTypeName[n.getType()]); 4753 snv.setDescription(n.getDescription()); 4754 if (n.getExecutor() != null) 4755 snv.setExecutor(n.getExecutor()); 4756 snv.setAnticipable(n.getAnticipable()); 4757 4761 if (n.getDeadlines().size() != 0) { 4762 Collection co = n.getDeadlines(); 4763 Iterator it = co.iterator(); 4764 Date date = null; 4765 while (it.hasNext()){ 4766 date = (Date )it.next(); 4767 } 4768 snv.setDeadline(date.toString()); 4769 } 4770 strutsNodes.add(snv); 4771 } 4772 return ((Collection ) strutsNodes); 4773 } 4774 4775 4786 public Collection getStrutsNodeEdges(String nodeName) 4787 throws HeroException { 4788 if (this.getProjectConfigTrace()) 4789 trace.info("parameter: nodeName=" + nodeName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4790 4791 BnNodeLocalHome nHome; 4792 BnNodeLocal mNode; 4793 BnNodeValue nv; 4794 4795 ArrayList edges = new ArrayList (); 4797 4798 try { 4799 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 4800 } catch (javax.naming.NamingException be) { 4801 if (this.getProjectConfigTrace()) 4802 trace.error(be.getMessage()); 4803 throw new HeroException(be.getMessage()); 4804 } 4805 try { 4806 mNode = nHome.findByName(nodeName, mProject.getId()); 4807 } catch (FinderException fe) { 4808 if (this.getProjectConfigTrace()) 4809 trace.error("In Node does not exist " + fe.getMessage()); 4810 throw new HeroException("In Node does not exist"); 4811 } 4812 Collection in = mNode.getInBnEdges(); 4813 Collection out = mNode.getOutBnEdges(); 4814 4815 Iterator iin = in.iterator(); 4816 while (iin.hasNext()) { 4817 StrutsEdgeValue sev = new StrutsEdgeValue(); 4818 hero.interfaces.BnEdgeLocal actualEdge =(hero.interfaces.BnEdgeLocal) iin.next(); 4819 sev.setState(hero.interfaces.Constants.Ed.edgeStateName[actualEdge.getState()]); 4820 sev.setInNode(((BnNodeLocal) actualEdge.getInBnNode()).getName()); 4821 sev.setOutNode(((BnNodeLocal) actualEdge.getOutBnNode()).getName()); 4822 edges.add(sev); 4823 } 4824 4825 Iterator iout = out.iterator(); 4826 while (iout.hasNext()) { 4827 StrutsEdgeValue sev = new StrutsEdgeValue(); 4828 BnEdgeLocal actualEdge = (BnEdgeLocal) iout.next(); 4829 sev.setState(hero.interfaces.Constants.Ed.edgeStateName[actualEdge.getState()]); 4830 sev.setInNode(((BnNodeLocal) actualEdge.getInBnNode()).getName()); 4831 sev.setOutNode(((BnNodeLocal) actualEdge.getOutBnNode()).getName()); 4832 edges.add(sev); 4833 } 4834 return ((Collection ) edges); 4835 } 4836 4837 4847 public Collection getStrutsEdges() throws HeroException { 4848 if (this.getProjectConfigTrace()) 4849 trace.info(" process name = " + this.getName()+ " started by " + this.getCaller()); 4850 4851 ArrayList strutsEdges = new ArrayList (); 4853 Collection edges = mProject.getBnEdges(); 4854 Iterator i = edges.iterator(); 4855 while (i.hasNext()) { 4856 BnEdgeLocal e = (BnEdgeLocal) i.next(); 4857 StrutsEdgeValue sev = new StrutsEdgeValue(); 4858 sev.setName(e.getName()); 4859 sev.setState( 4860 hero.interfaces.Constants.Ed.edgeStateName[e.getState()]); 4861 sev.setInNode(e.getInBnNode().getName()); 4862 sev.setOutNode(e.getOutBnNode().getName()); 4863 strutsEdges.add(sev); 4864 } 4865 return ((Collection ) strutsEdges); 4866 } 4867 4868 4877 public void importProject(String projectName) throws HeroException { 4878 if (this.getProjectConfigTrace()) 4879 trace.info("parameter: project=" + projectName + " process name = " + this.getName()+ " started by " + this.getCaller()); 4880 importProject(projectName, ""); 4881 } 4882 4883 4887 4897 public void importProject(String projectName, String prefix) 4898 throws HeroException { 4899 if (this.getProjectConfigTrace()) 4900 trace.info("parameters: project=" + projectName + " prefix=" + prefix + " process name = " + this.getName()+ " started by " + this.getCaller()); 4901 try { 4902 BnProjectLocalHome opHome = hero.interfaces.BnProjectUtil.getLocalHome(); 4903 BnProjectLocal oldProject = opHome.findByName(projectName); 4904 String actualProject = this.getName(); 4905 4906 BnProjectValue pv = oldProject.getBnProjectValue(); 4907 4908 mProject.setType(oldProject.getType()); 4909 mProject.setStatus(Constants.Pj.ACTIVE); 4910 4911 Collection props = oldProject.getBnProperties(); 4913 for (Iterator i = props.iterator(); i.hasNext();) { 4914 BnProjectPropertyLocal prop = (BnProjectPropertyLocal) i.next(); 4915 this.setProperty(prop.getTheKey(),prop.getTheValue()); 4916 } 4917 4918 Collection hooks = oldProject.getBnInterHooks(); 4920 for (Iterator i = hooks.iterator(); i.hasNext();) { 4921 BnProjectInterHookLocal hk = (BnProjectInterHookLocal) i.next(); 4922 this.addInterHook(hk.getName(),hk.getEvent(),hk.getType(),hk.getScript()); 4923 } 4924 4925 Collection pHooks = oldProject.getBnHooks(); 4927 for (Iterator i = pHooks.iterator(); i.hasNext();) { 4928 BnProjectHookLocal hk = (BnProjectHookLocal) i.next(); 4929 this.addHook(hk.getName(),hk.getEvent(),hk.getType()); 4930 } 4931 4932 Collection roles = oldProject.getBnRoles(); 4933 for (Iterator i = roles.iterator(); i.hasNext();) 4934 { 4935 BnRoleLocal ro = (BnRoleLocal)i.next(); 4936 String roleName = ro.getName(); 4937 if (!containsRole(roleName)) 4939 this.addRole(roleName, ro.getDescription()); 4940 if (ro.getBnRoleMapper()!=null) 4941 this.addRoleMapper(ro.getName(),ro.getBnRoleMapper().getName(),ro.getBnRoleMapper().getType()); 4942 } 4943 4944 Collection allNodes = oldProject.getBnNodes(); 4946 Iterator no = allNodes.iterator(); 4947 while (no.hasNext()) { 4948 BnNodeLocal node = (BnNodeLocal) no.next(); 4949 if (node.getInBnEdges().isEmpty()&& node.getOutBnEdges().isEmpty()) { 4950 String newNodeName=node.getName(); 4952 if (node.getType() == hero.interfaces.Constants.Nd.SUB_PROCESS_NODE) { 4953 Iterator pr = subProjects.iterator(); 4954 boolean exit = false; 4955 while (pr.hasNext()) { 4956 String nodePr = (String ) pr.next(); 4957 if (nodePr.equals(newNodeName)) { 4958 newNodeName = actualProject + nodePr; 4959 exit = true; 4960 } 4961 } 4962 try { 4963 if (!exit) { 4964 this.initProject(newNodeName, actualProject + newNodeName); 4965 subProjects.add(newNodeName); 4966 newNodeName = actualProject + newNodeName; 4967 mProject = opHome.findByName(actualProject); 4968 } 4969 } catch (Exception ce) { 4970 if (this.getProjectConfigTrace()) 4971 trace.error(ce.getMessage()); 4972 ce.printStackTrace(); 4973 } 4974 } 4975 4976 this.addNode(newNodeName, node.getType()); 4977 if (!node.getAnticipable()) 4978 this.setNodeTraditional(newNodeName); 4979 4985 4986 if (node.getDeadlines().size()!=0){ 4988 Collection co = node.getDeadlines(); 4989 Iterator it = co.iterator(); 4990 ArrayList ar = new ArrayList (); 4991 while (it.hasNext()){ 4992 Date date = (Date )it.next(); 4993 ar.add(new Long (date.getTime())); 4994 } 4995 this.setNodeDeadlines(newNodeName,ar); 4996 } 4997 if (node.getRelativeDeadlines().size()!=0){ 4999 Collection co = node.getRelativeDeadlines(); 5000 Iterator it = co.iterator(); 5001 ArrayList ar = new ArrayList (); 5002 while (it.hasNext()){ 5003 Date date = (Date )it.next(); 5004 ar.add(new Long (date.getTime())); 5005 } 5006 this.setNodeRelativeDeadlines(newNodeName,ar); 5007 } 5008 this.setNodeRole(newNodeName,node.getBnRole().getName()); 5009 this.setNodeDescription(newNodeName, node.getDescription()); 5010 5011 Collection nodeHooks = node.getBnInterHooks(); 5013 for (Iterator j = nodeHooks.iterator(); j.hasNext();) { 5014 BnNodeInterHookLocal nh = (BnNodeInterHookLocal) j.next(); 5015 try { 5016 this.addNodeInterHook(newNodeName,nh.getName(),nh.getEvent(),nh.getType(),nh.getScript()); 5017 } catch (Exception ih) { 5018 if (this.getProjectConfigTrace()) 5019 trace.error(ih.getMessage()); 5020 }; } 5022 5023 Collection nHooks = node.getBnHooks(); 5025 for (Iterator j = nHooks.iterator(); j.hasNext();) { 5026 BnNodeHookLocal nh = (BnNodeHookLocal) j.next(); 5027 try { 5028 this.addNodeHook(newNodeName,nh.getName(),nh.getEvent(),nh.getType()); 5029 } catch (Exception ih) {}; } 5031 } 5032 } 5033 5034 Collection edges = oldProject.getBnEdges(); 5035 Iterator e = edges.iterator(); 5036 while (e.hasNext()) 5037 { 5038 BnEdgeLocal ed = (BnEdgeLocal)e.next(); 5039 BnNodeLocal nodeIn = ed.getInBnNode(); 5040 BnNodeLocal nodeOut = ed.getOutBnNode(); 5041 BnNodeLocal[] nodes = { nodeIn, nodeOut }; 5042 String newNodeNameIn = null; 5043 String newNodeNameOut = null; 5044 for (int n = 0; n < nodes.length; n++) { 5045 String newNodeName = nodes[n].getName(); 5046 if (nodes[n].getType()== hero.interfaces.Constants.Nd.SUB_PROCESS_NODE){ 5048 Iterator pr = subProjects.iterator(); 5049 boolean exit = false; 5050 while (pr.hasNext()) { 5051 String nodePr = (String ) pr.next(); 5052 if (nodePr.equals(newNodeName)) { 5053 newNodeName = actualProject+nodePr; 5054 exit = true; 5055 } 5056 } 5057 try { 5058 if (!exit) { 5059 this.initProject(newNodeName,actualProject+newNodeName); 5060 subProjects.add(newNodeName); 5061 newNodeName=actualProject+newNodeName; 5062 mProject = opHome.findByName(actualProject); 5063 } 5064 }catch(Exception ce){ 5065 if (this.getProjectConfigTrace()) 5066 trace.error(ce.getMessage()); 5067 ce.printStackTrace(); 5068 } 5069 } 5070 try { 5071 this.addNode(newNodeName, nodes[n].getType()); 5072 if (!nodes[n].getAnticipable()) 5073 this.setNodeTraditional(newNodeName); 5074 5080 5081 if (nodes[n].getDeadlines().size()!=0){ 5083 Collection co = nodes[n].getDeadlines(); 5084 Iterator it = co.iterator(); 5085 ArrayList ar = new ArrayList (); 5086 while (it.hasNext()){ 5087 Date date = (Date )it.next(); 5088 ar.add(new Long (date.getTime())); 5089 } 5090 this.setNodeDeadlines(newNodeName,ar); 5091 } 5092 if (nodes[n].getRelativeDeadlines().size()!=0){ 5094 Collection co = nodes[n].getRelativeDeadlines(); 5095 Iterator it = co.iterator(); 5096 ArrayList ar = new ArrayList (); 5097 while (it.hasNext()){ 5098 Date date = (Date )it.next(); 5099 ar.add(new Long (date.getTime())); 5100 } 5101 this.setNodeRelativeDeadlines(newNodeName,ar); 5102 } 5103 this.setNodeRole(newNodeName,nodes[n].getBnRole().getName()); 5104 this.setNodeDescription(newNodeName,nodes[n].getDescription()); 5105 5106 BnNodeLocal nd = oldProject.getBnNode(nodes[n].getName()); 5108 Collection nodeHooks = nd.getBnInterHooks(); 5109 for (Iterator j = nodeHooks.iterator(); j.hasNext();) { 5110 BnNodeInterHookLocal nh = (BnNodeInterHookLocal) j.next(); 5111 try { 5112 this.addNodeInterHook(newNodeName,nh.getName(),nh.getEvent(),nh.getType(),nh.getScript()); 5113 } catch (Exception ih) { 5114 if (this.getProjectConfigTrace()) 5115 trace.error(ih.getMessage()); 5116 }; } 5118 5119 Collection nHooks = nd.getBnHooks(); 5121 for (Iterator j = nHooks.iterator(); j.hasNext();) { 5122 BnNodeHookLocal nh = (BnNodeHookLocal) j.next(); 5123 try { 5124 this.addNodeHook(newNodeName,nh.getName(),nh.getEvent(),nh.getType()); 5125 } catch (Exception ih) {}; } 5127 5128 } catch (Exception an) { 5129 if (this.getProjectConfigTrace()) 5130 trace.error(an.getMessage()); 5131 }; if (n == 0) 5133 newNodeNameIn = newNodeName; 5134 else 5135 newNodeNameOut = newNodeName; 5136 } 5137 5138 String edgeName = this.addEdge(newNodeNameIn, newNodeNameOut); 5139 this.setEdgeCondition(edgeName, ed.getCondition()); 5140 } 5141 5142 Collection ites = oldProject.getBnIterations(); 5144 Iterator iterations = ites.iterator(); 5145 while (iterations.hasNext()) 5146 { 5147 BnIterationLocal ite = (BnIterationLocal)iterations.next(); 5148 this.addIteration(ite.getFromNode(),ite.getToNode(),ite.getCondition()); 5149 } 5150 5151 5153 BnUserLightValue[] users = pv.getBnUsers(); 5154 int uIndex = 0; 5155 for (uIndex=0;uIndex<users.length;uIndex++) 5156 { 5157 BnUserLightValue userP = users[uIndex]; 5158 try { 5159 this.addUser(userP.getName()); 5160 } catch (Exception eUser) { 5161 if (this.getProjectConfigTrace()) 5162 trace.error(eUser.getMessage()); 5163 jms.sendProjectEvent(ADDUSERPROJECT,mProject.getName(),userP.getName()); 5164 } 5165 mProject = oldProject; 5166 Collection userRoles = this.getUserRolesInProjectNames(userP.getName()); 5167 mProject = opHome.findByName(actualProject); 5168 Iterator ir = userRoles.iterator(); 5169 while (ir.hasNext()) 5170 this.setUserRole(userP.getName(),(String ) ir.next()); 5171 } 5172 5173 5174 } catch (FinderException e) { 5175 if (this.getProjectConfigTrace()) 5176 trace.error("Cannot find project " + e.getMessage()); 5177 throw new HeroException("Cannot find project " + e.getMessage()); 5178 } catch (javax.naming.NamingException ne) { 5179 if (this.getProjectConfigTrace()) 5180 trace.error(ne.getMessage()); 5181 throw new HeroException(ne.getMessage()); 5182 } 5183 } 5184 5185 5196 public String importInstance(BonitaProjectValue pv, String instance) 5197 throws HeroException { 5198 BnUserLocalHome uhome = null; 5199 BnRoleLocalHome rhome = null; 5200 BnProjectConfigLocalHome pchome = null; 5201 BnProjectLocalHome opHome = null; 5202 UserServiceLocalHome ushome; 5203 5204 if (this.getProjectConfigTrace()) 5205 trace.info("parameter: project=" + pv.getName() + " process name = " + this.getName()+ " started by " + this.getCaller()); 5206 try { 5207 uhome = hero.interfaces.BnUserUtil.getLocalHome(); 5208 rhome = hero.interfaces.BnRoleUtil.getLocalHome(); 5209 pchome = hero.interfaces.BnProjectConfigUtil.getLocalHome(); 5210 opHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5211 5212 String creator = this.getCaller(); 5213 mProject = opHome.create(instance,creator); 5214 mProject.setType(Constants.Pj.INSTANCE); 5215 mProject.setStatus(Constants.Pj.ACTIVE); 5216 5217 instance=mProject.getName(); 5218 mProject.setParent(mProject.getName()); mProject.setModel(pv); 5220 mProject.setBnProjectConfig(pchome.create(pv.getProjectConfig(),instance)); 5221 5222 BnUserLocal user = uhome.findByName(creator); 5223 mProject.getBnUsers().add(user); 5224 BnRoleValue rv = new BnRoleValue(); 5226 rv.setName(hero.interfaces.Constants.ADMIN); 5227 rv.setDescription("the admin role"); 5228 BnRoleLocal role = rhome.create(rv); 5229 mProject.getBnRoles().add(role); 5230 user.getBnRoles().add(role); 5232 5233 rv = new BnRoleValue(); 5235 rv.setName(hero.interfaces.Constants.INITIALROLE); 5236 rv.setDescription("the initial role for nodes"); 5237 role = rhome.create(rv); 5238 mProject.getBnRoles().add(role); 5239 5240 if (!creator.equals(Constants.ADMIN)) 5241 { 5242 rv = new BnRoleValue(); 5244 rv.setName(creator); 5245 rv.setDescription(creator+" user role"); 5246 role = rhome.create(rv); 5247 mProject.getBnRoles().add(role); 5248 user.getBnRoles().add(role); 5250 } 5251 5252 Collection propers = pv.getProperties(); 5254 Iterator props = propers.iterator(); 5255 while (props.hasNext()) 5256 { 5257 BonitaPropertyValue prop = (BonitaPropertyValue) props.next(); 5258 this.setPropertyPossibleValues(prop.getKey(),prop.getPossibleValues()); 5259 if (prop.getValue()!=null || prop.getPossibleValues().size()==0) 5260 this.setProperty(prop.getKey(),prop.getValue()); 5261 5262 } 5263 Collection roles = pv.getRoles(); 5265 Iterator allRoles = roles.iterator(); 5266 while (allRoles.hasNext()) 5267 { 5268 BonitaRoleValue ro = (BonitaRoleValue)allRoles.next(); 5269 String roleName = ro.getName(); 5270 if (!containsRole(roleName)) 5272 this.addRole(roleName, ro.getDescription()); 5273 if (ro.getMapper()!=null) 5274 this.addRoleMapper(ro.getName(),ro.getMapper().getName(),ro.getMapper().getType()); 5275 } 5276 5277 Collection nds = pv.getNodes(); 5279 Iterator nodes = nds.iterator(); 5280 while (nodes.hasNext()) 5281 { 5282 BonitaNodeValue nd = (BonitaNodeValue)nodes.next(); 5283 if (nd.getInEdges().isEmpty()) 5284 { 5285 String newNodeName = nd.getName(); 5286 if (nd.getType() == Constants.Nd.SUB_PROCESS_NODE) { 5288 newNodeName = this.instantiateProject(newNodeName); 5289 mProject.setParent(instance); 5290 mProject = opHome.findByName(instance); 5291 } 5292 5293 this.addNode(newNodeName,nd.getType()); 5294 if (!nd.getAnticipable()) 5295 this.setNodeTraditional(newNodeName); 5296 5297 if (nd.getDeadlines().size()!=0){ 5299 Collection co = nd.getDeadlines(); 5300 Iterator it = co.iterator(); 5301 ArrayList ar = new ArrayList (); 5302 while (it.hasNext()){ 5303 Date date = (Date )it.next(); 5304 ar.add(new Long (date.getTime())); 5305 } 5306 this.setNodeDeadlines(newNodeName,ar); 5307 } 5308 if (nd.getRelativeDeadlines().size()!=0){ 5310 Collection co = nd.getRelativeDeadlines(); 5311 Iterator it = co.iterator(); 5312 ArrayList ar = new ArrayList (); 5313 while (it.hasNext()){ 5314 Date date = (Date )it.next(); 5315 ar.add(new Long (date.getTime())); 5316 } 5317 this.setNodeRelativeDeadlines(newNodeName,ar); 5318 } 5319 this.setNodeRole(newNodeName,nd.getRole()); 5320 this.setNodeDescription(newNodeName,nd.getDescription()); 5321 if (!nd.getProjectParent().equals(nd.getProjectName())) 5322 this.setNodeState(mProject.getBnNode(newNodeName),Constants.Nd.INITIAL); 5323 5324 if (nd.getPerformer()!=null) 5325 this.addNodePerformerAssign(newNodeName,nd.getPerformer().getName(),nd.getPerformer().getType(),nd.getPerformer().getPropertyName()); 5326 5327 Collection nodeProp = nd.getProperties(); 5328 Iterator nodeProps = nodeProp.iterator(); 5329 while (nodeProps.hasNext()) 5330 { 5331 BonitaPropertyValue ndProp = (BonitaPropertyValue)nodeProps.next(); 5332 this.setNodePropertyPossibleValues(newNodeName,ndProp.getKey(),ndProp.getPossibleValues()); 5333 if (ndProp.getValue()!=null || ndProp.getPossibleValues().size()==0) 5334 this.setNodeProperty(newNodeName,ndProp.getKey(),ndProp.getValue(),ndProp.getPropagate()); 5335 } 5336 5337 if (nd.getDeadlines().size()!=0 || nd.getRelativeDeadlines().size()!=0) 5339 BonitaDeadline.getInstance().startDeadlines(newNodeName, mProject.getId()); 5340 5341 Collection iterations = pv.getIterations(); 5343 Iterator iter = iterations.iterator(); 5344 while (iter.hasNext()) 5345 { 5346 BonitaIterationValue iteration = (BonitaIterationValue) iter.next(); 5347 String from = iteration.getFromNode(); 5348 if (newNodeName.matches(from+"_instance.*") || newNodeName.equals(from)) 5349 { 5350 this.addIteration(newNodeName, newNodeName,iteration.getCondition()); 5351 break; 5352 } 5353 } 5354 if ((nd.getType()==Constants.Nd.SUB_PROCESS_NODE || nd.getType()==Constants.Nd.AND_JOIN_AUTOMATIC_NODE || nd.getType()==Constants.Nd.OR_JOIN_AUTOMATIC_NODE) 5355 && (nd.getProjectParent().equals(nd.getProjectName()))) 5356 { 5357 EngineLocalHome enghome; 5358 try { 5359 enghome = hero.interfaces.EngineUtil.getLocalHome(); 5360 EngineLocal engine = enghome.create(); 5361 engine.startActivity(mProject.getName(), newNodeName); 5362 } catch (javax.naming.NamingException ne) { 5363 throw new HeroException(ne.getMessage()); 5364 } 5365 } 5366 5367 } 5368 } 5369 Collection users = pv.getUsers(); 5370 Iterator usersI = users.iterator(); 5371 while(usersI.hasNext()) 5372 { 5373 BonitaUserValue userP = (BonitaUserValue)usersI.next(); 5374 try { 5375 this.addUserLocal(userP.getName()); 5376 } catch (Exception eUser) { 5377 if (this.getProjectConfigTrace()) 5378 trace.error(eUser.getMessage()); 5379 } 5380 Collection userRoles = userP.getRoles(); 5381 Iterator ir = userRoles.iterator(); 5382 while (ir.hasNext()) 5383 { 5384 String roleName = (String ) ir.next(); 5385 this.setUserRoleLocal(userP.getName(),roleName); 5386 } 5387 } 5388 mProject.setCreationDate(new Date ()); 5389 5390 this.mapRole(); 5392 jms.sendProjectEvent(ADDUSERPROJECT, instance, creator); 5393 return instance; 5394 } catch (javax.naming.NamingException ne) { 5395 if (this.getProjectConfigTrace()) 5396 trace.error(ne.getMessage()); 5397 throw new HeroException(ne.getMessage()); 5398 } catch (Exception ce) {ce.printStackTrace(); 5399 if (this.getProjectConfigTrace()) 5400 trace.error("Instantiate process error " + ce.getMessage()); 5401 throw new HeroException("Instantiate process error " + ce.getMessage()); 5402 } 5403 } 5404 5405 5414 public void initProject(String projectName) throws HeroException { 5415 Context lContext; 5416 UserServiceLocalHome ushome = null; 5417 mProject=null; 5418 if (this.getProjectConfigTrace()) 5419 trace.info("parameter: project=" + projectName + " started by " + this.getCaller()); 5420 if (projectName.equals("")) 5421 throw new HeroException("Project name can not be empty..."); 5422 try { 5423 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 5424 5425 UserServiceLocal ul = ushome.create(); 5426 ul.findUserLocal(this.getCaller()); 5427 } catch (Exception ce) { 5428 if (this.getProjectConfigTrace()) 5429 trace.error(ce.getMessage()); 5430 throw new HeroException(ce.getMessage()); 5431 } 5432 try { 5433 if (!this.isInProject(projectName)) 5434 throw new AccessException("You don't have access to this project !!"); 5435 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5436 this.mProject = pHome.findByName(projectName); 5437 } catch (javax.naming.NamingException ne) { 5438 if (this.getProjectConfigTrace()) 5439 trace.error(ne.getMessage()); 5440 throw new HeroException(ne.getMessage()); 5441 } catch (javax.ejb.FinderException fe) { 5442 try{ 5443 this.createProcess(projectName); mProject.setType(Constants.Pj.COOPERATIVE); 5445 mProject.setStatus(Constants.Pj.ACTIVE); 5446 }catch (CreateException ce){ 5447 if (this.getProjectConfigTrace()) 5448 trace.error(ce.getMessage()); 5449 throw new HeroException(ce.getMessage()); 5450 } 5451 } 5452 } 5453 5454 5463 public void initModel(String modelName) throws HeroException { 5464 Context lContext; 5465 UserServiceLocalHome ushome = null; 5466 mProject=null; 5467 if (this.getProjectConfigTrace()) 5468 trace.info("parameter: project=" + modelName + " started by " + this.getCaller()); 5469 if (modelName.equals("")) 5470 throw new HeroException("Project name can not be empty..."); 5471 try { 5472 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 5473 UserServiceLocal ul = ushome.create(); 5474 ul.findUserLocal(this.getCaller()); 5475 } catch (Exception ce) { 5476 if (this.getProjectConfigTrace()) 5477 trace.error(ce.getMessage()); 5478 throw new HeroException(ce.getMessage()); 5479 } 5480 try { 5481 if (!this.isInProject(modelName)) 5482 throw new AccessException("You don't have access to this project !!"); 5483 5484 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5485 this.mProject = pHome.findByName(modelName); 5486 } catch (javax.naming.NamingException ne) { 5487 if (this.getProjectConfigTrace()) 5488 trace.error(ne.getMessage()); 5489 throw new HeroException(ne.getMessage()); 5490 } catch (javax.ejb.FinderException fe) { 5491 try{ 5492 this.createProcess(modelName); mProject.setType(Constants.Pj.MODEL); 5494 mProject.setStatus(Constants.Pj.ACTIVE); 5495 }catch (CreateException ce){ 5496 if (this.getProjectConfigTrace()) 5497 trace.error(ce.getMessage()); 5498 throw new HeroException(ce.getMessage()); 5499 } 5500 } 5501 } 5502 5503 5514 public void initProject(String oldProject, String newProject) 5515 throws CreateException { 5516 try{ 5517 if (this.getProjectConfigTrace()) 5518 trace.info("parameters: oldProject="+ oldProject+ " newProject="+ newProject + " started by " + this.getCaller()); 5519 Context lContext; 5520 BnUserLocalHome uhome = null; 5521 BnRoleLocalHome rhome = null; 5522 BnProjectConfigLocalHome pchome = null; 5523 UserServiceLocalHome ushome; 5524 try { 5525 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 5526 UserServiceLocal ul = ushome.create(); 5527 ul.findUserLocal(this.getCaller()); 5528 } catch (Exception ce) { 5529 if (this.getProjectConfigTrace()) 5530 trace.error(ce.getMessage()); 5531 throw new HeroException(ce.getMessage()); 5532 } 5533 if (oldProject.equals("") || newProject.equals("")) 5534 throw new CreateException ("Project name can not be empty..."); 5535 try { 5536 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5537 uhome = hero.interfaces.BnUserUtil.getLocalHome(); 5538 rhome = hero.interfaces.BnRoleUtil.getLocalHome(); 5539 pchome = hero.interfaces.BnProjectConfigUtil.getLocalHome(); 5540 mProject = pHome.findByName(newProject); 5541 } catch (javax.naming.NamingException ne) { 5542 if (this.getProjectConfigTrace()) 5543 trace.error(ne.getMessage()); 5544 throw new CreateException (ne.getMessage()); 5545 } catch (javax.ejb.FinderException fe) { 5546 if (this.getProjectConfigTrace()) 5547 trace.error(fe.getMessage()); 5548 try { 5550 String creator = this.getCaller(); 5551 mProject = pHome.create(newProject, creator); 5552 mProject.setParent(newProject); 5553 BonitaProjectValue pv = new BonitaProjectValue(); 5554 pv.setName(newProject); 5555 mProject.setModel(pv); 5556 5557 BnUserLocal user = uhome.findByName(creator); 5558 mProject.getBnUsers().add(user); 5559 mProject.setBnProjectConfig(pchome.create()); 5560 5561 BnRoleValue rv = new BnRoleValue(); 5563 rv.setName(hero.interfaces.Constants.ADMIN); 5564 rv.setDescription("the admin role"); 5565 BnRoleLocal role = rhome.create(rv); 5566 mProject.getBnRoles().add(role); 5567 user.getBnRoles().add(role); 5569 5570 rv = new BnRoleValue(); 5572 rv.setName(hero.interfaces.Constants.INITIALROLE); 5573 rv.setDescription("the initial role for nodes"); 5574 role = rhome.create(rv); 5575 mProject.getBnRoles().add(role); 5576 5577 if (!creator.equals(Constants.ADMIN)) 5578 { 5579 rv = new BnRoleValue(); 5581 rv.setName(creator); 5582 rv.setDescription(creator+" user role"); 5583 role = rhome.create(rv); 5584 mProject.getBnRoles().add(role); 5585 user.getBnRoles().add(role); 5587 } 5588 5589 importProject(oldProject); 5590 mProject.setCreationDate(new Date ()); 5591 5592 jms.sendProjectEvent(ADDUSERPROJECT, newProject, creator); 5593 5594 } catch (FinderException fie) { 5595 if (this.getProjectConfigTrace()) 5596 trace.error(fie.getMessage()); 5597 throw new CreateException (fie.getMessage()); 5598 } catch (InvalidValueException ie) { 5599 if (this.getProjectConfigTrace()) 5600 trace.error(ie.getMessage()); 5601 throw new CreateException (ie.getMessage()); 5602 } catch (HeroException he) { 5603 if (this.getProjectConfigTrace()) 5604 trace.error(he.getMessage()); 5605 throw new CreateException (he.getMessage()); 5606 } 5607 } 5608 }catch(HeroException traceEx){traceEx.printStackTrace();} 5609 } 5610 5611 5621 public String instantiateProject(String project) throws CreateException { 5622 Context lContext; 5623 String instance=null; 5624 UserServiceLocalHome ushome; 5625 try{ 5626 if (this.getProjectConfigTrace()) 5627 trace.info("parameter: project=" + project + " started by " + this.getCaller()); 5628 try { 5629 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5630 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 5631 UserServiceLocal ul = ushome.create(); 5632 ul.findUserLocal(this.getCaller()); 5633 } catch (Exception ce) { 5634 if (this.getProjectConfigTrace()) 5635 trace.error(ce.getMessage()); 5636 throw new HeroException(ce.getMessage()); 5637 } 5638 if (project.equals("")) 5639 throw new CreateException ("Project name can not be empty !!"); 5640 if (project.matches(".*_instance.*")) 5641 throw new CreateException ("You cannot instantiate an instance !!"); 5642 try { 5643 try { 5644 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5645 mProject = pHome.findByName(project); 5646 } catch (javax.naming.NamingException ne) { 5647 throw new BonitaServiceException(ne.getMessage()); 5648 } catch (javax.ejb.FinderException fe) {throw new BonitaServiceException(fe.getMessage());} 5649 5650 BonitaProjectValue pv=null; 5651 if (mProject.getModel().getType() != null) pv=mProject.getModel(); 5653 else 5654 { 5655 pv = BonitaProjectLocator.generateProjectValue(project); 5656 mProject.setModel(pv); 5657 } 5658 if (!pv.getType().equals(Constants.Pj.MODEL)) 5659 throw new BonitaServiceException("This process is not instantiable. Only model processes can be instantiated !!"); 5660 5661 if (pv.getStatus().equals(Constants.Pj.HIDDEN)) 5662 throw new BonitaServiceException("This model is not ACTIVE. Active the model before instantiate it !!"); 5663 5664 instance=project+"_instance"; 5665 instance=((ProjectSessionLocal)mContext.getEJBLocalObject()).importInstance(pv, instance); 5666 } catch (BonitaServiceException e) { 5667 throw new CreateException (e.getMessage()); 5668 } 5669 5670 if (this.getProjectConfigLog()) 5671 thelog.debug("User: "+ this.getCaller() + " instantiates project: " + project + ". " +instance + " is created"); 5672 }catch(HeroException traceEx){traceEx.printStackTrace();} 5673 return (instance); 5674 } 5675 5676 5684 5685 public void ejbCreate() throws CreateException { 5686 this.caller = mContext.getCallerPrincipal().getName(); 5687 } 5688 5689 5692 public void ejbPostCreate(String oldProject, String newProject) 5693 throws CreateException , RemoteException { 5694 } 5695 5696 5699 public void setSessionContext(final javax.ejb.SessionContext context) { 5700 mContext = context; 5701 try{ 5702 JMSServicesSessionLocalHome home = JMSServicesSessionUtil.getLocalHome(); 5703 this.jms=home.create(); 5704 this.bonitaConfig = new BonitaConfig(); 5705 }catch(Exception e){throw new EJBException (e.getMessage());} 5706 } 5707 5708 5711 5712 public void ejbRemove() { 5713 } 5714 5715 5718 5719 public void ejbActivate() { 5720 } 5721 5722 5725 5726 public void ejbPassivate() { 5727 } 5728 5729 5731 5732 private void createProcess(String projectName)throws HeroException, CreateException 5733 { 5734 BnUserLocalHome uhome = null; 5735 BnRoleLocalHome rhome = null; 5736 BnProjectConfigLocalHome pchome = null; 5737 try { 5738 pHome = hero.interfaces.BnProjectUtil.getLocalHome(); 5739 uhome = hero.interfaces.BnUserUtil.getLocalHome(); 5740 rhome = hero.interfaces.BnRoleUtil.getLocalHome(); 5741 pchome = hero.interfaces.BnProjectConfigUtil.getLocalHome(); 5742 } catch (javax.naming.NamingException ne) { 5743 if (this.getProjectConfigTrace()) 5744 trace.error(ne.getMessage()); 5745 throw new CreateException (ne.getMessage()); 5746 } 5747 try { 5749 String creator = this.getCaller(); 5750 mProject = pHome.create(projectName, creator); 5751 mProject.setParent(projectName); 5752 BonitaProjectValue pv = new BonitaProjectValue(); 5753 pv.setName(projectName); 5754 mProject.setModel(pv); 5755 mProject.setBnProjectConfig(pchome.create()); 5756 5757 BnUserLocal user = uhome.findByName(creator); 5758 mProject.getBnUsers().add(user); 5759 5760 BnRoleValue rv = new BnRoleValue(); 5762 rv.setName(hero.interfaces.Constants.ADMIN); 5763 rv.setDescription("the admin role"); 5764 BnRoleLocal role = rhome.create(rv); 5765 mProject.getBnRoles().add(role); 5766 5767 user.getBnRoles().add(role); 5769 5770 rv = new BnRoleValue(); 5772 rv.setName(hero.interfaces.Constants.INITIALROLE); 5773 rv.setDescription("the initial role for nodes"); 5774 role = rhome.create(rv); 5775 mProject.getBnRoles().add(role); 5776 5777 if (!creator.equals(Constants.ADMIN)) 5778 { 5779 rv = new BnRoleValue(); 5781 rv.setName(creator); 5782 rv.setDescription(creator+" user role"); 5783 role = rhome.create(rv); 5784 mProject.getBnRoles().add(role); 5785 user.getBnRoles().add(role); 5787 } 5788 5789 mProject.setCreationDate(new Date ()); 5790 5791 jms.sendProjectEvent(ADDUSERPROJECT, projectName, creator); 5792 } catch (FinderException fie) { 5793 if (this.getProjectConfigTrace()) 5794 trace.error(fie.getMessage()); 5795 throw new HeroException(fie.getMessage()); 5796 } catch (InvalidValueException ie) { 5797 if (this.getProjectConfigTrace()) 5798 trace.error(ie.getMessage()); 5799 throw new HeroException(ie.getMessage()); 5800 } catch (Exception he) { 5801 if (this.getProjectConfigTrace()) 5802 trace.error(he.getMessage()); 5803 throw new HeroException(he.getMessage()); 5804 } 5805 } 5806 5807 private boolean isInProject(String projectName) throws HeroException{ 5808 if (mContext.getCallerPrincipal().getName().equals(Constants.SECURITY_ROLE)) 5809 return true; 5810 BnProjectLocalHome phome = null; 5811 BnProjectLocal plocal = null; 5812 try { 5813 phome = hero.interfaces.BnProjectUtil.getLocalHome(); 5814 plocal = phome.findByName(projectName); 5815 Collection users = plocal.getBnUsers(); 5816 Iterator usrs = users.iterator(); 5817 while (usrs.hasNext()) 5818 { 5819 if (((BnUserLocal)usrs.next()).getName().equals(this.getCaller())) 5820 return true; 5821 } 5822 return false; 5823 5824 } catch (javax.naming.NamingException ne) { 5825 throw new HeroException(ne.getMessage()); 5826 } catch (FinderException fie) {return true;} } 5828 5829 5830 5838 public boolean isAdminOfProject(String projectName) throws HeroException{ 5839 if (mContext.getCallerPrincipal().getName().equals(Constants.SECURITY_ROLE)) 5840 return true; 5841 Collection projects = this.getUserRolesInProjectNames(this.getCaller()); 5842 Iterator i = projects.iterator(); 5843 while (i.hasNext()) { 5844 String roleName = (String ) i.next(); 5845 if (roleName.equals(Constants.ADMIN)) 5846 return true; 5847 } 5848 return false; 5849 } 5850 5851 private boolean isProjectHidden() throws HeroException{ 5852 if (mProject.getStatus().equals(Constants.Pj.HIDDEN)) 5853 return true; 5854 else 5855 return false; 5856 } 5857 5858 private boolean isUserInNodeRole(String nodeName) throws HeroException{ 5859 BnNodeLocalHome nhome = null; 5860 BnNodeLocal nlocal = null; 5861 try { 5862 nhome = hero.interfaces.BnNodeUtil.getLocalHome(); 5863 nlocal = nhome.findByName(nodeName,mProject.getId()); 5864 Collection users = nlocal.getBnRole().getBnUsers(); 5865 5866 Iterator i = users.iterator(); 5867 while (i.hasNext()) { 5868 BnUserLocal user = (BnUserLocal) i.next(); 5869 String userName = user.getName(); 5870 if (userName.equals(this.getCaller())) 5871 return true; 5872 } 5873 } catch (javax.naming.NamingException ne) { 5874 throw new HeroException(ne.getMessage()); 5875 } catch (FinderException fie) { 5876 throw new HeroException(fie.getMessage()); 5877 } 5878 return false; 5879 } 5880 5881 private boolean checkDynamics(String out) throws HeroException { 5882 BnNodeLocal nodeout = mProject.getBnNode(out); 5883 if ((nodeout.getState() == hero.interfaces.Constants.Nd.INITIAL) 5884 || (nodeout.getState() == hero.interfaces.Constants.Nd.READY) 5885 || (nodeout.getState() == hero.interfaces.Constants.Nd.ANTICIPABLE)) 5886 return true; 5887 return false; 5888 } 5889 5890 private void mapRole() throws HeroException { 5894 try { 5895 String creator = this.getCaller(); 5896 Collection mappers = new ArrayList (); 5897 Collection roles = mProject.getBnRoles(); 5898 BnRoleMapperLocal mapper = null; 5899 Iterator it = roles.iterator(); 5900 it = roles.iterator(); 5901 while (it.hasNext()){ 5902 BnRoleLocal role = (BnRoleLocal) it.next(); 5903 mapper = role.getBnRoleMapper(); 5904 if (mapper != null){ 5905 hero.mapper.Mapper h = hero.mapper.Mapper.make(mapper.getName(), mapper.getType()); 5906 Collection users = h.execute(this, mapper.getType(), role, creator); 5907 if (mapper.getType()==(Constants.Mapper.PROPERTIES)) 5908 this.setUserRoleLocal(creator,role.getName()); 5909 else 5910 { 5911 Iterator i = users.iterator(); 5912 while (i.hasNext()) 5913 { 5914 String userName = (String )i.next(); 5915 this.addUserLocal(userName); 5916 this.setUserRoleLocal(userName,role.getName()); 5917 } 5918 } 5919 } 5920 } 5921 } catch (HeroException he) { 5922 throw new HeroException(he.getMessage()); 5923 } 5924 } 5925 5926 private void addUserLocal(String userName) throws HeroException 5927 { 5928 BnUserLocalHome uHome; 5929 BnRoleLocalHome rHome; 5930 BnUserLocal mUser; 5931 UserServiceLocalHome ushome; 5932 try { 5933 uHome = hero.interfaces.BnUserUtil.getLocalHome(); 5934 rHome = hero.interfaces.BnRoleUtil.getLocalHome(); 5935 } catch (javax.naming.NamingException be) { 5936 throw new HeroException(be.getMessage()); 5937 } 5938 try { 5939 ushome = hero.interfaces.UserServiceUtil.getLocalHome(); 5940 UserServiceLocal ul = ushome.create(); 5941 mUser = ul.findUserLocal(userName); 5942 } catch (Exception ce) { 5943 throw new HeroException(ce.getMessage()); 5944 } 5945 Collection cUsers = mProject.getBnUsers(); 5946 if (!cUsers.contains(mUser)) 5947 { 5948 cUsers.add(mUser); 5949 if (!userName.equals(Constants.ADMIN)) 5950 this.addRole(userName, "BnUser BnRole"); 5951 this.setUserRoleLocal(userName, userName); 5952 } 5953 } 5954 5955 private void setUserRoleLocal(String userName, String roleName) throws HeroException 5956 { 5957 BnRoleLocalHome roleh; 5958 BnUserLocalHome userh; 5959 try { 5960 roleh = BnRoleUtil.getLocalHome(); 5961 userh = BnUserUtil.getLocalHome(); 5962 } catch (javax.naming.NamingException ne) { 5963 throw new HeroException(ne.getMessage()); 5964 } 5965 try { 5966 BnUserLocal user = userh.findByName(userName); 5967 BnRoleLocal role = roleh.findByName(roleName, mProject.getId()); 5968 user.getBnRoles().add(role); 5969 } catch (Exception fe) { 5970 throw new HeroException(fe.getMessage()); 5971 } 5972 5973 } 5974 5975 private void performAssign() throws HeroException { 5976 if (this.getProjectConfigTrace()) 5978 trace.debug("perform assign "); 5979 try { 5980 String creator = this.getCaller(); 5981 Collection performers = new ArrayList (); 5982 Collection nodes = mProject.getBnNodes(); 5983 BnNodePerformerAssignLocal performerAssign = null; 5984 Iterator it = nodes.iterator(); 5985 5986 it = nodes.iterator(); 5987 while (it.hasNext()){ 5988 BnNodeLocal node = (BnNodeLocal) it.next(); 5989 performerAssign = node.getBnNodePerformerAssign(); 5990 if (performerAssign != null){ 5991 hero.performerAssign.PerformerAssign h = hero.performerAssign.PerformerAssign.make(performerAssign.getName(), performerAssign.getType()); 5992 h.execute(this, performerAssign.getType(), node, creator); 5993 } 5994 } 5995 } catch (HeroException he) { 5996 throw new HeroException(he.getMessage()); 5997 } 5998 5999 } 6000 6001 private boolean checkStructuralConstraints(String in, String out) throws HeroException { 6002 visited.add(in); 6003 BnNodeLocal nodeout = mProject.getBnNode(out); 6004 if (visited.contains(out)) 6005 return false; 6006 Collection edges = nodeout.getOutBnEdges(); 6007 Iterator i = edges.iterator(); 6008 while (i.hasNext()) 6009 { 6010 BnEdgeLocal edge = (BnEdgeLocal)i.next(); 6011 if (!visited.contains(edge.getInBnNode().getName()) && ! checkStructuralConstraints(edge.getInBnNode().getName(),edge.getOutBnNode().getName())) 6012 return false; 6013 } 6014 6015 return true; 6016 } 6017 6018 private boolean checkDuplicateEdge(String in, String out) 6019 throws HeroException { 6020 Collection edges = mProject.getBnEdges(); 6021 Iterator i = edges.iterator(); 6022 while (i.hasNext()) { 6023 BnEdgeLocal edge = (BnEdgeLocal) i.next(); 6024 if ((edge.getInBnNode().getName()).equals(in) 6025 && (edge.getOutBnNode().getName()).equals(out)) 6026 return false; 6027 } 6028 return true; 6029 } 6030 6031 private boolean checkDuplicateAgentEdge(String in, String out) 6032 throws HeroException { 6033 Collection edges = mProject.getBnAgentEdges(); 6034 Iterator i = edges.iterator(); 6035 while (i.hasNext()) { 6036 BnAgentEdgeLocal edge = (BnAgentEdgeLocal) i.next(); 6037 if ((edge.getInBnAgent().getName()).equals(in) 6038 && (edge.getOutBnNode().getName()).equals(out)) 6039 return false; 6040 } 6041 return true; 6042 } 6043 6044 6045 6055 public void copyNode(String nodeName, BonitaNodeValue node) throws HeroException { 6056 if (this.getProjectConfigTrace()) 6057 trace.debug("copyNode: nodeName=" + nodeName + " node=" + node.getName()+ " inNode="); 6058 BnNodeLocalHome nHome; 6059 BnNodeLocal mNode; 6060 BnUserLocalHome uHome; 6061 BnNodePerformerAssignLocal ppLocal; 6062 BnNodePerformerAssignLocalHome performerAssignh; 6063 6064 try { 6065 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 6066 uHome = hero.interfaces.BnUserUtil.getLocalHome(); 6067 performerAssignh = BnNodePerformerAssignUtil.getLocalHome(); 6068 } catch (javax.naming.NamingException be) { 6069 if (this.getProjectConfigTrace()) 6070 trace.error(be.getMessage()); 6071 throw new HeroException(be.getMessage()); 6072 } 6073 try { 6074 if (nodeName.equals("")) 6075 throw new HeroException("Node name can not be empty..."); 6076 6077 BnNodeLocal nd = nHome.create(nodeName, node.getType()); 6079 BnNodeValue ndata = nd.getBnNodeValue(); 6080 ndata.setCreationDate(new java.util.Date ()); 6081 nd.setBnNodeValue(ndata); 6082 Collection cNodes = mProject.getBnNodes(); 6083 cNodes.add(nd); 6084 6085 nd.setCreator(node.getCreator()); 6086 nd.setExecutor(node.getExecutor()); 6088 BnRoleLocalHome rHome = BnRoleUtil.getLocalHome(); 6089 BnRoleLocal role = rHome.findByName(node.getRole(),mProject.getId()); 6090 nd.setBnRole(role); 6091 6092 if (!node.getAnticipable()) { 6094 nd.setAnticipable(false); 6095 nd.setTransition(NodeState.make(nd.getType(), false)); 6096 } 6097 nd.setDescription(node.getDescription()); 6099 if (node.getDeadlines().size()!=0) 6101 nd.setDeadlines(node.getDeadlines()); 6102 if (node.getRelativeDeadlines().size()!=0) 6104 nd.setRelativeDeadlines(node.getRelativeDeadlines()); 6105 6106 if (node.getPerformer() != null) { 6108 ppLocal = performerAssignh.create(node.getPerformer().getName(), 6109 node.getPerformer().getType(), 6110 node.getPerformer().getPropertyName()); 6111 ppLocal.setBnNode(nd); 6112 } 6113 6114 if (node.getType() == Constants.Nd.SUB_PROCESS_NODE) 6115 { 6116 try { 6117 BnProjectLocal pl = pHome.findByName(nodeName); 6118 pl.setParent(mProject.getName()); 6119 } catch (javax.ejb.FinderException pe) { 6120 if (this.getProjectConfigTrace()) 6121 trace.error("Project "+ nodeName+ " does not exist " + pe.getMessage()); 6122 throw new HeroException("Project "+ nodeName+ " does not exist");} 6123 } 6124 jms.sendNodeEvent(ADDNODE,this.getName(),nodeName,nd.getType(),nd.getState(),this.getCaller()); 6126 6127 } catch (InvalidValueException ie) { 6128 if (this.getProjectConfigTrace()) 6129 trace.error(ie.getMessage()); 6130 throw new HeroException(ie.getMessage()); 6131 } catch (CreateException ce) { 6132 if (this.getProjectConfigTrace()) 6133 trace.error(ce.getMessage()); 6134 throw new HeroException(ce.getMessage()); 6135 } catch (FinderException fe) { 6136 if (this.getProjectConfigTrace()) 6137 trace.error(fe.getMessage()); 6138 throw new HeroException(fe.getMessage()); 6139 } catch (javax.naming.NamingException ne) { 6140 if (this.getProjectConfigTrace()) 6141 trace.error(ne.getMessage()); 6142 throw new HeroException(ne.getMessage()); 6143 } 6144 } 6145 6146 6156 public void copyEdge(String nodeName, BnNodeLocal inNode, BonitaEdgeValue edge ) throws HeroException { 6157 if (this.getProjectConfigTrace()) 6158 trace.debug("copyEdge: nodeName=" + nodeName + " inNode=" + inNode.getName()+" edge=" + edge.getName()); 6159 BnEdgeLocalHome eHome; 6160 BnEdgeLocal mEdge; 6161 BnNodeLocalHome nHome; 6162 BnNodeLocal mNode; 6163 6164 try { 6165 nHome = hero.interfaces.BnNodeUtil.getLocalHome(); 6166 eHome = hero.interfaces.BnEdgeUtil.getLocalHome(); 6167 } catch (javax.naming.NamingException be) { 6168 if (this.getProjectConfigTrace()) 6169 trace.error(be.getMessage()); 6170 throw new HeroException(be.getMessage()); 6171 } 6172 try { 6173 BnNodeLocal nd = nHome.findByName(nodeName, mProject.getId()); 6174 6175 try{ 6176 mEdge = eHome.create(); 6177 mEdge.setBnProject(mProject); 6178 mEdge.setInBnNode(inNode); 6179 mEdge.setOutBnNode(nd); 6180 mEdge.setCondition(edge.getCondition()); 6181 6182 int inState = Constants.Nd.READY; 6183 if (inNode.getState() == Constants.Nd.ANTICIPATING) 6184 inState = Constants.Nd.ANTICIPABLE; 6185 6186 int edgeState = hero.interfaces.Constants.edgeTransition[Constants.CONDITION_TRUE][inState]; 6187 this.setEdgeState(mEdge, edgeState); 6188 int newOperation = nd.getActivation().state(nd); 6190 int newState = nd.getTransition().computeState(nd, newOperation); 6191 if (newState == hero.interfaces.Constants.Nd.BAD_TRANSITION) { 6192 throw new HeroException("AddEdge generated a bad Node transition"); 6193 } 6194 this.setNodeState(nd, newState); 6195 6196 jms.sendEdgeEvent(ADDEDGE,this.getName(),mEdge.getName(),inNode.getName(),nd.getName(),this.getCaller()); 6197 }catch (hero.util.NodeStartedException nse) {} } catch (InvalidValueException ie) { 6199 if (this.getProjectConfigTrace()) 6200 trace.error(ie.getMessage()); 6201 throw new HeroException(ie.getMessage()); 6202 } catch (CreateException ce) { 6203 if (this.getProjectConfigTrace()) 6204 trace.error(ce.getMessage()); 6205 throw new HeroException(ce.getMessage()); 6206 } catch (FinderException fe) { 6207 if (this.getProjectConfigTrace()) 6208 trace.error(fe.getMessage()); 6209 throw new HeroException(fe.getMessage()); 6210 } 6211 } 6212 6213 6223 public boolean containsUser(String userName) throws HeroException { 6224 if (this.getProjectConfigTrace()) 6225 trace.debug("containsUser : name=" + userName); 6226 BnUserLightValue[] uv = mProject.getBnProjectValue().getBnUsers(); 6227 for (int i = 0; i < uv.length; i++) { 6228 if (uv[i].getName().equalsIgnoreCase(userName)) 6229 return true; 6230 } 6231 return false; 6232 } 6233 6234 private boolean containsRole(String roleName) { 6235 BnRoleValue[] rv = mProject.getBnProjectValue().getBnRoles(); 6236 for (int i = 0; i < rv.length; i++) { 6237 if (rv[i].getName().equalsIgnoreCase(roleName)) 6238 return true; 6239 } 6240 return false; 6241 } 6242 6243 private Collection getNodeInEdges(BnNodeLocal nd ){ 6244 Collection edgeValues = new ArrayList (); 6245 Collection edges = nd.getInBnEdges(); 6246 Iterator nodeEdges = edges.iterator(); 6247 while (nodeEdges.hasNext()) 6248 edgeValues.add(((BnEdgeLocal)nodeEdges.next()).getBnEdgeValue()); 6249 return edgeValues; 6250 6251 } 6252 6253 private boolean getProjectConfigLog() throws HeroException{ 6254 if (this.getName()!=null) 6255 return (bonitaConfig.getProcessLog(this.getName())); 6256 else 6257 return true; 6258 } 6259 6260 private boolean getProjectConfigTrace() throws HeroException{ 6261 if (this.getName()!=null) 6262 return (bonitaConfig.getProcessTrace(this.getName())); 6263 else 6264 return true; 6265 } 6266 6267 private void addIterationInstance(String from, String to, String condition) throws HeroException { 6268 BnIterationLocalHome iteh; 6269 try { 6270 iteh = BnIterationUtil.getLocalHome(); 6271 } catch (javax.naming.NamingException ne) { 6272 throw new HeroException(ne.getMessage()); 6273 } 6274 6275 BnIterationLightValue iv = new BnIterationLightValue(); 6276 iv.setFromNode(from); 6277 iv.setToNode(to); 6278 iv.setCondition(condition); 6279 try { 6280 BnIterationLocal il = iteh.create(iv); 6281 mProject.getBnIterations().add(il); 6282 jms.sendIterationEvent(ADDITERATION,this.getName(), from, to); 6283 } catch (Exception ce) { 6284 throw new HeroException(ce.getMessage()); 6285 } 6286 } 6287 6288 6295 public String getCaller() { 6296 return this.caller; 6297 } 6298 6299 6300 6307 public void setCaller(String user) { 6308 this.caller=user; 6309 } 6310 6311} 6312 | Popular Tags |