// Path: common/src/main/java/com/nortal/jroad/jaxb/ByteArrayDataSource.java
// public class ByteArrayDataSource implements DataSource {
//   private byte[] data;
//   private String contentType;
// 
//   public ByteArrayDataSource(String contentType, byte[] data) {
//     this.contentType = contentType;
//     this.data = data;
//   }
// 
//   public InputStream getInputStream() throws IOException {
//     return new ByteArrayInputStream(data);
//   }
// 
//   public OutputStream getOutputStream() throws IOException {
//     throw new UnsupportedOperationException();
//   }
// 
//   public String getContentType() {
//     return contentType;
//   }
// 
//   public String getName() {
//     return "ByteArrayDataSource";
//   }
// }


import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import org.springframework.core.io.InputStreamSource;
import org.springframework.util.FileCopyUtils;
import com.nortal.jroad.jaxb.ByteArrayDataSource;
/**
 * Copyright 2015 Nortal Licensed under the Apache License, Version 2.0 (the "License"); you may not use
 * this file except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and limitations under the
 * License.
 **/

package com.nortal.jroad.model;





/**
 * XTee messages are sometimes allowed to contain MIME attachments, which this class encapsulates. Each attachment has
 * MIME content-type, data (content) and unique ID. This class implements {@link InputStreamSource} for a nice fit into
 * Spring-WS and provides easy access to attachment content. Attachments are the preferred way of transporting large
 * amounts of data because transmitting attachments requires much less bandwidth and resources (base64 etc) than
 * transmitting the same data within SOAP messages without attachments.
 * 
 * @author Dmitri Danilkin
 */
public class XRoadAttachment implements InputStreamSource {
  private String cid;
  private DataHandler dataHandler;

  public XRoadAttachment(String cid, String contentType, byte[] data) {
    this.cid = cid;
// Path: common/src/main/java/com/nortal/jroad/jaxb/ByteArrayDataSource.java
// public class ByteArrayDataSource implements DataSource {
//   private byte[] data;
//   private String contentType;
// 
//   public ByteArrayDataSource(String contentType, byte[] data) {
//     this.contentType = contentType;
//     this.data = data;
//   }
// 
//   public InputStream getInputStream() throws IOException {
//     return new ByteArrayInputStream(data);
//   }
// 
//   public OutputStream getOutputStream() throws IOException {
//     throw new UnsupportedOperationException();
//   }
// 
//   public String getContentType() {
//     return contentType;
//   }
// 
//   public String getName() {
//     return "ByteArrayDataSource";
//   }
// }


// Path: common/src/main/java/com/nortal/jroad/model/XRoadAttachment.java
import java.io.IOException;
import java.io.InputStream;
import javax.activation.DataHandler;
import org.springframework.core.io.InputStreamSource;
import org.springframework.util.FileCopyUtils;
import com.nortal.jroad.jaxb.ByteArrayDataSource;

/**
 * Copyright 2015 Nortal Licensed under the Apache License, Version 2.0 (the "License"); you may not use
 * this file except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language governing permissions and limitations under the
 * License.
 **/

package com.nortal.jroad.model;





/**
 * XTee messages are sometimes allowed to contain MIME attachments, which this class encapsulates. Each attachment has
 * MIME content-type, data (content) and unique ID. This class implements {@link InputStreamSource} for a nice fit into
 * Spring-WS and provides easy access to attachment content. Attachments are the preferred way of transporting large
 * amounts of data because transmitting attachments requires much less bandwidth and resources (base64 etc) than
 * transmitting the same data within SOAP messages without attachments.
 * 
 * @author Dmitri Danilkin
 */
public class XRoadAttachment implements InputStreamSource {
  private String cid;
  private DataHandler dataHandler;

  public XRoadAttachment(String cid, String contentType, byte[] data) {
    this.cid = cid;
    this.dataHandler = new DataHandler(new ByteArrayDataSource(contentType, data));