Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-09-10 08:39:20 +0000
committerEike Stepper2012-09-10 08:39:20 +0000
commit5b020d2fad69f85ceb9cd155ede7aa7295de9610 (patch)
treef5956d8a23b220b71e77ae36edc79ed0880c0858 /plugins
parent53881f8a9ce0e049de70acda44cbf72981a121ed (diff)
downloadcdo-5b020d2fad69f85ceb9cd155ede7aa7295de9610.tar.gz
cdo-5b020d2fad69f85ceb9cd155ede7aa7295de9610.tar.xz
cdo-5b020d2fad69f85ceb9cd155ede7aa7295de9610.zip
[388928] Develop a resource transfer framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=388928
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java88
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransfer.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferElement.java5
3 files changed, 69 insertions, 37 deletions
diff --git a/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java b/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
index 19f37ed956..c00978de68 100644
--- a/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
+++ b/plugins/org.eclipse.emf.cdo.transfer.repository/src/org/eclipse/emf/cdo/transfer/spi/repository/RepositoryTransferSystem.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.transfer.CDOTransferType;
import org.eclipse.emf.cdo.util.CDOURIUtil;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.emf.common.util.EList;
@@ -157,26 +158,40 @@ public class RepositoryTransferSystem extends CDOTransferSystem
}
@Override
- public void createFolder(IPath path) throws IOException
+ public void createFolder(IPath path)
{
((CDOTransaction)view).createResourceFolder(path.toString());
}
@Override
- public void createBinary(IPath path, InputStream source) throws IOException
+ public void createBinary(IPath path, InputStream source)
{
- CDOBlob blob = new CDOBlob(source);
- CDOBinaryResource resource = ((CDOTransaction)view).createBinaryResource(path.toString());
- resource.setContents(blob);
+ try
+ {
+ CDOBlob blob = new CDOBlob(source);
+ CDOBinaryResource resource = ((CDOTransaction)view).createBinaryResource(path.toString());
+ resource.setContents(blob);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
}
@Override
- public void createText(IPath path, InputStream source, String encoding) throws IOException
+ public void createText(IPath path, InputStream source, String encoding)
{
- CDOClob clob = new CDOClob(new InputStreamReader(source, encoding));
- CDOTextResource resource = ((CDOTransaction)view).createTextResource(path.toString());
- resource.setContents(clob);
- resource.setEncoding(encoding);
+ try
+ {
+ CDOClob clob = new CDOClob(new InputStreamReader(source, encoding));
+ CDOTextResource resource = ((CDOTransaction)view).createTextResource(path.toString());
+ resource.setContents(clob);
+ resource.setEncoding(encoding);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
}
@Override
@@ -217,7 +232,7 @@ public class RepositoryTransferSystem extends CDOTransferSystem
}
@Override
- protected CDOTransferElement[] doGetChildren() throws IOException
+ protected CDOTransferElement[] doGetChildren()
{
EList<EObject> children = rootResource.getContents();
int size = children.size();
@@ -233,7 +248,7 @@ public class RepositoryTransferSystem extends CDOTransferSystem
}
@Override
- protected InputStream doOpenInputStream() throws IOException
+ protected InputStream doOpenInputStream()
{
throw new UnsupportedOperationException();
}
@@ -271,7 +286,7 @@ public class RepositoryTransferSystem extends CDOTransferSystem
}
@Override
- protected CDOTransferElement[] doGetChildren() throws IOException
+ protected CDOTransferElement[] doGetChildren()
{
EList<CDOResourceNode> children = ((CDOResourceFolder)node).getNodes();
int size = children.size();
@@ -287,32 +302,39 @@ public class RepositoryTransferSystem extends CDOTransferSystem
}
@Override
- protected InputStream doOpenInputStream() throws IOException
+ protected InputStream doOpenInputStream()
{
- if (node instanceof CDOBinaryResource)
- {
- CDOBinaryResource resource = (CDOBinaryResource)node;
- return resource.getContents().getContents();
- }
-
- if (node instanceof CDOTextResource)
+ try
{
- CDOTextResource resource = (CDOTextResource)node;
- Reader reader = resource.getContents().getContents();
- CharArrayWriter buffer = new CharArrayWriter(); // TODO Make more scalable
-
- try
+ if (node instanceof CDOBinaryResource)
{
- IOUtil.copyCharacter(reader, buffer);
+ CDOBinaryResource resource = (CDOBinaryResource)node;
+ return resource.getContents().getContents();
}
- finally
+
+ if (node instanceof CDOTextResource)
{
- IOUtil.close(reader);
+ CDOTextResource resource = (CDOTextResource)node;
+ Reader reader = resource.getContents().getContents();
+ CharArrayWriter buffer = new CharArrayWriter(); // TODO Make more scalable
+
+ try
+ {
+ IOUtil.copyCharacter(reader, buffer);
+ }
+ finally
+ {
+ IOUtil.close(reader);
+ }
+
+ String encoding = resource.getEncoding();
+ byte[] bytes = buffer.toString().getBytes(encoding);
+ return new ByteArrayInputStream(bytes);
}
-
- String encoding = resource.getEncoding();
- byte[] bytes = buffer.toString().getBytes(encoding);
- return new ByteArrayInputStream(bytes);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
}
throw new IllegalStateException("Not a file resource: " + node);
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 b876f40751..ed1f6b3c0a 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
@@ -14,6 +14,7 @@ import org.eclipse.net4j.util.event.Event;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.INotifier;
import org.eclipse.net4j.util.event.Notifier;
+import org.eclipse.net4j.util.io.IORuntimeException;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.emf.common.util.EList;
@@ -30,6 +31,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
@@ -672,9 +674,16 @@ public class CDOTransfer implements INotifier
protected void save()
{
- for (Resource resource : elementResources.values())
+ try
{
- resource.save(null);
+ for (Resource resource : elementResources.values())
+ {
+ resource.save(null);
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferElement.java b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferElement.java
index 1192904a9b..adb5cebcec 100644
--- a/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferElement.java
+++ b/plugins/org.eclipse.emf.cdo.transfer/src/org/eclipse/emf/cdo/transfer/CDOTransferElement.java
@@ -10,12 +10,13 @@
*/
package org.eclipse.emf.cdo.transfer;
+import org.eclipse.net4j.util.io.IORuntimeException;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import java.io.IOException;
import java.io.InputStream;
/**
@@ -164,7 +165,7 @@ public abstract class CDOTransferElement
{
if (isDirectory())
{
- throw new IOException("Not supported for directories");
+ throw new IORuntimeException("Not supported for directories");
}
}
}

Back to the top