KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > applications > packaging > projects > gui > Controller


1 /*
2  * This software is OSI Certified Open Source Software.
3  * OSI Certified is a certification mark of the Open Source Initiative.
4  * The license (Mozilla version 1.0) can be read at the MMBase site.
5  * See http://www.MMBase.org/license
6  */

7 package org.mmbase.applications.packaging.projects.gui;
8
9 import java.util.*;
10
11 import org.mmbase.applications.packaging.InstallManager;
12 import org.mmbase.applications.packaging.PackageManager;
13 import org.mmbase.applications.packaging.Person;
14 import org.mmbase.applications.packaging.ProjectManager;
15 import org.mmbase.applications.packaging.packagehandlers.PackageInterface;
16 import org.mmbase.applications.packaging.projects.IncludedPackage;
17 import org.mmbase.applications.packaging.projects.PackageDepend;
18 import org.mmbase.applications.packaging.projects.Project;
19 import org.mmbase.applications.packaging.projects.Target;
20 import org.mmbase.applications.packaging.projects.packageStep;
21 import org.mmbase.applications.packaging.projects.creators.CreatorInterface;
22 import org.mmbase.bridge.Cloud;
23 import org.mmbase.bridge.CloudContext;
24 import org.mmbase.bridge.LocalContext;
25 import org.mmbase.bridge.NodeManager;
26 import org.mmbase.module.core.MMBase;
27 import org.mmbase.module.core.MMObjectNode;
28 import org.mmbase.module.core.VirtualBuilder;
29 import org.mmbase.util.logging.Logger;
30 import org.mmbase.util.logging.Logging;
31
32 /**
33  * @author Daniel Ockeloen
34  * @created July 20, 2004
35  * @version $Id: Controller.java,v 1.9 2005/07/22 20:10:31 michiel Exp $
36  */

