Search in sources :

Example 1 with FederationToken

use of com.gitblit.Constants.FederationToken in project gitblit by gitblit.

the class FederationManager method createFederationProposal.

/**
	 * Creates a proposal from the token.
	 *
	 * @param gitblitUrl
	 *            the url of this Gitblit instance
	 * @param token
	 * @return a potential proposal
	 */
@Override
public FederationProposal createFederationProposal(String gitblitUrl, String token) {
    FederationToken tokenType = FederationToken.REPOSITORIES;
    for (FederationToken type : FederationToken.values()) {
        if (token.equals(getFederationToken(type))) {
            tokenType = type;
            break;
        }
    }
    Map<String, RepositoryModel> repositories = getRepositories(gitblitUrl, token);
    FederationProposal proposal = new FederationProposal(gitblitUrl, tokenType, token, repositories);
    return proposal;
}
Also used : FederationProposal(com.gitblit.models.FederationProposal) RepositoryModel(com.gitblit.models.RepositoryModel) FederationToken(com.gitblit.Constants.FederationToken)

Example 2 with FederationToken

use of com.gitblit.Constants.FederationToken in project gitblit by gitblit.

the class ServicesManager method configureFederation.

protected void configureFederation() {
    boolean validPassphrase = true;
    String passphrase = settings.getString(Keys.federation.passphrase, "");
    if (StringUtils.isEmpty(passphrase)) {
        logger.info("Federation passphrase is blank! This server can not be PULLED from.");
        validPassphrase = false;
    }
    if (validPassphrase) {
        // standard tokens
        for (FederationToken tokenType : FederationToken.values()) {
            logger.info(MessageFormat.format("Federation {0} token = {1}", tokenType.name(), gitblit.getFederationToken(tokenType)));
        }
        // federation set tokens
        for (String set : settings.getStrings(Keys.federation.sets)) {
            logger.info(MessageFormat.format("Federation Set {0} token = {1}", set, gitblit.getFederationToken(set)));
        }
    }
    // Schedule or run the federation executor
    List<FederationModel> registrations = gitblit.getFederationRegistrations();
    if (registrations.size() > 0) {
        FederationPuller executor = new FederationPuller(registrations);
        scheduledExecutor.schedule(executor, 1, TimeUnit.MINUTES);
    }
}
Also used : FederationModel(com.gitblit.models.FederationModel) FederationToken(com.gitblit.Constants.FederationToken)

Example 3 with FederationToken

use of com.gitblit.Constants.FederationToken in project gitblit by gitblit.

the class FederationManager method getFederationSets.

/**
	 * Returns the list of federation sets.
	 *
	 * @return list of federation sets
	 */
@Override
public List<FederationSet> getFederationSets(String gitblitUrl) {
    List<FederationSet> list = new ArrayList<FederationSet>();
    // generate standard tokens
    for (FederationToken type : FederationToken.values()) {
        FederationSet fset = new FederationSet(type.toString(), type, getFederationToken(type));
        fset.repositories = getRepositories(gitblitUrl, fset.token);
        list.add(fset);
    }
    // generate tokens for federation sets
    for (String set : settings.getStrings(Keys.federation.sets)) {
        FederationSet fset = new FederationSet(set, FederationToken.REPOSITORIES, getFederationToken(set));
        fset.repositories = getRepositories(gitblitUrl, fset.token);
        list.add(fset);
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) FederationSet(com.gitblit.models.FederationSet) FederationToken(com.gitblit.Constants.FederationToken)

Aggregations

FederationToken (com.gitblit.Constants.FederationToken)3 FederationModel (com.gitblit.models.FederationModel)1 FederationProposal (com.gitblit.models.FederationProposal)1 FederationSet (com.gitblit.models.FederationSet)1 RepositoryModel (com.gitblit.models.RepositoryModel)1 ArrayList (java.util.ArrayList)1