Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-13 11:48:21 +0000
committerEike Stepper2012-09-13 11:48:21 +0000
commit240559c52a4962ed329281c2a406497d59a6e5fc (patch)
treee340d892ecec82da2e13304b2be9f52434a5e42d /plugins/org.eclipse.emf.cdo.transfer/src
parentef5ba89f34d14882fc82127fe79e64e8f492fda0 (diff)
downloadcdo-240559c52a4962ed329281c2a406497d59a6e5fc.tar.gz
cdo-240559c52a4962ed329281c2a406497d59a6e5fc.tar.xz
cdo-240559c52a4962ed329281c2a406497d59a6e5fc.zip
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.transfer/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferType.java29
2 files changed, 60 insertions, 27 deletions
diff --git a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java
index dedc0d42d9..867bb0171d 100644
--- a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java
+++ b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java
@@ -22,7 +22,6 @@ 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.Resource.Factory;
-import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -607,11 +606,15 @@ public class CDOTransfer implements INotifier
{
CDOTransferElement element = mapping.getSource();
Resource resource = elementResources.remove(element);
- resourceElements.remove(resource);
- resource.unload();
+ if (resource != null)
+ {
+ resourceElements.remove(resource);
+ resource.unload();
+
+ ResourceSet resourceSet = getSourceResourceSet();
+ resourceSet.getResources().remove(resource);
+ }
- ResourceSet resourceSet = getSourceResourceSet();
- resourceSet.getResources().remove(resource);
unmappedModels = null;
}
@@ -631,34 +634,17 @@ public class CDOTransfer implements INotifier
protected ResourceSet createResourceSet(CDOTransferSystem system)
{
- Resource.Factory.Registry registry = new ResourceFactoryRegistryImpl()
- {
- {
- getProtocolToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap());
- getExtensionToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap());
- getContentTypeToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap());
-
- getExtensionToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_EXTENSION);
- getContentTypeToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER);
- }
-
- @Override
- protected Factory delegatedGetFactory(URI uri, String contentTypeIdentifier)
- {
- return null;
- }
- };
-
ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.setResourceFactoryRegistry(registry);
+ resourceSet.setResourceFactoryRegistry(new ResourceFactoryRegistryWithoutDefaults());
return resourceSet;
}
protected boolean hasResourceFactory(CDOTransferElement source)
{
URI uri = source.getURI();
+
// TODO Derive resourceSet from element.getSystem()?
- Registry registry = getSourceResourceSet().getResourceFactoryRegistry();
+ Resource.Factory.Registry registry = getSourceResourceSet().getResourceFactoryRegistry();
return registry.getFactory(uri) != null;
}
@@ -689,4 +675,26 @@ public class CDOTransfer implements INotifier
}
}
}
+
+ /**
+ * @author Eike Stepper
+ */
+ protected static class ResourceFactoryRegistryWithoutDefaults extends ResourceFactoryRegistryImpl
+ {
+ public ResourceFactoryRegistryWithoutDefaults()
+ {
+ getProtocolToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getProtocolToFactoryMap());
+ getExtensionToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap());
+ getContentTypeToFactoryMap().putAll(Resource.Factory.Registry.INSTANCE.getContentTypeToFactoryMap());
+
+ getExtensionToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_EXTENSION);
+ getContentTypeToFactoryMap().remove(Resource.Factory.Registry.DEFAULT_CONTENT_TYPE_IDENTIFIER);
+ }
+
+ @Override
+ protected Factory delegatedGetFactory(URI uri, String contentTypeIdentifier)
+ {
+ return null;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferType.java b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferType.java
index 86a19be097..40b7d5b08d 100644
--- a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferType.java
+++ b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferType.java
@@ -10,8 +10,11 @@
*/
package org.eclipse.emf.cdo.transfer;
+import org.eclipse.emf.cdo.internal.transfer.bundle.OM;
+
import org.eclipse.net4j.util.ObjectUtil;
+import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
@@ -110,17 +113,39 @@ public class CDOTransferType implements Comparable<CDOTransferType>
{
return (Text)type;
}
-
+
if (type == null)
{
Text text = new Text(encoding);
MAP.put(encoding, text);
return text;
}
-
+
throw new IllegalArgumentException("Illegal encoding: " + encoding);
}
+ static
+ {
+ try
+ {
+ for (Charset charset : Charset.availableCharsets().values())
+ {
+ try
+ {
+ text(charset.toString());
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+
/**
* @author Eike Stepper
*/

Back to the top