mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
only migrate public flag if repository-v1-xml-backup
This commit is contained in:
@@ -148,8 +148,6 @@ public class MigrateVerbsToPermissionRoles implements UpdateStep {
|
||||
private String name;
|
||||
@XmlElement(name = "permission")
|
||||
private final Set<RepositoryPermission> permissions = new HashSet<>();
|
||||
@XmlElement(name = "public")
|
||||
private boolean publicReadable = false;
|
||||
private boolean archived = false;
|
||||
private String type;
|
||||
}
|
||||
|
||||
@@ -19,22 +19,27 @@ import static java.util.Optional.of;
|
||||
|
||||
class V1RepositoryHelper {
|
||||
|
||||
static File resolveV1File(SCMContextProvider contextProvider, String filename) {
|
||||
return contextProvider
|
||||
.resolve(
|
||||
Paths.get(StoreConstants.CONFIG_DIRECTORY_NAME).resolve(filename)
|
||||
).toFile();
|
||||
static Optional<File> resolveV1File(SCMContextProvider contextProvider, String filename) {
|
||||
File v1XmlFile = contextProvider.resolve(Paths.get(StoreConstants.CONFIG_DIRECTORY_NAME).resolve(filename)).toFile();
|
||||
if (v1XmlFile.exists()) {
|
||||
return Optional.of(v1XmlFile);
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
static Optional<V1RepositoryDatabase> readV1Database(SCMContextProvider contextProvider, String filename) throws JAXBException {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(V1RepositoryDatabase.class);
|
||||
Object unmarshal = jaxbContext.createUnmarshaller().unmarshal(resolveV1File(contextProvider, filename));
|
||||
Optional<File> file = resolveV1File(contextProvider, filename);
|
||||
if (file.isPresent()) {
|
||||
Object unmarshal = jaxbContext.createUnmarshaller().unmarshal(file.get());
|
||||
if (unmarshal instanceof V1RepositoryHelper.V1RepositoryDatabase) {
|
||||
return of((V1RepositoryHelper.V1RepositoryDatabase) unmarshal);
|
||||
} else {
|
||||
return empty();
|
||||
}
|
||||
}
|
||||
return empty();
|
||||
}
|
||||
|
||||
static class RepositoryList {
|
||||
@XmlElement(name = "repository")
|
||||
|
||||
@@ -91,7 +91,7 @@ public class XmlRepositoryV1UpdateStep implements CoreUpdateStep {
|
||||
|
||||
@Override
|
||||
public void doUpdate() throws JAXBException {
|
||||
if (!resolveV1File(contextProvider, V1_REPOSITORY_FILENAME).exists()) {
|
||||
if (!resolveV1File(contextProvider, V1_REPOSITORY_FILENAME).isPresent()) {
|
||||
LOG.info("no v1 repositories database file found");
|
||||
return;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class XmlRepositoryV1UpdateStep implements CoreUpdateStep {
|
||||
}
|
||||
|
||||
public List<V1Repository> getRepositoriesWithoutMigrationStrategies() {
|
||||
if (!resolveV1File(contextProvider, V1_REPOSITORY_FILENAME).exists()) {
|
||||
if (!resolveV1File(contextProvider, V1_REPOSITORY_FILENAME).isPresent()) {
|
||||
LOG.info("no v1 repositories database file found");
|
||||
return emptyList();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ public class RepositorySimplePermissionITCase
|
||||
|
||||
repository.setName("test-repo");
|
||||
repository.setType("git");
|
||||
// repository.setPublicReadable(false);
|
||||
|
||||
ScmClient client = createAdminClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user