| | |
| | | import java.nio.charset.Charset; |
| | | import java.security.Principal; |
| | | import java.text.MessageFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | import javax.mail.MessagingException; |
| | | import javax.mail.internet.MimeBodyPart; |
| | | import javax.mail.internet.MimeMultipart; |
| | | import javax.naming.Context; |
| | | import javax.naming.InitialContext; |
| | | import javax.naming.NamingException; |
| | | import javax.servlet.ServletContext; |
| | | import javax.servlet.ServletContextEvent; |
| | | import javax.servlet.ServletContextListener; |
| | |
| | | |
| | | private final Logger logger = LoggerFactory.getLogger(GitBlit.class); |
| | | |
| | | private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(5); |
| | | private final ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(10); |
| | | |
| | | private final List<FederationModel> federationRegistrations = Collections |
| | | .synchronizedList(new ArrayList<FederationModel>()); |
| | |
| | | private LuceneExecutor luceneExecutor; |
| | | |
| | | private GCExecutor gcExecutor; |
| | | |
| | | private MirrorExecutor mirrorExecutor; |
| | | |
| | | private TimeZone timezone; |
| | | |
| | |
| | | model.verifyCommitter = getConfig(config, "verifyCommitter", false); |
| | | model.showRemoteBranches = getConfig(config, "showRemoteBranches", hasOrigin); |
| | | model.isFrozen = getConfig(config, "isFrozen", false); |
| | | model.showReadme = getConfig(config, "showReadme", false); |
| | | model.skipSizeCalculation = getConfig(config, "skipSizeCalculation", false); |
| | | model.skipSummaryMetrics = getConfig(config, "skipSummaryMetrics", false); |
| | | model.commitMessageRenderer = CommitMessageRenderer.fromName(getConfig(config, "commitMessageRenderer", |
| | |
| | | model.origin = config.getString("remote", "origin", "url"); |
| | | if (model.origin != null) { |
| | | model.origin = model.origin.replace('\\', '/'); |
| | | model.isMirror = config.getBoolean("remote", "origin", "mirror", false); |
| | | } |
| | | model.preReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList( |
| | | Constants.CONFIG_GITBLIT, null, "preReceiveScript"))); |
| | |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "verifyCommitter", repository.verifyCommitter); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "showRemoteBranches", repository.showRemoteBranches); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFrozen", repository.isFrozen); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "showReadme", repository.showReadme); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSizeCalculation", repository.skipSizeCalculation); |
| | | config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSummaryMetrics", repository.skipSummaryMetrics); |
| | | config.setString(Constants.CONFIG_GITBLIT, null, "federationStrategy", |
| | |
| | | try { |
| | | String prepared = processCommitMessageRegex(repository.name, text); |
| | | return MarkdownUtils.transformMarkdown(prepared); |
| | | } catch (ParseException e) { |
| | | } catch (Exception e) { |
| | | logger.error("Failed to render commit message as markdown", e); |
| | | } |
| | | break; |
| | |
| | | mailExecutor = new MailExecutor(settings); |
| | | luceneExecutor = new LuceneExecutor(settings, repositoriesFolder); |
| | | gcExecutor = new GCExecutor(settings); |
| | | mirrorExecutor = new MirrorExecutor(settings); |
| | | |
| | | // initialize utilities |
| | | String prefix = settings.getString(Keys.git.userRepositoryPrefix, "~"); |
| | |
| | | configureMailExecutor(); |
| | | configureLuceneIndexing(); |
| | | configureGarbageCollector(); |
| | | configureMirrorExecutor(); |
| | | if (startFederation) { |
| | | configureFederation(); |
| | | } |
| | |
| | | } |
| | | logger.info(MessageFormat.format("Next scheculed GC scan is in {0}", when)); |
| | | scheduledExecutor.scheduleAtFixedRate(gcExecutor, delay, 60*24, TimeUnit.MINUTES); |
| | | } |
| | | } |
| | | |
| | | protected void configureMirrorExecutor() { |
| | | if (mirrorExecutor.isReady()) { |
| | | int mins = TimeUtils.convertFrequencyToMinutes(settings.getString(Keys.git.mirrorPeriod, "30 mins")); |
| | | if (mins < 5) { |
| | | mins = 5; |
| | | } |
| | | int delay = 1; |
| | | scheduledExecutor.scheduleAtFixedRate(mirrorExecutor, delay, mins, TimeUnit.MINUTES); |
| | | logger.info("Mirror executor is scheduled to fetch updates every {} minutes.", mins); |
| | | logger.info("Next scheduled mirror fetch is in {} minutes", delay); |
| | | } |
| | | } |
| | | |
| | |
| | | logger.error(""); |
| | | } |
| | | |
| | | try { |
| | | // try to lookup JNDI env-entry for the baseFolder |
| | | InitialContext ic = new InitialContext(); |
| | | Context env = (Context) ic.lookup("java:comp/env"); |
| | | String val = (String) env.lookup("baseFolder"); |
| | | if (!StringUtils.isEmpty(val)) { |
| | | path = val; |
| | | } |
| | | } catch (NamingException n) { |
| | | logger.error("Failed to get JNDI env-entry: " + n.getExplanation()); |
| | | } |
| | | |
| | | File base = com.gitblit.utils.FileUtils.resolveParameter(Constants.contextFolder$, contextFolder, path); |
| | | base.mkdirs(); |
| | | |
| | |
| | | scheduledExecutor.shutdownNow(); |
| | | luceneExecutor.close(); |
| | | gcExecutor.close(); |
| | | mirrorExecutor.close(); |
| | | if (fanoutService != null) { |
| | | fanoutService.stop(); |
| | | } |