Package hudson.plugins.scm_sync_configuration

Examples of hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin


    assertThat(plugin.getScmRepositoryUrl(), is(equalTo("scm:svn:https://myrepo/synchronizedDirectory/")));
  }
 
  @Test
  public void should0_0_2_pluginConfigurationMigrationBeIdemPotent() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
   
    // Plugin has been loaded : let's record scm & repository url
    String expectedRepositoryUrl = plugin.getScmRepositoryUrl();
    SCM expectedScm = plugin.getSCM();
   
    // Persisting data
    mockStatic(SaveableListener.class);
    doNothing().when(SaveableListener.class); SaveableListener.fireOnChange((Saveable)notNull(), (XmlFile)notNull());
    plugin.save();
   
    // Then reloading it...
    PluginUtil.loadPlugin(plugin);
   
    // Verifying repositoryUrl & SCM
    assertThat(plugin.getSCM().getId(), is(equalTo(expectedScm.getId())));
    assertThat(plugin.getScmRepositoryUrl(), is(equalTo(expectedRepositoryUrl)));
  }
View Full Code Here


    assertThat(plugin.getScmRepositoryUrl(), is(equalTo(expectedRepositoryUrl)));
  }
 
  @Test
  public void should0_0_2_pluginEmptyConfigurationFileShouldLoadCorrectly() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
    assertThat(plugin.getSCM(), is(notNullValue()));
    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncNoSCM.class.getName())));
  }
View Full Code Here

    public void init(FilterConfig filterConfig) throws ServletException {
    }

    public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
        // In the beginning of every http request, we should create a new threaded transaction
        final ScmSyncConfigurationPlugin plugin;
        try {
            plugin = ScmSyncConfigurationPlugin.getInstance();
        } catch(Throwable t){
            LOG.log(Level.SEVERE, "Error when retrieving ScmSyncConfig plugin instance => No filtering enabled on current request", t);
            return;
        }

        if(plugin != null){
            plugin.startThreadedTransaction();

            try {
                // Providing current ServletRequest in ScmSyncConfigurationDataProvider's thread local
                // in order to be able to access it from everywhere inside this call
                ScmSyncConfigurationDataProvider.provideRequestDuring((HttpServletRequest)request, new Callable() {
                    public Object call() throws Exception {
                        try {
                            // Handling "normally" http request
                            chain.doFilter(request, response);
                        }finally{
                            // In the end of http request, we should commit current transaction
                            plugin.getTransaction().commit();
                        }

                        return null;
                    }
                });
View Full Code Here

  public void onLoaded() {
    super.onLoaded();
   
    // After every plugin is loaded, let's init ScmSyncConfigurationPlugin
    // Init is needed after plugin loads since it relies on scm implementations plugins loaded
        ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
        if(plugin != null){
            plugin.init();
        }
  }
View Full Code Here

 
  @Override
  public void onDeleted(Item item) {
    super.onDeleted(item);
   
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
        if(plugin != null){
            ScmSyncStrategy strategy = plugin.getStrategyForSaveable(item, null);

            if(strategy != null){
                WeightedMessage message = strategy.getCommitMessageFactory().getMessageWhenItemDeleted(item);
                plugin.getTransaction().defineCommitMessage(message);
                String path = JenkinsFilesHelper.buildPathRelativeToHudsonRoot(item.getRootDir());
                plugin.getTransaction().registerPathForDeletion(path);
            }
        }
  }
View Full Code Here

  }
 
  @Override
  public void onRenamed(Item item, String oldName, String newName) {
    super.onRenamed(item, oldName, newName);
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
        if(plugin != null){
            ScmSyncStrategy strategy = plugin.getStrategyForSaveable(item, null);

            if(strategy != null){
                File parentDir = item.getRootDir().getParentFile();
                File oldDir = new File( parentDir.getAbsolutePath()+File.separator+oldName );
                File newDir = new File( parentDir.getAbsolutePath()+File.separator+newName );

                String oldPath = JenkinsFilesHelper.buildPathRelativeToHudsonRoot(oldDir);
                String newPath = JenkinsFilesHelper.buildPathRelativeToHudsonRoot(newDir);
                WeightedMessage message = strategy.getCommitMessageFactory().getMessageWhenItemRenamed(item, oldPath, newPath);
                plugin.getTransaction().defineCommitMessage(message);
                plugin.getTransaction().registerRenamedPath(oldPath, newPath);
            }
        }
  }
View Full Code Here

  @Override
  public void onChange(Saveable o, XmlFile file) {
   
    super.onChange(o, file);
   
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
        if(plugin != null){
            ScmSyncStrategy strategy = plugin.getStrategyForSaveable(o, file.getFile());

            if(strategy != null){
                WeightedMessage message = strategy.getCommitMessageFactory().getMessageWhenSaveableUpdated(o, file);
                plugin.getTransaction().defineCommitMessage(message);
                String path = JenkinsFilesHelper.buildPathRelativeToHudsonRoot(file.getFile());
                plugin.getTransaction().registerPath(path);
            }
        }
  }
View Full Code Here

TOP

Related Classes of hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.