1 package org.enhydra.shark; 2 3 import org.enhydra.shark.api.client.wfmodel.*; 4 5 import java.util.Iterator ; 6 import java.util.List ; 7 import java.util.Map ; 8 import org.enhydra.shark.api.RootException; 9 import org.enhydra.shark.api.SharkTransaction; 10 import org.enhydra.shark.api.client.timebase.UtcT; 11 import org.enhydra.shark.api.client.wfbase.BaseException; 12 import org.enhydra.shark.api.client.wfbase.InvalidQuery; 13 import org.enhydra.shark.api.client.wfbase.NameMismatch; 14 import org.enhydra.shark.api.common.SharkConstants; 15 import org.enhydra.shark.api.internal.eventaudit.EventAuditManagerInterface; 16 import org.enhydra.shark.api.internal.security.SecurityManager; 17 import org.enhydra.shark.api.internal.toolagent.ToolAgentGeneralException; 18 import org.enhydra.shark.api.internal.working.WfActivityInternal; 19 import org.enhydra.shark.api.internal.working.WfProcessInternal; 20 import org.enhydra.shark.api.internal.working.WfRequesterInternal; 21 22 27 public class WfProcessWrapper implements WfProcess { 28 29 private String userAuth; 30 private String mgrName; 31 private String processId; 32 33 36 protected WfProcessWrapper(String userAuth,String mgrName,String processId) { 37 this.userAuth=userAuth; 38 this.mgrName=mgrName; 39 this.processId = processId; 40 } 41 42 43 50 public WfRequester requester() throws BaseException { 51 WfRequester ret = null; 52 SharkTransaction t = null; 53 try { 54 t = SharkUtilities.createTransaction(); 55 ret = requester(t); 56 } catch (RootException e) { 58 SharkUtilities.emptyCaches(t); 60 if (e instanceof BaseException) 61 throw (BaseException)e; 62 else 63 throw new BaseException(e); 64 } finally { 65 SharkUtilities.releaseTransaction(t); 66 } 67 return ret; 68 } 69 70 79 public WfRequester requester(SharkTransaction t) throws BaseException { 80 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 81 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 82 if (sm!=null) { 83 try { 84 sm.check_process_requester(t, 85 processId, 86 userAuth, 87 procInternal.requester(t).getResourceRequesterUsername(t)); 88 } catch (Exception ex) { 89 throw new BaseException(ex); 90 } 91 } 92 93 try { 94 WfRequester req=null; 95 WfRequesterInternal requester=procInternal.requester(t); 96 if (requester instanceof WfActivityInternal) { 97 WfActivityInternal act=(WfActivityInternal)requester; 98 req=SharkEngineManager.getInstance().getObjectFactory().createActivityWrapper(userAuth,act.manager_name(t),act.process_id(t),act.key(t)); 99 } else { 100 WfRequester r=requester.getExternalRequester(t); 101 if (r!=null) { 102 req=r; 103 } else { 104 String reqUname=((WfRequesterInternal)requester).getResourceRequesterUsername(t); 105 req=SharkEngineManager.getInstance().getObjectFactory().createRequesterWrapper(userAuth,reqUname); 106 } 107 } 108 return req; 109 } catch (Exception ex) { 110 throw new BaseException(ex); 111 } 112 } 113 114 122 public void set_requester (WfRequester new_value) throws BaseException, CannotChangeRequester { 123 SharkTransaction t = null; 124 try { 125 t = SharkUtilities.createTransaction(); 126 set_requester(t, new_value); 127 SharkUtilities.commitTransaction(t); 128 } catch (RootException e) { 129 SharkUtilities.rollbackTransaction(t,e); 130 if (e instanceof CannotChangeRequester) 131 throw (CannotChangeRequester)e; 132 else if (e instanceof BaseException) 133 throw (BaseException)e; 134 else 135 throw new BaseException(e); 136 } finally { 137 SharkUtilities.releaseTransaction(t); 138 } 139 } 140 141 150 public void set_requester(SharkTransaction t,WfRequester new_value) throws BaseException, CannotChangeRequester { 151 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 152 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 153 if (sm!=null) { 154 try { 155 sm.check_process_set_requester(t, 156 processId, 157 userAuth, 158 procInternal.requester(t).getResourceRequesterUsername(t)); 159 } catch (Exception ex) { 160 throw new BaseException(ex); 161 } 162 } 163 WfRequesterInternal requester=procInternal.requester(t); 164 if (requester instanceof WfActivityInternal) { 165 throw new CannotChangeRequester("Can't change requester for a process instantiated as a subflow!"); 166 } else { 167 String extReqClassName=null; 168 if (new_value!=null) { 169 extReqClassName=new_value.getClass().getName(); 170 } 171 procInternal.setExternalRequesterClassName(t,extReqClassName); 172 } 173 } 174 175 182 public int how_many_step () throws BaseException { 183 int ret = -1; 184 SharkTransaction t = null; 185 try { 186 t = SharkUtilities.createTransaction(); 187 ret = how_many_step(t); 188 } catch (RootException e) { 190 SharkUtilities.emptyCaches(t); 192 if (e instanceof BaseException) 193 throw (BaseException)e; 194 else 195 throw new BaseException(e); 196 } finally { 197 SharkUtilities.releaseTransaction(t); 198 } 199 return ret; 200 } 201 202 211 public int how_many_step (SharkTransaction t) throws BaseException { 212 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 213 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 214 if (sm!=null) { 215 try { 216 sm.check_process_how_many_step(t, 217 processId, 218 userAuth, 219 procInternal.requester(t).getResourceRequesterUsername(t)); 220 } catch (Exception ex) { 221 throw new BaseException(ex); 222 } 223 } 224 return procInternal.how_many_step(t); 225 } 226 227 234 public WfActivityIterator get_iterator_step () throws BaseException { 235 WfActivityIterator ret = null; 236 SharkTransaction t = null; 237 try { 238 t = SharkUtilities.createTransaction(); 239 ret = get_iterator_step(t); 240 } catch (RootException e) { 242 SharkUtilities.emptyCaches(t); 244 if (e instanceof BaseException) 245 throw (BaseException)e; 246 else 247 throw new BaseException(e); 248 } finally { 249 SharkUtilities.releaseTransaction(t); 250 } 251 return ret; 252 } 253 254 263 public WfActivityIterator get_iterator_step (SharkTransaction t) throws BaseException { 264 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 265 if (sm!=null) { 266 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 267 try { 268 sm.check_process_get_iterator_step(t, 269 processId, 270 userAuth, 271 procInternal.requester(t).getResourceRequesterUsername(t)); 272 } catch (Exception ex) { 273 throw new BaseException(ex); 274 } 275 } 276 return SharkEngineManager.getInstance().getObjectFactory().createActivityIteratorWrapper(t,userAuth,processId); 277 } 278 279 288 public WfActivity[] get_sequence_step (int max_number) throws BaseException { 289 WfActivity[] ret = null; 290 SharkTransaction t = null; 291 try { 292 t = SharkUtilities.createTransaction(); 293 ret = get_sequence_step(t, max_number); 294 } catch (RootException e) { 296 SharkUtilities.emptyCaches(t); 298 if (e instanceof BaseException) 299 throw (BaseException)e; 300 else 301 throw new BaseException(e); 302 } finally { 303 SharkUtilities.releaseTransaction(t); 304 } 305 return ret; 306 } 307 308 319 public WfActivity[] get_sequence_step (SharkTransaction t,int max_number) throws BaseException { 320 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 321 if (sm!=null) { 322 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 323 try { 324 sm.check_process_get_sequence_step(t, 325 processId, 326 userAuth, 327 procInternal.requester(t).getResourceRequesterUsername(t)); 328 } catch (Exception ex) { 329 throw new BaseException(ex); 330 } 331 } 332 333 List alist = SharkUtilities.createProcessActivityWrappers(t,userAuth,processId); 336 if (max_number > alist.size() || max_number<=0) { 337 max_number = alist.size(); 338 } 339 WfActivity[] ret = new WfActivity[max_number]; 340 alist.subList(0, max_number).toArray(ret); 341 return ret; 342 } 343 344 354 public boolean is_member_of_step (WfActivity member) throws BaseException { 355 boolean ret = false; 356 SharkTransaction t = null; 357 try { 358 t = SharkUtilities.createTransaction(); 359 ret = is_member_of_step(t, member); 360 } catch (RootException e) { 362 SharkUtilities.emptyCaches(t); 364 if (e instanceof BaseException) 365 throw (BaseException)e; 366 else 367 throw new BaseException(e); 368 } finally { 369 SharkUtilities.releaseTransaction(t); 370 } 371 return ret; 372 } 373 374 384 public boolean is_member_of_step (SharkTransaction t,WfActivity member) throws BaseException { 385 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 386 if (sm!=null) { 387 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 388 try { 389 sm.check_process_is_member_of_step(t, 390 processId, 391 userAuth, 392 procInternal.requester(t).getResourceRequesterUsername(t)); 393 } catch (Exception ex) { 394 throw new BaseException(ex); 395 } 396 } 397 String pId=member.container(t).key(t); 398 return pId.equals(this.processId); 399 } 400 401 408 public WfProcessMgr manager () throws BaseException { 409 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 410 if (sm==null) { 411 return SharkEngineManager 412 .getInstance() 413 .getObjectFactory() 414 .createProcessMgrWrapper(userAuth,mgrName); 415 } 416 WfProcessMgr ret = null; 417 SharkTransaction t = null; 418 try { 419 t = SharkUtilities.createTransaction(); 420 ret = manager(t); 421 } catch (RootException e) { 423 SharkUtilities.emptyCaches(t); 425 if (e instanceof BaseException) 426 throw (BaseException)e; 427 else 428 throw new BaseException(e); 429 } finally { 430 SharkUtilities.releaseTransaction(t); 431 } 432 return ret; 433 } 434 435 444 public WfProcessMgr manager (SharkTransaction t) throws BaseException { 445 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 446 if (sm!=null) { 447 try { 448 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 449 sm.check_process_manager(t, 450 processId, 451 userAuth, 452 procInternal.requester(t).getResourceRequesterUsername(t)); 453 } catch (Exception ex) { 454 throw new BaseException(ex); 455 } 456 } 457 return SharkEngineManager 458 .getInstance() 459 .getObjectFactory() 460 .createProcessMgrWrapper(userAuth,mgrName); 461 } 462 463 472 public Map result () throws BaseException, ResultNotAvailable { 473 Map ret = null; 474 SharkTransaction t = null; 475 try { 476 t = SharkUtilities.createTransaction(); 477 ret = result(t); 478 } catch (RootException e) { 480 SharkUtilities.emptyCaches(t); 482 if (e instanceof ResultNotAvailable) 483 throw (ResultNotAvailable)e; 484 else if (e instanceof BaseException) 485 throw (BaseException)e; 486 else 487 throw new BaseException(e); 488 } finally { 489 SharkUtilities.releaseTransaction(t); 490 } 491 return ret; 492 } 493 494 504 public Map result (SharkTransaction t) throws BaseException, ResultNotAvailable { 505 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 506 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 507 if (sm!=null) { 508 try { 509 sm.check_process_result(t, 510 processId, 511 userAuth, 512 procInternal.requester(t).getResourceRequesterUsername(t)); 513 } catch (Exception ex) { 514 throw new BaseException(ex); 515 } 516 } 517 return procInternal.result(t); 518 } 519 520 527 public void start() throws BaseException, CannotStart, AlreadyRunning { 528 SharkTransaction t = null; 529 try { 530 t = SharkUtilities.createTransaction(); 531 start(t); 532 SharkUtilities.commitTransaction(t); 533 } catch (RootException e) { 534 SharkUtilities.rollbackTransaction(t,e); 535 if (e instanceof CannotStart) 536 throw (CannotStart)e; 537 else if (e instanceof AlreadyRunning) 538 throw (AlreadyRunning)e; 539 else if (e instanceof BaseException) 540 throw (BaseException)e; 541 else 542 throw new BaseException(e); 543 } finally { 544 SharkUtilities.releaseTransaction(t); 545 } 546 } 547 548 557 public void start(SharkTransaction t) throws BaseException, CannotStart, AlreadyRunning { 558 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 559 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 560 if (sm!=null) { 561 try { 562 sm.check_process_start(t, 563 processId, 564 userAuth, 565 procInternal.requester(t).getResourceRequesterUsername(t)); 566 } catch (Exception ex) { 567 throw new BaseException(ex); 568 } 569 } 570 try { 571 procInternal.start(t); 572 } catch (ToolAgentGeneralException tage) { 573 throw new BaseException(tage); 574 } 575 } 576 577 587 public WfActivityIterator get_activities_in_state (String state) throws BaseException, InvalidState { 588 WfActivityIterator ret = null; 589 SharkTransaction t = null; 590 try { 591 t = SharkUtilities.createTransaction(); 592 ret = get_activities_in_state(t, state); 593 } catch (RootException e) { 595 SharkUtilities.emptyCaches(t); 597 if (e instanceof InvalidState) 598 throw (InvalidState)e; 599 else if (e instanceof BaseException) 600 throw (BaseException)e; 601 else 602 throw new BaseException(e); 603 } finally { 604 SharkUtilities.releaseTransaction(t); 605 } 606 return ret; 607 } 608 609 620 public WfActivityIterator get_activities_in_state (SharkTransaction t,String state) throws BaseException, InvalidState { 621 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 622 if (sm!=null) { 623 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 624 try { 625 sm.check_process_get_activities_in_state(t, 626 processId, 627 userAuth, 628 procInternal.requester(t).getResourceRequesterUsername(t)); 629 } catch (Exception ex) { 630 throw new BaseException(ex); 631 } 632 } 633 if (!SharkConstants.possibleActivityStates.contains(state)) { 634 throw new InvalidState("The activity state "+state+" is not valid - can't get activities in such state!"); 635 } 636 637 WfActivityIterator ret = SharkEngineManager.getInstance().getObjectFactory().createActivityIteratorWrapper(t,userAuth, processId); 638 try { 639 ret.set_query_expression(t, SharkConstants.QUERY_STATE_PREFIX+"state.equals(\""+state+"\")"); 640 } catch (InvalidQuery iq) { 641 throw new BaseException(iq); 642 } 643 return ret; 644 } 645 646 653 public workflow_stateType workflow_state () throws BaseException { 654 workflow_stateType ret = null; 655 SharkTransaction t = null; 656 try { 657 t = SharkUtilities.createTransaction(); 658 ret = workflow_state(t); 659 } catch (RootException e) { 661 SharkUtilities.emptyCaches(t); 663 if (e instanceof BaseException) 664 throw (BaseException)e; 665 else 666 throw new BaseException(e); 667 } finally { 668 SharkUtilities.releaseTransaction(t); 669 } 670 return ret; 671 } 672 673 682 public workflow_stateType workflow_state (SharkTransaction t) throws BaseException { 683 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 684 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 685 if (sm!=null) { 686 try { 687 sm.check_process_workflow_state(t, 688 processId, 689 userAuth, 690 procInternal.requester(t).getResourceRequesterUsername(t)); 691 } catch (Exception ex) { 692 throw new BaseException(ex); 693 } 694 } 695 String state=procInternal.state(t); 696 if (state.startsWith(SharkConstants.STATEPREFIX_CLOSED)) { 697 return workflow_stateType.closed; 698 } else { 699 return workflow_stateType.open; 700 } 701 } 702 703 public while_openType while_open () throws BaseException { 704 while_openType ret = null; 705 SharkTransaction t = null; 706 try { 707 t = SharkUtilities.createTransaction(); 708 ret = while_open(t); 709 } catch (RootException e) { 711 SharkUtilities.emptyCaches(t); 713 if (e instanceof BaseException) 714 throw (BaseException)e; 715 else 716 throw new BaseException(e); 717 } finally { 718 SharkUtilities.releaseTransaction(t); 719 } 720 return ret; 721 } 722 723 732 public while_openType while_open (SharkTransaction t) throws BaseException { 733 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 734 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 735 if (sm!=null) { 736 try { 737 sm.check_process_while_open(t, 738 processId, 739 userAuth, 740 procInternal.requester(t).getResourceRequesterUsername(t)); 741 } catch (Exception ex) { 742 throw new BaseException(ex); 743 } 744 } 745 String state=procInternal.state(t); 746 if (state.equals(SharkConstants.STATE_OPEN_RUNNING)) { 747 return while_openType.running; 748 } else { 749 return while_openType.not_running; 750 } 751 } 752 753 760 public why_not_runningType why_not_running () throws BaseException { 761 why_not_runningType ret = null; 762 SharkTransaction t = null; 763 try { 764 t = SharkUtilities.createTransaction(); 765 ret = why_not_running(t); 766 } catch (RootException e) { 768 SharkUtilities.emptyCaches(t); 770 if (e instanceof BaseException) 771 throw (BaseException)e; 772 else 773 throw new BaseException(e); 774 } finally { 775 SharkUtilities.releaseTransaction(t); 776 } 777 return ret; 778 } 779 780 789 public why_not_runningType why_not_running (SharkTransaction t) throws BaseException { 790 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 791 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 792 if (sm!=null) { 793 try { 794 sm.check_process_why_not_running(t, 795 processId, 796 userAuth, 797 procInternal.requester(t).getResourceRequesterUsername(t)); 798 } catch (Exception ex) { 799 throw new BaseException(ex); 800 } 801 } 802 803 String state=procInternal.state(t); 804 if (state.equals(SharkConstants.STATE_OPEN_NOT_RUNNING_SUSPENDED)) { 805 return why_not_runningType.suspended; 806 } else { 807 return why_not_runningType.not_started; 808 } 809 } 810 811 818 public how_closedType how_closed () throws BaseException { 819 how_closedType ret = null; 820 SharkTransaction t = null; 821 try { 822 t = SharkUtilities.createTransaction(); 823 ret = how_closed(t); 824 } catch (RootException e) { 826 SharkUtilities.emptyCaches(t); 828 if (e instanceof BaseException) 829 throw (BaseException)e; 830 else 831 throw new BaseException(e); 832 } finally { 833 SharkUtilities.releaseTransaction(t); 834 } 835 return ret; 836 } 837 838 847 public how_closedType how_closed (SharkTransaction t) throws BaseException { 848 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 849 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 850 if (sm!=null) { 851 try { 852 sm.check_process_how_closed(t, 853 processId, 854 userAuth, 855 procInternal.requester(t).getResourceRequesterUsername(t)); 856 } catch (Exception ex) { 857 throw new BaseException(ex); 858 } 859 } 860 String state=procInternal.state(t); 861 if (state.equals(SharkConstants.STATE_CLOSED_COMPLETED)) { 862 return how_closedType.completed; 863 } else if (state.equals(SharkConstants.STATE_CLOSED_TERMINATED)) { 864 return how_closedType.terminated; 865 } else { 866 return how_closedType.aborted; 867 } 868 } 869 870 877 public String [] valid_states () throws BaseException { 878 String [] ret = null; 879 SharkTransaction t = null; 880 try { 881 t = SharkUtilities.createTransaction(); 882 ret = valid_states(t); 883 } catch (RootException e) { 885 SharkUtilities.emptyCaches(t); 887 if (e instanceof BaseException) 888 throw (BaseException)e; 889 else 890 throw new BaseException(e); 891 } finally { 892 SharkUtilities.releaseTransaction(t); 893 } 894 return ret; 895 } 896 897 906 public String [] valid_states (SharkTransaction t) throws BaseException { 907 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 908 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 909 if (sm!=null) { 910 try { 911 sm.check_process_valid_states(t, 912 processId, 913 userAuth, 914 procInternal.requester(t).getResourceRequesterUsername(t)); 915 } catch (Exception ex) { 916 throw new BaseException(ex); 917 } 918 } 919 List vs=SharkUtilities.valid_process_states(procInternal.state(t)); 920 String [] vss=new String [vs.size()]; 921 vs.toArray(vss); 922 return vss; 923 } 924 925 932 public String state () throws BaseException { 933 String ret = null; 934 SharkTransaction t = null; 935 try { 936 t = SharkUtilities.createTransaction(); 937 ret = state(t); 938 } catch (RootException e) { 940 SharkUtilities.emptyCaches(t); 942 if (e instanceof BaseException) 943 throw (BaseException)e; 944 else 945 throw new BaseException(e); 946 } finally { 947 SharkUtilities.releaseTransaction(t); 948 } 949 return ret; 950 } 951 952 961 public String state (SharkTransaction t) throws BaseException { 962 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 963 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 964 if (sm!=null) { 965 try { 966 sm.check_process_state(t, 967 processId, 968 userAuth, 969 procInternal.requester(t).getResourceRequesterUsername(t)); 970 } catch (Exception ex) { 971 throw new BaseException(ex); 972 } 973 } 974 return procInternal.state(t); 975 } 976 977 986 public void change_state (String new_state) throws BaseException, InvalidState, TransitionNotAllowed { 987 SharkTransaction t = null; 988 try { 989 t = SharkUtilities.createTransaction(); 990 change_state(t, new_state); 991 SharkUtilities.commitTransaction(t); 992 } catch (RootException e) { 993 SharkUtilities.rollbackTransaction(t,e); 994 if (e instanceof InvalidState) 995 throw (InvalidState)e; 996 else if (e instanceof TransitionNotAllowed) 997 throw (TransitionNotAllowed)e; 998 else if (e instanceof BaseException) 999 throw (BaseException)e; 1000 else 1001 throw new BaseException(e); 1002 } finally { 1003 SharkUtilities.releaseTransaction(t); 1004 } 1005 } 1006 1007 1017 public void change_state (SharkTransaction t,String new_state) throws BaseException, InvalidState, TransitionNotAllowed { 1018 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1019 String curState=procInternal.state(t); 1020 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1021 if (sm!=null) { 1022 try { 1023 sm.check_process_change_state(t, 1024 processId, 1025 userAuth, 1026 procInternal.requester(t).getResourceRequesterUsername(t), 1027 curState, 1028 new_state); 1029 } catch (Exception ex) { 1030 throw new BaseException(ex); 1031 } 1032 } 1033 1034 if (!SharkConstants.possibleProcessStates.contains(new_state)) { 1035 throw new InvalidState("Can't change process state to "+new_state+" - no such state!"); 1036 } 1037 if (!SharkUtilities.valid_process_states(procInternal.state(t)).contains(new_state)) { 1038 throw new TransitionNotAllowed("Current process state is "+curState+" - can't change to state "+new_state+"!"); 1039 } 1040 if (new_state.equals(SharkConstants.STATE_CLOSED_ABORTED)) { 1041 try { 1042 procInternal.abort(t); 1043 } catch (CannotStop cns) { 1044 throw new TransitionNotAllowed(cns); 1045 } catch (NotRunning nr) { 1046 throw new TransitionNotAllowed(nr); 1047 } 1048 } else if (new_state.equals(SharkConstants.STATE_CLOSED_COMPLETED)) { 1049 throw new TransitionNotAllowed("Current process state is "+curState+" - can't change to state "+new_state+"!"); 1050 } else if (new_state.equals(SharkConstants.STATE_CLOSED_TERMINATED)) { 1051 try { 1052 procInternal.terminate(t); 1053 } catch (CannotStop cns) { 1054 throw new TransitionNotAllowed(cns); 1055 } catch (NotRunning nr) { 1056 throw new TransitionNotAllowed(nr); 1057 } 1058 } else if (new_state.equals(SharkConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED)) { 1059 throw new TransitionNotAllowed("Current process state is "+curState+" - can't change to state "+new_state+"!"); 1060 } else if (new_state.equals(SharkConstants.STATE_OPEN_NOT_RUNNING_SUSPENDED)) { 1061 try { 1062 procInternal.suspend(t); 1063 } catch (AlreadySuspended as) { 1064 throw new TransitionNotAllowed(as); 1065 } catch (CannotSuspend cns) { 1066 throw new TransitionNotAllowed(cns); 1067 } catch (NotRunning nr) { 1068 throw new TransitionNotAllowed(nr); 1069 } 1070 } else { try { 1072 procInternal.start(t); 1073 } catch (CannotStart cns) { 1074 throw new TransitionNotAllowed(cns); 1075 } catch (AlreadyRunning ar) { 1076 throw new TransitionNotAllowed(ar); 1077 } catch (ToolAgentGeneralException tage) { 1078 throw new BaseException(tage); 1079 } 1080 } 1081 } 1082 1083 1090 public String name () throws BaseException { 1091 String ret = null; 1092 SharkTransaction t = null; 1093 try { 1094 t = SharkUtilities.createTransaction(); 1095 ret = name(t); 1096 } catch (RootException e) { 1098 SharkUtilities.emptyCaches(t); 1100 if (e instanceof BaseException) 1101 throw (BaseException)e; 1102 else 1103 throw new BaseException(e); 1104 } finally { 1105 SharkUtilities.releaseTransaction(t); 1106 } 1107 return ret; 1108 } 1109 1110 1119 public String name (SharkTransaction t) throws BaseException { 1120 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1121 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1122 if (sm!=null) { 1123 try { 1124 sm.check_process_name(t, 1125 processId, 1126 userAuth, 1127 procInternal.requester(t).getResourceRequesterUsername(t)); 1128 } catch (Exception ex) { 1129 throw new BaseException(ex); 1130 } 1131 } 1132 return procInternal.name(t); 1133 } 1134 1135 1142 public void set_name (String new_value) throws BaseException { 1143 SharkTransaction t = null; 1144 try { 1145 t = SharkUtilities.createTransaction(); 1146 set_name(t, new_value); 1147 SharkUtilities.commitTransaction(t); 1148 } catch (RootException e) { 1149 SharkUtilities.rollbackTransaction(t,e); 1150 if (e instanceof BaseException) 1151 throw (BaseException)e; 1152 else 1153 throw new BaseException(e); 1154 } finally { 1155 SharkUtilities.releaseTransaction(t); 1156 } 1157 } 1158 1159 1167 public void set_name (SharkTransaction t,String new_value) throws BaseException { 1168 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1169 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1170 if (sm!=null) { 1171 try { 1172 sm.check_process_set_name(t, 1173 processId, 1174 userAuth, 1175 procInternal.requester(t).getResourceRequesterUsername(t)); 1176 } catch (Exception ex) { 1177 throw new BaseException(ex); 1178 } 1179 } 1180 procInternal.set_name(t, new_value); 1181 } 1182 1183 1190 public String key () throws BaseException { 1191 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1192 if (sm==null) { 1193 return processId; 1194 } 1195 String ret = null; 1196 SharkTransaction t = null; 1197 try { 1198 t = SharkUtilities.createTransaction(); 1199 ret = key(t); 1200 } catch (RootException e) { 1202 SharkUtilities.emptyCaches(t); 1204 if (e instanceof BaseException) 1205 throw (BaseException)e; 1206 else 1207 throw new BaseException(e); 1208 } finally { 1209 SharkUtilities.releaseTransaction(t); 1210 } 1211 return ret; 1212 } 1213 1214 1223 public String key (SharkTransaction t) throws BaseException { 1224 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1225 if (sm!=null) { 1226 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1227 try { 1228 sm.check_process_key(t, 1229 processId, 1230 userAuth, 1231 procInternal.requester(t).getResourceRequesterUsername(t)); 1232 } catch (Exception ex) { 1233 throw new BaseException(ex); 1234 } 1235 } 1236 return processId; 1237 } 1238 1239 1246 public String description () throws BaseException { 1247 String ret = null; 1248 SharkTransaction t = null; 1249 try { 1250 t = SharkUtilities.createTransaction(); 1251 ret = description(t); 1252 } catch (RootException e) { 1254 SharkUtilities.emptyCaches(t); 1256 if (e instanceof BaseException) 1257 throw (BaseException)e; 1258 else 1259 throw new BaseException(e); 1260 } finally { 1261 SharkUtilities.releaseTransaction(t); 1262 } 1263 return ret; 1264 } 1265 1266 1275 public String description (SharkTransaction t) throws BaseException { 1276 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1277 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1278 if (sm!=null) { 1279 try { 1280 sm.check_process_description(t, 1281 processId, 1282 userAuth, 1283 procInternal.requester(t).getResourceRequesterUsername(t)); 1284 } catch (Exception ex) { 1285 throw new BaseException(ex); 1286 } 1287 } 1288 return procInternal.description(t); 1289 } 1290 1291 1298 public void set_description (String new_value) throws BaseException { 1299 SharkTransaction t = null; 1300 try { 1301 t = SharkUtilities.createTransaction(); 1302 set_description(t, new_value); 1303 SharkUtilities.commitTransaction(t); 1304 } catch (RootException e) { 1305 SharkUtilities.rollbackTransaction(t,e); 1306 if (e instanceof BaseException) 1307 throw (BaseException)e; 1308 else 1309 throw new BaseException(e); 1310 } finally { 1311 SharkUtilities.releaseTransaction(t); 1312 } 1313 } 1314 1315 1323 public void set_description (SharkTransaction t,String new_value) throws BaseException { 1324 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1325 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1326 if (sm!=null) { 1327 try { 1328 sm.check_process_set_description(t, 1329 processId, 1330 userAuth, 1331 procInternal.requester(t).getResourceRequesterUsername(t)); 1332 } catch (Exception ex) { 1333 throw new BaseException(ex); 1334 } 1335 } 1336 1337 procInternal.set_description(t, new_value); 1338 } 1339 1340 1347 public Map process_context () throws BaseException { 1348 Map ret = null; 1349 SharkTransaction t = null; 1350 try { 1351 t = SharkUtilities.createTransaction(); 1352 ret = process_context(t); 1353 } catch (RootException e) { 1355 SharkUtilities.emptyCaches(t); 1357 if (e instanceof BaseException) 1358 throw (BaseException)e; 1359 else 1360 throw new BaseException(e); 1361 } finally { 1362 SharkUtilities.releaseTransaction(t); 1363 } 1364 return ret; 1365 } 1366 1367 1376 public Map process_context (SharkTransaction t) throws BaseException { 1377 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1378 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1379 if (sm!=null) { 1380 try { 1381 sm.check_process_process_context(t, 1382 processId, 1383 userAuth, 1384 procInternal.requester(t).getResourceRequesterUsername(t)); 1385 } catch (Exception ex) { 1386 throw new BaseException(ex); 1387 } 1388 } 1389 return procInternal.process_context(t); 1390 } 1391 1392 1401 public void set_process_context (Map new_value) throws BaseException, InvalidData, UpdateNotAllowed { 1402 SharkTransaction t = null; 1403 try { 1404 t = SharkUtilities.createTransaction(); 1405 set_process_context(t, new_value); 1406 SharkUtilities.commitTransaction(t); 1407 } catch (RootException e) { 1408 SharkUtilities.rollbackTransaction(t,e); 1409 if (e instanceof InvalidData) 1410 throw (InvalidData)e; 1411 else if (e instanceof UpdateNotAllowed) 1412 throw (UpdateNotAllowed)e; 1413 else if (e instanceof BaseException) 1414 throw (BaseException)e; 1415 else 1416 throw new BaseException(e); 1417 } finally { 1418 SharkUtilities.releaseTransaction(t); 1419 } 1420 } 1421 1422 1432 public void set_process_context (SharkTransaction t,Map new_value) throws BaseException, InvalidData, UpdateNotAllowed { 1433 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1434 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1435 if (sm!=null) { 1436 try { 1437 sm.check_process_set_process_context(t, 1438 processId, 1439 userAuth, 1440 procInternal.requester(t).getResourceRequesterUsername(t)); 1441 } catch (Exception ex) { 1442 throw new BaseException(ex); 1443 } 1444 } 1445 1446 procInternal.set_process_context(t, new_value); 1447 } 1448 1449 1456 public short priority () throws BaseException { 1457 short ret = -1; 1458 SharkTransaction t = null; 1459 try { 1460 t = SharkUtilities.createTransaction(); 1461 ret = priority(t); 1462 } catch (RootException e) { 1464 SharkUtilities.emptyCaches(t); 1466 if (e instanceof BaseException) 1467 throw (BaseException)e; 1468 else 1469 throw new BaseException(e); 1470 } finally { 1471 SharkUtilities.releaseTransaction(t); 1472 } 1473 return ret; 1474 } 1475 1476 1485 public short priority (SharkTransaction t) throws BaseException { 1486 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1487 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1488 if (sm!=null) { 1489 try { 1490 sm.check_process_priority(t, 1491 processId, 1492 userAuth, 1493 procInternal.requester(t).getResourceRequesterUsername(t)); 1494 } catch (Exception ex) { 1495 throw new BaseException(ex); 1496 } 1497 } 1498 return procInternal.priority(t); 1499 } 1500 1501 1508 public void set_priority (short new_value) throws BaseException { 1509 SharkTransaction t = null; 1510 try { 1511 t = SharkUtilities.createTransaction(); 1512 set_priority(t, new_value); 1513 SharkUtilities.commitTransaction(t); 1514 } catch (RootException e) { 1515 SharkUtilities.rollbackTransaction(t,e); 1516 if (e instanceof BaseException) 1517 throw (BaseException)e; 1518 else 1519 throw new BaseException(e); 1520 } finally { 1521 SharkUtilities.releaseTransaction(t); 1522 } 1523 } 1524 1525 1533 public void set_priority (SharkTransaction t,short new_value) throws BaseException { 1534 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1535 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1536 if (sm!=null) { 1537 try { 1538 sm.check_process_set_priority(t, 1539 processId, 1540 userAuth, 1541 procInternal.requester(t).getResourceRequesterUsername(t)); 1542 } catch (Exception ex) { 1543 throw new BaseException(ex); 1544 } 1545 } 1546 1547 procInternal.set_priority(t, new_value); 1548 } 1549 1550 1557 public void resume() throws BaseException, CannotResume, NotSuspended { 1558 SharkTransaction t = null; 1559 try { 1560 t = SharkUtilities.createTransaction(); 1561 resume(t); 1562 SharkUtilities.commitTransaction(t); 1563 } catch (RootException e) { 1564 SharkUtilities.rollbackTransaction(t,e); 1565 if (e instanceof CannotResume) 1566 throw (CannotResume)e; 1567 else if (e instanceof NotSuspended) 1568 throw (NotSuspended)e; 1569 else if (e instanceof BaseException) 1570 throw (BaseException)e; 1571 else 1572 throw new BaseException(e); 1573 } finally { 1574 SharkUtilities.releaseTransaction(t); 1575 } 1576 } 1577 1578 1587 public void resume(SharkTransaction t) throws BaseException, CannotResume, NotSuspended { 1588 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1589 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1590 if (sm!=null) { 1591 try { 1592 sm.check_process_resume(t, 1593 processId, 1594 userAuth, 1595 procInternal.requester(t).getResourceRequesterUsername(t)); 1596 } catch (Exception ex) { 1597 throw new BaseException(ex); 1598 } 1599 } 1600 1601 procInternal.resume(t); 1602 } 1603 1604 1612 public void suspend() throws BaseException, CannotSuspend, NotRunning, AlreadySuspended { 1613 SharkTransaction t = null; 1614 try { 1615 t = SharkUtilities.createTransaction(); 1616 suspend(t); 1617 SharkUtilities.commitTransaction(t); 1618 } catch (RootException e) { 1619 SharkUtilities.rollbackTransaction(t,e); 1620 if (e instanceof CannotSuspend) 1621 throw (CannotSuspend)e; 1622 else if (e instanceof NotRunning) 1623 throw (NotRunning)e; 1624 else if (e instanceof AlreadySuspended) 1625 throw (AlreadySuspended)e; 1626 else if (e instanceof BaseException) 1627 throw (BaseException)e; 1628 else 1629 throw new BaseException(e); 1630 } finally { 1631 SharkUtilities.releaseTransaction(t); 1632 } 1633 } 1634 1635 1645 public void suspend(SharkTransaction t) throws BaseException, CannotSuspend, NotRunning, AlreadySuspended { 1646 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1647 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1648 if (sm!=null) { 1649 try { 1650 sm.check_process_suspend(t, 1651 processId, 1652 userAuth, 1653 procInternal.requester(t).getResourceRequesterUsername(t)); 1654 } catch (Exception ex) { 1655 throw new BaseException(ex); 1656 } 1657 } 1658 1659 procInternal.suspend(t); 1660 } 1661 1662 1669 public void terminate() throws BaseException, CannotStop, NotRunning { 1670 SharkTransaction t = null; 1671 try { 1672 t = SharkUtilities.createTransaction(); 1673 terminate(t); 1674 SharkUtilities.commitTransaction(t); 1675 } catch (RootException e) { 1676 SharkUtilities.rollbackTransaction(t,e); 1677 if (e instanceof CannotStop) 1678 throw (CannotStop)e; 1679 else if (e instanceof NotRunning) 1680 throw (NotRunning)e; 1681 else if (e instanceof BaseException) 1682 throw (BaseException)e; 1683 else 1684 throw new BaseException(e); 1685 } finally { 1686 SharkUtilities.releaseTransaction(t); 1687 } 1688 } 1689 1690 1699 public void terminate(SharkTransaction t) throws BaseException, CannotStop, NotRunning { 1700 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1701 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1702 if (sm!=null) { 1703 try { 1704 sm.check_process_terminate(t, 1705 processId, 1706 userAuth, 1707 procInternal.requester(t).getResourceRequesterUsername(t)); 1708 } catch (Exception ex) { 1709 throw new BaseException(ex); 1710 } 1711 } 1712 1713 procInternal.terminate(t); 1714 } 1715 1716 1723 public void abort() throws BaseException, CannotStop, NotRunning { 1724 SharkTransaction t = null; 1725 try { 1726 t = SharkUtilities.createTransaction(); 1727 abort(t); 1728 SharkUtilities.commitTransaction(t); 1729 } catch (RootException e) { 1730 SharkUtilities.rollbackTransaction(t,e); 1731 if (e instanceof CannotStop) 1732 throw (CannotStop)e; 1733 else if (e instanceof NotRunning) 1734 throw (NotRunning)e; 1735 else if (e instanceof BaseException) 1736 throw (BaseException)e; 1737 else 1738 throw new BaseException(e); 1739 } finally { 1740 SharkUtilities.releaseTransaction(t); 1741 } 1742 } 1743 1744 1753 public void abort(SharkTransaction t) throws BaseException, CannotStop, NotRunning { 1754 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1755 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1756 if (sm!=null) { 1757 try { 1758 sm.check_process_abort(t, 1759 processId, 1760 userAuth, 1761 procInternal.requester(t).getResourceRequesterUsername(t)); 1762 } catch (Exception ex) { 1763 throw new BaseException(ex); 1764 } 1765 } 1766 1767 procInternal.abort(t); 1768 } 1769 1770 1778 public int how_many_history() throws BaseException, HistoryNotAvailable { 1779 int ret = -1; 1780 SharkTransaction t = null; 1781 try { 1782 t = SharkUtilities.createTransaction(); 1783 ret = how_many_history(t); 1784 } catch (RootException e) { 1786 SharkUtilities.emptyCaches(t); 1788 if (e instanceof HistoryNotAvailable) 1789 throw (HistoryNotAvailable)e; 1790 else if (e instanceof BaseException) 1791 throw (BaseException)e; 1792 else 1793 throw new BaseException(e); 1794 } finally { 1795 SharkUtilities.releaseTransaction(t); 1796 } 1797 return ret; 1798 } 1799 1800 1810 public int how_many_history(SharkTransaction t) throws BaseException, HistoryNotAvailable { 1811 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1812 if (sm!=null) { 1813 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1814 try { 1815 sm.check_process_how_many_history(t, 1816 processId, 1817 userAuth, 1818 procInternal.requester(t).getResourceRequesterUsername(t)); 1819 } catch (Exception ex) { 1820 throw new BaseException(ex); 1821 } 1822 } 1823 1824 try { 1825 EventAuditManagerInterface eam = SharkEngineManager 1826 .getInstance() 1827 .getEventAuditManager(); 1828 if (null == eam) 1829 return 0; 1830 return eam.restoreProcessHistory(processId,t).size(); 1831 } catch (Exception ex) { 1832 throw new BaseException(ex); 1833 } 1834 } 1835 1836 1847 public WfEventAuditIterator get_iterator_history (String query, Map names_in_query) throws BaseException, HistoryNotAvailable { 1848 WfEventAuditIterator ret = null; 1849 SharkTransaction t = null; 1850 try { 1851 t = SharkUtilities.createTransaction(); 1852 ret = get_iterator_history(t, query, names_in_query); 1853 } catch (RootException e) { 1855 SharkUtilities.emptyCaches(t); 1857 if (e instanceof HistoryNotAvailable) 1858 throw (HistoryNotAvailable)e; 1859 else if (e instanceof BaseException) 1860 throw (BaseException)e; 1861 else 1862 throw new BaseException(e); 1863 } finally { 1864 SharkUtilities.releaseTransaction(t); 1865 } 1866 return ret; 1867 } 1868 1869 1881 public WfEventAuditIterator get_iterator_history (SharkTransaction t,String query, Map names_in_query) throws BaseException, HistoryNotAvailable { 1882 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1883 if (sm!=null) { 1884 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1885 try { 1886 sm.check_process_get_iterator_history(t, 1887 processId, 1888 userAuth, 1889 procInternal.requester(t).getResourceRequesterUsername(t)); 1890 } catch (Exception ex) { 1891 throw new BaseException(ex); 1892 } 1893 } 1894 1895 WfEventAuditIterator ret = SharkEngineManager.getInstance().getObjectFactory().createEventAuditIteratorWrapper(t,userAuth,processId); 1896 try { 1897 ret.set_query_expression(t, query); 1898 ret.set_names_in_expression(t, names_in_query); 1899 } catch (NameMismatch e) { 1900 throw new HistoryNotAvailable(e); 1901 } catch (InvalidQuery e) { 1902 throw new HistoryNotAvailable(e); 1903 } 1904 return ret; 1905 } 1906 1907 1918 public WfEventAudit[] get_sequence_history (int max_number) throws BaseException, HistoryNotAvailable { 1919 WfEventAudit[] ret = null; 1920 SharkTransaction t = null; 1921 try { 1922 t = SharkUtilities.createTransaction(); 1923 ret = get_sequence_history(t, max_number); 1924 } catch (RootException e) { 1926 SharkUtilities.emptyCaches(t); 1928 if (e instanceof HistoryNotAvailable) 1929 throw (HistoryNotAvailable)e; 1930 else if (e instanceof BaseException) 1931 throw (BaseException)e; 1932 else 1933 throw new BaseException(e); 1934 } finally { 1935 SharkUtilities.releaseTransaction(t); 1936 } 1937 return ret; 1938 } 1939 1940 1951 public WfEventAudit[] get_sequence_history (SharkTransaction t,int max_number) throws BaseException, HistoryNotAvailable { 1952 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 1953 if (sm!=null) { 1954 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 1955 try { 1956 sm.check_process_get_sequence_history(t, 1957 processId, 1958 userAuth, 1959 procInternal.requester(t).getResourceRequesterUsername(t)); 1960 } catch (Exception ex) { 1961 throw new BaseException(ex); 1962 } 1963 } 1964 1965 List history=SharkUtilities.createProcessHistoryEvents(t,userAuth,processId); 1966 if (max_number>history.size() || max_number<=0) { 1967 max_number=history.size(); 1968 } 1969 WfEventAudit[] eas=new WfEventAudit[max_number]; 1970 history.subList(0,max_number).toArray(eas); 1971 return eas; 1972 } 1973 1974 1983 public boolean is_member_of_history (WfExecutionObject member) throws BaseException { 1984 boolean ret = false; 1985 SharkTransaction t = null; 1986 try { 1987 t = SharkUtilities.createTransaction(); 1988 ret = is_member_of_history(t, member); 1989 } catch (RootException e) { 1991 SharkUtilities.emptyCaches(t); 1993 if (e instanceof BaseException) 1994 throw (BaseException)e; 1995 else 1996 throw new BaseException(e); 1997 } finally { 1998 SharkUtilities.releaseTransaction(t); 1999 } 2000 return ret; 2001 } 2002 2003 2013 public boolean is_member_of_history (SharkTransaction t,WfExecutionObject member) throws BaseException { 2014 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 2015 if (sm!=null) { 2016 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 2017 try { 2018 sm.check_process_is_member_of_history(t, 2019 processId, 2020 userAuth, 2021 procInternal.requester(t).getResourceRequesterUsername(t)); 2022 } catch (Exception ex) { 2023 throw new BaseException(ex); 2024 } 2025 } 2026 2027 boolean ret=false; 2028 List history=SharkUtilities.createProcessHistoryEvents(t,userAuth,processId); 2029 Iterator it=history.iterator(); 2030 while (it.hasNext()) { 2031 WfEventAudit ea=(WfEventAudit)it.next(); 2032 if (member instanceof WfActivity) { 2033 WfActivity act=(WfActivity)member; 2034 if (act.container(t).key(t).equals(ea.process_key()) && 2035 act.key(t).equals(ea.activity_key())) { 2036 ret=true; 2037 break; 2038 } 2039 } else { 2040 if (member.key(t).equals(ea.process_key())) { 2041 ret=true; 2042 break; 2043 } 2044 } 2045 } 2046 return ret; 2047 } 2048 2049 2056 public UtcT last_state_time () throws BaseException { 2057 UtcT ret = null; 2058 SharkTransaction t = null; 2059 try { 2060 t = SharkUtilities.createTransaction(); 2061 ret = last_state_time(t); 2062 } catch (RootException e) { 2064 SharkUtilities.emptyCaches(t); 2066 if (e instanceof BaseException) 2067 throw (BaseException)e; 2068 else 2069 throw new BaseException(e); 2070 } finally { 2071 SharkUtilities.releaseTransaction(t); 2072 } 2073 return ret; 2074 } 2075 2076 2085 public UtcT last_state_time (SharkTransaction t) throws BaseException { 2086 WfProcessInternal procInternal=WfProcessWrapper.getProcessImpl(t,processId); 2087 SecurityManager sm=SharkEngineManager.getInstance().getSecurityManager(); 2088 if (sm!=null) { 2089 try { 2090 sm.check_process_last_state_time(t, 2091 processId, 2092 userAuth, 2093 procInternal.requester(t).getResourceRequesterUsername(t)); 2094 } catch (Exception ex) { 2095 throw new BaseException(ex); 2096 } 2097 } 2098 2099 return procInternal.last_state_time(t); 2100 } 2101 2102 2107 public String toString () { 2108 return "[key="+processId+"]"; 2109 } 2110 2111 2115 public boolean equals (java.lang.Object obj) { 2116 if (!(obj instanceof WfProcess)) return false; 2117 WfProcess proc=(WfProcess)obj; 2118 try { 2119 if (obj instanceof WfProcessWrapper) { 2120 return ((WfProcessWrapper)obj).processId.equals(processId); 2121 } else { 2122 return proc.key().equals(processId); 2123 } 2124 } catch (Exception ex) { 2125 return false; 2126 } 2127 } 2128 2129 private static WfProcessInternal getProcessImpl ( 2130 SharkTransaction t, 2131 String procId) throws BaseException { 2132 WfProcessInternal proc=SharkUtilities.getProcess(t,procId); 2133 if (proc==null) throw new BaseException("Process does not exist"); 2134 return proc; 2135 } 2136 2137} 2138 2139 | Popular Tags |