Commit ff3dfa8f authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Project: Enable Importing Projects from any Source

Reenables importing projects from platform resources such as projects
embedded in AF3 plugins. The new solution is based on In-/OutputStreams
instead of File descriptors rendering the solution way more robust. We
are now using the intended way.

Issue-Ref: 4064

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <>
parent 264a57aa
......@@ -3,7 +3,7 @@ 70e81c85ae7c2d8076e190ebad7eae648451b645 GREEN 054c92406affa0c0ad8ac7a067de9608d0bbca2b GREEN a5a30a0e6b274d220c397d9bf0f14756d49bd19f GREEN 2963d3a1fe651025bae3ae4dc0b6e0b77bbaadd5 GREEN f1465eb779a321f3bf895dd5a6983fdfd9e0fa70 GREEN ec338a0640e7e6170942aa619ac853a6deb22d48 YELLOW 83dc50f1fc28c7f1d9dcde9e4e0d02480656b7aa GREEN 54f2397f0d6720c90948ccc295f1a63b7319daac GREEN 031591687c2461a990d0534cf4ed4d6df39b1551 GREEN
......@@ -15,7 +15,7 @@
package org.fortiss.af3.project.utils;
import static org.conqat.lib.commons.filesystem.FileSystemUtils.copyFile;
import static org.conqat.lib.commons.filesystem.FileSystemUtils.copy;
import static org.conqat.lib.commons.reflect.ReflectionUtils.pickInstanceOf;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.fortiss.af3.project.AF3Project.AF3_PRJ_SUFFIX;
......@@ -36,6 +36,8 @@ import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import java.util.List;
import org.eclipse.core.resources.IFile;
......@@ -50,6 +52,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.fortiss.af3.project.AF3ProjectActivator;
import org.fortiss.af3.project.model.FileLibrary;
......@@ -268,8 +271,14 @@ public final class ProjectUtils {
// We need to copy the file instead of creating a new resource from the FileProject since
// few internal references would point to the original file (NOTE: This can only be observed
// with few entities and only with large projects). This indicates a problem in EMF's href
// resolution algorithm.
copyFile(new File(sourceFileURI.toFileString()), new File(targetFileURI.toFileString()));
// resolution algorithm
InputStream inStream = URIConverter.INSTANCE.createInputStream(sourceFileURI);
OutputStream outStream = URIConverter.INSTANCE.createOutputStream(targetFileURI);
int size = copy(inStream, outStream);
if(size <= 0) {
error(getDefault(), "Failed to import " + sourceFileProject.getName() + "." +
" Zero bytes were copied.");
// Using the Java-API is not directly possible, as we would need to load the file before,
// which could destroy some element references. Using listeners we can avoid the problem by
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