Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-04-24 00:32:21 -0400
committerEike Stepper2018-04-24 00:32:21 -0400
commit5fe0848ec3ae550523f1204e11903f804adab999 (patch)
tree28ad30e17f77f2c0def65443a3b7d5f803d69f69
parent71558cffe67d4e4d42dd883d5f037d3d28102427 (diff)
downloadcdo-5fe0848ec3ae550523f1204e11903f804adab999.tar.gz
cdo-5fe0848ec3ae550523f1204e11903f804adab999.tar.xz
cdo-5fe0848ec3ae550523f1204e11903f804adab999.zip
[517391] [CDO] Exporter/Importer do not handle byte array attributes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=517391
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java44
3 files changed, 60 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
index 5ac6a618c3..491b8071a2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
@@ -349,6 +349,11 @@ public abstract class CDOServerExporter<OUT>
public static final String TYPE_CLOB = "Clob";
+ /**
+ * @since 4.7
+ */
+ public static final String TYPE_BYTE_ARRAY = "ByteArray";
+
public static final String TYPE_FEATURE_MAP = "FeatureMap";
public static final String LOBS = "lobs";
@@ -600,6 +605,12 @@ public abstract class CDOServerExporter<OUT>
out.attribute(FEATURE_INNER_FEATURE, innerFeature.getName());
exportFeature(out, innerFeature, FEATURE_INNER_TYPE, innerValue);
}
+ else if (value instanceof byte[])
+ {
+ byte[] array = (byte[])value;
+ out.attribute(featureType, TYPE_BYTE_ARRAY);
+ out.attribute(FEATURE_VALUE, HexUtil.bytesToHex(array));
+ }
else
{
if (!(value instanceof String))
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
index c971760930..832510fda9 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
@@ -740,6 +740,11 @@ public abstract class CDOServerImporter
return new BigInteger(str);
}
+ if (TYPE_BYTE_ARRAY.equals(type))
+ {
+ return HexUtil.hexToBytes(str);
+ }
+
throw new IllegalArgumentException("Invalid type: " + type);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
index d97d29b13e..25bdc07975 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
@@ -27,6 +27,7 @@ import org.eclipse.emf.cdo.tests.model3.Point;
import org.eclipse.emf.cdo.tests.model3.Polygon;
import org.eclipse.emf.cdo.tests.model5.Doctor;
import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
+import org.eclipse.emf.cdo.tests.model6.UnsettableAttributes;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
@@ -163,6 +164,24 @@ public class BackupTest extends AbstractCDOTest
exporter.exportRepository(baos);
}
+ public void testExportByteArray() throws Exception
+ {
+ UnsettableAttributes object = getModel6Factory().createUnsettableAttributes();
+ object.setAttrByteArray(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -128, 127 });
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(object);
+ transaction.commit();
+
+ InternalRepository repo1 = getRepository();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CDOServerExporter.XML exporter = new CDOServerExporter.XML(repo1);
+ exporter.exportRepository(baos);
+ }
+
public void testExportCustomDataType() throws Exception
{
CDOSession session = openSession();
@@ -381,6 +400,31 @@ public class BackupTest extends AbstractCDOTest
}
@CleanRepositoriesBefore(reason = "Inactive repository required")
+ public void testImportByteArray() throws Exception
+ {
+ UnsettableAttributes object = getModel6Factory().createUnsettableAttributes();
+ object.setAttrByteArray(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -128, 127 });
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(object);
+ transaction.commit();
+
+ InternalRepository repo1 = getRepository();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CDOServerExporter.XML exporter = new CDOServerExporter.XML(repo1);
+ exporter.exportRepository(baos);
+
+ InternalRepository repo2 = getRepository("repo2", false);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ CDOServerImporter.XML importer = new CDOServerImporter.XML(repo2);
+ importer.importRepository(bais);
+ }
+
+ @CleanRepositoriesBefore(reason = "Inactive repository required")
public void testImportCustomDataType() throws Exception
{
CDOSession session = openSession();

Back to the top