only migrate public flag if repository-v1-xml-backup

This commit is contained in:
Eduard Heimbuch
2019-11-19 15:42:22 +01:00
parent e7cb674bb5
commit aa7b6f5282
4 changed files with 17 additions and 15 deletions

View File

@@ -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;
}

View File

@@ -19,21 +19,26 @@ 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));
if (unmarshal instanceof V1RepositoryHelper.V1RepositoryDatabase) {
return of((V1RepositoryHelper.V1RepositoryDatabase) unmarshal);
} else {
return empty();
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 {

View File

@@ -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();
}