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

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit a4b1716bba877e70af77e6af0311ae17dbcf89b1
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Sun Nov 17 11:39:59 2019 +0700

    [Refactoring] mailet-base DataContentHandlers are not used
---
 .../base/mail/AbstractDataContentHandler.java      | 125 -------------------
 .../base/mail/MessageDispositionNotification.java  | 133 ---------------------
 .../apache/mailet/base/mail/MultipartReport.java   |  72 -----------
 .../java/org/apache/mailet/base/mail/package.html  |  56 ---------
 4 files changed, 386 deletions(-)

diff --git 
a/mailet/base/src/main/java/org/apache/mailet/base/mail/AbstractDataContentHandler.java
 
b/mailet/base/src/main/java/org/apache/mailet/base/mail/AbstractDataContentHandler.java
deleted file mode 100644
index 16c7b5c..0000000
--- 
a/mailet/base/src/main/java/org/apache/mailet/base/mail/AbstractDataContentHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************
- * 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.mailet.base.mail;
-
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.UnsupportedFlavorException;
-import java.io.IOException;
-
-import javax.activation.ActivationDataFlavor;
-import javax.activation.DataContentHandler;
-import javax.activation.DataSource;
-import javax.mail.MessagingException;
-
-
-/**
- * Abstract class providing common Data Handler behavior.
- */
-public abstract class AbstractDataContentHandler implements DataContentHandler 
{
-
-    private ActivationDataFlavor fieldDataFlavor;
-
-    /**
-     * Default Constructor
-     */
-    public AbstractDataContentHandler() {
-        super();
-    }
-
-    /**
-     * Update the current DataFlavor.
-     * 
-     */    
-    protected void updateDataFlavor() {
-        setDataFlavor(computeDataFlavor());
-    }
-
-    /**
-     * Compute an ActivationDataFlavor.
-     * 
-     * @return A new ActivationDataFlavor
-     */
-    protected abstract ActivationDataFlavor computeDataFlavor();
-
-    protected void setDataFlavor(ActivationDataFlavor aDataFlavor) {
-        fieldDataFlavor = aDataFlavor;
-    }
-
-    @Override
-    public Object getContent(DataSource aDataSource) throws IOException {
-        Object content = null;
-        try {
-            content = computeContent(aDataSource);
-        } catch (MessagingException e) {
-            // No-op
-        }
-        return content;
-    }
-
-    /**
-     * Compute the content from aDataSource.
-     * 
-     * @param aDataSource
-     * @return new Content built from the DataSource
-     * @throws MessagingException
-     */
-    protected abstract Object computeContent(DataSource aDataSource)
-            throws MessagingException;
-
-    @Override
-    public Object getTransferData(DataFlavor aDataFlavor, DataSource 
aDataSource)
-            throws UnsupportedFlavorException, IOException {
-        Object content = null;
-        if (getDataFlavor().equals(aDataFlavor)) {
-            content = getContent(aDataSource);
-        }
-        return content;
-    }
-
-    @Override
-    public DataFlavor[] getTransferDataFlavors() {
-        return new DataFlavor[]{getDataFlavor()};
-    }
-
-    /**
-     * Get the DataFlavor, lazily initialised if required.
-     * 
-     * @return Returns the dataFlavor, lazily initialised.
-     */
-    protected ActivationDataFlavor getDataFlavor() {
-        ActivationDataFlavor dataFlavor;
-        if (null == (dataFlavor = getDataFlavorBasic())) {
-            updateDataFlavor();
-            return getDataFlavor();
-        }
-        return dataFlavor;
-    }
-
-    /**
-     * Get the DataFlavor.
-     * 
-     * @return Returns the dataFlavor.
-     */
-    private ActivationDataFlavor getDataFlavorBasic() {
-        return fieldDataFlavor;
-    }
-
-}
diff --git 
a/mailet/base/src/main/java/org/apache/mailet/base/mail/MessageDispositionNotification.java
 
