Search in sources :

Example 11 with IStoredSettings

use of com.gitblit.IStoredSettings in project gitblit by gitblit.

the class BranchTicketServiceTest 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();
    BranchTicketService service = (BranchTicketService) new BranchTicketService(runtimeManager, pluginManager, notificationManager, userManager, repositoryManager).start();
    if (deleteAll) {
        service.deleteAll(getRepository());
    }
    return service;
}
Also used : BranchTicketService(com.gitblit.tickets.BranchTicketService) 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) 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 12 with IStoredSettings

use of com.gitblit.IStoredSettings in project gitblit by gitblit.

the class IPublicKeyManagerProvider method get.

@Override
public synchronized IPublicKeyManager get() {
    if (manager != null) {
        return manager;
    }
    IStoredSettings settings = runtimeManager.getSettings();
    String clazz = settings.getString(Keys.git.sshKeysManager, FileKeyManager.class.getName());
    if (StringUtils.isEmpty(clazz)) {
        clazz = FileKeyManager.class.getName();
    }
    try {
        Class<? extends IPublicKeyManager> mgrClass = (Class<? extends IPublicKeyManager>) Class.forName(clazz);
        manager = runtimeManager.getInjector().getInstance(mgrClass);
    } catch (Exception e) {
        logger.error("failed to create public key manager", e);
        manager = new NullKeyManager();
    }
    return manager;
}
Also used : NullKeyManager(com.gitblit.transport.ssh.NullKeyManager) IStoredSettings(com.gitblit.IStoredSettings) FileKeyManager(com.gitblit.transport.ssh.FileKeyManager) IPublicKeyManager(com.gitblit.transport.ssh.IPublicKeyManager)

Example 13 with IStoredSettings

use of com.gitblit.IStoredSettings in project gitblit by gitblit.

the class ITicketServiceProvider method get.

@Override
public synchronized ITicketService get() {
    if (service != null) {
        return service;
    }
    IStoredSettings settings = runtimeManager.getSettings();
    String clazz = settings.getString(Keys.tickets.service, NullTicketService.class.getName());
    if (StringUtils.isEmpty(clazz)) {
        clazz = NullTicketService.class.getName();
    }
    try {
        Class<? extends ITicketService> serviceClass = (Class<? extends ITicketService>) Class.forName(clazz);
        service = runtimeManager.getInjector().getInstance(serviceClass);
    } catch (Exception e) {
        logger.error("failed to create ticket service", e);
        service = runtimeManager.getInjector().getInstance(NullTicketService.class);
    }
    return service;
}
Also used : ITicketService(com.gitblit.tickets.ITicketService) NullTicketService(com.gitblit.tickets.NullTicketService) IStoredSettings(com.gitblit.IStoredSettings)

Example 14 with IStoredSettings

use of com.gitblit.IStoredSettings in project gitblit by gitblit.

the class SshDaemon method formatUrl.

public String formatUrl(String gituser, String servername, String repository) {
    IStoredSettings settings = gitblit.getSettings();
    int port = sshd.getPort();
    int displayPort = settings.getInteger(Keys.git.sshAdvertisedPort, port);
    String displayServername = settings.getString(Keys.git.sshAdvertisedHost, "");
    if (displayServername.isEmpty()) {
        displayServername = servername;
    }
    if (displayPort == DEFAULT_PORT) {
        // standard port
        return MessageFormat.format("ssh://{0}@{1}/{2}", gituser, displayServername, repository);
    } else {
        // non-standard port
        return MessageFormat.format("ssh://{0}@{1}:{2,number,0}/{3}", gituser, displayServername, displayPort, repository);
    }
}
Also used : IStoredSettings(com.gitblit.IStoredSettings)

Example 15 with IStoredSettings

use of com.gitblit.IStoredSettings in project gitblit by gitblit.

the class SshCommand method getRepositoryUrl.

protected String getRepositoryUrl(String repository) {
    String username = getContext().getClient().getUsername();
    IStoredSettings settings = getContext().getGitblit().getSettings();
    String displayHostname = settings.getString(Keys.git.sshAdvertisedHost, "");
    if (displayHostname.isEmpty()) {
        displayHostname = getHostname();
    }
    int port = settings.getInteger(Keys.git.sshPort, 0);
    int displayPort = settings.getInteger(Keys.git.sshAdvertisedPort, port);
    if (displayPort == 22) {
        // standard port
        return MessageFormat.format("{0}@{1}/{2}.git", username, displayHostname, repository);
    } else {
        // non-standard port
        return MessageFormat.format("ssh://{0}@{1}:{2,number,0}/{3}", username, displayHostname, displayPort, repository);
    }
}
Also used : IStoredSettings(com.gitblit.IStoredSettings)

Aggregations

IStoredSettings (com.gitblit.IStoredSettings)18 IPluginManager (com.gitblit.manager.IPluginManager)5 IRuntimeManager (com.gitblit.manager.IRuntimeManager)5 INotificationManager (com.gitblit.manager.INotificationManager)4 IRepositoryManager (com.gitblit.manager.IRepositoryManager)4 IUserManager (com.gitblit.manager.IUserManager)4 NotificationManager (com.gitblit.manager.NotificationManager)4 PluginManager (com.gitblit.manager.PluginManager)4 RepositoryManager (com.gitblit.manager.RepositoryManager)4 RuntimeManager (com.gitblit.manager.RuntimeManager)4 UserManager (com.gitblit.manager.UserManager)4 MemorySettings (com.gitblit.tests.mock.MemorySettings)4 XssFilter (com.gitblit.utils.XssFilter)4 AllowXssFilter (com.gitblit.utils.XssFilter.AllowXssFilter)4 AvatarGenerator (com.gitblit.AvatarGenerator)3 GravatarGenerator (com.gitblit.GravatarGenerator)3 Injector (com.google.inject.Injector)3 File (java.io.File)3 Test (org.junit.Test)3 BranchTicketService (com.gitblit.tickets.BranchTicketService)2