mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-04 20:45:52 +01:00
Add the repository import and export with metadata for Subversion repositories (#1501)
* 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>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.migration;
|
||||
|
||||
import sonia.scm.plugin.ExtensionPoint;
|
||||
@@ -50,6 +50,7 @@ import sonia.scm.version.Version;
|
||||
* <ul>
|
||||
* <li>a {@link sonia.scm.security.KeyGenerator},</li>
|
||||
* <li>the {@link sonia.scm.repository.RepositoryLocationResolver},</li>
|
||||
* <li>an {@link sonia.scm.update.RepositoryUpdateIterator},</li>
|
||||
* <li>the {@link sonia.scm.io.FileSystem},</li>
|
||||
* <li>the {@link sonia.scm.security.CipherHandler},</li>
|
||||
* <li>a {@link sonia.scm.store.ConfigurationStoreFactory},</li>
|
||||
@@ -82,6 +83,8 @@ import sonia.scm.version.Version;
|
||||
* </li>
|
||||
* </ul>
|
||||
* </p>
|
||||
* <p>Mind that an implementation of this class has to be annotated with {@link sonia.scm.plugin.Extension}, so that the
|
||||
* step will be found. </p>
|
||||
*/
|
||||
@ExtensionPoint
|
||||
public interface UpdateStep {
|
||||
|
||||
@@ -56,7 +56,7 @@ import java.util.Set;
|
||||
@XmlRootElement(name = "repositories")
|
||||
@StaticPermissions(
|
||||
value = "repository",
|
||||
permissions = {"read", "modify", "delete", "rename", "healthCheck", "pull", "push", "permissionRead", "permissionWrite", "archive"},
|
||||
permissions = {"read", "modify", "delete", "rename", "healthCheck", "pull", "push", "permissionRead", "permissionWrite", "archive", "export"},
|
||||
custom = true, customGlobal = true,
|
||||
guards = {
|
||||
@Guard(guard = RepositoryPermissionGuard.class)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.repository.api;
|
||||
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.ExceptionWithContext;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ExportFailedException extends ExceptionWithContext {
|
||||
|
||||
private static final String CODE = "67SM3DANZ1";
|
||||
|
||||
public ExportFailedException(List<ContextEntry> context, String message, Exception cause) {
|
||||
super(context, message, cause);
|
||||
}
|
||||
|
||||
public ExportFailedException(List<ContextEntry> context, String message) {
|
||||
super(context, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return CODE;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,10 @@ public class ImportFailedException extends ExceptionWithContext {
|
||||
super(context, message, cause);
|
||||
}
|
||||
|
||||
public ImportFailedException(List<ContextEntry> context, String message) {
|
||||
super(context, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return CODE;
|
||||
|
||||
49
scm-core/src/main/java/sonia/scm/store/ExportableStore.java
Normal file
49
scm-core/src/main/java/sonia/scm/store/ExportableStore.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The {@link ExportableStore} is used to export the stored data inside the store.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface ExportableStore {
|
||||
|
||||
/**
|
||||
* Contains the information about this store.
|
||||
*/
|
||||
StoreEntryMetaData getMetaData();
|
||||
|
||||
/**
|
||||
* Exports the data of this store to the given {@param exporter}.
|
||||
*/
|
||||
void export(Exporter exporter) throws IOException;
|
||||
}
|
||||
48
scm-core/src/main/java/sonia/scm/store/Exporter.java
Normal file
48
scm-core/src/main/java/sonia/scm/store/Exporter.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* The {@link Exporter} is used to export a single store entry to an {@link OutputStream}.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface Exporter {
|
||||
/**
|
||||
* Returns the {@link OutputStream} that should be used to export a single store entry with the given name.
|
||||
*
|
||||
* @param name The name of the exported store entry.
|
||||
* @param size The size of the exported store entry (the size of the bytes that will be written to the output stream).
|
||||
* @return The output stream the raw data of the store entry must be written to.
|
||||
*/
|
||||
OutputStream put(String name, long size) throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* The {@link StoreEntryImporter} is used to import a store entry from an {@link InputStream}.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface StoreEntryImporter {
|
||||
|
||||
/**
|
||||
* Will be called for each entry of the store.
|
||||
* @param name The name of the store entry.
|
||||
* @param stream An input stream with the raw data of the store entry.
|
||||
*/
|
||||
void importEntry(String name, InputStream stream);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
/**
|
||||
* Create a {@link StoreEntryImporter} for the store type and store name.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface StoreEntryImporterFactory {
|
||||
/**
|
||||
* Returns a {@link StoreEntryImporter}.
|
||||
*
|
||||
* @param metaData The metaData about this store. For example store type and store name.
|
||||
*/
|
||||
StoreEntryImporter importStore(StoreEntryMetaData metaData);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
@Value
|
||||
public class StoreEntryMetaData {
|
||||
StoreType type;
|
||||
String name;
|
||||
}
|
||||
42
scm-core/src/main/java/sonia/scm/store/StoreExporter.java
Normal file
42
scm-core/src/main/java/sonia/scm/store/StoreExporter.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import sonia.scm.repository.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The {@link StoreExporter} is used to collect all {@link ExportableStore}s for a given repository.
|
||||
* An {@link ExportableStore} can be used to export all data which is stored inside.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface StoreExporter {
|
||||
List<ExportableStore> listExportableStores(Repository repository);
|
||||
}
|
||||
44
scm-core/src/main/java/sonia/scm/store/StoreImporter.java
Normal file
44
scm-core/src/main/java/sonia/scm/store/StoreImporter.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import sonia.scm.repository.Repository;
|
||||
|
||||
/**
|
||||
* The {@link StoreImporter} is used to create a {@link StoreEntryImporterFactory} for a {@link Repository}.
|
||||
* <p><b>This interface is not yet finalized and might change in the upcoming versions.</b></p>
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
@Beta
|
||||
public interface StoreImporter {
|
||||
/**
|
||||
* Returns a {@link StoreEntryImporterFactory} for the {@link Repository}
|
||||
*
|
||||
* @param repository
|
||||
*/
|
||||
StoreEntryImporterFactory doImport(Repository repository);
|
||||
}
|
||||
43
scm-core/src/main/java/sonia/scm/store/StoreType.java
Normal file
43
scm-core/src/main/java/sonia/scm/store/StoreType.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.store;
|
||||
|
||||
public enum StoreType {
|
||||
|
||||
DATA("data"),
|
||||
CONFIG("config"),
|
||||
BLOB("blob"),
|
||||
CONFIG_ENTRY("configEntry");
|
||||
|
||||
StoreType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private final String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.update;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Implementations of this interface can be used to iterate all repositories in update steps.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
public interface RepositoryUpdateIterator {
|
||||
|
||||
/**
|
||||
* Calls the given consumer with each repository id.
|
||||
*
|
||||
* @since 2.13.0
|
||||
*/
|
||||
void forEachRepository(Consumer<String> repositoryIdConsumer);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.update;
|
||||
|
||||
import sonia.scm.store.StoreParameters;
|
||||
import sonia.scm.store.StoreType;
|
||||
|
||||
public interface StoreUpdateStepUtilFactory {
|
||||
|
||||
default UtilForTypeBuilder forType(StoreType type) {
|
||||
return new UtilForTypeBuilder(this, type);
|
||||
}
|
||||
|
||||
final class UtilForTypeBuilder {
|
||||
private final StoreUpdateStepUtilFactory factory;
|
||||
private final StoreType type;
|
||||
|
||||
public UtilForTypeBuilder(StoreUpdateStepUtilFactory factory, StoreType type) {
|
||||
this.factory = factory;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public UtilForNameBuilder forName(String name) {
|
||||
return new UtilForNameBuilder(factory, type, name);
|
||||
}
|
||||
}
|
||||
|
||||
final class UtilForNameBuilder {
|
||||
|
||||
private final StoreUpdateStepUtilFactory factory;
|
||||
private final StoreType type;
|
||||
private final String name;
|
||||
private String repositoryId;
|
||||
|
||||
public UtilForNameBuilder(StoreUpdateStepUtilFactory factory, StoreType type, String name) {
|
||||
this.factory = factory;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public UtilForNameBuilder forRepository(String repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public StoreUpdateStepUtil build() {
|
||||
return factory.build(
|
||||
type,
|
||||
new StoreParameters() {
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
StoreUpdateStepUtil build(StoreType type, StoreParameters parameters);
|
||||
|
||||
interface StoreUpdateStepUtil {
|
||||
void renameStore(String newName);
|
||||
|
||||
void deleteStore();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user