Commit dec0cdc4 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

feat(profiles) reuse 'profiles' store name (#760)

* Remove old profiles at import
* Remove old profiles at migration
* Rename stores Class name

Closes BS-17366
parent 72a0ceab
......@@ -372,9 +372,8 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
final IResource r = fs.getResource();
if (r instanceof IFile && r.exists()) {
final IFile iFile = (IFile) r;
final InputStream is = iFile.getContents();
InputStream newIs;
try {
try(final InputStream is = iFile.getContents()) {
newIs = handlePreImport(r.getName(), is);
if (!is.equals(newIs)) {
iFile.setContents(newIs, IResource.FORCE, monitor);
......
......@@ -97,6 +97,9 @@ public class BosArchive {
parseFolder(archiveModel.addStore(store), segments.subList(2, segments.size()), parentSegments, resourcesToOpen,
true);
if(store.getChildren().length == 0) {
archiveModel.removeStore(store);
}
}
private void parseFolder(AbstractFolderModel store, List<String> segments, List<String> parentSegments,
......@@ -105,8 +108,10 @@ public class BosArchive {
&& directStoreChild) { // File
final ImportFileStoreModel file = new ImportFileStoreModel(Joiner.on('/').join(concat(parentSegments, segments)),
store);
file.setToOpen(openAll || resourcesToOpen.contains(file.getFileName()));
store.addFile(file);
if(!isALegacyProfile(store, file)) {
file.setToOpen(openAll || resourcesToOpen.contains(file.getFileName()));
store.addFile(file);
}
} else if (segments.size() == 1 && !directStoreChild) {
final ImportFileModel file = new ImportFileModel(Joiner.on('/').join(concat(parentSegments, segments)), store);
if (shouldReadNameInJSON(store, file)) {
......@@ -134,6 +139,10 @@ public class BosArchive {
}
}
protected boolean isALegacyProfile(AbstractFolderModel store, final ImportFileStoreModel file) {
return file.getFileName().endsWith(".profile") && "profiles".equals(store.getFolderName());
}
private boolean shouldReadNameInJSON(AbstractFolderModel store, final ImportFileModel file) {
return isAWebRepositoryStore(store)
&& file.getFileName().startsWith(file.getParent().get().getFolderName())
......
......@@ -24,6 +24,10 @@ public class ImportArchiveModel {
});
}
public void removeStore(ImportStoreModel store) {
stores.remove(store);
}
public List<ImportStoreModel> getStores() {
Collections.sort(stores, (f1, f2) -> f1.getFolderName().compareTo(f2.getFolderName()));
return Collections.unmodifiableList(stores);
......@@ -56,4 +60,5 @@ public class ImportArchiveModel {
public void resetStatus() {
stores.stream().forEach(ImportStoreModel::resetStatus);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment