| | |
| | | import com.gitblit.models.FederationSet;
|
| | | import com.gitblit.models.Metric;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.SearchResult;
|
| | | import com.gitblit.models.ServerSettings;
|
| | | import com.gitblit.models.ServerStatus;
|
| | | import com.gitblit.models.SettingModel;
|
| | |
| | |
|
| | | private MailExecutor mailExecutor;
|
| | |
|
| | | private LuceneExecutor luceneExecutor;
|
| | | |
| | | private TimeZone timezone;
|
| | |
|
| | | public GitBlit() {
|
| | |
| | | }
|
| | | return self().timezone;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Returns the boolean value for the specified key. If the key does not
|
| | |
| | | RepositoryModel model = new RepositoryModel();
|
| | | model.name = repositoryName;
|
| | | model.hasCommits = JGitUtils.hasCommits(r);
|
| | | model.lastChange = JGitUtils.getLastChange(r, null);
|
| | | model.lastChange = JGitUtils.getLastChange(r);
|
| | | model.isBare = r.isBare();
|
| | | StoredConfig config = JGitUtils.readConfig(r);
|
| | | if (config != null) {
|
| | |
| | | "gitblit", null, "postReceiveScript")));
|
| | | model.mailingLists = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | | "gitblit", null, "mailingList")));
|
| | | model.indexedBranches = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | | "gitblit", null, "indexBranch")));
|
| | | }
|
| | | model.HEAD = JGitUtils.getHEADRef(r);
|
| | | model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
|
| | |
| | | repository.close();
|
| | | }
|
| | | }
|
| | | |
| | | // close any open index writer/searcher in the Lucene executor
|
| | | luceneExecutor.close(repositoryName);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | if (repositoryMetricsCache.hasCurrent(model.name, model.lastChange)) {
|
| | | return new ArrayList<Metric>(repositoryMetricsCache.getObject(model.name));
|
| | | }
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null, getTimezone());
|
| | | repositoryMetricsCache.updateObject(model.name, model.lastChange, metrics);
|
| | | return new ArrayList<Metric>(metrics);
|
| | | }
|
| | |
| | | config.setBoolean("gitblit", null, "showReadme", repository.showReadme);
|
| | | config.setBoolean("gitblit", null, "skipSizeCalculation", repository.skipSizeCalculation);
|
| | | config.setBoolean("gitblit", null, "skipSummaryMetrics", repository.skipSummaryMetrics);
|
| | | config.setStringList("gitblit", null, "federationSets", repository.federationSets);
|
| | | config.setString("gitblit", null, "federationStrategy",
|
| | | repository.federationStrategy.name());
|
| | | config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
|
| | | if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
|
| | | config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
|
| | | config.setStringList("gitblit", null, "postReceiveScript",
|
| | | repository.postReceiveScripts);
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(repository.mailingLists)) {
|
| | | config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
|
| | | }
|
| | |
|
| | | updateList(config, "federationSets", repository.federationSets);
|
| | | updateList(config, "preReceiveScript", repository.preReceiveScripts);
|
| | | updateList(config, "postReceiveScript", repository.postReceiveScripts);
|
| | | updateList(config, "mailingList", repository.mailingLists);
|
| | | updateList(config, "indexBranch", repository.indexedBranches);
|
| | |
|
| | | try {
|
| | | config.save();
|
| | | } catch (IOException e) {
|
| | | logger.error("Failed to save repository config!", e);
|
| | | }
|
| | | }
|
| | | |
| | | private void updateList(StoredConfig config, String field, List<String> list) {
|
| | | // a null list is skipped, not cleared
|
| | | // this is for RPC administration where an older manager might be used
|
| | | if (list == null) {
|
| | | return;
|
| | | }
|
| | | if (ArrayUtils.isEmpty(list)) {
|
| | | config.unset("gitblit", null, field);
|
| | | } else {
|
| | | config.setStringList("gitblit", null, field, list);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | return scripts;
|
| | | }
|
| | | |
| | | /**
|
| | | * Search the specified repositories using the Lucene query.
|
| | | * |
| | | * @param query
|
| | | * @param page
|
| | | * @param pageSize
|
| | | * @param repositories
|
| | | * @return
|
| | | */
|
| | | public List<SearchResult> search(String query, int page, int pageSize, List<String> repositories) { |
| | | List<SearchResult> srs = luceneExecutor.search(query, page, pageSize, repositories);
|
| | | return srs;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Notify the administrators by email.
|
| | |
| | | setUserService(loginService);
|
| | | mailExecutor = new MailExecutor(settings);
|
| | | if (mailExecutor.isReady()) {
|
| | | logger.info("Mail executor is scheduled to process the message queue every 2 minutes.");
|
| | | scheduledExecutor.scheduleAtFixedRate(mailExecutor, 1, 2, TimeUnit.MINUTES);
|
| | | } else {
|
| | | logger.warn("Mail server is not properly configured. Mail services disabled.");
|
| | | }
|
| | | luceneExecutor = new LuceneExecutor(settings, repositoriesFolder);
|
| | | logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
|
| | | scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
|
| | | if (startFederation) {
|
| | | configureFederation();
|
| | | }
|
| | |
| | | WebXmlSettings webxmlSettings = new WebXmlSettings(context);
|
| | |
|
| | | // 0.7.0 web.properties in the deployed war folder
|
| | | File overrideFile = new File(context.getRealPath("/WEB-INF/web.properties"));
|
| | | if (overrideFile.exists()) {
|
| | | webxmlSettings.applyOverrides(overrideFile);
|
| | | String webProps = context.getRealPath("/WEB-INF/web.properties");
|
| | | if (!StringUtils.isEmpty(webProps)) {
|
| | | File overrideFile = new File(webProps);
|
| | | if (overrideFile.exists()) {
|
| | | webxmlSettings.applyOverrides(overrideFile);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 0.8.0 gitblit.properties file located outside the deployed war
|
| | | // folder lie, for example, on RedHat OpenShift.
|
| | | overrideFile = getFileOrFolder("gitblit.properties");
|
| | | File overrideFile = getFileOrFolder("gitblit.properties");
|
| | | if (!overrideFile.getPath().equals("gitblit.properties")) {
|
| | | webxmlSettings.applyOverrides(overrideFile);
|
| | | }
|
| | |
| | | public void contextDestroyed(ServletContextEvent contextEvent) {
|
| | | logger.info("Gitblit context destroyed by servlet container.");
|
| | | scheduledExecutor.shutdownNow();
|
| | | luceneExecutor.close();
|
| | | }
|
| | | }
|