b/mailet/base/src/main/java/org/apache/mailet/base/mail/MessageDispositionNotification.java
deleted file mode 100644
index 49177b3..0000000
--- 
a/mailet/base/src/main/java/org/apache/mailet/base/mail/MessageDispositionNotification.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************
- * 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.mailet.base.mail;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-
-import javax.activation.ActivationDataFlavor;
-import javax.activation.DataSource;
-import javax.mail.MessagingException;
-import javax.mail.internet.ContentType;
-import javax.mail.internet.MimeUtility;
-import javax.mail.internet.ParseException;
-
-/**
- * <p>Data Content Handler for...</p>
- * <dl>
- * <dt>MIME type name</dt><dd>message</dd>
- * <dt>MIME subtype name</dt><dd>disposition-notification</dd>
- * </dl>
- */
-public class MessageDispositionNotification extends AbstractDataContentHandler 
{
-
-    /**
-     * Default Constructor.
-     */
-    public MessageDispositionNotification() {
-        super();
-    }
-
-    @Override
-    protected ActivationDataFlavor computeDataFlavor() {
-        return new ActivationDataFlavor(String.class,
-                "message/disposition-notification", "Message String");
-    }
-
-    @Override
-    protected Object computeContent(DataSource aDataSource)
-            throws MessagingException {
-        String encoding = getCharacterSet(aDataSource.getContentType());
-        Reader reader = null;
-        Writer writer = new StringWriter(2048);
-        String content = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(aDataSource
-                    .getInputStream(), encoding), 2048);
-            while (reader.ready()) {
-                writer.write(reader.read());
-            }
-            writer.flush();
-            content = writer.toString();
-        } catch (IllegalArgumentException e) {
-            throw new MessagingException("Encoding = \"" + encoding + "\"", e);
-        } catch (IOException e) {
-            throw new MessagingException(
-                    "Exception obtaining content from DataSource", e);
-        } finally {
-            try {
-                writer.close();
-            } catch (IOException e1) {
-                // No-op
-            }
-            try {
-                if (reader != null) {
-                    reader.close();
-                }
-            } catch (IOException e1) {
-                // No-op
-            }
-        }
-        return content;
-    }
-
-    @Override
-    public void writeTo(Object aPart, String aMimeType, OutputStream aStream)
-            throws IOException {
-        if (!(aPart instanceof String)) {
-            throw new IOException("Type \"" + aPart.getClass().getName()
-                + "\" is not supported.");
-        }
-
-        String encoding = getCharacterSet(getDataFlavor().getMimeType());
-        Writer writer;
-        try {
-            writer = new BufferedWriter(new OutputStreamWriter(aStream,
-                    encoding), 2048);
-        } catch (IllegalArgumentException e) {
-            throw new UnsupportedEncodingException(encoding);
-        }
-        writer.write((String) aPart);
-        writer.flush();
-    }
-
-    protected String getCharacterSet(String aType) {
-        String characterSet = null;
-        try {
-            characterSet = new ContentType(aType).getParameter("charset");
-        } catch (ParseException e) {
-            // no-op
-        } finally {
-            if (null == characterSet) {
-                characterSet = "us-ascii";
-            }
-        }
-        return MimeUtility.javaCharset(characterSet);
-    }
-
-}
diff --git 
a/mailet/base/src/main/java/org/apache/mailet/base/mail/MultipartReport.java 
b/mailet/base/src/main/java/org/apache/mailet/base/mail/MultipartReport.java
deleted file mode 100644
index a65690d..0000000
--- a/mailet/base/src/main/java/org/apache/mailet/base/mail/MultipartReport.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************
- * 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.mailet.base.mail;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.activation.ActivationDataFlavor;
-import javax.activation.DataSource;
-import javax.mail.MessagingException;
-
-import org.apache.james.javax.MimeMultipartReport;
-
-
-/**
- * <p>Data Content Handler for...</p>
- * <dl>
- * <dt>MIME type name</dt><dd>multipart</dd>
- * <dt>MIME subtype name</dt><dd>report</dd>
- * </dl>
- */
-public class MultipartReport extends AbstractDataContentHandler {
-    /**
-     * Default constructor.
-     */
-    public MultipartReport() {
-        super();
-    }
-
-    @Override
-    protected ActivationDataFlavor computeDataFlavor() {
-        return new ActivationDataFlavor(MimeMultipartReport.class,
-                "multipart/report", "Multipart Report");
-    }
-
-    @Override
-    public void writeTo(Object aPart, String aMimeType, OutputStream aStream)
-            throws IOException {
-        if (!(aPart instanceof MimeMultipartReport)) {
-            throw new IOException("Type \"" + aPart.getClass().getName()
-                + "\" is not supported.");
-        }
-        try {
-            ((MimeMultipartReport) aPart).writeTo(aStream);
-        } catch (MessagingException e) {
-            throw new IOException(e.getMessage());
-        }
-    }
-
-    @Override
-    protected Object computeContent(DataSource aDataSource)
-            throws MessagingException {
-        return new MimeMultipartReport(aDataSource);
-    }
-}
diff --git a/mailet/base/src/main/java/org/apache/mailet/base/mail/package.html 
b/mailet/base/src/main/java/org/apache/mailet/base/mail/package.html
deleted file mode 100644
index 4bf22c5..0000000
--- a/mailet/base/src/main/java/org/apache/mailet/base/mail/package.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!--
-  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.    
--->
-<HTML>
-<HEAD>
-<!--
-
-  @(#)package.html
-
-  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.
-
--->
-
-</HEAD>
-<BODY>
-
-<p>This package and its sub-packages extend and provide utilities for use with
-<code>javax.mail</code>, its sub-packages and its implementations.
-</p>
-<p>The intent is to mirror the related package structures where possible.
-So, <code>org.apache.utils.mail</code> is a mirror of <code>javax.mail</code> 
and
-<code>org.apache.utils.mail.handlers</code> is a mirror of 
<code>com.sun.mail.handlers</code>.
-</p>
-</BODY>
-</HTML>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to