| | |
| | | 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
|
| | |
| | | "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);
|
| | | }
|
| | |
| | | }
|
| | | if (!ArrayUtils.isEmpty(repository.mailingLists)) {
|
| | | config.setStringList("gitblit", null, "mailingList", repository.mailingLists);
|
| | | }
|
| | | if (!ArrayUtils.isEmpty(repository.indexedBranches)) {
|
| | | config.setStringList("gitblit", null, "indexBranch", repository.indexedBranches);
|
| | | }
|
| | | try {
|
| | | config.save();
|
| | |
| | | }
|
| | | 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();
|
| | | }
|
| | |
| | | public void contextDestroyed(ServletContextEvent contextEvent) {
|
| | | logger.info("Gitblit context destroyed by servlet container.");
|
| | | scheduledExecutor.shutdownNow();
|
| | | luceneExecutor.close();
|
| | | }
|
| | | }
|