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; private String name;
@XmlElement(name = "permission") @XmlElement(name = "permission")
private final Set<RepositoryPermission> permissions = new HashSet<>(); private final Set<RepositoryPermission> permissions = new HashSet<>();
@XmlElement(name = "public")
private boolean publicReadable = false;
private boolean archived = false; private boolean archived = false;
private String type; private String type;
} }

View File

@@ -19,22 +19,27 @@ import static java.util.Optional.of;
class V1RepositoryHelper { class V1RepositoryHelper {
static File resolveV1File(SCMContextProvider contextProvider, String filename) { static Optional<File> resolveV1File(SCMContextProvider contextProvider, String filename) {
return contextProvider File v1XmlFile = contextProvider.resolve(Paths.get(StoreConstants.CONFIG_DIRECTORY_NAME).resolve(filename)).toFile();
.resolve( if (v1XmlFile.exists()) {
Paths.get(StoreConstants.CONFIG_DIRECTORY_NAME).resolve(filename) return Optional.of(v1XmlFile);
).toFile(); }
return Optional.empty();
} }
static Optional<V1RepositoryDatabase> readV1Database(SCMContextProvider contextProvider, String filename) throws JAXBException { static Optional<V1RepositoryDatabase> readV1Database(SCMContextProvider contextProvider, String filename) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(V1RepositoryDatabase.class); 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) { if (unmarshal instanceof V1RepositoryHelper.V1RepositoryDatabase) {
return of((V1RepositoryHelper.V1RepositoryDatabase) unmarshal); return of((V1RepositoryHelper.V1RepositoryDatabase) unmarshal);
} else { } else {
return empty(); return empty();
} }
} }
return empty();
}
static class RepositoryList { static class RepositoryList {
@XmlElement(name = "repository") @XmlElement(name = "repository")

View File

@@ -91,7 +91,7 @@ public class XmlRepositoryV1UpdateStep implements CoreUpdateStep {
@Override @Override
public void doUpdate() throws JAXBException { 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"); LOG.info("no v1 repositories database file found");
return; return;
} }
@@ -105,7 +105,7 @@ public class XmlRepositoryV1UpdateStep implements CoreUpdateStep {
} }
public List<V1Repository> getRepositoriesWithoutMigrationStrategies() { 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"); LOG.info("no v1 repositories database file found");
return emptyList(); return emptyList();
} }

View File

@@ -94,7 +94,6 @@ public class RepositorySimplePermissionITCase
repository.setName("test-repo"); repository.setName("test-repo");
repository.setType("git"); repository.setType("git");
// repository.setPublicReadable(false);
ScmClient client = createAdminClient(); ScmClient client = createAdminClient();