| | |
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.inject.Inject;
|
| | | import javax.inject.Singleton;
|
| | | import com.google.inject.Inject;
|
| | | import com.google.inject.Singleton;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Constants.FederationRequest;
|
| | | import com.gitblit.IStoredSettings;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.Constants.FederationRequest;
|
| | | import com.gitblit.Keys.federation;
|
| | | import com.gitblit.Keys.git;
|
| | | import com.gitblit.Keys.groovy;
|
| | | import com.gitblit.manager.IFederationManager;
|
| | | import com.gitblit.manager.IRepositoryManager;
|
| | | import com.gitblit.manager.IRuntimeManager;
|
| | | import com.gitblit.manager.IUserManager;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.FederationProposal;
|
| | |
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private final IStoredSettings settings;
|
| | | private IStoredSettings settings;
|
| | |
|
| | | private final IUserManager userManager;
|
| | | private IUserManager userManager;
|
| | |
|
| | | private final IRepositoryManager repositoryManager;
|
| | | private IRepositoryManager repositoryManager;
|
| | |
|
| | | private final IFederationManager federationManager;
|
| | | private IFederationManager federationManager;
|
| | |
|
| | | @Inject
|
| | | public FederationServlet(
|
| | | IRuntimeManager runtimeManager,
|
| | | IStoredSettings settings,
|
| | | IUserManager userManager,
|
| | | IRepositoryManager repositoryManager,
|
| | | IFederationManager federationManager) {
|
| | |
|
| | | super();
|
| | | this.settings = runtimeManager.getSettings();
|
| | | this.settings = settings;
|
| | | this.userManager = userManager;
|
| | | this.repositoryManager = repositoryManager;
|
| | | this.federationManager = federationManager;
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | String url = HttpUtils.getGitblitURL(request);
|
| | | federationManager.submitFederationProposal(proposal, url);
|
| | | String gitblitUrl = settings.getString(Keys.web.canonicalUrl, null);
|
| | | if (StringUtils.isEmpty(gitblitUrl)) {
|
| | | gitblitUrl = HttpUtils.getGitblitURL(request);
|
| | | }
|
| | | federationManager.submitFederationProposal(proposal, gitblitUrl);
|
| | | logger.info(MessageFormat.format(
|
| | | "Submitted {0} federation proposal to pull {1} repositories from {2}",
|
| | | proposal.tokenType.name(), proposal.repositories.size(), proposal.url));
|
| | |
| | |
|
| | | // setup the last and netx pull dates
|
| | | results.lastPull = new Date();
|
| | | int mins = TimeUtils.convertFrequencyToMinutes(results.frequency);
|
| | | int mins = TimeUtils.convertFrequencyToMinutes(results.frequency, 5);
|
| | | results.nextPull = new Date(System.currentTimeMillis() + (mins * 60 * 1000L));
|
| | |
|
| | | // acknowledge the receipt of status
|
| | |
| | |
|
| | | Object result = null;
|
| | | if (FederationRequest.PULL_REPOSITORIES.equals(reqType)) {
|
| | | String gitblitUrl = HttpUtils.getGitblitURL(request);
|
| | | String gitblitUrl = settings.getString(Keys.web.canonicalUrl, null);
|
| | | if (StringUtils.isEmpty(gitblitUrl)) {
|
| | | gitblitUrl = HttpUtils.getGitblitURL(request);
|
| | | }
|
| | | result = federationManager.getRepositories(gitblitUrl, token);
|
| | | } else {
|
| | | if (FederationRequest.PULL_SETTINGS.equals(reqType)) {
|