1 26 27 package org.objectweb.openccm.packaging; 28 29 import org.objectweb.util.browser.api.MenuItem; 31 import org.objectweb.util.browser.api.MenuItemTreeView; 32 import org.objectweb.openccm.descriptor.softpkg.gui.SoftpkgZipper; 33 34 38 public class ComponentPackager 39 implements MenuItem 40 { 41 47 53 59 60 66 71 public int 72 getStatus(org.objectweb.util.browser.api.TreeView treeView) 73 { 74 return org.objectweb.util.browser.api.MenuItem.ENABLED_STATUS; 75 } 76 77 80 public void actionPerformed(MenuItemTreeView e) 81 throws Exception 82 { 83 String action = e.getActionEvent().getActionCommand(); 84 85 org.objectweb.apollon.framework.Bean zeus_instance 87 = (org.objectweb.apollon.framework.Bean) 88 e.getSelectedObject(); 89 90 org.objectweb.util.browser.api.Entry entry 92 = e.getSelectedEntry(); 93 94 String descriptor_filename 97 = CCMSplitPane.get_file_by_id( 98 (String ) entry.getName() 99 ); 100 101 make_zip (zeus_instance, descriptor_filename); 103 } 104 105 112 public void 113 make_zip ( 114 org.objectweb.apollon.framework.Bean zeus_instance, 115 String descriptor_filename 116 ) 117 throws Exception 118 { 119 if (zeus_instance.idBean().equals("[Softpkg]")) 120 { 121 throw new Exception ( 122 "Undefined Soft Package NAME for " 123 +descriptor_filename); 124 } 125 else 126 { 127 java.io.File zipfile 128 = new java.io.File ( 129 zeus_instance.idBean() 130 +".car" 131 ); 132 133 System.err.println("Starting Component ARchive creation..."); 134 135 ZipFactory zip_factory 137 = new ZipFactory(); 138 139 zip_factory.setZipName(zipfile.getAbsolutePath()); 140 141 java.io.File original_descriptor_file 143 = new java.io.File ( 144 descriptor_filename 145 ); 146 java.io.File temp_descriptor_file 148 = new java.io.File ( 149 "META-INF" 150 +System.getProperty("file.separator") 151 +original_descriptor_file.getName() 152 ); 153 154 try 155 { 156 zeus_instance.marshalBean(temp_descriptor_file); 158 } catch (Exception except) { 159 except.printStackTrace(); 160 } 161 162 zip_factory 164 .addFileToZip( 165 temp_descriptor_file.getPath() 166 ); 167 168 SoftpkgZipper zipper 170 = (SoftpkgZipper) zeus_instance 171 .getExtensionManager() 172 .getExtensionByName("gui.Zipper") 173 .getInstance(); 174 zipper.zipCall( 175 (org.objectweb.openccm.descriptor 176 .softpkg.beans.SoftpkgBean) 177 zeus_instance 178 , zip_factory); 179 180 try 182 { 183 zip_factory.buildZip(); 184 System.err.println("End of the CAR creation, writing file:"); 185 System.err.println(zipfile.getAbsolutePath()); 186 } catch (Exception exc) { 187 System.err.println("Package could not be built. See following stacktrace"); 188 exc.printStackTrace(); 189 } 190 } 191 } 192 } 193 | Popular Tags |