diff --git a/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java b/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java index ef5971b9..82d2a76c 100644 --- a/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java +++ b/src/main/java/hudson/plugins/promoted_builds/JobPropertyImpl.java @@ -64,13 +64,6 @@ public final class JobPropertyImpl extends JobProperty> imp * These {@link PromotionProcess}es are active. */ private final Set activeProcessNames = new HashSet(); - -// /** -// * Names of the processes that are configured. -// * Used to construct {@link #processes}. -// */ -// private final List names = new ArrayList(); - /** * Programmatic construction. */ @@ -117,13 +110,13 @@ private JobPropertyImpl(StaplerRequest req, JSONObject json) throws Descriptor.F init(); } private void loadAllProcesses(File rootDir) throws IOException { - File[] subdirs = rootDir.listFiles(new FileFilter() { - public boolean accept(File child) { - return child.isDirectory(); - } - }); - - loadProcesses(subdirs); + File[] subdirs = rootDir.listFiles(new FileFilter() { + public boolean accept(File child) { + return child.isDirectory(); + } + }); + + loadProcesses(subdirs); } private void init() throws IOException { // load inactive processes @@ -134,8 +127,8 @@ public boolean accept(File child) { }); loadProcesses(subdirs); } - private void loadProcesses(File[] subdirs) throws IOException { - if(subdirs!=null) { + private void loadProcesses(File[] subdirs) throws IOException { + if(subdirs!=null) { for (File subdir : subdirs) { try { PromotionProcess p = (PromotionProcess) Items.load(this, subdir); @@ -147,7 +140,7 @@ private void loadProcesses(File[] subdirs) throws IOException { } buildActiveProcess(); - } + } /** * Adds a new promotion process of the given name. @@ -194,7 +187,7 @@ protected synchronized void setOwner(AbstractProject owner) { // so use this as the initialization opportunity. // CopyListener is also using setOwner to re-init after copying config from another job. processes = new ArrayList(ItemGroupMixIn.loadChildren( - this,getRootDir(),ItemGroupMixIn.KEYED_BY_NAME).values()); + this,getRootDir(),ItemGroupMixIn.KEYED_BY_NAME).values()); try { buildActiveProcess(); } catch (IOException e) { @@ -219,7 +212,7 @@ private void buildActiveProcess() throws IOException { String processName = p.getName(); String activeProcessName = getActiveProcessName(processName); if (!activeProcessName.equals(processName)){ - p.renameTo(activeProcessName); + p.renameTo(activeProcessName); } } } @@ -371,16 +364,16 @@ public Action getJobAction(AbstractProject job) { @Extension public static final class DescriptorImpl extends JobPropertyDescriptor { - + public DescriptorImpl() { - super(); - } + super(); + } - public DescriptorImpl(Class> clazz) { - super(clazz); - } + public DescriptorImpl(Class> clazz) { + super(clazz); + } - public String getDisplayName() { + public String getDisplayName() { return "Promote Builds When..."; } diff --git a/src/main/java/hudson/plugins/promoted_builds/inheritance/JobPropertyImplSelector.java b/src/main/java/hudson/plugins/promoted_builds/inheritance/JobPropertyImplSelector.java index f5a4f49d..342095f3 100644 --- a/src/main/java/hudson/plugins/promoted_builds/inheritance/JobPropertyImplSelector.java +++ b/src/main/java/hudson/plugins/promoted_builds/inheritance/JobPropertyImplSelector.java @@ -14,53 +14,54 @@ /** * * @author Jacek Tomaka + * @since TODO */ @Extension(optional=true) public class JobPropertyImplSelector extends InheritanceSelector> { - private static final long serialVersionUID = 6297336734737164557L; - private static Logger logger = Logger.getLogger(JobPropertyImplSelector.class); + private static final long serialVersionUID = 1L; + private static final Logger logger = Logger.getLogger(JobPropertyImplSelector.class); - @Override - public boolean isApplicableFor(Class clazz){ - return JobProperty.class.isAssignableFrom(clazz); - } - - @Override - public InheritanceSelector.MODE getModeFor(Class clazz){ - if (JobPropertyImpl.class.isAssignableFrom(clazz)) return MODE.USE_LAST; - return MODE.NOT_RESPONSIBLE; - } - - @Override - public String getObjectIdentifier(JobProperty obj){ - if (JobPropertyImpl.class.getName().equals(obj.getClass().getName())){ - return "JobPropertyImpl"; - } - return null; - } - - @Override - public JobPropertyImpl merge(JobProperty prior, JobProperty latter, InheritanceProject caller){ - return null; - } - - @Override - public JobProperty handleSingleton(JobProperty object, InheritanceProject caller){ - if (!isApplicableFor(object.getClass())) return object; - if (caller.isAbstract) return object; - - JobPropertyImpl jobProperty = (JobPropertyImpl)object; - - try { - JobPropertyImpl newJobProperty = new JobPropertyImpl(jobProperty, caller); - return newJobProperty; - } catch (Exception ex){ - logger.error("inheritance-extension-for-promoted-builds: Error during hacking up JobPropertyImpl", ex ); - } - return object; - } - - - + @Override + public boolean isApplicableFor(Class clazz){ + return JobProperty.class.isAssignableFrom(clazz); + } + + @Override + public InheritanceSelector.MODE getModeFor(Class clazz){ + if (JobPropertyImpl.class.isAssignableFrom(clazz)) return MODE.USE_LAST; + return MODE.NOT_RESPONSIBLE; + } + + @Override + public String getObjectIdentifier(JobProperty obj){ + if ( obj!=null && JobPropertyImpl.class.getName().equals(obj.getClass().getName())){ + return JobPropertyImplSelector.class.getName(); + } + return null; + } + + @Override + public JobPropertyImpl merge(JobProperty prior, JobProperty latter, InheritanceProject caller){ + return null; + } + + @Override + public JobProperty handleSingleton(JobProperty jobProperty, InheritanceProject caller){ + if (jobProperty == null || caller == null) return jobProperty; + if (caller.isAbstract) return jobProperty; + + if (!JobPropertyImpl.class.isAssignableFrom(jobProperty.getClass())) return jobProperty; + + + JobPropertyImpl jobPropertyImpl = (JobPropertyImpl)jobProperty; + + try { + JobPropertyImpl newJobProperty = new JobPropertyImpl(jobPropertyImpl, caller); + return newJobProperty; + } catch (Exception ex){ + logger.error("Error during hacking up JobPropertyImpl", ex ); + } + return jobProperty; + } }