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

hudson.plugins.scm_sync_configuration.strategies.model.ClassAndFileConfigurationEntityMatcher 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.model;

import hudson.model.Saveable;
import hudson.plugins.scm_sync_configuration.HudsonFilesHelper;

import java.io.File;
import java.util.regex.Pattern;

public class ClassAndFileConfigurationEntityMatcher implements
		ConfigurationEntityMatcher {

	private Class saveableClazz;
	private Pattern filePathRegex;

	public ClassAndFileConfigurationEntityMatcher(Class clazz, String _filePathRegex){
		this.saveableClazz = clazz;
		this.filePathRegex = Pattern.compile(_filePathRegex);
	}
	
	public boolean matches(Saveable saveable, File file) {
		if(saveableClazz.isAssignableFrom(saveable.getClass())){
			if(file == null){
				return true;
			} else {
				String filePathRelativeToHudsonRoot = HudsonFilesHelper.buildPathRelativeToHudsonRoot(file);
				return this.filePathRegex.matcher(filePathRelativeToHudsonRoot).matches();
			}
		}
		
		return false;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy