001/* 002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Alexandre Russel 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.mail.service; 023 024import java.util.Map; 025 026import javax.mail.Address; 027import javax.mail.MessagingException; 028import javax.mail.Session; 029import javax.mail.Store; 030import javax.mail.Transport; 031 032import org.nuxeo.ecm.platform.mail.action.MailBoxActions; 033import org.nuxeo.ecm.platform.mail.action.MessageActionPipe; 034import org.nuxeo.ecm.platform.mail.fetcher.PropertiesFetcher; 035 036/** 037 * @author Alexandre Russel 038 */ 039public interface MailService { 040 041 /** 042 * Returns an actions pipe configured with this factory. 043 * <p> 044 * The actions will start from this folder. The context is be passed to the sessionFactory to be able to find the 045 * session. Use the default session if context is not used. 046 */ 047 MailBoxActions getMailBoxActions(String factoryName, String folderName) throws MessagingException; 048 049 MailBoxActions getMailBoxActions(String factoryName, String folderName, Map<String, Object> context) 050 throws MessagingException; 051 052 /** 053 * Gets the pipe of actions for given name 054 */ 055 MessageActionPipe getPipe(String name); 056 057 /** 058 * Sends a mail using the setting of this factory to this recipients. 059 * <p> 060 * The context is passed to the sessionFactory to be able to find the session. Use the default session if context is 061 * not used. This template is used, replacing variables with the ones from this variables. 062 */ 063 void sendMail(String text, String subject, String factory, Address[] recipients); 064 065 void sendMail(String text, String subject, String factory, Address[] recipients, Map<String, Object> context); 066 067 /** 068 * Returns a connected store for this factory. The store needs to be closed after use. 069 * 070 * @param name The name of the factory that provides the properties. 071 * @return the store. 072 */ 073 Store getConnectedStore(String name) throws MessagingException; 074 075 Store getConnectedStore(String name, Map<String, Object> context) throws MessagingException; 076 077 /** 078 * Returns a connected transport for this factory. The transport needs to be closed after use. 079 * 080 * @param name the name of the factory that provides the properties. 081 * @return the transport. 082 */ 083 Transport getConnectedTransport(String name) throws MessagingException; 084 085 Transport getConnectedTransport(String name, Map<String, Object> context) throws MessagingException; 086 087 /** 088 * Returns a session for this factory, using the context to find the session or the default if no context is 089 * provided. 090 */ 091 Session getSession(String name); 092 093 Session getSession(String name, Map<String, Object> context); 094 095 PropertiesFetcher getFetcher(String name); 096 097}