| | |
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Type;
|
| | | import java.net.URI;
|
| | | import java.net.URISyntaxException;
|
| | | import java.nio.charset.Charset;
|
| | |
| | | import org.eclipse.jgit.lib.RepositoryCache.FileKey;
|
| | | import org.eclipse.jgit.lib.StoredConfig;
|
| | | import org.eclipse.jgit.storage.file.FileBasedConfig;
|
| | | import org.eclipse.jgit.storage.file.WindowCache;
|
| | | import org.eclipse.jgit.storage.file.WindowCacheConfig;
|
| | | import org.eclipse.jgit.util.FS;
|
| | | import org.eclipse.jgit.util.FileUtils;
|
| | |
| | | import com.gitblit.fanout.FanoutService;
|
| | | import com.gitblit.fanout.FanoutSocketService;
|
| | | import com.gitblit.git.GitDaemon;
|
| | | import com.gitblit.models.GitClientApplication;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.FederationProposal;
|
| | | import com.gitblit.models.FederationSet;
|
| | |
| | | import com.gitblit.utils.X509Utils.X509Metadata;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonIOException;
|
| | | import com.google.gson.JsonSyntaxException;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | |
|
| | | /**
|
| | | * GitBlit is the servlet context listener singleton that acts as the core for
|
| | |
| | |
|
| | | private final List<FederationModel> federationRegistrations = Collections
|
| | | .synchronizedList(new ArrayList<FederationModel>());
|
| | | |
| | | private final List<GitClientApplication> clientApplications = Collections
|
| | | .synchronizedList(new ArrayList<GitClientApplication>());
|
| | |
|
| | | private final Map<String, FederationModel> federationPullResults = new ConcurrentHashMap<String, FederationModel>();
|
| | |
|
| | |
| | | cloneUrls.add(MessageFormat.format(url, repositoryName, username));
|
| | | }
|
| | | return cloneUrls;
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns the list of custom client applications to be used for the
|
| | | * repository url panel;
|
| | | * |
| | | * @return a list of client applications
|
| | | */
|
| | | public List<GitClientApplication> getClientApplications() {
|
| | | if (clientApplications.isEmpty()) {
|
| | | try {
|
| | | InputStream is = getClass().getResourceAsStream("/clientapps.json");
|
| | | Collection<GitClientApplication> clients = readClientApplications(is);
|
| | | is.close();
|
| | | if (clients != null) {
|
| | | clientApplications.clear();
|
| | | clientApplications.addAll(clients);
|
| | | }
|
| | | } catch (IOException e) {
|
| | | logger.error("Failed to deserialize clientapps.json resource!", e);
|
| | | }
|
| | | }
|
| | | return clientApplications;
|
| | | }
|
| | | |
| | | private Collection<GitClientApplication> readClientApplications(InputStream is) {
|
| | | try {
|
| | | Type type = new TypeToken<Collection<GitClientApplication>>() {
|
| | | }.getType();
|
| | | InputStreamReader reader = new InputStreamReader(is);
|
| | | Gson gson = new GsonBuilder().create();
|
| | | Collection<GitClientApplication> links = gson.fromJson(reader, type);
|
| | | return links;
|
| | | } catch (JsonIOException e) {
|
| | | logger.error("Error deserializing client applications!", e);
|
| | | } catch (JsonSyntaxException e) {
|
| | | logger.error("Error deserializing client applications!", e);
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | for (String repo : list) {
|
| | | RepositoryModel model = getRepositoryModel(user, repo);
|
| | | if (model != null) {
|
| | | repositories.add(model);
|
| | | if (!model.hasCommits) {
|
| | | // only add empty repositories that user can push to
|
| | | if (UserModel.ANONYMOUS.canPush(model)
|
| | | || user != null && user.canPush(model)) {
|
| | | repositories.add(model);
|
| | | }
|
| | | } else {
|
| | | repositories.add(model);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (getBoolean(Keys.web.showRepositorySizes, true)) {
|
| | |
| | | cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
|
| | |
|
| | | try {
|
| | | WindowCache.reconfigure(cfg);
|
| | | cfg.install();
|
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
|
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
|
| | | logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
|
| | |
| | |
|
| | | protected void configureGitDaemon() {
|
| | | String bindInterface = settings.getString(Keys.git.daemonBindInterface, "localhost");
|
| | | int port = settings.getInteger(Keys.git.daemonPort, GitDaemon.DEFAULT_PORT);
|
| | | int port = settings.getInteger(Keys.git.daemonPort, 0);
|
| | | if (port > 0) {
|
| | | try {
|
| | | gitDaemon = new GitDaemon(bindInterface, port, getRepositoriesFolder());
|
| | | gitDaemon.start();
|
| | | logger.info(MessageFormat.format("Git daemon is listening on {0}:{1,number,0}", bindInterface, port));
|
| | | } catch (IOException e) {
|
| | | logger.error(MessageFormat.format("Failed to start Git daemon on {0}:{1,number.0}", bindInterface, port), e);
|
| | | gitDaemon = null;
|
| | | logger.error(MessageFormat.format("Failed to start Git daemon on {0}:{1,number,0}", bindInterface, port), e);
|
| | | }
|
| | | }
|
| | | }
|