1 package org.enhydra.shark.corbaclient.workflowadmin.definition.actions; 2 3 import org.omg.WfBase.*; 4 import org.enhydra.shark.corba.WorkflowService.*; 5 6 import java.awt.event.*; 7 import javax.swing.*; 8 import java.util.*; 9 10 import org.enhydra.shark.corbaclient.*; 11 import org.enhydra.shark.corbaclient.workflowadmin.*; 12 import org.enhydra.shark.corbaclient.workflowadmin.definition.*; 13 14 20 public class UpdatePackage extends ActionBase { 21 22 public UpdatePackage (PackageManagement pdm) { 23 super(pdm); 24 } 25 26 public void actionPerformed(ActionEvent e) { 27 PackageManagement pdm=(PackageManagement)actionPanel; 28 SharkAdmin workflowAdmin=pdm.getWorkflowAdmin(); 29 30 String selPkgId=pdm.getSelectedPackageId(); 32 if (selPkgId==null) return; 33 try { 34 boolean ipr=SharkAdmin.getPackageAmin().isPackageReferenced(selPkgId); 35 36 if (ipr) { 37 String msg=ResourceManager.getLanguageDependentString("MessagePackageIsReferencedDoYouWantToProceed"); 38 int r=JOptionPane.showConfirmDialog(pdm.getWindow(),msg, 39 workflowAdmin.getAppTitle(),JOptionPane.YES_NO_OPTION); 40 if (r==JOptionPane.NO_OPTION) return; 41 } 42 } catch (Exception be) { 43 String errMsg=ResourceManager.getLanguageDependentString("ErrorTheUpdateOfSelectedPackageIsNotAllowedAtTheMoment"); 44 JOptionPane.showMessageDialog(workflowAdmin.getFrame(),errMsg, 45 workflowAdmin.getAppTitle(),JOptionPane.ERROR_MESSAGE); 46 return; 47 } 48 49 List allPackages=new ArrayList(); 52 try { 53 NameValue[] allPkgs=SharkAdmin.getRepositoryManager().getPackagePathToIdMapping(); 54 if (allPkgs!=null && allPkgs.length>0) { 55 for (int i=0; i<allPkgs.length; i++) { 56 if (allPkgs[i].the_value.extract_wstring().equals(selPkgId)) { 57 allPackages.add(WorkflowUtilities.convertNameValueToNameValueString(allPkgs[i])); 58 } 59 } 60 } 61 } catch (Exception ex) { 62 String errMsg=ResourceManager.getLanguageDependentString("ErrorTheUpdateOfSelectedPackageIsNotAllowedAtTheMoment"); 63 JOptionPane.showMessageDialog(workflowAdmin.getFrame(),errMsg, 64 workflowAdmin.getAppTitle(),JOptionPane.ERROR_MESSAGE); 65 return; 66 } 67 68 SelectPackage spd=new SelectPackage (this,pdm.getWindow(),allPackages); 69 spd.showDialog(); 70 } 71 72 public void updatePackage (String pkgId,String newPkgFilename) { 73 74 PackageManagement pdm=(PackageManagement)actionPanel; 75 SharkAdmin workflowAdmin=pdm.getWorkflowAdmin(); 76 workflowAdmin.stopRefresher(); 77 while (workflowAdmin.isRefresherActive()); 79 String selPkgId=pdm.getSelectedPackageId(); 80 if (selPkgId!=null) { 81 SplashScreen ss=workflowAdmin.getSplashScreen(); 82 ss.show("WaitImage", 83 workflowAdmin.getFullUserName(), 84 ResourceManager.getLanguageDependentString("MessagePleaseWait")); 85 86 String errMsg=null; 87 String xpdlReport="Something went wrong"; 88 try { 89 try { 90 SharkAdmin.getPackageAmin().updatePackage1(pkgId,newPkgFilename); 91 } catch (BaseException be){ 92 throw new PackageUpdateNotAllowed(); 93 } 94 } catch (PackageInvalid ipe) { 95 errMsg=ResourceManager.getLanguageDependentString("ErrorTheUpdaterPackageIsInvalid"); 96 xpdlReport=ipe.XPDLValidationErrors; 97 } catch (PackageUpdateNotAllowed puna) { 98 errMsg=ResourceManager.getLanguageDependentString("ErrorTheUpdateOfSelectedPackageIsNotAllowedAtTheMoment"); 99 } catch (Exception ex) { 100 errMsg=ResourceManager.getLanguageDependentString("ErrorTheUpdateOfSelectedPackageFailed"); 101 } 102 workflowAdmin.refreshAfterUpdate(); 103 workflowAdmin.requestFocus(); 104 ss.hide(); 105 106 if (errMsg!=null) { 107 JOptionPane.showMessageDialog(workflowAdmin.getFrame(),errMsg, 108 workflowAdmin.getAppTitle(),JOptionPane.ERROR_MESSAGE); 109 pdm.getWorkflowAdmin().showXPDLErrorsReport(xpdlReport); 110 } 111 } 112 workflowAdmin.startRefresher(); 113 } 114 115 } 116 117 | Popular Tags |