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