Search in sources :

Example 6 with FederationModel

use of com.gitblit.models.FederationModel in project gitblit by gitblit.

the class FederationClient method main.

public static void main(String[] args) {
    Params params = new Params();
    CmdLineParser parser = new CmdLineParser(params);
    try {
        parser.parseArgument(args);
    } catch (CmdLineException t) {
        usage(parser, t);
    }
    System.out.println("Gitblit Federation Client v" + Constants.getVersion() + " (" + Constants.getBuildDate() + ")");
    // command-line specified base folder
    File baseFolder = new File(System.getProperty("user.dir"));
    if (!StringUtils.isEmpty(params.baseFolder)) {
        baseFolder = new File(params.baseFolder);
    }
    File regFile = com.gitblit.utils.FileUtils.resolveParameter(Constants.baseFolder$, baseFolder, params.registrationsFile);
    FileSettings settings = new FileSettings(regFile.getAbsolutePath());
    List<FederationModel> registrations = new ArrayList<FederationModel>();
    if (StringUtils.isEmpty(params.url)) {
        registrations.addAll(FederationUtils.getFederationRegistrations(settings));
    } else {
        if (StringUtils.isEmpty(params.token)) {
            System.out.println("Must specify --token parameter!");
            System.exit(0);
        }
        FederationModel model = new FederationModel("Gitblit");
        model.url = params.url;
        model.token = params.token;
        model.mirror = params.mirror;
        model.bare = params.bare;
        model.folder = "";
        registrations.add(model);
    }
    if (registrations.size() == 0) {
        System.out.println("No Federation Registrations!  Nothing to do.");
        System.exit(0);
    }
    // command-line specified repositories folder
    if (!StringUtils.isEmpty(params.repositoriesFolder)) {
        settings.overrideSetting(Keys.git.repositoriesFolder, new File(params.repositoriesFolder).getAbsolutePath());
    }
    // configure the Gitblit singleton for minimal, non-server operation
    XssFilter xssFilter = new AllowXssFilter();
    RuntimeManager runtime = new RuntimeManager(settings, xssFilter, baseFolder).start();
    NoopNotificationManager notifications = new NoopNotificationManager().start();
    UserManager users = new UserManager(runtime, null).start();
    RepositoryManager repositories = new RepositoryManager(runtime, null, users).start();
    FederationManager federation = new FederationManager(runtime, notifications, repositories).start();
    IGitblit gitblit = new GitblitManager(null, null, runtime, null, notifications, users, null, repositories, null, federation, null);
    FederationPullService puller = new FederationPullService(gitblit, federation.getFederationRegistrations()) {

        @Override
        public void reschedule(FederationModel registration) {
        // NOOP
        }
    };
    puller.run();
    System.out.println("Finished.");
    System.exit(0);
}
Also used : FederationModel(com.gitblit.models.FederationModel) CmdLineParser(org.kohsuke.args4j.CmdLineParser) GitblitManager(com.gitblit.manager.GitblitManager) FederationManager(com.gitblit.manager.FederationManager) ArrayList(java.util.ArrayList) RuntimeManager(com.gitblit.manager.RuntimeManager) IGitblit(com.gitblit.manager.IGitblit) FederationPullService(com.gitblit.service.FederationPullService) UserManager(com.gitblit.manager.UserManager) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) XssFilter(com.gitblit.utils.XssFilter) AllowXssFilter(com.gitblit.utils.XssFilter.AllowXssFilter) RepositoryManager(com.gitblit.manager.RepositoryManager) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException)

Aggregations

FederationModel (com.gitblit.models.FederationModel)6 ArrayList (java.util.ArrayList)3 File (java.io.File)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 FederationPullStatus (com.gitblit.Constants.FederationPullStatus)1 FederationRequest (com.gitblit.Constants.FederationRequest)1 FederationToken (com.gitblit.Constants.FederationToken)1 FederationManager (com.gitblit.manager.FederationManager)1 GitblitManager (com.gitblit.manager.GitblitManager)1 IGitblit (com.gitblit.manager.IGitblit)1 RepositoryManager (com.gitblit.manager.RepositoryManager)1 RuntimeManager (com.gitblit.manager.RuntimeManager)1 UserManager (com.gitblit.manager.UserManager)1 FederationProposal (com.gitblit.models.FederationProposal)1 TeamModel (com.gitblit.models.TeamModel)1 UserModel (com.gitblit.models.UserModel)1 FederationPullService (com.gitblit.service.FederationPullService)1 XssFilter (com.gitblit.utils.XssFilter)1 AllowXssFilter (com.gitblit.utils.XssFilter.AllowXssFilter)1