37 public class Controller {
38
39     private static Logger log = Logging.getLoggerInstance(Controller.class);
40     private static Cloud cloud;
41     NodeManager manager;
42     CloudContext context;
43
44
45     /**
46      *Constructor for the Controller object
47      */

48     public Controller() {
49         cloud = LocalContext.getCloudContext().getCloud("mmbase");
50
51         // hack needs to be solved
52
manager = cloud.getNodeManager("typedef");
53         if (manager == null) {
54             log.error("Can't access builder typedef");
55         }
56         context = LocalContext.getCloudContext();
57         if (!InstallManager.isRunning()) {
58             InstallManager.init();
59         }
60     }
61
62
63     /**
64      * Gets the projectBundleTargets attribute of the Controller object
65      *
66      * @param name Description of the Parameter
67      * @return The projectBundleTargets value
68      */

69     public List getProjectBundleTargets(String JavaDoc name) {
70         List list = new ArrayList();
71         Project p = ProjectManager.getProject(name);
72         if (p != null) {
73             Iterator targets = p.getBundleTargets();
74
75             VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
76             while (targets.hasNext()) {
77                 Target t = (Target) targets.next();
78                 MMObjectNode virtual = builder.getNewNode("admin");
79                 virtual.setValue("name", t.getName());
80                 virtual.setValue("type", t.getType());
81                 virtual.setValue("path", t.getPath());
82                 virtual.setValue("syntaxerrors", t.hasSyntaxErrors());
83                 list.add(virtual);
84             }
85         }
86         return list;
87     }
88
89
90     /**
91      * Gets the projectPackageTargets attribute of the Controller object
92      *
93      * @param name Description of the Parameter
94      * @return The projectPackageTargets value
95      */

96     public List getProjectPackageTargets(String JavaDoc name) {
97         List list = new ArrayList();
98         Project p = ProjectManager.getProject(name);
99         if (p != null) {
100             Iterator targets = p.getPackageTargets();
101
102             VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
103             while (targets.hasNext()) {
104                 Target t = (Target) targets.next();
105                 MMObjectNode virtual = builder.getNewNode("admin");
106                 virtual.setValue("name", t.getName());
107                 virtual.setValue("type", t.getType());
108                 virtual.setValue("path", t.getPath());
109                 virtual.setValue("syntaxerrors", t.hasSyntaxErrors());
110                 list.add(virtual);
111             }
112         }
113         return list;
114     }
115
116
117     /**
118      * Gets the projectTargets attribute of the Controller object
119      *
120      * @param name Description of the Parameter
121      * @return The projectTargets value
122      */

123     public List getProjectTargets(String JavaDoc name) {
124         List list = new ArrayList();
125         Project p = ProjectManager.getProject(name);
126         if (p != null) {
127             Iterator targets = p.getTargets();
128
129             VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
130             while (targets.hasNext()) {
131                 Target t = (Target) targets.next();
132                 MMObjectNode virtual = builder.getNewNode("admin");
133                 virtual.setValue("name", t.getName());
134                 virtual.setValue("depends", t.getDepends());
135                 list.add(virtual);
136             }
137         }
138         return list;
139     }
140
141
142     /**
143      * Gets the targetPackageSteps attribute of the Controller object
144      *
145      * @param project Description of the Parameter
146      * @param target Description of the Parameter
147      * @param logid Description of the Parameter
148      * @return The targetPackageSteps value
149      */

150     public List getTargetPackageSteps(String JavaDoc project, String JavaDoc target, int logid) {
151         List list = new ArrayList();
152         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
153         Project p = ProjectManager.getProject(project);
154         if (p != null) {
155             Target t = p.getTarget(target);
156             if (t != null) {
157                 Iterator steps = null;
158                 if (logid == -1) {
159                     steps = t.getPackageSteps();
160                 } else {
161                     steps = t.getPackageSteps(logid);
162                 }
163                 if (steps != null) {
164                     while (steps.hasNext()) {
165                         packageStep step = (packageStep) steps.next();
166                         MMObjectNode virtual = builder.getNewNode("admin");
167                         virtual.setValue("userfeedback", step.getUserFeedBack());
168                         virtual.setValue("timestamp", step.getTimeStamp());
169                         virtual.setValue("errorcount", step.getErrorCount());
170                         virtual.setValue("warningcount", step.getWarningCount());
171                         virtual.setValue("id", step.getId());
172                         virtual.setValue("parent", step.getParent());
173                         if (step.hasChilds()) {
174                             virtual.setValue("haschilds", "true");
175                         } else {
176                             virtual.setValue("haschilds", "false");
177                         }
178                         list.add(virtual);
179                     }
180                 }
181             }
182         }
183         return list;
184     }
185
186
187     /**
188      * Description of the Method
189      *
190      * @param project Description of the Parameter
191      * @param target Description of the Parameter
192      * @return Description of the Return Value
193      */

194     public List haveTargetLog(String JavaDoc project, String JavaDoc target) {
195         List list = new ArrayList();
196         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
197         MMObjectNode virtual = builder.getNewNode("admin");
198         Project p = ProjectManager.getProject(project);
199         if (p != null) {
200             Target t = p.getTarget(target);
201             if (t != null) {
202                 Iterator steps = t.getPackageSteps();
203
204                 if (steps != null) {
205                     virtual.setValue("log", "true");
206                 } else {
207                     virtual.setValue("log", "false");
208                 }
209         virtual.setValue("state",t.getState());
210         virtual.setValue("createprogressbarvalue",t.getProgressBarValue());
211         virtual.setValue("createsubprogressbarvalue",t.getSubProgressBarValue());
212             }
213             list.add(virtual);
214         }
215         return list;
216     }
217
218
219     /**
220      * Gets the targetPackageDepends attribute of the Controller object
221      *
222      * @param project Description of the Parameter
223      * @param target Description of the Parameter
224      * @return The targetPackageDepends value
225      */

226     public List getTargetPackageDepends(String JavaDoc project, String JavaDoc target) {
227         List list = new ArrayList();
228         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
229         Project pr = ProjectManager.getProject(project);
230         if (pr != null) {
231             Target t = pr.getTarget(target);
232             if (t != null) {
233                 ArrayList in = t.getPackageDepends();
234                 if (in != null) {
235                     for (Iterator i = in.iterator(); i.hasNext(); ) {
236                         PackageDepend p = (PackageDepend) i.next();
237                         MMObjectNode virtual = builder.getNewNode("admin");
238                         virtual.setValue("name", p.getName());
239                         virtual.setValue("maintainer", p.getMaintainer());
240                         virtual.setValue("version", p.getVersion());
241                         virtual.setValue("versionmode", p.getVersionMode());
242                         virtual.setValue("type", p.getType());
243                         virtual.setValue("id", p.getId());
244                         list.add(virtual);
245                     }
246                 }
247             }
248         }
249         return list;
250     }
251
252
253     /**
254      * Gets the projectTargetInfo attribute of the Controller object
255      *
256      * @param project Description of the Parameter
257      * @param target Description of the Parameter
258      * @return The projectTargetInfo value
259      */

260     public MMObjectNode getProjectTargetInfo(String JavaDoc project, String JavaDoc target) {
261         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
262         MMObjectNode virtual = builder.getNewNode("admin");
263         Project p = ProjectManager.getProject(project);
264         if (p != null) {
265             Target t = p.getTarget(target);
266             if (t != null) {
267                 virtual.setValue("lastversion", t.getLastVersion());
268                 virtual.setValue("nextversion", t.getNextVersion());
269                 virtual.setValue("lastdate", "" + t.getLastDate());
270                 virtual.setValue("description", t.getDescription());
271                 virtual.setValue("maintainer", t.getMaintainer());
272                 virtual.setValue("syntaxerrors", t.hasSyntaxErrors());
273                 virtual.setValue("publishprovider", t.getPublishProvider());
274                 virtual.setValue("publishstate", t.getPublishState());
275                 virtual.setValue("publishsharepassword", t.getPublishSharePassword());
276                 if (t.getRelatedPeople("initiators") == null || t.getRelatedPeople("initiators").size() == 0) {
277                     virtual.setValue("haveinitiators", "false");
278                 } else {
279                     virtual.setValue("haveinitiators", "true");
280                 }
281                 if (t.getRelatedPeople("developers") == null || t.getRelatedPeople("developers").size() == 0) {
282                     virtual.setValue("havedevelopers", "false");
283                 } else {
284                     virtual.setValue("havedevelopers", "true");
285                 }
286                 if (t.getRelatedPeople("contacts") == null || t.getRelatedPeople("contacts").size() == 0) {
287                     virtual.setValue("havecontacts", "false");
288                 } else {
289                     virtual.setValue("havecontacts", "true");
290                 }
291                 virtual.setValue("name", t.getName());
292                 if (t.isBundle()) {
293                     virtual.setValue("bundlename", t.getPackageName());
294                 } else {
295                     virtual.setValue("packagename", t.getPackageName());
296                 }
297                 virtual.setValue("type", t.getType());
298                 virtual.setValue("licensetype", t.getLicenseType());
299                 virtual.setValue("releasenotes", t.getReleaseNotes());
300                 virtual.setValue("installationnotes", t.getInstallationNotes());
301                 virtual.setValue("licensename", t.getLicenseName());
302                 virtual.setValue("licenseversion", t.getLicenseVersion());
303
304         // get info
305
}
306         }
307         return virtual;
308     }
309
310
311     /**
312      * Gets the projectInfo attribute of the Controller object
313      *
314      * @param project Description of the Parameter
315      * @return The projectInfo value
316      */

317     public MMObjectNode getProjectInfo(String JavaDoc project) {
318         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
319         MMObjectNode virtual = builder.getNewNode("admin");
320         Project p = ProjectManager.getProject(project);
321         if (p != null) {
322             virtual.setValue("name", p.getName());
323             virtual.setValue("path", "" + p.getPath());
324             virtual.setValue("dir", "" + p.getDir());
325         }
326         return virtual;
327     }
328
329
330     /**
331      * Gets the targetIncludedPackages attribute of the Controller object
332      *
333      * @param project Description of the Parameter
334      * @param target Description of the Parameter
335      * @return The targetIncludedPackages value
336      */

337     public List getTargetIncludedPackages(String JavaDoc project, String JavaDoc target) {
338         List list = new ArrayList();
339         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
340         Project p = ProjectManager.getProject(project);
341         if (p != null) {
342             Target t = p.getTarget(target);
343             if (t != null) {
344                 ArrayList in = t.getIncludedPackages();
345                 if (in != null) {
346                     for (Iterator i = in.iterator(); i.hasNext(); ) {
347                         IncludedPackage ip = (IncludedPackage) i.next();
348                         MMObjectNode virtual = builder.getNewNode("admin");
349                         virtual.setValue("name", ip.getName());
350                         virtual.setValue("maintainer", ip.getMaintainer());
351                         virtual.setValue("version", ip.getVersion());
352             PackageInterface pa = PackageManager.getPackage(ip.getId());
353             if (pa != null) {
354                             virtual.setValue("forcednew", "false");
355                             virtual.setValue("lastversion", pa.getVersion());
356                 // weird way
357
try {
358                             virtual.setValue("nextversion", Integer.parseInt(pa.getVersion())+1);
359                 } catch (Exception JavaDoc e) {
360                     log.info("Can't create a new version string : "+pa.getVersion());
361                 }
362             } else {
363                             virtual.setValue("forcednew", "true");
364                             virtual.setValue("lastversion", ip.getVersion());
365                 try {
366                                 virtual.setValue("nextversion", Integer.parseInt(ip.getVersion())+1);
367                 } catch (Exception JavaDoc e) {}
368             }
369                         virtual.setValue("type", ip.getType());
370                         virtual.setValue("id", ip.getId());
371                         virtual.setValue("included", ip.getIncluded());
372
373             // add the target name if this is a created inside
374
// the current project.
375
Target t2 = p.getTargetById(ip.getId());
376             if (t2 != null ) {
377                             virtual.setValue("target", t2.getName());
378             } else {
379                             virtual.setValue("target", "");
380             }
381                         list.add(virtual);
382                     }
383                 }
384             }
385         }
386         return list;
387     }
388
389
390     /**
391      * Gets the targetPeople attribute of the Controller object
392      *
393      * @param project Description of the Parameter
394      * @param target Description of the Parameter
395      * @param type Description of the Parameter
396      * @param subtype Description of the Parameter
397      * @return The targetPeople value
398      */

399     public List getTargetPeople(String JavaDoc project, String JavaDoc target, String JavaDoc type, String JavaDoc subtype) {
400         List list = new ArrayList();
401         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
402         Project p = ProjectManager.getProject(project);
403         if (p != null) {
404             Target t = p.getTarget(target);
405             if (t != null) {
406                 List people = t.getRelatedPeople(type);
407                 if (people != null) {
408                     for (Iterator i = people.iterator(); i.hasNext(); ) {
409                         Person pr = (Person) i.next();
410                         MMObjectNode virtual = builder.getNewNode("admin");
411                         virtual.setValue("name", pr.getName());
412                         virtual.setValue("company", pr.getCompany());
413                         virtual.setValue("reason", pr.getReason());
414                         virtual.setValue("mailto", pr.getMailto());
415                         list.add(virtual);
416                     }
417                 }
418             }
419         }
420         return list;
421     }
422
423
424     /**
425      * Gets the targetScreenshots attribute of the Controller object
426      *
427      * @param project Description of the Parameter
428      * @param target Description of the Parameter
429      * @return The Screenshots value
430      */

431     public List getTargetScreenshots(String JavaDoc project, String JavaDoc target) {
432         List list = new ArrayList();
433         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
434         Project p = ProjectManager.getProject(project);
435         if (p != null) {
436             Target t = p.getTarget(target);
437             if (t != null) {
438                 List screenshots = t.getScreenshots();
439                 if (screenshots != null) {
440                     for (Iterator i = screenshots.iterator(); i.hasNext(); ) {
441                         MMObjectNode virtual = builder.getNewNode("admin");
442                         virtual.setValue("name", (String JavaDoc)i.next());
443                         virtual.setValue("link", (String JavaDoc)i.next());
444                         virtual.setValue("description", (String JavaDoc)i.next());
445                         list.add(virtual);
446                     }
447                 }
448             }
449         }
450         return list;
451     }
452
453
454     /**
455      * Description of the Method
456      *
457      * @param project Description of the Parameter
458      * @param target Description of the Parameter
459      * @param newversion Description of the Parameter
460      * @return Description of the Return Value
461      */

462     public boolean packageTarget(String JavaDoc project, String JavaDoc target, int newversion,String JavaDoc latest,String JavaDoc createnew,String JavaDoc publishprovider,String JavaDoc publishstate,String JavaDoc publishsharepassword) {
463         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
464         MMObjectNode virtual = builder.getNewNode("admin");
465         Project p = ProjectManager.getProject(project);
466         if (p != null) {
467     // this first part handles auto includes and updates (mostly for bundles)
468
if (!latest.equals("")) {
469             StringTokenizer tok = new StringTokenizer(latest,",\n\t");
470             while (tok.hasMoreTokens()) {
471                 String JavaDoc pid = tok.nextToken();
472                 PackageInterface pa = PackageManager.getPackage(pid);
473                 if (pa!=null) {
474                         setIncludedVersion(project,target,pid,pa.getVersion());
475                 }
476             }
477         }
478
479                 Target t = p.getTarget(target);
480
481         if (!createnew.equals("")) {
482             StringTokenizer tok = new StringTokenizer(createnew,",\n\t");
483             while (tok.hasMoreTokens()) {
484                 String JavaDoc tid = tok.nextToken();
485                 Target t2 = p.getTarget(tid);
486                 if (t2 != null) {
487                     t.addRelatedTargetsCreate(t2);
488                 }
489             }
490         }
491
492             // set publish changes
493
t.setPublishProvider(publishprovider);
494         t.setPublishSharePassword(publishsharepassword);
495         if (publishstate.equals("true")) {
496             t.setPublishState(true);
497         } else {
498             t.setPublishState(false);
499         }
500         
501             t.createPackageThreaded(newversion);
502         }
503         return true;
504     }
505
506
507     /**
508      * Gets the packageValue attribute of the Controller object
509      *
510      * @param project Description of the Parameter
511      * @param target Description of the Parameter
512      * @param name Description of the Parameter
513      * @return The packageValue value
514      */

515     public String JavaDoc getPackageValue(String JavaDoc project, String JavaDoc target, String JavaDoc name) {
516         Project p = ProjectManager.getProject(project);
517         if (p != null) {
518             Target t = p.getTarget(target);
519             Object JavaDoc o = t.getItem(name);
520             if (o != null) {
521                 return (String JavaDoc) o;
522             }
523         }
524         return "";
525     }
526
527
528     /**
529      * Turn publish mode on for this target
530      *
531      * @return result true/false
532      */

533     public boolean setPublishModeOn(String JavaDoc project, String JavaDoc target,String JavaDoc publishprovider,String JavaDoc sharepassword) {
534     log.info("PROJECT="+project);
535         Project p = ProjectManager.getProject(project);
536         if (p != null) {
537         log.info("TARGET="+target);
538             Target t = p.getTarget(target);
539             if (t != null) {
540             log.info("PROVIDER="+publishprovider);
541         t.setPublishProvider(publishprovider);
542         t.setPublishState(true);
543         t.setPublishSharePassword(sharepassword);
544         t.save();
545         return true;
546             }
547         }
548         return false;
549     }
550
551
552     /**
553      * Turn publish mode off for this target
554      *
555      * @return result true/false
556      */

557     public boolean setPublishModeOff(String JavaDoc project, String JavaDoc target) {
558         Project p = ProjectManager.getProject(project);
559         if (p != null) {
560             Target t = p.getTarget(target);
561             if (t != null) {
562         t.setPublishProvider("");
563         t.setPublishState(false);
564         t.setPublishSharePassword("");
565         t.save();
566         return true;
567             }
568         }
569         return false;
570     }
571
572
573     /**
574      * Sets the packageValue attribute of the Controller object
575      *
576      * @param project The new packageValue value
577      * @param target The new packageValue value
578      * @param newname The new packageValue value
579      * @param newvalue The new packageValue value
580      * @return Description of the Return Value
581      */

582     public boolean setPackageValue(String JavaDoc project, String JavaDoc target, String JavaDoc newname, String JavaDoc newvalue) {
583         Project p = ProjectManager.getProject(project);
584         if (p != null) {
585             Target t = p.getTarget(target);
586             t.setItem(newname, newvalue);
587             t.save();
588             return true;
589         }
590         return false;
591     }
592
593
594     /**
595      * Description of the Method
596      *
597      * @param project Description of the Parameter
598      * @param newname Description of the Parameter
599      * @param newpath Description of the Parameter
600      * @return Description of the Return Value
601      */

602     public boolean changeProjectSettings(String JavaDoc project, String JavaDoc newname, String JavaDoc newpath) {
603         return ProjectManager.changeProjectSettings(project, newname, newpath);
604     }
605
606
607     /**
608      * Sets the includedVersion attribute of the Controller object
609      *
610      * @param project The new includedVersion value
611      * @param target The new includedVersion value
612      * @param id The new includedVersion value
613      * @param newversion The new includedVersion value
614      * @return Description of the Return Value
615      */

616     public boolean setIncludedVersion(String JavaDoc project, String JavaDoc target, String JavaDoc id, String JavaDoc newversion) {
617         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
618         Project p = ProjectManager.getProject(project);
619         if (p != null) {
620             Target t = p.getTarget(target);
621             t.setIncludedVersion(id, newversion);
622         }
623         return true;
624     }
625
626
627     /**
628      * Sets the packageDescription attribute of the Controller object
629      *
630      * @param project The new packageDescription value
631      * @param target The new packageDescription value
632      * @param newdescription The new packageDescription value
633      * @return Description of the Return Value
634      */

635     public boolean setPackageDescription(String JavaDoc project, String JavaDoc target, String JavaDoc newdescription) {
636         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
637         Project p = ProjectManager.getProject(project);
638         if (p != null) {
639             Target t = p.getTarget(target);
640             t.setDescription(newdescription);
641         }
642         return true;
643     }
644
645
646     /**
647      * Sets the packageName attribute of the Controller object
648      *
649      * @param project The new packageName value
650      * @param target The new packageName value
651      * @param newname The new packageName value
652      * @return Description of the Return Value
653      */

654     public boolean setPackageName(String JavaDoc project, String JavaDoc target, String JavaDoc newname) {
655         Project p = ProjectManager.getProject(project);
656         if (p != null) {
657             Target t = p.getTarget(target);
658             t.setName(newname);
659         }
660         return true;
661     }
662
663
664     /**
665      * Sets the packageMaintainer attribute of the Controller object
666      *
667      * @param project The new packageMaintainer value
668      * @param target The new packageMaintainer value
669      * @param newmaintainer The new packageMaintainer value
670      * @return Description of the Return Value
671      */

672     public boolean setPackageMaintainer(String JavaDoc project, String JavaDoc target, String JavaDoc newmaintainer) {
673         Project p = ProjectManager.getProject(project);
674         if (p != null) {
675             Target t = p.getTarget(target);
676             t.setMaintainer(newmaintainer);
677         }
678         return true;
679     }
680
681
682     /**
683      * Sets the packageLicenseVersion attribute of the Controller object
684      *
685      * @param project The new packageLicenseVersion value
686      * @param target The new packageLicenseVersion value
687      * @param newlicenseversion The new packageLicenseVersion value
688      * @return Description of the Return Value
689      */

690     public boolean setPackageLicenseVersion(String JavaDoc project, String JavaDoc target, String JavaDoc newlicenseversion) {
691         Project p = ProjectManager.getProject(project);
692         if (p != null) {
693             Target t = p.getTarget(target);
694             t.setLicenseVersion(newlicenseversion);
695         }
696         return true;
697     }
698
699
700     /**
701      * Sets the packageLicenseName attribute of the Controller object
702      *
703      * @param project The new packageLicenseName value
704      * @param target The new packageLicenseName value
705      * @param newlicensename The new packageLicenseName value
706      * @return Description of the Return Value
707      */

708     public boolean setPackageLicenseName(String JavaDoc project, String JavaDoc target, String JavaDoc newlicensename) {
709         Project p = ProjectManager.getProject(project);
710         if (p != null) {
711             Target t = p.getTarget(target);
712             t.setLicenseName(newlicensename);
713         }
714         return true;
715     }
716
717
718     /**
719      * Sets the packageLicenseType attribute of the Controller object
720      *
721      * @param project The new packageLicenseType value
722      * @param target The new packageLicenseType value
723      * @param newlicensetype The new packageLicenseType value
724      * @return Description of the Return Value
725      */

726     public boolean setPackageLicenseType(String JavaDoc project, String JavaDoc target, String JavaDoc newlicensetype) {
727         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
728         Project p = ProjectManager.getProject(project);
729         if (p != null) {
730             Target t = p.getTarget(target);
731             t.setLicenseType(newlicensetype);
732         }
733         return true;
734     }
735
736
737     /**
738      * Sets the packageInitiator attribute of the Controller object
739      *
740      * @param project The new packageInitiator value
741      * @param target The new packageInitiator value
742      * @param oldname The new packageInitiator value
743      * @param newname The new packageInitiator value
744      * @param oldcompany The new packageInitiator value
745      * @param newcompany The new packageInitiator value
746      * @return Description of the Return Value
747      */

748     public boolean setPackageInitiator(String JavaDoc project, String JavaDoc target, String JavaDoc oldname, String JavaDoc newname, String JavaDoc oldcompany, String JavaDoc newcompany) {
749         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
750         Project p = ProjectManager.getProject(project);
751         if (p != null) {
752             Target t = p.getTarget(target);
753             t.setPackageInitiator(oldname, newname, oldcompany, newcompany);
754         }
755         return true;
756     }
757
758
759     /**
760      * Adds a feature to the PackageInitiator attribute of the Controller object
761      *
762      * @param project The feature to be added to the PackageInitiator attribute
763      * @param target The feature to be added to the PackageInitiator attribute
764      * @param newname The feature to be added to the PackageInitiator attribute
765      * @param newcompany The feature to be added to the PackageInitiator attribute
766      * @return Description of the Return Value
767      */

768     public boolean addPackageInitiator(String JavaDoc project, String JavaDoc target, String JavaDoc newname, String JavaDoc newcompany) {
769         Project p = ProjectManager.getProject(project);
770         if (p != null) {
771             Target t = p.getTarget(target);
772             t.addPackageInitiator(newname, newcompany);
773         }
774         return true;
775     }
776
777
778     /**
779      * Adds a feature to the PackageDepends attribute of the Controller object
780      *
781      * @param project The feature to be added to the PackageDepends attribute
782      * @param target The feature to be added to the PackageDepends attribute
783      * @param packageid The feature to be added to the PackageDepends attribute
784      * @param version The feature to be added to the PackageDepends attribute
785      * @return Description of the Return Value
786      */

787     public boolean addPackageDepends(String JavaDoc project, String JavaDoc target, String JavaDoc packageid, String JavaDoc version) {
788         Project p = ProjectManager.getProject(project);
789         if (p != null) {
790             Target t = p.getTarget(target);
791             t.addPackageDepends(packageid, version);
792         }
793         return true;
794     }
795
796
797     /**
798      * Description of the Method
799      *
800      * @param project Description of the Parameter
801      * @param target Description of the Parameter
802      * @param packageid Description of the Parameter
803      * @param version Description of the Parameter
804      * @param versionmode Description of the Parameter
805      * @return Description of the Return Value
806      */

807     public boolean delPackageDepends(String JavaDoc project, String JavaDoc target, String JavaDoc packageid, String JavaDoc version, String JavaDoc versionmode) {
808         Project p = ProjectManager.getProject(project);
809         if (p != null) {
810             Target t = p.getTarget(target);
811             t.delPackageDepends(packageid, version, versionmode);
812         }
813         return true;
814     }
815
816
817     /**
818      * Description of the Method
819      *
820      * @param project Description of the Parameter
821      * @param target Description of the Parameter
822      * @return Description of the Return Value
823      */

824     public boolean delTarget(String JavaDoc project, String JavaDoc target) {
825         Project p = ProjectManager.getProject(project);
826         if (p != null) {
827             Target t = p.getTarget(target);
828             p.deleteTarget(t.getName());
829         }
830         return true;
831     }
832
833
834     /**
835      * Description of the Method
836      *
837      * @param project Description of the Parameter
838      * @return Description of the Return Value
839      */

840     public boolean delProject(String JavaDoc project) {
841         return ProjectManager.deleteProject(project);
842     }
843
844
845     /**
846      * Sets the packageDepends attribute of the Controller object
847      *
848      * @param project The new packageDepends value
849      * @param target The new packageDepends value
850      * @param packageid The new packageDepends value
851      * @param oldversion The new packageDepends value
852      * @param oldversionmode The new packageDepends value
853      * @param newversion The new packageDepends value
854      * @param newversionmode The new packageDepends value
855      * @return Description of the Return Value
856      */

857     public boolean setPackageDepends(String JavaDoc project, String JavaDoc target, String JavaDoc packageid, String JavaDoc oldversion, String JavaDoc oldversionmode, String JavaDoc newversion, String JavaDoc newversionmode) {
858         Project p = ProjectManager.getProject(project);
859         if (p != null) {
860             Target t = p.getTarget(target);
861             t.setPackageDepends(packageid, oldversion, oldversionmode, newversion, newversionmode);
862         }
863         return true;
864     }
865
866
867     /**
868      * Adds a feature to the BundleTarget attribute of the Controller object
869      *
870      * @param project The feature to be added to the BundleTarget attribute
871      * @param name The feature to be added to the BundleTarget attribute
872      * @param type The feature to be added to the BundleTarget attribute
873      * @param path The feature to be added to the BundleTarget attribute
874      * @return Description of the Return Value
875      */

876     public boolean addBundleTarget(String JavaDoc project, String JavaDoc name, String JavaDoc type, String JavaDoc path) {
877         Project p = ProjectManager.getProject(project);
878         if (p != null) {
879             p.addBundleTarget(name, type, path);
880         }
881         return true;
882     }
883
884
885     /**
886      * Adds a feature to the PackageTarget attribute of the Controller object
887      *
888      * @param project The feature to be added to the PackageTarget attribute
889      * @param name The feature to be added to the PackageTarget attribute
890      * @param type The feature to be added to the PackageTarget attribute
891      * @param path The feature to be added to the PackageTarget attribute
892      * @return Description of the Return Value
893      */

894     public boolean addPackageTarget(String JavaDoc project, String JavaDoc name, String JavaDoc type, String JavaDoc path) {
895         Project p = ProjectManager.getProject(project);
896         if (p != null) {
897             p.addPackageTarget(name, type, path);
898         }
899         return true;
900     }
901
902
903     /**
904      * Description of the Method
905      *
906      * @param project Description of the Parameter
907      * @param target Description of the Parameter
908      * @param oldname Description of the Parameter
909      * @param oldcompany Description of the Parameter
910      * @return Description of the Return Value
911      */

912     public boolean delPackageInitiator(String JavaDoc project, String JavaDoc target, String JavaDoc oldname, String JavaDoc oldcompany) {
913         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
914         Project p = ProjectManager.getProject(project);
915         if (p != null) {
916             Target t = p.getTarget(target);
917             t.delPackageInitiator(oldname, oldcompany);
918         }
919         return true;
920     }
921
922
923     /**
924      * Sets the packageDeveloper attribute of the Controller object
925      *
926      * @param project The new packageDeveloper value
927      * @param target The new packageDeveloper value
928      * @param oldname The new packageDeveloper value
929      * @param newname The new packageDeveloper value
930      * @param oldcompany The new packageDeveloper value
931      * @param newcompany The new packageDeveloper value
932      * @return Description of the Return Value
933      */

934     public boolean setPackageDeveloper(String JavaDoc project, String JavaDoc target, String JavaDoc oldname, String JavaDoc newname, String JavaDoc oldcompany, String JavaDoc newcompany) {
935         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
936         Project p = ProjectManager.getProject(project);
937         if (p != null) {
938             Target t = p.getTarget(target);
939             t.setPackageDeveloper(oldname, newname, oldcompany, newcompany);
940         }
941         return true;
942     }
943
944
945     /**
946      * Adds a feature to the PackageDeveloper attribute of the Controller object
947      *
948      * @param project The feature to be added to the PackageDeveloper attribute
949      * @param target The feature to be added to the PackageDeveloper attribute
950      * @param newname The feature to be added to the PackageDeveloper attribute
951      * @param newcompany The feature to be added to the PackageDeveloper attribute
952      * @return Description of the Return Value
953      */

954     public boolean addPackageDeveloper(String JavaDoc project, String JavaDoc target, String JavaDoc newname, String JavaDoc newcompany) {
955         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
956         Project p = ProjectManager.getProject(project);
957         if (p != null) {
958             Target t = p.getTarget(target);
959             t.addPackageDeveloper(newname, newcompany);
960         }
961         return true;
962     }
963
964
965     /**
966      * Description of the Method
967      *
968      * @param project Description of the Parameter
969      * @param target Description of the Parameter
970      * @param oldname Description of the Parameter
971      * @param oldcompany Description of the Parameter
972      * @return Description of the Return Value
973      */

974     public boolean delPackageDeveloper(String JavaDoc project, String JavaDoc target, String JavaDoc oldname, String JavaDoc oldcompany) {
975         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
976         Project p = ProjectManager.getProject(project);
977         if (p != null) {
978             Target t = p.getTarget(target);
979             t.delPackageDeveloper(oldname, oldcompany);
980         }
981         return true;
982     }
983
984
985     /**
986      * Sets the packageContact attribute of the Controller object
987      *
988      * @param project The new packageContact value
989      * @param target The new packageContact value
990      * @param oldreason The new packageContact value
991      * @param newreason The new packageContact value
992      * @param oldname The new packageContact value
993      * @param newname The new packageContact value
994      * @param oldemail The new packageContact value
995      * @param newemail The new packageContact value
996      * @return Description of the Return Value
997      */

998     public boolean setPackageContact(String JavaDoc project, String JavaDoc target, String JavaDoc oldreason, String JavaDoc newreason, String JavaDoc oldname, String JavaDoc newname, String JavaDoc oldemail, String JavaDoc newemail) {
999         VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1000        Project p = ProjectManager.getProject(project);
1001        if (p != null) {
1002            Target t = p.getTarget(target);
1003            t.setPackageContact(oldreason, newreason, oldname, newname, oldemail, newemail);
1004        }
1005        return true;
1006    }
1007
1008
1009    /**
1010     * Adds a feature to the PackageContact attribute of the Controller object
1011     *
1012     * @param project The feature to be added to the PackageContact attribute
1013     * @param target The feature to be added to the PackageContact attribute
1014     * @param newreason The feature to be added to the PackageContact attribute
1015     * @param newname The feature to be added to the PackageContact attribute
1016     * @param newemail The feature to be added to the PackageContact attribute
1017     * @return Description of the Return Value
1018     */

1019    public boolean addPackageContact(String JavaDoc project, String JavaDoc target, String JavaDoc newreason, String JavaDoc newname, String JavaDoc newemail) {
1020        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1021        Project p = ProjectManager.getProject(project);
1022        if (p != null) {
1023            Target t = p.getTarget(target);
1024            t.addPackageContact(newreason, newname, newemail);
1025        }
1026        return true;
1027    }
1028
1029
1030    /**
1031     * Description of the Method
1032     *
1033     * @param project Description of the Parameter
1034     * @param target Description of the Parameter
1035     * @param oldreason Description of the Parameter
1036     * @param oldname Description of the Parameter
1037     * @param oldemail Description of the Parameter
1038     * @return Description of the Return Value
1039     */

1040    public boolean delPackageContact(String JavaDoc project, String JavaDoc target, String JavaDoc oldreason, String JavaDoc oldname, String JavaDoc oldemail) {
1041        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1042        Project p = ProjectManager.getProject(project);
1043        if (p != null) {
1044            Target t = p.getTarget(target);
1045            t.delPackageContact(oldreason, oldname, oldemail);
1046        }
1047        return true;
1048    }
1049
1050
1051    /**
1052     * Sets the packageSupporter attribute of the Controller object
1053     *
1054     * @param project The new packageSupporter value
1055     * @param target The new packageSupporter value
1056     * @param oldcompany The new packageSupporter value
1057     * @param newcompany The new packageSupporter value
1058     * @return Description of the Return Value
1059     */

1060    public boolean setPackageSupporter(String JavaDoc project, String JavaDoc target, String JavaDoc oldcompany, String JavaDoc newcompany) {
1061        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1062        Project p = ProjectManager.getProject(project);
1063        if (p != null) {
1064            Target t = p.getTarget(target);
1065            t.setPackageSupporter(oldcompany, newcompany);
1066        }
1067        return true;
1068    }
1069
1070
1071    /**
1072     * Adds a feature to the PackageSupporter attribute of the Controller object
1073     *
1074     * @param project The feature to be added to the PackageSupporter attribute
1075     * @param target The feature to be added to the PackageSupporter attribute
1076     * @param newcompany The feature to be added to the PackageSupporter attribute
1077     * @return Description of the Return Value
1078     */

1079    public boolean addPackageSupporter(String JavaDoc project, String JavaDoc target, String JavaDoc newcompany) {
1080        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1081        Project p = ProjectManager.getProject(project);
1082        if (p != null) {
1083            Target t = p.getTarget(target);
1084            t.addPackageSupporter(newcompany);
1085        }
1086        return true;
1087    }
1088
1089
1090    /**
1091     * Description of the Method
1092     *
1093     * @param project Description of the Parameter
1094     * @param target Description of the Parameter
1095     * @param oldcompany Description of the Parameter
1096     * @return Description of the Return Value
1097     */

1098    public boolean delPackageSupporter(String JavaDoc project, String JavaDoc target, String JavaDoc oldcompany) {
1099        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1100        Project p = ProjectManager.getProject(project);
1101        if (p != null) {
1102            Target t = p.getTarget(target);
1103            t.delPackageSupporter(oldcompany);
1104        }
1105        return true;
1106    }
1107
1108
1109    /**
1110     * Description of the Method
1111     *
1112     * @param project Description of the Parameter
1113     * @param target Description of the Parameter
1114     * @param id Description of the Parameter
1115     * @return Description of the Return Value
1116     */

1117    public boolean delIncludedPackage(String JavaDoc project, String JavaDoc target, String JavaDoc id) {
1118        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1119        Project p = ProjectManager.getProject(project);
1120        if (p != null) {
1121            Target t = p.getTarget(target);
1122            t.delIncludedPackage(id);
1123        }
1124        return true;
1125    }
1126
1127
1128    /**
1129     * Adds a feature to the TargetPackage attribute of the Controller object
1130     *
1131     * @param project The feature to be added to the TargetPackage attribute
1132     * @param target The feature to be added to the TargetPackage attribute
1133     * @param newpackage The feature to be added to the TargetPackage attribute
1134     * @return Description of the Return Value
1135     */

1136    public boolean addTargetPackage(String JavaDoc project, String JavaDoc target, String JavaDoc newpackage) {
1137        Project p = ProjectManager.getProject(project);
1138        if (p != null) {
1139            Target t = p.getTarget(target);
1140            t.addPackage(newpackage);
1141        }
1142        return true;
1143    }
1144
1145
1146    /**
1147     * Adds a feature to the Project attribute of the Controller object
1148     *
1149     * @param newprojectname The feature to be added to the Project attribute
1150     * @param newprojectpath The feature to be added to the Project attribute
1151     * @return Description of the Return Value
1152     */

1153    public boolean addProject(String JavaDoc newprojectname, String JavaDoc newprojectpath) {
1154        ProjectManager.addProject(newprojectname, newprojectpath);
1155        return true;
1156    }
1157
1158
1159    /**
1160     * Gets the projects attribute of the Controller object
1161     *
1162     * @return The projects value
1163     */

1164    public List getProjects() {
1165        // get the current best packages
1166
Iterator projects = ProjectManager.getProjects();
1167
1168        List list = new ArrayList();
1169        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1170
1171        while (projects.hasNext()) {
1172            Project p = (Project) projects.next();
1173            MMObjectNode virtual = builder.getNewNode("admin");
1174            virtual.setValue("name", p.getName());
1175            virtual.setValue("path", p.getPath());
1176            virtual.setValue("syntaxerrors", p.hasSyntaxErrors());
1177            list.add(virtual);
1178        }
1179        return list;
1180    }
1181
1182
1183    /**
1184     * Gets the creators attribute of the Controller object
1185     *
1186     * @return The creators value
1187     */

1188    public List getCreators() {
1189        // get the current creators we have installed
1190
Map creators = ProjectManager.getCreators();
1191        List list = new ArrayList();
1192        VirtualBuilder builder = new VirtualBuilder(MMBase.getMMBase());
1193
1194        Iterator e = creators.keySet().iterator();
1195        while (e.hasNext()) {
1196            String JavaDoc key = (String JavaDoc) e.next();
1197            CreatorInterface cr = (CreatorInterface) creators.get(key);
1198
1199            MMObjectNode virtual = builder.getNewNode("admin");
1200            virtual.setValue("name", key);
1201            virtual.setValue("value", cr.getClass());
1202            list.add(virtual);
1203        }
1204        return list;
1205    }
1206
1207}
1208
Popular Tags