1 10 11 package org.mmbase.applications.packaging.bundlehandlers; 12 13 import java.io.BufferedInputStream ; 14 import java.util.HashMap ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.jar.JarFile ; 18 19 import org.mmbase.applications.packaging.providerhandlers.ProviderInterface; 20 import org.mmbase.applications.packaging.sharehandlers.ShareInfo; 21 22 34 public class BundleContainer implements BundleInterface { 35 36 private ShareInfo shareinfo; 37 38 private BundleInterface activeBundle; 39 40 private HashMap versions = new HashMap (); 41 42 public BundleContainer(BundleInterface b) { 43 this.activeBundle = b; 45 46 BundleVersionContainer bvc=new BundleVersionContainer(b); 48 versions.put(b.getVersion(),bvc); 49 } 50 51 52 public boolean contains(String version,ProviderInterface provider) { 53 BundleVersionContainer vc=(BundleVersionContainer)versions.get(version); 54 if (vc!=null) { 55 return vc.contains(provider); 56 } 57 return false; 58 } 59 60 61 public boolean removeBundle(BundleInterface b) { 62 versions.remove(b.getVersion()); 63 return true; 64 } 65 66 public int getBundleCount() { 67 return versions.size(); 68 } 69 70 public boolean addBundle(BundleInterface b) { 71 BundleVersionContainer vc = (BundleVersionContainer)versions.get(b.getVersion()); 72 if (vc != null) { 74 vc.addBundle(b); 75 } else { 76 BundleVersionContainer bvc = new BundleVersionContainer(b); 77 versions.put(b.getVersion(),bvc); 78 } 79 80 try { 82 int oldversion = Integer.parseInt(activeBundle.getVersion()); 83 int newversion = Integer.parseInt(b.getVersion()); 84 if (newversion > oldversion) { 85 activeBundle = b; 87 } else if (newversion == oldversion) { 88 int oldbaseScore = activeBundle.getProvider().getBaseScore(); 89 int newbaseScore = b.getProvider().getBaseScore(); 90 if (newbaseScore > oldbaseScore) { 91 activeBundle = b; 92 } 93 } 94 } catch(Exception e) {}; 95 return true; 96 } 97 98 public Iterator getNeededPackages() { 99 return activeBundle.getNeededPackages(); 100 } 101 102 public List getRelatedPeople(String type) { 103 return activeBundle.getRelatedPeople(type); 104 } 105 106 public List getScreenshots() { 107 return activeBundle.getScreenshots(); 108 } 109 110 public List getStarturls() { 111 return activeBundle.getStarturls(); 112 } 113 114 public String getName() { 115 return activeBundle.getName(); 116 } 117 118 public String getVersion() { 119 return activeBundle.getVersion(); 120 } 121 122 public String getState() { 123 return activeBundle.getState(); 124 } 125 126 public boolean setState(String state) { 127 return activeBundle.setState(state); 128 } 129 130 public boolean install() { 131 return activeBundle.install(); 132 } 133 134 public boolean uninstall() { 135 return activeBundle.uninstall(); 136 } 137 138 public String getCreationDate() { 139 return activeBundle.getCreationDate(); 140 } 141 142 public String getMaintainer() { 143 return activeBundle.getMaintainer(); 144 } 145 146 public String getType() { 147 return activeBundle.getType(); 148 } 149 150 public String getId() { 151 return activeBundle.getId(); 152 } 153 154 public String getPath() { 155 return activeBundle.getPath(); 156 } 157 158 public ProviderInterface getProvider() { 159 return activeBundle.getProvider(); 160 } 161 162 public Iterator getVersions() { 163 return ((HashMap )versions.clone()).values().iterator(); 164 } 165 166 public BundleInterface getVersion(String version,ProviderInterface provider) { 167 BundleVersionContainer bvc = (BundleVersionContainer)versions.get(version); 168 if (bvc != null) { 169 BundleInterface b = (BundleInterface)bvc.get(provider); 170 if (b != null) { 171 return b; 172 } else { 173 return null; 174 } 175 } else { 176 return null; 177 } 178 } 179 180 181 public BundleInterface getBundleByScore(String version) { 182 BundleVersionContainer bvc=(BundleVersionContainer)versions.get(version); 183 if (bvc!=null) { 184 return bvc.getBundleByScore(); 185 } 186 return null; 187 } 188 189 public Iterator getInstallSteps() { 190 return activeBundle.getInstallSteps(); 191 } 192 193 public Iterator getInstallSteps(int logid) { 194 return activeBundle.getInstallSteps(logid); 195 } 196 197 public void clearInstallSteps() { 198 activeBundle.clearInstallSteps(); 199 } 200 201 public JarFile getJarFile() { 202 return activeBundle.getJarFile(); 203 } 204 205 public JarFile getIncludedPackageJarFile(String packageid,String packageversion) { 206 return activeBundle.getIncludedPackageJarFile(packageid,packageversion); 207 } 208 209 public BufferedInputStream getJarStream() { 210 return activeBundle.getJarStream(); 211 } 212 213 public boolean isShared() { 214 if (shareinfo != null) { 215 return true; 216 } 217 return false; 218 } 219 220 public ShareInfo getShareInfo() { 221 return shareinfo; 222 } 223 224 public void setShareInfo(ShareInfo shareinfo) { 225 this.shareinfo = shareinfo; 226 } 227 228 public void removeShare() { 229 this.shareinfo = null; 230 } 231 232 233 public String getDescription() { 234 return activeBundle.getDescription(); 235 } 236 237 public String getReleaseNotes() { 238 return activeBundle.getReleaseNotes(); 239 } 240 241 public String getInstallationNotes() { 242 return activeBundle.getInstallationNotes(); 243 } 244 245 246 public String getLicenseType() { 247 return activeBundle.getLicenseType(); 248 } 249 250 public String getLicenseName() { 251 return activeBundle.getLicenseName(); 252 } 253 254 public String getLicenseVersion() { 255 return activeBundle.getLicenseVersion(); 256 } 257 258 public String getLicenseBody() { 259 return activeBundle.getLicenseBody(); 260 } 261 262 public void setProgressBar(int stepcount) { 263 activeBundle.setProgressBar(stepcount); 264 } 265 266 public void increaseProgressBar() { 267 activeBundle.increaseProgressBar(); 268 } 269 270 public void increaseProgressBar(int stepcount) { 271 activeBundle.increaseProgressBar(stepcount); 272 } 273 274 public int getProgressBarValue() { 275 return activeBundle.getProgressBarValue(); 276 } 277 278 public int getPackageProgressBarValue() { 279 return activeBundle.getPackageProgressBarValue(); 280 } 281 282 } 283 | Popular Tags |