Commit 5e06d4e0 authored by Romain Bioteau's avatar Romain Bioteau Committed by Adrien

fix(import) import workspace failing (#1561)

* Import workspace fails when trying to load an EMF resource containing
v6 legacy forms feature
* Fix some issue during migration

Closes BS-19292
parent adb6d62a
......@@ -29,6 +29,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.edapt.migration.MigrationException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Bundle;
/**
......@@ -120,7 +121,9 @@ public class ActorFilterDefRepositoryStore extends AbstractDefinitionRepositoryS
@Override
public void migrate(final IProgressMonitor monitor) throws CoreException, MigrationException {
super.migrate(monitor);
if(PlatformUI.isWorkbenchRunning()) {
getResourceProvider().loadDefinitionsCategories(null);
}
}
}
......@@ -722,10 +722,6 @@ public class Repository implements IRepository, IJavaContainer, IRenamable {
public void migrate(final IProgressMonitor monitor) throws CoreException, MigrationException {
Assert.isNotNull(project);
monitor.beginTask(String.format(Messages.migratingRepository, getName()), IProgressMonitor.UNKNOWN);
IFolder settings = project.getFolder(".settings");
if (settings.exists()) {
settings.delete(true, null);
}
for (final IRepositoryStore<?> store : getAllStores()) {
store.createRepositoryStore(this);
......
......@@ -27,8 +27,10 @@ import org.bonitasoft.studio.connectors.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.edapt.migration.MigrationException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Bundle;
/**
......@@ -128,7 +130,9 @@ public class ConnectorDefRepositoryStore extends AbstractDefinitionRepositorySto
@Override
public void migrate(final IProgressMonitor monitor) throws CoreException, MigrationException {
super.migrate(monitor);
if(PlatformUI.isWorkbenchRunning()) {
getResourceProvider().loadDefinitionsCategories(null);
}
}
}
......@@ -33,6 +33,9 @@ public abstract class WebArtifactRepositoryStore<T extends IRepositoryFileStore>
final List<T> result = new ArrayList<>();
final IFolder folder = getResource();
if(!folder.exists() || !folder.isAccessible()) {
return result;
}
try {
for (final IResource r : folder.members()) {
if (!r.isHidden() && !r.getName().startsWith(".") && r instanceof IFolder) {
......
......@@ -15,7 +15,9 @@
package org.bonitasoft.studio.importer.bos.operation;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
......@@ -39,6 +41,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.edapt.migration.MigrationException;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
......@@ -80,7 +83,8 @@ public class ImportWorkspaceApplication implements IApplication {
.map(repositoryAccessor::getRepository)
.forEach(repository -> {
System.out.println(
String.format("$SCAN_PROGRESS_%s:%s:%s:%s", repository.getName(), repository.getVersion(),
String.format("$SCAN_PROGRESS_%s:%s:%s:%s", repository.getName(),
repository.getVersion(),
findEdition(repository), connected(repository)));
export
.map(value -> value.split("=")[1])
......@@ -146,6 +150,7 @@ public class ImportWorkspaceApplication implements IApplication {
AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
new BasicCommandStack(), new HashMap<Resource, Boolean>());
URI fileURI = URI.createFileURI(file.getAbsolutePath());
editingDomain.getResourceSet().getLoadOptions().put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
Resource resource = editingDomain.getResourceSet().getResource(fileURI, true);
MainProcess process = (MainProcess) resource.getContents().get(0);
return process.getConfigId().toString().contains("sp");
......
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