All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.scm_sync_configuration.strategies.AbstractScmSyncStrategy Maven / Gradle / Ivy

Go to download

SCM Sync Configuration Hudson plugin is aimed at 2 main features : First, keep sync'ed your config.xml (and other ressources) hudson files with a SCM repository (backup), Secondly, track changes (and author) made on every file with commit messages.

The newest version!
package hudson.plugins.scm_sync_configuration.strategies;

import hudson.model.Saveable;
import hudson.model.Hudson;
import hudson.plugins.scm_sync_configuration.strategies.model.ConfigurationEntityMatcher;
import hudson.plugins.scm_sync_configuration.strategies.model.PageMatcher;

import java.io.File;
import java.util.List;

public abstract class AbstractScmSyncStrategy implements ScmSyncStrategy {

	private ConfigurationEntityMatcher configEntityMatcher;
	private List pageMatchers;
	
	protected AbstractScmSyncStrategy(ConfigurationEntityMatcher _configEntityMatcher, List _pageMatchers){
		this.configEntityMatcher = _configEntityMatcher;
		this.pageMatchers = _pageMatchers;
	}
	
	public boolean isSaveableApplicable(Saveable saveable, File file) {
		return configEntityMatcher.matches(saveable, file);
	}

	public PageMatcher getPageMatcherMatching(String url){
		String rootUrl = Hudson.getInstance().getRootUrl();
		String cleanedUrl = null;
		if(url.startsWith(rootUrl)){
			cleanedUrl = url.substring(rootUrl.length());
		} else {
			cleanedUrl = url;
		}
		for(PageMatcher pm : pageMatchers){
			if(pm.getUrlRegex().matcher(cleanedUrl).matches()){
				return pm;
			}
		}
		return null;
	}
	
	public boolean isCurrentUrlApplicable(String url) {
		return getPageMatcherMatching(url)!=null;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy