mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-10-28 17:16:16 +01:00
* Add store exporter to collect the repository metadata * Add EnvironmentInformationXmlGenerator * Collect export data and put into compressed tar archive output stream * Create full repository export endpoint. * Add full repository export to ui * Ignore irrelevant files from config store directory * write metadata stores to file since a baos could teardown the server memory * Migrate store name for git lfs files (#1504) Changes the directory name for the git LFS blob store by removing the repository id from the store name. This is necessary for im- and exports of lfs blob stores, because the original name had the repository id as a part of it and therefore the old store would not be found when the repository is imported with another id. Existing blob files will be moved to the new store location by an update step. Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com> * Introduce util for migrations (#1505) With this util it is more simple to rename or delete stores. * Rename files in export Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
138 lines
5.6 KiB
Java
138 lines
5.6 KiB
Java
/*
|
|
* MIT License
|
|
*
|
|
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
package sonia.scm.lifecycle.modules;
|
|
|
|
import com.google.inject.AbstractModule;
|
|
import com.google.inject.TypeLiteral;
|
|
import com.google.inject.throwingproviders.ThrowingProviderBinder;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import sonia.scm.SCMContext;
|
|
import sonia.scm.SCMContextProvider;
|
|
import sonia.scm.io.DefaultFileSystem;
|
|
import sonia.scm.io.FileSystem;
|
|
import sonia.scm.lifecycle.DefaultRestarter;
|
|
import sonia.scm.lifecycle.Restarter;
|
|
import sonia.scm.plugin.PluginLoader;
|
|
import sonia.scm.repository.EventDrivenRepositoryArchiveCheck;
|
|
import sonia.scm.repository.RepositoryArchivedCheck;
|
|
import sonia.scm.repository.RepositoryLocationResolver;
|
|
import sonia.scm.repository.xml.MetadataStore;
|
|
import sonia.scm.repository.xml.PathBasedRepositoryLocationResolver;
|
|
import sonia.scm.security.CipherHandler;
|
|
import sonia.scm.security.CipherUtil;
|
|
import sonia.scm.security.DefaultKeyGenerator;
|
|
import sonia.scm.security.KeyGenerator;
|
|
import sonia.scm.store.BlobStoreFactory;
|
|
import sonia.scm.store.ConfigurationEntryStoreFactory;
|
|
import sonia.scm.store.ConfigurationStoreFactory;
|
|
import sonia.scm.store.DataStoreFactory;
|
|
import sonia.scm.store.DefaultBlobDirectoryAccess;
|
|
import sonia.scm.store.FileBlobStoreFactory;
|
|
import sonia.scm.store.FileRepositoryUpdateIterator;
|
|
import sonia.scm.store.FileStoreUpdateStepUtilFactory;
|
|
import sonia.scm.store.JAXBConfigurationEntryStoreFactory;
|
|
import sonia.scm.store.JAXBConfigurationStoreFactory;
|
|
import sonia.scm.store.JAXBDataStoreFactory;
|
|
import sonia.scm.store.JAXBPropertyFileAccess;
|
|
import sonia.scm.update.BlobDirectoryAccess;
|
|
import sonia.scm.update.PropertyFileAccess;
|
|
import sonia.scm.update.RepositoryUpdateIterator;
|
|
import sonia.scm.update.StoreUpdateStepUtilFactory;
|
|
import sonia.scm.update.UpdateStepRepositoryMetadataAccess;
|
|
import sonia.scm.update.V1PropertyDAO;
|
|
import sonia.scm.update.xml.XmlV1PropertyDAO;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
public class BootstrapModule extends AbstractModule {
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(BootstrapModule.class);
|
|
|
|
private final ClassOverrides overrides;
|
|
private final PluginLoader pluginLoader;
|
|
|
|
public BootstrapModule(PluginLoader pluginLoader) {
|
|
this.overrides = ClassOverrides.findOverrides(pluginLoader.getUberClassLoader());
|
|
this.pluginLoader = pluginLoader;
|
|
}
|
|
|
|
@Override
|
|
protected void configure() {
|
|
install(ThrowingProviderBinder.forModule(this));
|
|
|
|
SCMContextProvider context = SCMContext.getContext();
|
|
|
|
bind(SCMContextProvider.class).toInstance(context);
|
|
|
|
bind(KeyGenerator.class).to(DefaultKeyGenerator.class);
|
|
|
|
bind(RepositoryLocationResolver.class).to(PathBasedRepositoryLocationResolver.class);
|
|
|
|
bind(FileSystem.class, DefaultFileSystem.class);
|
|
|
|
bind(Restarter.class, DefaultRestarter.class);
|
|
|
|
// note CipherUtil uses an other generator
|
|
bind(CipherHandler.class).toInstance(CipherUtil.getInstance().getCipherHandler());
|
|
|
|
// bind core
|
|
bind(RepositoryArchivedCheck.class, EventDrivenRepositoryArchiveCheck.class);
|
|
bind(ConfigurationStoreFactory.class, JAXBConfigurationStoreFactory.class);
|
|
bind(ConfigurationEntryStoreFactory.class, JAXBConfigurationEntryStoreFactory.class);
|
|
bind(DataStoreFactory.class, JAXBDataStoreFactory.class);
|
|
bind(BlobStoreFactory.class, FileBlobStoreFactory.class);
|
|
bind(PluginLoader.class).toInstance(pluginLoader);
|
|
bind(V1PropertyDAO.class, XmlV1PropertyDAO.class);
|
|
bind(PropertyFileAccess.class, JAXBPropertyFileAccess.class);
|
|
bind(BlobDirectoryAccess.class, DefaultBlobDirectoryAccess.class);
|
|
bind(RepositoryUpdateIterator.class, FileRepositoryUpdateIterator.class);
|
|
bind(StoreUpdateStepUtilFactory.class, FileStoreUpdateStepUtilFactory.class);
|
|
bind(new TypeLiteral<UpdateStepRepositoryMetadataAccess<Path>>() {}).to(new TypeLiteral<MetadataStore>() {});
|
|
}
|
|
|
|
private <T> void bind(Class<T> clazz, Class<? extends T> defaultImplementation) {
|
|
Class<? extends T> implementation = find(clazz, defaultImplementation);
|
|
LOG.debug("bind {} to {}", clazz, implementation);
|
|
bind(clazz).to(implementation);
|
|
}
|
|
|
|
private <T> Class<? extends T> find(Class<T> clazz, Class<? extends T> defaultImplementation) {
|
|
Class<? extends T> implementation = overrides.getOverride(clazz);
|
|
|
|
if (implementation != null) {
|
|
LOG.info("found override {} for {}", implementation, clazz);
|
|
} else {
|
|
implementation = defaultImplementation;
|
|
|
|
LOG.trace(
|
|
"no override available for {}, using default implementation {}",
|
|
clazz, implementation);
|
|
}
|
|
|
|
return implementation;
|
|
}
|
|
}
|