Search in sources :

Example 1 with RuntimeManager

use of com.gitblit.manager.RuntimeManager in project gitblit by gitblit.

the class MigrateTickets method migrate.

/**
	 * Migrate all tickets
	 *
	 * @param baseFolder
	 * @param settings
	 * @param outputServiceName
	 */
protected void migrate(File baseFolder, IStoredSettings settings, String outputServiceName) {
    // disable some services
    settings.overrideSetting(Keys.web.allowLuceneIndexing, false);
    settings.overrideSetting(Keys.git.enableGarbageCollection, false);
    settings.overrideSetting(Keys.git.enableMirroring, false);
    settings.overrideSetting(Keys.web.activityCacheDays, 0);
    settings.overrideSetting(ITicketService.SETTING_UPDATE_DIFFSTATS, false);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter, baseFolder).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, null, null).start();
    String inputServiceName = settings.getString(Keys.tickets.service, BranchTicketService.class.getSimpleName());
    if (StringUtils.isEmpty(inputServiceName)) {
        System.err.println(MessageFormat.format("Please define a ticket service in \"{0}\"", Keys.tickets.service));
        System.exit(1);
    }
    ITicketService inputService = null;
    ITicketService outputService = null;
    try {
        inputService = getService(inputServiceName, runtimeManager, repositoryManager);
        outputService = getService(outputServiceName, runtimeManager, repositoryManager);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    if (!inputService.isReady()) {
        System.err.println(String.format("%s INPUT service is not ready, check config.", inputService.getClass().getSimpleName()));
        System.exit(1);
    }
    if (!outputService.isReady()) {
        System.err.println(String.format("%s OUTPUT service is not ready, check config.", outputService.getClass().getSimpleName()));
        System.exit(1);
    }
    // migrate tickets
    long start = System.nanoTime();
    long totalTickets = 0;
    long totalChanges = 0;
    for (RepositoryModel repository : repositoryManager.getRepositoryModels()) {
        Set<Long> ids = inputService.getIds(repository);
        if (ids == null || ids.isEmpty()) {
            // nothing to migrate
            continue;
        }
        // delete any tickets we may have in the output ticket service
        outputService.deleteAll(repository);
        for (long id : ids) {
            List<Change> journal = inputService.getJournal(repository, id);
            if (journal == null || journal.size() == 0) {
                continue;
            }
            TicketModel ticket = outputService.createTicket(repository, id, journal.get(0));
            if (ticket == null) {
                System.err.println(String.format("Failed to migrate %s #%s", repository.name, id));
                System.exit(1);
            }
            totalTickets++;
            System.out.println(String.format("%s #%s: %s", repository.name, ticket.number, ticket.title));
            for (int i = 1; i < journal.size(); i++) {
                TicketModel updated = outputService.updateTicket(repository, ticket.number, journal.get(i));
                if (updated != null) {
                    System.out.println(String.format("   applied change %d", i));
                    totalChanges++;
                } else {
                    System.err.println(String.format("Failed to apply change %d:\n%s", i, journal.get(i)));
                    System.exit(1);
                }
            }
        }
    }
    inputService.stop();
    outputService.stop();
    repositoryManager.stop();
    runtimeManager.stop();
    long end = System.nanoTime();
    System.out.println(String.format("Migrated %d tickets composed of %d journal entries in %d seconds", totalTickets, totalTickets + totalChanges, TimeUnit.NANOSECONDS.toSeconds(end - start)));
}
Also used : ITicketService(com.gitblit.tickets.ITicketService) BranchTicketService(com.gitblit.tickets.BranchTicketService) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) TicketModel(com.gitblit.models.TicketModel) RepositoryModel(com.gitblit.models.RepositoryModel) Change(com.gitblit.models.TicketModel.Change) CmdLineException(org.kohsuke.args4j.CmdLineException) IRuntimeManager(com.gitblit.manager.IRuntimeManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 2 with RuntimeManager

use of com.gitblit.manager.RuntimeManager in project gitblit by gitblit.

the class ReindexTickets method reindex.

/**
	 * Reindex all tickets
	 *
	 * @param settings
	 */
protected void reindex(File baseFolder, IStoredSettings settings) {
    // disable some services
    settings.overrideSetting(Keys.web.allowLuceneIndexing, false);
    settings.overrideSetting(Keys.git.enableGarbageCollection, false);
    settings.overrideSetting(Keys.git.enableMirroring, false);
    settings.overrideSetting(Keys.web.activityCacheDays, 0);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter, baseFolder).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, null, null).start();
    String serviceName = settings.getString(Keys.tickets.service, BranchTicketService.class.getSimpleName());
    if (StringUtils.isEmpty(serviceName)) {
        System.err.println(MessageFormat.format("Please define a ticket service in \"{0}\"", Keys.tickets.service));
        System.exit(1);
    }
    ITicketService ticketService = null;
    try {
        Class<?> serviceClass = Class.forName(serviceName);
        if (RedisTicketService.class.isAssignableFrom(serviceClass)) {
            // Redis ticket service
            ticketService = new RedisTicketService(runtimeManager, null, null, null, repositoryManager).start();
        } else if (BranchTicketService.class.isAssignableFrom(serviceClass)) {
            // Branch ticket service
            ticketService = new BranchTicketService(runtimeManager, null, null, null, repositoryManager).start();
        } else if (FileTicketService.class.isAssignableFrom(serviceClass)) {
            // File ticket service
            ticketService = new FileTicketService(runtimeManager, null, null, null, repositoryManager).start();
        } else {
            System.err.println("Unknown ticket service " + serviceName);
            System.exit(1);
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    ticketService.reindex();
    ticketService.stop();
    repositoryManager.stop();
    runtimeManager.stop();
}
Also used : ITicketService(com.gitblit.tickets.ITicketService) BranchTicketService(com.gitblit.tickets.BranchTicketService) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) CmdLineException(org.kohsuke.args4j.CmdLineException) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RedisTicketService(com.gitblit.tickets.RedisTicketService) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) FileTicketService(com.gitblit.tickets.FileTicketService) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 3 with RuntimeManager

