Search in sources :

Example 6 with IStoredSettings

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

the class UITicketTest method getSettings.

protected IStoredSettings getSettings(boolean deleteAll) throws Exception {
    File dir = new File(GitBlitSuite.REPOSITORIES, repoName);
    if (deleteAll) {
        if (dir.exists()) {
            FileUtils.delete(dir, FileUtils.RECURSIVE | FileUtils.RETRY);
        }
        JGitUtils.createRepository(GitBlitSuite.REPOSITORIES, repoName).close();
    }
    File luceneDir = new File(dir, "tickets/lucene");
    luceneDir.mkdirs();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put(Keys.git.repositoriesFolder, GitBlitSuite.REPOSITORIES.getAbsolutePath());
    map.put(Keys.tickets.indexFolder, luceneDir.getAbsolutePath());
    IStoredSettings settings = new MemorySettings(map);
    return settings;
}
Also used : HashMap(java.util.HashMap) IStoredSettings(com.gitblit.IStoredSettings) MemorySettings(com.gitblit.tests.mock.MemorySettings) File(java.io.File)

Example 7 with IStoredSettings

use of com.gitblit.IStoredSettings 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 8 with IStoredSettings

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

the class GitblitContext method startCore.

/**
 * Prepare runtime settings and start all manager instances.
 */
protected void startCore(ServletContext context) {
    Injector injector = (Injector) context.getAttribute(Injector.class.getName());
    // create the runtime settings object
    IStoredSettings runtimeSettings = injector.getInstance(IStoredSettings.class);
    final File baseFolder;
    if (goSettings != null) {
        // Gitblit GO
        baseFolder = configureGO(context, goSettings, goBaseFolder, runtimeSettings);
    } else {
        // servlet container
        WebXmlSettings webxmlSettings = new WebXmlSettings(context);
        String contextRealPath = context.getRealPath("/");
        File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;
        // if the base folder dosen't match the default assume they don't want to use express,
        // this allows for other containers to customise the basefolder per context.
        String defaultBase = Constants.contextFolder$ + "/WEB-INF/data";
        String base = getBaseFolderPath(defaultBase);
        if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) {
            // RedHat OpenShift
            baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings);
        } else {
            // standard WAR
            baseFolder = configureWAR(context, webxmlSettings, contextFolder, runtimeSettings);
        }
        // Test for Tomcat forward-slash/%2F issue and auto-adjust settings
        ContainerUtils.CVE_2007_0450.test(runtimeSettings);
    }
    // Manually configure IRuntimeManager
    logManager(IRuntimeManager.class);
    IRuntimeManager runtime = injector.getInstance(IRuntimeManager.class);
    runtime.setBaseFolder(baseFolder);
    runtime.getStatus().isGO = goSettings != null;
    runtime.getStatus().servletContainer = context.getServerInfo();
    runtime.start();
    managers.add(runtime);
    // create the plugin manager instance but do not start it
    loadManager(injector, IPluginManager.class);
    // start all other managers
    startManager(injector, INotificationManager.class);
    startManager(injector, IUserManager.class);
    startManager(injector, IAuthenticationManager.class);
    startManager(injector, IPublicKeyManager.class);
    startManager(injector, IRepositoryManager.class);
    startManager(injector, IProjectManager.class);
    startManager(injector, IFederationManager.class);
    startManager(injector, ITicketService.class);
    startManager(injector, IGitblit.class);
    startManager(injector, IServicesManager.class);
    startManager(injector, IFilestoreManager.class);
    // start the plugin manager last so that plugins can depend on
    // deterministic access to all other managers in their start() methods
    startManager(injector, IPluginManager.class);
    logger.info("");
    logger.info("All managers started.");
    logger.info("");
    IPluginManager pluginManager = injector.getInstance(IPluginManager.class);
    for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) {
        try {
            listener.onStartup();
        } catch (Throwable t) {
            logger.error(null, t);
        }
    }
}
Also used : IRuntimeManager(com.gitblit.manager.IRuntimeManager) Injector(com.google.inject.Injector) IStoredSettings(com.gitblit.IStoredSettings) WebXmlSettings(com.gitblit.WebXmlSettings) IPluginManager(com.gitblit.manager.IPluginManager) LifeCycleListener(com.gitblit.extensions.LifeCycleListener) File(java.io.File)

