@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { return this.deserializer.deserialize(byteStream); } catch (Throwable ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
/** * Serializes the source object and returns the byte array result. */ @Override public byte[] convert(Object source) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024); try { this.serializer.serialize(source, byteStream); return byteStream.toByteArray(); } catch (Throwable ex) { throw new SerializationFailedException("Failed to serialize object using " + this.serializer.getClass().getSimpleName(), ex); } }
@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { return this.deserializer.deserialize(byteStream); } catch (Throwable ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
/** * Serializes the source object and returns the byte array result. */ @Override public byte[] convert(Object source) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024); try { this.serializer.serialize(source, byteStream); return byteStream.toByteArray(); } catch (Throwable ex) { throw new SerializationFailedException("Failed to serialize object using " + this.serializer.getClass().getSimpleName(), ex); } }
public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { return this.deserializer.deserialize(byteStream); } catch (Throwable ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
/** * Serializes the source object and returns the byte array result. */ public byte[] convert(Object source) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(128); try { this.serializer.serialize(source, byteStream); return byteStream.toByteArray(); } catch (Throwable ex) { throw new SerializationFailedException("Failed to serialize object using " + this.serializer.getClass().getSimpleName(), ex); } }
@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { if (this.usingDefaultDeserializer) { return deserialize(byteStream); } else { return this.deserializer.deserialize(byteStream); } } catch (Exception ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { return this.deserializer.deserialize(byteStream); } catch (Throwable ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { return this.deserializer.deserialize(byteStream); } catch (Throwable ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
/** * Serializes the source object and returns the byte array result. */ @Override public byte[] convert(Object source) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024); try { this.serializer.serialize(source, byteStream); return byteStream.toByteArray(); } catch (Throwable ex) { throw new SerializationFailedException("Failed to serialize object using " + this.serializer.getClass().getSimpleName(), ex); } }
/** * Serializes the source object and returns the byte array result. */ @Override public byte[] convert(Object source) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(1024); try { this.serializer.serialize(source, byteStream); return byteStream.toByteArray(); } catch (Throwable ex) { throw new SerializationFailedException("Failed to serialize object using " + this.serializer.getClass().getSimpleName(), ex); } }
@Override public Object convert(byte[] source) { ByteArrayInputStream byteStream = new ByteArrayInputStream(source); try { if (this.usingDefaultDeserializer) { return deserialize(byteStream); } else { return this.deserializer.deserialize(byteStream); } } catch (Exception ex) { throw new SerializationFailedException("Failed to deserialize payload. " + "Is the byte array a result of corresponding serialization for " + this.deserializer.getClass().getSimpleName() + "?", ex); } }
@RequestMapping(value = "/download", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void downloadHandler(HttpServletRequest request, HttpServletResponse response) throws IOException { ZOutputStream zOutput = new ZOutputStream(response.getOutputStream(), JZlib.Z_BEST_COMPRESSION); DataInputStream dataInput = new DataInputStream(request.getInputStream()); DataOutputStream dataOutput = new DataOutputStream(zOutput); try { readParameters(dataInput); byte action = readActionByte(dataInput); ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); if (action == ACTION_DOWNLOAD_STUDY_LIST) { handleDownloadStudies(byteStream); } else if (action == ACTION_DOWNLOAD_USERS_AND_FORMS) { handleDownloadUsersAndForms(byteStream, dataInput); } dataOutput.writeByte(RESPONSE_SUCCESS); dataOutput.write(byteStream.toByteArray()); log.info("successfully downloaded the xforms"); } catch (Exception e) { dataOutput.writeByte(RESPONSE_ERROR); throw new SerializationFailedException(FAILED_TO_SERIALIZE_DATA, e); } finally { dataOutput.close(); response.flushBuffer(); } }
log.error("Error in uploading form:", e); dataOutput.writeByte(RESPONSE_ERROR); throw new SerializationFailedException(FAILED_TO_SERIALIZE_DATA, e); } finally { dataOutput.close();