use of org.eclipse.winery.repository.filebased.TenantRepository 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);
}
}
use of org.eclipse.winery.repository.filebased.TenantRepository in project winery by eclipse.
the class RepositoryFactory method reconfigure.
public static void reconfigure(FileBasedRepositoryConfiguration configuration) {
RepositoryFactory.fileBasedRepositoryConfiguration = configuration;
RepositoryFactory.gitBasedRepositoryConfiguration = null;
if (repositoryContainsMultiRepositoryConfiguration(configuration)) {
try {
repository = new MultiRepository(configuration.getRepositoryPath().get());
} catch (IOException | GitAPIException e) {
LOGGER.error("Error while initializing Multi-Repository!");
}
} else if (Environments.getInstance().getRepositoryConfig().isTenantRepository()) {
try {
repository = new TenantRepository(configuration.getRepositoryPath().get());
} catch (IOException | GitAPIException e) {
LOGGER.error("Error while initializing Tenant-Repository");
}
} else {
// if a repository root is specified, use it instead of the root specified in the config
repository = configuration.getRepositoryPath().isPresent() ? createXmlOrYamlRepository(configuration, configuration.getRepositoryPath().get()) : createXmlOrYamlRepository(configuration, Paths.get(Environments.getInstance().getRepositoryConfig().getRepositoryRoot()));
}
}
use of org.eclipse.winery.repository.filebased.TenantRepository in project winery by eclipse.
the class TenantFilter method filter.
@Override
public void filter(ContainerRequestContext containerRequestContext) throws IOException {
MultivaluedMap<String, String> headers = containerRequestContext.getHeaders();
MultivaluedMap<String, String> queryParameters = containerRequestContext.getUriInfo().getQueryParameters();
String tenantName = null;
if (headers.containsKey(WINERY_TENANT)) {
tenantName = headers.getFirst(WINERY_TENANT);
} else if (queryParameters.containsKey(WINERY_TENANT)) {
tenantName = queryParameters.getFirst(WINERY_TENANT);
}
if (tenantName != null) {
LOGGER.debug("Got new request for tenant: " + tenantName);
IRepository repo = RepositoryFactory.getRepository();
if (repo instanceof TenantRepository) {
((TenantRepository) repo).useTenant(tenantName);
}
}
}
Aggregations