/** * {@inheritDoc} */ public void deserialize(InputStream in, DigitalObject out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator .deserialize(in, out, format, encoding, transContext); }
/** * {@inheritDoc} */ public void serialize(DigitalObject in, OutputStream out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator.serialize(in, out, format, encoding, transContext); }
System.out.println("Deserializing..."); in = new FileInputStream(new File(args[0])); trans.deserialize(in, obj, args[1], ByteArrayOutputStream outStream = new ByteArrayOutputStream(); System.out.println("Re-serializing..."); trans.serialize(obj, outStream, args[1],
m_translator.serialize(obj, out, m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); m_translator.deserialize(serialized, new BasicDigitalObject(), m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL);
m_translator.serialize(obj, out, m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); m_translator.deserialize(serialized, new BasicDigitalObject(), m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL);
/** * {@inheritDoc} */ public void deserialize(InputStream in, DigitalObject out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator .deserialize(in, out, format, encoding, transContext); }
/** * {@inheritDoc} */ public void serialize(DigitalObject in, OutputStream out, String format, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_wrappedTranslator.serialize(in, out, format, encoding, transContext); }
public SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, String exportFormat, String storageFormat, String encoding, InputStream serializedObject) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_context = context; m_repoReader = repoReader; m_translator = translator; m_exportFormat = exportFormat; m_storageFormat = storageFormat; m_obj = new BasicDigitalObject(); m_translator.deserialize(serializedObject, m_obj, m_storageFormat, encoding, DOTranslationUtility.DESERIALIZE_INSTANCE); }
@Override public void write(OutputStream output) throws IOException, WebApplicationException { try { m_translator.serialize(m_object, output, m_exportFormat, m_encoding, m_transContext); } catch (ServerException e) { throw new WebApplicationException(e); } } }
public SimpleDOReader(Context context, RepositoryReader repoReader, DOTranslator translator, String exportFormat, String storageFormat, String encoding, InputStream serializedObject) throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { m_context = context; m_repoReader = repoReader; m_translator = translator; m_exportFormat = exportFormat; m_storageFormat = storageFormat; m_obj = new BasicDigitalObject(); m_translator.deserialize(serializedObject, m_obj, m_storageFormat, encoding, DOTranslationUtility.DESERIALIZE_INSTANCE); }
@Override public void write(OutputStream output) throws IOException, WebApplicationException { try { m_translator.serialize(m_object, output, m_exportFormat, m_encoding, m_transContext); } catch (ServerException e) { throw new WebApplicationException(e); } } }
private DigitalObject doDeserialize(String format) throws UnsupportedTranslationException { DigitalObject obj = new BasicDigitalObject(); try { InputStream in = getInputStream(format + "\n" + TEST_PID + "\n"); m_trans.deserialize(in, obj, format, "UTF-8", 0); return obj; } catch (UnsupportedTranslationException e) { throw e; } catch (Exception e) { e.printStackTrace(); throw new Error("Test failure: " + e.getClass().getName()); } }
/** * Return the object as an XML input stream in the internal serialization * format. */ @Override public InputStream GetObjectXML() throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); m_translator.serialize(m_obj, bytes, m_storageFormat, "UTF-8", DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); return bytes.toInputStream(); }
/** * Gets a writer on an existing object. */ @Override public DOWriter getWriter(boolean cachedObjectRequired, Context context, String pid) throws ServerException, ObjectLockedException { if (cachedObjectRequired) { throw new InvalidContextException( "A DOWriter is unavailable in a cached context."); } else { BasicDigitalObject obj = new BasicDigitalObject(); getWriteLock(pid); boolean clean = false; try { m_translator.deserialize(m_permanentStore.retrieveObject(pid), obj, m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.DESERIALIZE_INSTANCE); DOWriter w = new SimpleDOWriter(context, this, m_translator, m_defaultStorageFormat, m_storageCharacterEncoding, obj); clean = true; return w; } finally { if (!clean) { releaseWriteLock(pid); } } } }
/** * Return the object as an XML input stream in the internal serialization * format. */ @Override public InputStream GetObjectXML() throws ObjectIntegrityException, StreamIOException, UnsupportedTranslationException, ServerException { ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096); m_translator.serialize(m_obj, bytes, m_storageFormat, "UTF-8", DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL); return bytes.toInputStream(); }
/** * Gets a writer on an existing object. */ @Override public DOWriter getWriter(boolean cachedObjectRequired, Context context, String pid) throws ServerException, ObjectLockedException { if (cachedObjectRequired) { throw new InvalidContextException( "A DOWriter is unavailable in a cached context."); } else { BasicDigitalObject obj = new BasicDigitalObject(); getWriteLock(pid); boolean clean = false; try { m_translator.deserialize(m_permanentStore.retrieveObject(pid), obj, m_defaultStorageFormat, m_storageCharacterEncoding, DOTranslationUtility.DESERIALIZE_INSTANCE); DOWriter w = new SimpleDOWriter(context, this, m_translator, m_defaultStorageFormat, m_storageCharacterEncoding, obj); clean = true; return w; } finally { if (!clean) { releaseWriteLock(pid); } } } }
private String[] doSerialize(String format) throws UnsupportedTranslationException { DigitalObject obj = new BasicDigitalObject(); obj.setPid(TEST_PID); try { ByteArrayOutputStream out = new ByteArrayOutputStream(); m_trans.serialize(obj, out, format, "UTF-8", 0); String[] lines = new String(out.toByteArray(), "UTF-8").split("\n"); for (int i = 0; i < lines.length; i++) { lines[i] = lines[i].replaceAll("\r", ""); } return lines; } catch (UnsupportedTranslationException e) { throw e; } catch (Exception e) { e.printStackTrace(); throw new Error("Test failure: " + e.getClass().getName()); } }
obj.setNew(true); logger.debug("Deserializing from format: {}", format); m_translator.deserialize(new FileInputStream(tempFile), obj, format, encoding, DOTranslationUtility.DESERIALIZE_INSTANCE);
obj.setNew(true); logger.debug("Deserializing from format: {}", format); m_translator.deserialize(new FileInputStream(tempFile), obj, format, encoding, DOTranslationUtility.DESERIALIZE_INSTANCE);