This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-email.git


The following commit(s) were added to refs/heads/master by this push:
     new 737f287  [EMAIL-207] Add org.apache.commons.mail.InputStreamDataSource
737f287 is described below

commit 737f287ad4872c5e4ceba526c1cf2650e0abe749
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Dec 10 15:10:36 2023 -0500

    [EMAIL-207] Add org.apache.commons.mail.InputStreamDataSource
---
 src/changes/changes.xml                            |  3 +-
 .../apache/commons/mail/InputStreamDataSource.java | 89 ++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c5f68f0..2d671f6 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -52,7 +52,8 @@
       <action type="add" due-to="Gary Gregory" dev="ggregory">
         Add Maven plugin JapiCmp and remove Clirr.
       </action>
-      <action issue="EMAIL-176" type="add" dev="pschumacher">Add 
Automatic-Module-Name MANIFEST entry for Java 9 compatibility</action>
+      <action issue="EMAIL-176" type="add" dev="pschumacher">Add 
Automatic-Module-Name MANIFEST entry for Java 9 compatibility.</action>
+      <action issue="EMAIL-207" type="add" dev="ggregory" due-to="Lee Jaeheon, 
Gary Gregory">Add org.apache.commons.mail.InputStreamDataSource.</action>
       <!-- UPDATE -->
       <action type="update" due-to="Dependabot, Gary Gregory" dev="ggregory">
         Bump actions/cache from 2 to 3.0.11 #39, #48, #60, #70, #102.
diff --git a/src/main/java/org/apache/commons/mail/InputStreamDataSource.java 
b/src/main/java/org/apache/commons/mail/InputStreamDataSource.java
new file mode 100644
index 0000000..5bfc002
--- /dev/null
+++ b/src/main/java/org/apache/commons/mail/InputStreamDataSource.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.commons.mail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.activation.DataSource;
+
+/**
+ * An Activation {@link DataSource} specialized for {@link InputStream}.
+ * <p>
+ * Copied from <a href="https://cxf.apache.org/";>Apache CXF</a> and modified.
+ * </p>
+ * @since 1.6.0
+ */
+public final class InputStreamDataSource implements DataSource {
+
+    private final String contentType;
+    private final InputStream inputStream;
+    private String name;
+
+    /**
+     * Constructs a new instance.
+     *
+     * @param inputStream An input stream.
+     * @param contentType A content type.
+     */
+    public InputStreamDataSource(final InputStream inputStream, final String 
contentType) {
+        this.inputStream = inputStream;
+        this.contentType = contentType;
+    }
+
+    /**
+     * Constructs a new instance.
+     *
+     * @param inputStream An input stream.
+     * @param contentType A content type.
+     * @param name A name.
+     */
+    public InputStreamDataSource(final InputStream inputStream, final String 
contentType, final String name) {
+        this.inputStream = inputStream;
+        this.contentType = contentType;
+        this.name = name;
+    }
+
+    @Override
+    public String getContentType() {
+        return contentType;
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return inputStream;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Always throws {@link UnsupportedOperationException}.
+     *
+     * @return Always throws {@link UnsupportedOperationException}.
+     * @throws UnsupportedOperationException Always throws {@link 
UnsupportedOperationException}.
+     */
+    @Override
+    public OutputStream getOutputStream() {
+        throw new UnsupportedOperationException();
+    }
+
+}
\ No newline at end of file

Reply via email to