use of com.gitblit.manager.RuntimeManager in project gitblit by gitblit.

the class RedisTicketServiceTest method getService.

@Override
protected ITicketService getService(boolean deleteAll) throws Exception {
    IStoredSettings settings = getSettings(deleteAll);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
    IPluginManager pluginManager = new PluginManager(runtimeManager).start();
    INotificationManager notificationManager = new NotificationManager(settings).start();
    IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
    RedisTicketService service = (RedisTicketService) new RedisTicketService(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager).start();
    if (deleteAll) {
        service.deleteAll(getRepository());
    }
    return service;
}
Also used : NotificationManager(com.gitblit.manager.NotificationManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) IStoredSettings(com.gitblit.IStoredSettings) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) IRuntimeManager(com.gitblit.manager.IRuntimeManager) IPluginManager(com.gitblit.manager.IPluginManager) PluginManager(com.gitblit.manager.PluginManager) RedisTicketService(com.gitblit.tickets.RedisTicketService) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) IPluginManager(com.gitblit.manager.IPluginManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 4 with RuntimeManager

use of com.gitblit.manager.RuntimeManager in project gitblit by gitblit.

the class UITicketTest method getService.

protected ITicketService getService(boolean deleteAll) throws Exception {
    IStoredSettings settings = getSettings(deleteAll);
    XssFilter xssFilter = new AllowXssFilter();
    IRuntimeManager runtimeManager = new RuntimeManager(settings, xssFilter).start();
    IPluginManager pluginManager = new PluginManager(runtimeManager).start();
    INotificationManager notificationManager = new NotificationManager(settings).start();
    IUserManager userManager = new UserManager(runtimeManager, pluginManager).start();
    IRepositoryManager repositoryManager = new RepositoryManager(runtimeManager, pluginManager, userManager).start();
    BranchTicketService service = (BranchTicketService) new BranchTicketService(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager).start();
    if (deleteAll) {
        service.deleteAll(repo);
    }
    return service;
}
Also used : BranchTicketService(com.gitblit.tickets.BranchTicketService) INotificationManager(com.gitblit.manager.INotificationManager) NotificationManager(com.gitblit.manager.NotificationManager) IUserManager(com.gitblit.manager.IUserManager) IStoredSettings(com.gitblit.IStoredSettings) IRuntimeManager(com.gitblit.manager.IRuntimeManager) RuntimeManager(com.gitblit.manager.RuntimeManager) IRepositoryManager(com.gitblit.manager.IRepositoryManager) IRuntimeManager(com.gitblit.manager.IRuntimeManager) IPluginManager(com.gitblit.manager.IPluginManager) PluginManager(com.gitblit.manager.PluginManager) INotificationManager(com.gitblit.manager.INotificationManager) IUserManager(com.gitblit.manager.IUserManager) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) IPluginManager(com.gitblit.manager.IPluginManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) IRepositoryManager(com.gitblit.manager.IRepositoryManager) RepositoryManager(com.gitblit.manager.RepositoryManager)

Example 5 with RuntimeManager

use of com.gitblit.manager.RuntimeManager in project gitblit by gitblit.

the class LuceneExecutorTest method newLuceneExecutor.

private LuceneService newLuceneExecutor() {
    MemorySettings settings = new MemorySettings();
    settings.put(Keys.git.repositoriesFolder, GitBlitSuite.REPOSITORIES);
    XssFilter xssFilter = new AllowXssFilter();
    RuntimeManager runtime = new RuntimeManager(settings, xssFilter, GitBlitSuite.BASEFOLDER).start();
    UserManager users = new UserManager(runtime, null).start();
    RepositoryManager repos = new RepositoryManager(runtime, null, users);
    return new LuceneService(settings, repos);
}
Also used : UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) RuntimeManager(com.gitblit.manager.RuntimeManager) MemorySettings(com.gitblit.tests.mock.MemorySettings) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) RepositoryManager(com.gitblit.manager.RepositoryManager) LuceneService(com.gitblit.service.LuceneService)

Aggregations

RuntimeManager (com.gitblit.manager.RuntimeManager)15 XssFilter (com.gitblit.utils.XssFilter)15 AllowXssFilter (com.gitblit.utils.XssFilter.AllowXssFilter)15 UserManager (com.gitblit.manager.UserManager)12 RepositoryManager (com.gitblit.manager.RepositoryManager)8 IRuntimeManager (com.gitblit.manager.IRuntimeManager)7 IRepositoryManager (com.gitblit.manager.IRepositoryManager)6 IUserManager (com.gitblit.manager.IUserManager)5 IStoredSettings (com.gitblit.IStoredSettings)4 AuthenticationManager (com.gitblit.manager.AuthenticationManager)4 INotificationManager (com.gitblit.manager.INotificationManager)4 IPluginManager (com.gitblit.manager.IPluginManager)4 NotificationManager (com.gitblit.manager.NotificationManager)4 PluginManager (com.gitblit.manager.PluginManager)4 BranchTicketService (com.gitblit.tickets.BranchTicketService)4 CmdLineException (org.kohsuke.args4j.CmdLineException)3 HtpasswdAuthProvider (com.gitblit.auth.HtpasswdAuthProvider)2 RedmineAuthProvider (com.gitblit.auth.RedmineAuthProvider)2 FileTicketService (com.gitblit.tickets.FileTicketService)2 ITicketService (com.gitblit.tickets.ITicketService)2