Permalink
Browse files

bug fixes

  • Loading branch information...
kohsuke
kohsuke committed Oct 9, 2010
1 parent 3c6a73d commit 0b2408e4681836949f79e7da1210453581993495
@@ -88,7 +88,7 @@ public String getDisplayName() {
return "Associate Persona";
}
- public ListBoxModel doFillPersonaItems() {
+ public ListBoxModel doFillPersonaIdItems() {
ListBoxModel r = new ListBoxModel();
for (Persona p : Persona.all()) {
r.add(p.getDisplayName(),p.id);
@@ -26,6 +26,7 @@
import hudson.Extension;
import hudson.ExtensionFinder;
import hudson.FilePath;
+import hudson.PluginWrapper;
import hudson.model.AbstractBuild;
import hudson.model.Hudson;
import hudson.model.Result;
@@ -61,27 +62,34 @@
List<SimplePersona> r = new ArrayList<SimplePersona>();
+ // locate personas from $HUDSON_HOME
try {
FilePath baseDir = new FilePath(hudson.getRootDir());
for (FilePath xml : baseDir.list("persona/**/*.xml")) {
- try {
- URL url = xml.toURI().toURL();
- r.add(parsePersona(url,
- xml.getParent().toURI().toURL(),
- xml.getParent().getRemote().substring(baseDir.getRemote().length()+1)));
- } catch (IOException e) {
- LOGGER.log(Level.SEVERE, "Faied to load a persona from "+xml,e);
- } catch (DocumentException e) {
- LOGGER.log(Level.SEVERE, "Faied to load a persona from "+xml,e);
- }
+ URL url = xml.toURI().toURL();
+ parsePersonaInto(url,
+ xml.getParent().toURI().toURL(),
+ xml.getParent().getRemote().substring(baseDir.getRemote().length()+1),r);
}
} catch (IOException e) {
- LOGGER.log(Level.SEVERE, "Faied to load personas",e);
+ LOGGER.log(Level.SEVERE, "Failed to load personas",e);
} catch (InterruptedException e) {
// all local processing. can't happen
throw new Error(e);
}
+ // locate personas from plugins
+ for (PluginWrapper pw : hudson.getPluginManager().getPlugins()) {
+ URL xml;
+ try {
+ xml = new URL(pw.baseResourceURL,"persona.xml");
+ xml.openStream().close();
+ } catch (IOException e) {
+ continue; // no such file
+ }
+ parsePersonaInto(xml,pw.baseResourceURL,"plugin/"+pw.getShortName(),r);
+ }
+
return (List)r;
}
@@ -101,6 +109,16 @@ private String findImage(URL imageBase, String imageBasePath, String baseName) t
throw new IOException("No image found that matches "+imageBase+"/"+baseName+".*");
}
+ private void parsePersonaInto(URL xml, URL imageBase, String imageBasePath, Collection<SimplePersona> result) {
+ try {
+ result.add(parsePersona(xml,imageBase,imageBasePath));
+ } catch (DocumentException e) {
+ LOGGER.log(Level.SEVERE, "Faied to load a persona from "+xml,e);
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, "Faied to load a persona from "+xml,e);
+ }
+ }
+
/**
* Parses a persona from an XML file.
*

0 comments on commit 0b2408e

Please sign in to comment.