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;
}
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;
}
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);
}
}
}
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");
}
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;
}
Aggregations