1 10 package org.mmbase.applications.packaging.bundlehandlers.gui; 11 12 import java.util.ArrayList ; 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.mmbase.applications.packaging.BundleManager; 18 import org.mmbase.applications.packaging.InstallManager; 19 import org.mmbase.applications.packaging.PackageManager; 20 import org.mmbase.applications.packaging.Person; 21 import org.mmbase.applications.packaging.ProviderManager; 22 import org.mmbase.applications.packaging.bundlehandlers.BundleInterface; 23 import org.mmbase.applications.packaging.bundlehandlers.BundleVersionContainer; 24 import org.mmbase.applications.packaging.packagehandlers.PackageInterface; 25 import org.mmbase.applications.packaging.providerhandlers.ProviderInterface; 26 import org.mmbase.bridge.Cloud; 27 import org.mmbase.bridge.CloudContext; 28 import org.mmbase.bridge.LocalContext; 29 import org.mmbase.bridge.NodeManager; 30 import org.mmbase.module.core.MMBase; 31 import org.mmbase.module.core.MMObjectNode; 32 import org.mmbase.module.core.VirtualBuilder; 33 import org.mmbase.util.logging.Logger; 34 import org.mmbase.util.logging.Logging; 35 36 37 41 public class Controller { 42 43 private static Logger log = Logging.getLoggerInstance(Controller.class); 44 private static Cloud cloud; 45 NodeManager manager; 46 CloudContext context; 47 48 49 public Controller() { 50 cloud = LocalContext.getCloudContext().getCloud("mmbase"); 51 52 manager = cloud.getNodeManager("typedef"); 54 if (manager == null) log.error("Can't access builder typedef"); 55 context = LocalContext.getCloudContext(); 56 if (!InstallManager.isRunning()) InstallManager.init(); 57 } 58 59 60 public List getBundles() { 61 ProviderManager.resetSleepCounter(); 63 64 Iterator bundles = BundleManager.getBundles(); 66 67 List list = new ArrayList (); 68 VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase()); 69 70 while (bundles.hasNext()) { 71 BundleInterface b = (BundleInterface)bundles.next(); 72 MMObjectNode virtual = builder.getNewNode("admin"); 73 virtual.setValue("id",b.getId()); 74 virtual.setValue("name",b.getName()); 75 virtual.setValue("type",b.getType()); 76 virtual.setValue("maintainer",b.getMaintainer()); 77 virtual.setValue("version",b.getVersion()); 78 virtual.setValue("creation-date",b.getCreationDate()); 79 virtual.setValue("state",b.getState()); 80 list.add(virtual); 81 } 82 return list; 83 } 84 85 86 public List getBundleVersions(String id) { 87 Iterator bundleversions = BundleManager.getBundleVersions(id); 89 90 List list = new ArrayList (); 91 VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase()); 92 93 while (bundleversions.hasNext()) { 94 BundleVersionContainer bvc = (BundleVersionContainer)bundleversions.next(); 95 96 Iterator bundles = bvc.getBundles(); 97 while (bundles.hasNext()) { 98 BundleInterface b = (BundleInterface)bundles.next(); 99 MMObjectNode virtual = builder.getNewNode("admin"); 100 virtual.setValue("id",b.getId()); 101 virtual.setValue("name",b.getName()); 102 virtual.setValue("type",b.getType()); 103 virtual.setValue("maintainer",b.getMaintainer()); 104 virtual.setValue("version",b.getVersion()); 105 virtual.setValue("state",b.getState()); 106 virtual.setValue("creation-date",b.getCreationDate()); 107 ProviderInterface provider=b.getProvider(); 108 if (provider != null) { 109 virtual.setValue("provider",provider.getName()); 110 } 111 list.add(virtual); 112 } 113 } 114 return list; 115 } 116 117 118 public List getBundleNeededPackages(String id,String wv,String newuser) { 119 BundleInterface bundle = BundleManager.getBundle(id); 121 Iterator neededpackages = bundle.getNeededPackages(); 122 List list = new ArrayList (); 123 VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase()); 124 125 while (neededpackages.hasNext()) { 126 HashMap np = (HashMap )neededpackages.next(); 127 128 MMObjectNode virtual = builder.getNewNode("admin"); 129 virtual.setValue("name",(String )np.get("name")); 130 virtual.setValue("id",(String )np.get("id")); 131 virtual.setValue("type",(String )np.get("type")); 132 virtual.setValue("maintainer",(String )np.get("maintainer")); 133 virtual.setValue("version",(String )np.get("version")); 134 PackageInterface fp = PackageManager.getPackage((String )np.get("id")); 135 if (fp != null) { 136 String state = fp.getState(); 137 String provider = (fp.getProvider()).getName(); 138 virtual.setValue("state",state); 139 virtual.setValue("provider",provider); 140 virtual.setValue("creation-date",fp.getCreationDate()); 141 virtual.setValue("description",fp.getDescription()); 142 virtual.setValue("releasenotes",fp.getReleaseNotes()); 143 virtual.setValue("installationnotes",fp.getInstallationNotes()); 144 virtual.setValue("licensename",fp.getLicenseName()); 145 virtual.setValue("licensetype",fp.getLicenseType()); 146 virtual.setValue("licenseversion",fp.getLicenseVersion()); 147 virtual.setValue("licensebody",fp.getLicenseBody()); 148 List l = fp.getRelatedPeople("initiators"); 149 if (l != null) virtual.setValue("initiators",getRelatedPeopleString(l,"initiators")); 150 l = fp.getRelatedPeople("supporters"); 151 if (l != null) virtual.setValue("supporters",getRelatedPeopleString(l,"supporters")); 152 l = fp.getRelatedPeople("developers"); 153 if (l != null) virtual.setValue("developers",getRelatedPeopleString(l,"developers")); 154 l = fp.getRelatedPeople("contacts"); 155 if (l != null) virtual.setValue("contacts",getRelatedPeopleString(l,"contacts")); 156 } else { 157 virtual.setValue("state","missing"); 158 virtual.setValue("provider",""); 159 } 160 list.add(virtual); 161 } 162 return list; 163 } 164 165 166 public String getRelatedPeopleString(List people,String type) { 167 String body = ""; 168 if (people != null) { 169 for (Iterator i = people.iterator(); i.hasNext();) { 170 Person pr = (Person)i.next(); 171 if (type.equals("initiators")) { 172 body += "\t\t\t<initiator name=\""+pr.getName()+"\" company=\""+pr.getCompany()+"\" />\n"; 173 } else if (type.equals("developers")) { 174 body += "\t\t\t<developer name=\""+pr.getName()+"\" company=\""+pr.getCompany()+"\" mailto=\""+pr.getMailto()+"\" />\n"; 175 } else if (type.equals("contacts")) { 176 body += "\t\t\t<contact reason=\""+pr.getReason()+"\" name=\""+pr.getName()+"\" mailto=\""+pr.getMailto()+"\" />\n"; 177 } else if (type.equals("supporters")) { 178 body += "\t\t\t<supporter company=\""+pr.getCompany()+"\" />\n"; 179 } 180 } 181 } 182 return body; 183 } 184 185 } 186 | Popular Tags |