Example 9 with IStoredSettings

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

the class WicketUtils method getFileImage.

public static ContextImage getFileImage(String wicketId, String filename) {
    filename = filename.toLowerCase();
    if (filename.endsWith(".java")) {
        return newImage(wicketId, "file_java_16x16.png");
    } else if (filename.endsWith(".rb")) {
        return newImage(wicketId, "file_ruby_16x16.png");
    } else if (filename.endsWith(".php")) {
        return newImage(wicketId, "file_php_16x16.png");
    } else if (filename.endsWith(".cs")) {
        return newImage(wicketId, "file_cs_16x16.png");
    } else if (filename.endsWith(".cpp")) {
        return newImage(wicketId, "file_cpp_16x16.png");
    } else if (filename.endsWith(".c")) {
        return newImage(wicketId, "file_c_16x16.png");
    } else if (filename.endsWith(".h")) {
        return newImage(wicketId, "file_h_16x16.png");
    } else if (filename.endsWith(".sln")) {
        return newImage(wicketId, "file_vs_16x16.png");
    } else if (filename.endsWith(".csv") || filename.endsWith(".xls") || filename.endsWith(".xlsx")) {
        return newImage(wicketId, "file_excel_16x16.png");
    } else if (filename.endsWith(".doc") || filename.endsWith(".docx")) {
        return newImage(wicketId, "file_doc_16x16.png");
    } else if (filename.endsWith(".ppt") || filename.endsWith(".pptx")) {
        return newImage(wicketId, "file_ppt_16x16.png");
    } else if (filename.endsWith(".zip")) {
        return newImage(wicketId, "file_zip_16x16.png");
    } else if (filename.endsWith(".pdf")) {
        return newImage(wicketId, "file_acrobat_16x16.png");
    } else if (filename.endsWith(".htm") || filename.endsWith(".html")) {
        return newImage(wicketId, "file_world_16x16.png");
    } else if (filename.endsWith(".xml")) {
        return newImage(wicketId, "file_code_16x16.png");
    } else if (filename.endsWith(".properties")) {
        return newImage(wicketId, "file_settings_16x16.png");
    }
    String ext = StringUtils.getFileExtension(filename).toLowerCase();
    IStoredSettings settings = GitBlitWebApp.get().settings();
    if (MarkupProcessor.getMarkupExtensions(settings).contains(ext)) {
        return newImage(wicketId, "file_world_16x16.png");
    }
    return newImage(wicketId, "file_16x16.png");
}
Also used : IStoredSettings(com.gitblit.IStoredSettings)

Example 10 with IStoredSettings

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

the class AvatarGeneratorProvider method get.

@Override
public synchronized AvatarGenerator get() {
    if (avatarGenerator != null) {
        return avatarGenerator;
    }
    IStoredSettings settings = runtimeManager.getSettings();
    String clazz = settings.getString(Keys.web.avatarClass, GravatarGenerator.class.getName());
    if (StringUtils.isEmpty(clazz)) {
        clazz = GravatarGenerator.class.getName();
    }
    try {
        Class<? extends AvatarGenerator> generatorClass = (Class<? extends AvatarGenerator>) Class.forName(clazz);
        avatarGenerator = runtimeManager.getInjector().getInstance(generatorClass);
    } catch (Exception e) {
        logger.error("failed to create avatar generator", e);
        avatarGenerator = new GravatarGenerator();
    }
    return avatarGenerator;
}
Also used : GravatarGenerator(com.gitblit.GravatarGenerator) AvatarGenerator(com.gitblit.AvatarGenerator) 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