Search in sources :

Example 1 with AbstractFileBasedRepository

use of org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository in project winery by eclipse.

the class RepositoryFactory method reconfigure.

public static void reconfigure(GitBasedRepositoryConfiguration configuration) throws IOException, GitAPIException {
    RepositoryFactory.gitBasedRepositoryConfiguration = configuration;
    RepositoryFactory.fileBasedRepositoryConfiguration = null;
    if (repositoryContainsMultiRepositoryConfiguration(configuration)) {
        repository = new MultiRepository(configuration.getRepositoryPath().get());
    } else if (Environments.getInstance().getRepositoryConfig().isTenantRepository()) {
        repository = new TenantRepository(configuration.getRepositoryPath().get());
    } else {
        // if a repository root is specified, use it instead of the root specified in the config
        AbstractFileBasedRepository localRepository = configuration.getRepositoryPath().isPresent() ? createXmlOrYamlRepository(configuration, configuration.getRepositoryPath().get()) : createXmlOrYamlRepository(configuration, Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot()));
        repository = new GitBasedRepository(configuration, localRepository);
    }
}
Also used : MultiRepository(org.eclipse.winery.repository.filebased.MultiRepository) AbstractFileBasedRepository(org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository) TenantRepository(org.eclipse.winery.repository.filebased.TenantRepository) GitBasedRepository(org.eclipse.winery.repository.backend.filebased.GitBasedRepository)

Example 2 with AbstractFileBasedRepository

use of org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository in project winery by eclipse.

the class WineryUsingHttpServer method main.

public static void main(String[] args) throws Exception {
    // Initialize repository
    new Prefs(true);
    Server server = createHttpServer();
    server.start();
    IRepository repository = RepositoryFactory.getRepository();
    if (repository instanceof AbstractFileBasedRepository) {
        LOGGER.debug("Using path " + repository.getRepositoryRoot());
    } else {
        LOGGER.debug("Repository is not filebased");
    }
    // Waits until server is finished.
    // Will never happen, thus user has to press Ctrl+C.
    // See also https://stackoverflow.com/a/14981621/873282.
    server.join();
}
Also used : Server(org.eclipse.jetty.server.Server) AbstractFileBasedRepository(org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository) Prefs(org.eclipse.winery.repository.rest.Prefs) IRepository(org.eclipse.winery.repository.backend.IRepository)

Example 3 with AbstractFileBasedRepository

use of org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository in project winery by eclipse.

the class WineryCli method main.

public static void main(String[] args) throws Exception {
    Option repositoryPathOption = new Option("p", "path", true, "use given path as repository path");
    Option serviceTemplatesOnlyOption = new Option("so", "servicetemplatesonly", false, "checks service templates instead of the whole repository");
    Option checkDocumentationOption = new Option("cd", "checkdocumentation", false, "check existence of README.md and LICENSE. Default: No check");
    Option verboseOption = new Option("v", "verbose", false, "be verbose: Output the checked elements");
    Option generateCopybaraConfigOption = new Option("cb", "generatecopybaraconfig", true, "Generates a configuration for Copybara.");
    generateCopybaraConfigOption.setOptionalArg(true);
    Option helpOption = new Option("h", "help", false, "prints this help");
    Options options = new Options();
    options.addOption(repositoryPathOption);
    options.addOption(serviceTemplatesOnlyOption);
    options.addOption(checkDocumentationOption);
    options.addOption(verboseOption);
    options.addOption(generateCopybaraConfigOption);
    options.addOption(helpOption);
    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);
    if (line.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("winery", options);
        System.exit(0);
    }
    IRepository repository;
    if (line.hasOption("p")) {
        repository = RepositoryFactory.getRepository(Paths.get(line.getOptionValue("p")));
    } else {
        repository = RepositoryFactory.getRepository();
    }
    if (line.hasOption("cb")) {
        CopybaraGenerator copybaraGenerator = new CopybaraGenerator();
        String outfile = line.getOptionValue("cb");
        if (outfile == null) {
            String copybaraConfigFile = copybaraGenerator.generateCopybaraConfigFile();
            System.out.println(copybaraConfigFile);
        } else {
            Path file = Paths.get(outfile);
            copybaraGenerator.generateCopybaraConfigFile(file);
        }
        System.exit(0);
    }
    if (repository instanceof AbstractFileBasedRepository) {
        System.out.println("Using repository path " + repository.getRepositoryRoot() + "...");
    } else {
        System.out.println("Using non-filebased repository");
    }
    doConsistencyCheck(line, repository);
}
Also used : HelpFormatter(org.apache.commons.cli.HelpFormatter) Path(java.nio.file.Path) Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) AbstractFileBasedRepository(org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository) CopybaraGenerator(org.eclipse.winery.tools.copybaragenerator.CopybaraGenerator) Option(org.apache.commons.cli.Option) CommandLineParser(org.apache.commons.cli.CommandLineParser) IRepository(org.eclipse.winery.repository.backend.IRepository) DefaultParser(org.apache.commons.cli.DefaultParser)

Aggregations

AbstractFileBasedRepository (org.eclipse.winery.repository.backend.filebased.AbstractFileBasedRepository)3 IRepository (org.eclipse.winery.repository.backend.IRepository)2 Path (java.nio.file.Path)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 DefaultParser (org.apache.commons.cli.DefaultParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Option (org.apache.commons.cli.Option)1 Options (org.apache.commons.cli.Options)1 Server (org.eclipse.jetty.server.Server)1 GitBasedRepository (org.eclipse.winery.repository.backend.filebased.GitBasedRepository)1 MultiRepository (org.eclipse.winery.repository.filebased.MultiRepository)1 TenantRepository (org.eclipse.winery.repository.filebased.TenantRepository)1 Prefs (org.eclipse.winery.repository.rest.Prefs)1 CopybaraGenerator (org.eclipse.winery.tools.copybaragenerator.CopybaraGenerator)1