Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-992

Limit max line length for protocol when using Netty

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: None
    • Fix Version/s: 3.0-M1
    • Component/s: None
    • Labels:
      None

      Description

      We should limit the max characters per line so nobody can cause OOM when doing a DOS attach

        Issue Links

          Activity

          Hide
          norman Norman Maurer added a comment -

          We limit it to 8096 already. I overlooked this

          Show
          norman Norman Maurer added a comment - We limit it to 8096 already. I overlooked this
          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user vVv-AA opened a pull request:

          https://github.com/apache/james-project/pull/73

          JAMES-992 Added HasMimeType matcher and tests.

          Added HasMimeType matcher that will check if a given MimeMessage's content type is present in a possibility set.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/vVv-AA/james-project master

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/james-project/pull/73.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #73


          commit c34d83ba8c514589266903a018d9e17205682f00
          Author: Jasmin <jasmin.patel@bigbasket.com>
          Date: 2017-10-01T07:22:57Z

          Added HasMimeType matcher and tests.


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user vVv-AA opened a pull request: https://github.com/apache/james-project/pull/73 JAMES-992 Added HasMimeType matcher and tests. Added HasMimeType matcher that will check if a given MimeMessage's content type is present in a possibility set. You can merge this pull request into a Git repository by running: $ git pull https://github.com/vVv-AA/james-project master Alternatively you can review and apply these changes as the patch at: https://github.com/apache/james-project/pull/73.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #73 commit c34d83ba8c514589266903a018d9e17205682f00 Author: Jasmin <jasmin.patel@bigbasket.com> Date: 2017-10-01T07:22:57Z Added HasMimeType matcher and tests.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142032964

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          — End diff –

          Could you give in the javadoc a configuration examplefor this mailet?

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142032964 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> — End diff – Could you give in the javadoc a configuration examplefor this mailet?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033072

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          +
          + public void init() throws javax.mail.MessagingException

          { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          + try

          { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + }

          catch (MimeTypeParseException e) {
          + mimeType = null;
          — End diff –

          We should avoid swallowing exceptions. We should add a warning log here...

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033072 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; + + public void init() throws javax.mail.MessagingException { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + try { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + } catch (MimeTypeParseException e) { + mimeType = null; — End diff – We should avoid swallowing exceptions. We should add a warning log here...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142032975

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          — End diff –

          We enforce contentType

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142032975 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; — End diff – We enforce contentType
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033136

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          — End diff –

          We tend to start with the Apache license on the top of our files

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033136 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; — End diff – We tend to start with the Apache license on the top of our files
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033204

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          — End diff –

          We tend to put static imports above normal imports

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033204 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; — End diff – We tend to put static imports above normal imports
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033108

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          +
          + public void init() throws javax.mail.MessagingException

          { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          + try {
          — End diff –

          You can move the try/catch in getMimeTypeFrom message.

          It avoid mimeType double allocation in parallel branches.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033108 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; + + public void init() throws javax.mail.MessagingException { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + try { — End diff – You can move the try/catch in getMimeTypeFrom message. It avoid mimeType double allocation in parallel branches.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033024

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          +
          + public void init() throws javax.mail.MessagingException

          { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          + try

          { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + }

          catch (MimeTypeParseException e)

          { + mimeType = null; + }

          + return (content_types.contains(mimeType)) ? mail.getRecipients() : null;
          — End diff –

          A if here would be more readable...

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033024 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; + + public void init() throws javax.mail.MessagingException { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + try { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + } catch (MimeTypeParseException e) { + mimeType = null; + } + return (content_types.contains(mimeType)) ? mail.getRecipients() : null; — End diff – A if here would be more readable...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033017

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          +
          + public void init() throws javax.mail.MessagingException

          { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          + try

          { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + }

          catch (MimeTypeParseException e)

          { + mimeType = null; + }

          + return (content_types.contains(mimeType)) ? mail.getRecipients() : null;
          — End diff –

          We should avoid returning null. An empty list is better

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033017 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; + + public void init() throws javax.mail.MessagingException { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,\\s*")); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + try { + mimeType = getMimeTypeFromMessage(mail.getMessage()); + } catch (MimeTypeParseException e) { + mimeType = null; + } + return (content_types.contains(mimeType)) ? mail.getRecipients() : null; — End diff – We should avoid returning null. An empty list is better
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033179

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          +
          +public class HasMimeTypeTest {
          +
          + private HasMimeType matcher;
          + private final String RECIPIENT = "test@james.apache.org";
          + private final String FROM = "test@james.apache.org";
          + private final String MIME_TYPES = "multipart/mixed";
          + private MimeMessage message;
          + private FakeMail mail;
          +
          + @Before
          + public void setUp() throws Exception

          { + matcher = new HasMimeType(); + message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + }

          +
          + @Test
          + public void hasMimeType() throws Exception

          { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(MIME_TYPES) + .build()); + assertNotNull(matcher.match(mail)); + }

          +
          — End diff –

          You miss one test on a non matching case.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033179 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; + +public class HasMimeTypeTest { + + private HasMimeType matcher; + private final String RECIPIENT = "test@james.apache.org"; + private final String FROM = "test@james.apache.org"; + private final String MIME_TYPES = "multipart/mixed"; + private MimeMessage message; + private FakeMail mail; + + @Before + public void setUp() throws Exception { + matcher = new HasMimeType(); + message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + } + + @Test + public void hasMimeType() throws Exception { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(MIME_TYPES) + .build()); + assertNotNull(matcher.match(mail)); + } + — End diff – You miss one test on a non matching case.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033168

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          +
          +public class HasMimeTypeTest {
          +
          + private HasMimeType matcher;
          + private final String RECIPIENT = "test@james.apache.org";
          + private final String FROM = "test@james.apache.org";
          + private final String MIME_TYPES = "multipart/mixed";
          + private MimeMessage message;
          + private FakeMail mail;
          +
          + @Before
          + public void setUp() throws Exception

          { + matcher = new HasMimeType(); + message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + }

          +
          + @Test
          + public void hasMimeType() throws Exception {
          + matcher.init(FakeMatcherConfig.builder()
          + .matcherName("HasMimeType")
          + .condition(MIME_TYPES)
          + .build());
          + assertNotNull(matcher.match(mail));
          — End diff –

          Can we be more explicit than is not null? It sould contain the list of recipients.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033168 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; + +public class HasMimeTypeTest { + + private HasMimeType matcher; + private final String RECIPIENT = "test@james.apache.org"; + private final String FROM = "test@james.apache.org"; + private final String MIME_TYPES = "multipart/mixed"; + private MimeMessage message; + private FakeMail mail; + + @Before + public void setUp() throws Exception { + matcher = new HasMimeType(); + message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + } + + @Test + public void hasMimeType() throws Exception { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(MIME_TYPES) + .build()); + assertNotNull(matcher.match(mail)); — End diff – Can we be more explicit than is not null? It sould contain the list of recipients.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033190

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          +
          +public class HasMimeTypeTest {
          +
          + private HasMimeType matcher;
          + private final String RECIPIENT = "test@james.apache.org";
          + private final String FROM = "test@james.apache.org";
          + private final String MIME_TYPES = "multipart/mixed";
          — End diff –

          It's more MIME_TYPE

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033190 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; + +public class HasMimeTypeTest { + + private HasMimeType matcher; + private final String RECIPIENT = "test@james.apache.org"; + private final String FROM = "test@james.apache.org"; + private final String MIME_TYPES = "multipart/mixed"; — End diff – It's more MIME_TYPE
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142032994

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,61 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +
          +import java.util.*;
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private Set<String> content_types;
          +
          + public void init() throws javax.mail.MessagingException {
          + content_types = ImmutableSet.copyOf(getCondition().split("\\s*,
          s*"));
          — End diff –

          You can have a look to the excellent guava's Splitter for this.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142032994 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,61 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; + +import java.util.*; + +/** + * <p>This matcher checks if the content type matches.</p> + */ +public class HasMimeType extends GenericMatcher { + + private Set<String> content_types; + + public void init() throws javax.mail.MessagingException { + content_types = ImmutableSet.copyOf(getCondition().split("\\s*, s*")); — End diff – You can have a look to the excellent guava's Splitter for this.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142033152

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          +
          +public class HasMimeTypeTest {
          +
          + private HasMimeType matcher;
          + private final String RECIPIENT = "test@james.apache.org";
          — End diff –

          You can add the static modifier here for these constants.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142033152 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; + +public class HasMimeTypeTest { + + private HasMimeType matcher; + private final String RECIPIENT = "test@james.apache.org"; — End diff – You can add the static modifier here for these constants.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142057705

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,60 @@
          +package org.apache.james.transport.matchers;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.internet.MimeMessage;
          +
          +import static org.junit.Assert.assertNotNull;
          +
          +public class HasMimeTypeTest {
          +
          + private HasMimeType matcher;
          + private final String RECIPIENT = "test@james.apache.org";
          + private final String FROM = "test@james.apache.org";
          + private final String MIME_TYPES = "multipart/mixed";
          — End diff –

          You can specify multiple mime types in MIME_TYPES.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142057705 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,60 @@ +package org.apache.james.transport.matchers; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.internet.MimeMessage; + +import static org.junit.Assert.assertNotNull; + +public class HasMimeTypeTest { + + private HasMimeType matcher; + private final String RECIPIENT = "test@james.apache.org"; + private final String FROM = "test@james.apache.org"; + private final String MIME_TYPES = "multipart/mixed"; — End diff – You can specify multiple mime types in MIME_TYPES.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA commented on the issue:

          https://github.com/apache/james-project/pull/73

          @chibenwa Updated.

          I did a soft reset before pushing and its screwed up your review comments. Did not know that would happen. Sorry.

          Also, I kept MIME_TYPES as the variable name because it can contain multiple mime types as is the case with NON_MATCHING_MIME_TYPES if that is fine with you.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on the issue: https://github.com/apache/james-project/pull/73 @chibenwa Updated. I did a soft reset before pushing and its screwed up your review comments. Did not know that would happen. Sorry. Also, I kept MIME_TYPES as the variable name because it can contain multiple mime types as is the case with NON_MATCHING_MIME_TYPES if that is fine with you.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on the issue:

          https://github.com/apache/james-project/pull/73

          No problem, the PR is short. I can do another review pass on it?

          Ok, your explanation convince me for MIME_TYPES

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on the issue: https://github.com/apache/james-project/pull/73 No problem, the PR is short. I can do another review pass on it? Ok, your explanation convince me for MIME_TYPES
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062386

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException

          { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          — End diff –

          You can do :

          ```
          Strin mimeType = getMimeTypeFromMessage(...);
          ```

          Directly....

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062386 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; — End diff – You can do : ``` Strin mimeType = getMimeTypeFromMessage(...); ``` Directly....
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062712

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException

          { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException

          { + String mimeType; + mimeType = getMimeTypeFromMessage(mail.getMessage()); + if (contentType.contains(mimeType)) + return mail.getRecipients(); + else + return Collections.emptyList(); + }

          +
          + private static String getMimeTypeFromMessage(MimeMessage message) throws MessagingException {
          + try

          { + return new MimeType(message.getContentType()).getBaseType(); + }

          catch (MimeTypeParseException e) {
          + LOGGER.warn(e.toString());
          + return "";
          — End diff –

          If we return nothing, that has to be explicit on the type.

          The way we handle this in a clean way is using java Optional.

          You can then:

          • Modify the mimeType of this method to return Optional<String>
          • When returning something, return Optional.of(something)
          • When we encouter the error, we can then return Optional.empty()
          • Finally in *match* methods, we can handle the if resoluion in a functional manner using filter and orElse (that might replace the if block)
          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062712 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + mimeType = getMimeTypeFromMessage(mail.getMessage()); + if (contentType.contains(mimeType)) + return mail.getRecipients(); + else + return Collections.emptyList(); + } + + private static String getMimeTypeFromMessage(MimeMessage message) throws MessagingException { + try { + return new MimeType(message.getContentType()).getBaseType(); + } catch (MimeTypeParseException e) { + LOGGER.warn(e.toString()); + return ""; — End diff – If we return nothing, that has to be explicit on the type. The way we handle this in a clean way is using java Optional. You can then: Modify the mimeType of this method to return Optional<String> When returning something, return Optional.of(something) When we encouter the error, we can then return Optional.empty() Finally in * match * methods, we can handle the if resoluion in a functional manner using filter and orElse (that might replace the if block)
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062325

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException {
          + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,
          s*").split(getCondition()));
          — End diff –

          Also what happens if I got:

          ```
          text/plain, text/html
          ```

          As a condition? Could we trimm the results? (Splitter have an option for that...)

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062325 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*, s*").split(getCondition())); — End diff – Also what happens if I got: ``` text/plain, text/html ``` As a condition? Could we trimm the results? (Splitter have an option for that...)
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062473

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException

          { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException {
          + String mimeType;
          + mimeType = getMimeTypeFromMessage(mail.getMessage());
          + if (contentType.contains(mimeType))
          — End diff –

          We use to always put blocks ^^

          ```
          if

          { //... } else { //... }

          ```

          Sorry for being picky...

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062473 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,\\s*").split(getCondition())); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + String mimeType; + mimeType = getMimeTypeFromMessage(mail.getMessage()); + if (contentType.contains(mimeType)) — End diff – We use to always put blocks ^^ ``` if { //... } else { //... } ``` Sorry for being picky...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062789

          — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java —
          @@ -0,0 +1,93 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import static org.assertj.core.api.Assertions.assertThat;
          +import static org.junit.Assert.assertEquals;
          +
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.base.test.FakeMail;
          +import org.apache.mailet.base.test.FakeMatcherConfig;
          +import org.apache.mailet.base.test.MimeMessageBuilder;
          +import org.junit.Before;
          +import org.junit.Test;
          +
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collections;
          +
          +public class HasMimeTypeTest {
          +
          + private static final String RECIPIENT = "test@james.apache.org";
          + private static final String FROM = "test@james.apache.org";
          + private static final String MIME_TYPES = "multipart/mixed";
          + private static final String NON_MATCHING_MIME_TYPES = "text/plain, application/zip";
          +
          + private HasMimeType matcher;
          + private FakeMail mail;
          +
          + @Before
          + public void setUp() throws Exception

          { + matcher = new HasMimeType(); + MimeMessage message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + }

          +
          + @Test
          + public void hasMimeType() throws MessagingException

          { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(MIME_TYPES) + .build()); + + assertThat(matcher.match(mail)).containsAll(mail.getRecipients()); + }

          +
          + @Test
          + public void doesNotHaveMimeType() throws MessagingException{
          + matcher.init(FakeMatcherConfig.builder()
          + .matcherName("HasMimeType")
          + .condition(NON_MATCHING_MIME_TYPES)
          + .build());
          +
          + assertEquals(matcher.match(mail), Collections.emptyList());
          — End diff –

          You can do this one also with assertJ :

          ```
          assertThat(matcher.match(mail)).isEmpty();
          ```

          Then you might simplify imports.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062789 — Diff: mailet/standard/src/test/java/org/apache/james/transport/matchers/HasMimeTypeTest.java — @@ -0,0 +1,93 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +import org.apache.james.core.MailAddress; +import org.apache.mailet.base.test.FakeMail; +import org.apache.mailet.base.test.FakeMatcherConfig; +import org.apache.mailet.base.test.MimeMessageBuilder; +import org.junit.Before; +import org.junit.Test; + +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collections; + +public class HasMimeTypeTest { + + private static final String RECIPIENT = "test@james.apache.org"; + private static final String FROM = "test@james.apache.org"; + private static final String MIME_TYPES = "multipart/mixed"; + private static final String NON_MATCHING_MIME_TYPES = "text/plain, application/zip"; + + private HasMimeType matcher; + private FakeMail mail; + + @Before + public void setUp() throws Exception { + matcher = new HasMimeType(); + MimeMessage message = MimeMessageBuilder.mimeMessageBuilder() + .setMultipartWithBodyParts( + MimeMessageBuilder.bodyPartBuilder() + .data("simple text") + .disposition("text") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .filename("text_file.txt") + .disposition("attachment") + .build(), + MimeMessageBuilder.bodyPartBuilder() + .type("application/zip") + .filename("zip_file.zip") + .disposition("attachment") + .build()) + .setSubject("test") + .build(); + + mail = FakeMail.builder() + .mimeMessage(message) + .sender(new MailAddress(FROM)) + .recipient(new MailAddress(RECIPIENT)) + .build(); + } + + @Test + public void hasMimeType() throws MessagingException { + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(MIME_TYPES) + .build()); + + assertThat(matcher.match(mail)).containsAll(mail.getRecipients()); + } + + @Test + public void doesNotHaveMimeType() throws MessagingException{ + matcher.init(FakeMatcherConfig.builder() + .matcherName("HasMimeType") + .condition(NON_MATCHING_MIME_TYPES) + .build()); + + assertEquals(matcher.match(mail), Collections.emptyList()); — End diff – You can do this one also with assertJ : ``` assertThat(matcher.match(mail)).isEmpty(); ``` Then you might simplify imports.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142062265

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException {
          + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,
          s*").split(getCondition()));
          — End diff –

          Actually, we do believe regex are counter intuitive.

          Maybe:

          ```
          Splitter.on(',').split(...)
          ```

          Is more explicit.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142062265 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*, s*").split(getCondition())); — End diff – Actually, we do believe regex are counter intuitive. Maybe: ``` Splitter.on(',').split(...) ``` Is more explicit.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on the issue:

          https://github.com/apache/james-project/pull/73

          By the way, you might add the Hacktaberfest label on this PR, no?

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on the issue: https://github.com/apache/james-project/pull/73 By the way, you might add the Hacktaberfest label on this PR, no?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142063391

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Collections;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          +
          + public void init() throws javax.mail.MessagingException {
          + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*,
          s*").split(getCondition()));
          — End diff –

          The regex was to pre-trim to handle cases like text/plain, text/html. I'll replace regex.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142063391 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; + + public void init() throws javax.mail.MessagingException { + contentType = ImmutableSet.copyOf(Splitter.onPattern("\\s*, s*").split(getCondition())); — End diff – The regex was to pre-trim to handle cases like text/plain, text/html. I'll replace regex.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142105362

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableList;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Optional;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> contentType;
          — End diff –

          Shouldn't the name of the variable be "acceptedContentTypes" ? This would be more descriptive.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142105362 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Optional; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> contentType; — End diff – Shouldn't the name of the variable be "acceptedContentTypes" ? This would be more descriptive.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA commented on the issue:

          https://github.com/apache/james-project/pull/73

          @chibenwa Done.

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on the issue: https://github.com/apache/james-project/pull/73 @chibenwa Done.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on a diff in the pull request:

          https://github.com/apache/james-project/pull/73#discussion_r142121913

          — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java —
          @@ -0,0 +1,74 @@
          +/****************************************************************
          + * 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.james.transport.matchers;
          +
          +import com.google.common.base.Splitter;
          +import com.google.common.collect.ImmutableList;
          +import com.google.common.collect.ImmutableSet;
          +import org.apache.james.core.MailAddress;
          +import org.apache.mailet.Mail;
          +import org.apache.mailet.base.GenericMatcher;
          +import org.slf4j.Logger;
          +import org.slf4j.LoggerFactory;
          +
          +import javax.activation.MimeType;
          +import javax.activation.MimeTypeParseException;
          +import javax.mail.MessagingException;
          +import javax.mail.internet.MimeMessage;
          +import java.util.Collection;
          +import java.util.Optional;
          +import java.util.Set;
          +
          +
          +/**
          + * <p>This matcher checks if the content type matches.</p>
          + *
          + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre>
          + */
          +public class HasMimeType extends GenericMatcher {
          +
          + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class);
          +
          + private Set<String> acceptedContentTypes;
          +
          + public void init() throws javax.mail.MessagingException

          { + acceptedContentTypes = ImmutableSet.copyOf(Splitter.on(",").trimResults().split(getCondition())); + }

          +
          + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException

          { + Optional<String> mimeTypes = getMimeTypeFromMessage(mail.getMessage()); + + return mimeTypes.filter(acceptedContentTypes::contains) + .map(any -> mail.getRecipients()) + .orElse(ImmutableList.of()); + }

          +
          + private static Optional<String> getMimeTypeFromMessage(MimeMessage message) throws MessagingException {
          + try

          { + return Optional.of(new MimeType(message.getContentType()).getBaseType()); + }

          catch (MimeTypeParseException e) {
          + LOGGER.warn(e.toString());
          — End diff –

          Ah, I missed this one.

          My big concern here is that "we loose the stacktrace", which makes understanding and categorizing possible errors harder.

          We should add an error message explaining what's happening ("Error while checking message mimeType") and pass the exception as a second argument.

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on a diff in the pull request: https://github.com/apache/james-project/pull/73#discussion_r142121913 — Diff: mailet/standard/src/main/java/org/apache/james/transport/matchers/HasMimeType.java — @@ -0,0 +1,74 @@ +/**************************************************************** + * 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.james.transport.matchers; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import org.apache.james.core.MailAddress; +import org.apache.mailet.Mail; +import org.apache.mailet.base.GenericMatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.activation.MimeType; +import javax.activation.MimeTypeParseException; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.Collection; +import java.util.Optional; +import java.util.Set; + + +/** + * <p>This matcher checks if the content type matches.</p> + * + * use: <pre><code><mailet match="HasMimeType=text/plain,text/html" class="..." /></code></pre> + */ +public class HasMimeType extends GenericMatcher { + + private static final Logger LOGGER = LoggerFactory.getLogger(HasHabeasWarrantMark.class); + + private Set<String> acceptedContentTypes; + + public void init() throws javax.mail.MessagingException { + acceptedContentTypes = ImmutableSet.copyOf(Splitter.on(",").trimResults().split(getCondition())); + } + + public Collection<MailAddress> match(Mail mail) throws javax.mail.MessagingException { + Optional<String> mimeTypes = getMimeTypeFromMessage(mail.getMessage()); + + return mimeTypes.filter(acceptedContentTypes::contains) + .map(any -> mail.getRecipients()) + .orElse(ImmutableList.of()); + } + + private static Optional<String> getMimeTypeFromMessage(MimeMessage message) throws MessagingException { + try { + return Optional.of(new MimeType(message.getContentType()).getBaseType()); + } catch (MimeTypeParseException e) { + LOGGER.warn(e.toString()); — End diff – Ah, I missed this one. My big concern here is that "we loose the stacktrace", which makes understanding and categorizing possible errors harder. We should add an error message explaining what's happening ("Error while checking message mimeType") and pass the exception as a second argument.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user chibenwa commented on the issue:

          https://github.com/apache/james-project/pull/73

          Thanks @vVv-AA for your great work and this added bonus matcher!

          I scheduled a build on your PR in https://github.com/linagora/james-project/pull/1005 . We might have further review pass on it, but I will handle it.

          If you are looking forward more Hacktoberfest contributions, I let you have look at some other Hacktoberfest related issues.

          Especially https://github.com/linagora/james-project/issues/993 will allow you to discover the James Command Line client, and would ease Sieve scripts deployment. Also in this issue, a good part of the wiring is already done. Hence the functionality should not be too hard to implement.

          Appart the Hacktober fest, the James community is actively looking for new contributors (be it communication, articles, blogpost, documentation, code, packaging, or anything else.). I let you check the James website (http://james.apache.org/#second).

          Show
          githubbot ASF GitHub Bot added a comment - Github user chibenwa commented on the issue: https://github.com/apache/james-project/pull/73 Thanks @vVv-AA for your great work and this added bonus matcher! I scheduled a build on your PR in https://github.com/linagora/james-project/pull/1005 . We might have further review pass on it, but I will handle it. If you are looking forward more Hacktoberfest contributions, I let you have look at some other Hacktoberfest related issues. Especially https://github.com/linagora/james-project/issues/993 will allow you to discover the James Command Line client, and would ease Sieve scripts deployment. Also in this issue, a good part of the wiring is already done. Hence the functionality should not be too hard to implement. Appart the Hacktober fest, the James community is actively looking for new contributors (be it communication, articles, blogpost, documentation, code, packaging, or anything else.). I let you check the James website ( http://james.apache.org/#second ).
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA commented on the issue:

          https://github.com/apache/james-project/pull/73

          Thanks @chibenwa
          I will check out linagora#993(https://github.com/linagora/james-project/issues/993)

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on the issue: https://github.com/apache/james-project/pull/73 Thanks @chibenwa I will check out linagora#993 ( https://github.com/linagora/james-project/issues/993 )
          Hide
          githubbot ASF GitHub Bot added a comment -
          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA commented on the issue: https://github.com/apache/james-project/pull/73 Merged as https://github.com/linagora/james-project/pull/1005 . Closing.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user vVv-AA closed the pull request at:

          https://github.com/apache/james-project/pull/73

          Show
          githubbot ASF GitHub Bot added a comment - Github user vVv-AA closed the pull request at: https://github.com/apache/james-project/pull/73

            People

            • Assignee:
              Unassigned
              Reporter:
              norman Norman Maurer
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development