001 /*
002 * Copyright (c) 2009 The openGion Project.
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,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.hayabusa.taglib;
017
018 import org.opengion.hayabusa.common.HybsSystem;
019 import org.opengion.hayabusa.common.HybsSystemException;
020 import org.opengion.hayabusa.resource.LDAPSearch;
021 import org.opengion.fukurou.db.DBUtil;
022 import org.opengion.fukurou.mail.MailTX;
023 import org.opengion.fukurou.util.StringUtil;
024 import org.opengion.hayabusa.mail.AbstractMailManager;
025 import org.opengion.hayabusa.mail.MailPattern;
026
027 import static org.opengion.fukurou.util.StringUtil.nval ;
028
029 import java.util.List;
030 import java.io.ObjectOutputStream;
031 import java.io.ObjectInputStream;
032 import java.io.IOException;
033
034 /**
035 * メールをé?ä¿¡ã™ã‚‹ãŸã‚ã®ç°¡æ˜“ã‚¿ã‚°ã§ã™ã?
036 *
037 * Body 部ã«ã€ãƒ¡ãƒ?‚»ãƒ¼ã‚¸ã‚’記述ã—ã¾ã™ã?
038 *
039 * @og.formSample
040 * â—å½¢å¼ï¼?lt;og:mailSender from="…" to="…" subject="?¥?¥?¥"/>
041 * â—body?šã‚ã‚?EVAL_BODY_BUFFERED:BODYを評価ã—ã?{@XXXX} ã‚’è§£æžã—ã¾ã?
042 *
043 * â—Tag定義??
044 * <og:mailSender
045 * subject ã€TAG】タイトルを指定ã—ã¾ã?
046 * from ã€TAG】é?ä¿¡å…??¦?²?¯?)アドレスを指定ã—ã¾ã?
047 * to ã€TAG】é?ä¿¡å…??´?¯)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã?
048 * cc ã€TAG】é?ä¿¡å…??£?£)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã?
049 * bcc ã€TAG】é?ä¿¡å…??¢?£?£)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã?
050 * replyTo ã€TAG】返信å…?replyTo)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã?
051 * host ã€TAG】メールサーãƒã?を指定ã—ã¾ã?(åˆæœŸå€¤:COMMON_MAIL_SERVER[=])
052 * charset ã€TAG】文å—エンコーãƒ?‚£ãƒ³ã‚°ã‚’指定ã—ã¾ã?(åˆæœŸå€¤:MAIL_DEFAULT_CHARSET[=ISO-2022-JP])
053 * fileURL ã€TAG】添付ファイルã®ã‚»ãƒ¼ãƒ–ディレクトリを指定ã—ã¾ã?(åˆæœŸå€¤:FILE_URL[=filetemp/])
054 * filename ã€TAG】添付ファイルåã‚’CSVå½¢å¼ã§æŒ?®šã—ã¾ã?
055 * useLDAP ã€TAG】メールアドレスをLDAPを利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)
056 * ldapKey ã€TAG】アドレスを検索ã™ã‚‹ã‚ーを指定ã—ã¾ã?åˆæœŸå€¤:LDAP_MAILSEND_KEY[=uid] C社員番å·)
057 * ldapVals ã€TAG】LDAP検索時ã?属æ?åã‚’æŒ?®šã—ã¾ã?åˆæœŸå€¤:LDAP_MAILSEND_VALS[=cn,mail])
058 * debug ã€TAG】デãƒãƒƒã‚°æƒ??ã‚’å?力ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)
059 * > ... Body ...
060 * </og:mailSender>
061 *
062 * â—使用ä¾?
063 * <og:mailSender from="C00000" to="C99999" subject="{@SUBJECT}" >
064 * メールå†?®¹
065 * </og:mailSender >
066 *
067 * charset = ã‚ャラクタセãƒ?ƒˆ (例:Windows-31J , ISO-2022-JP)
068 * from = From é€ä¿¡å…?
069 * to = To é€ä¿¡å…?è¤?•°ç™»éŒ²å¯èƒ½)
070 * cc = Cc é€ä¿¡å…?è¤?•°ç™»éŒ²å¯èƒ½)
071 * bcc = Bcc é€ä¿¡å…?è¤?•°ç™»éŒ²å¯èƒ½)
072 * replyTo = ReplyTo 返信先å?(è¤?•°ç™»éŒ²å¯èƒ½)
073 * useLDAP = false/true メールアドレスをLDAPを利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹
074 * ldapKey = "uid" アドレスを検索ã™ã‚‹ã‚ー(åˆæœŸå€¤:シスãƒ?ƒ リソース C社員番å·)
075 * ldapVals = "cn,mail" LDAP検索時ã?属æ?åã?ã²ã¨ã¤ãªã‚‰ã‚¢ãƒ‰ãƒ¬ã‚¹ã€‚ï¼’ã¤ãªã‚‰åå‰ã¨ã‚¢ãƒ‰ãƒ¬ã‚¹
076 * host = ?³??´?°ã‚µãƒ¼ãƒã?å?
077 * subject = タイトル
078 * fileURL = 添付ファイルã®ã‚»ãƒ¼ãƒ–ディレクトリ
079 * filename = 添付ファイルå?ãƒãƒ¼ã‚«ãƒ«ã«ã‚»ãƒ¼ãƒ–ã•れãŸãƒ•ァイルå?(è¤?•°ç™»éŒ²å¯èƒ½)
080 * debug = true/false;
081 *
082 * è¤?•°ç™»éŒ²å¯èƒ½ãªå€‹æ‰€ã¯ã€ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã§ã€è¤?•°ç™»éŒ²ã§ãã¾ã™ã?
083 * アドレス(from,to,cc,bcc,replyTo)ã¯ã€ã?"åç§°" <メールアドレス>ã€å½¢å¼ãŒ
084 * æŒ?®šã§ãã¾ã™ã?< 㨠> ã§å›²ã¾ã‚ŒãŸç¯?›²ãŒãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã«ãªã‚Šã¾ã™ã?
085 * åç§°ã«ã¯ã€æ¼¢å—ãŒä½¿ç”¨ã§ãã¾ã™ã?
086 *
087 * host ã¯ã€ã‚·ã‚¹ãƒ?ƒ パラメータ ã® COMMON_MAIL_SERVER 属æ?ãŒå?期å?ã§è¨å®šã•れã¾ã™ã?
088 * charset ã¯ã€ã‚·ã‚¹ãƒ?ƒ パラメータ ã® MAIL_DEFAULT_CHARSET 属æ?ãŒå?期å?ã§è¨å®šã•れã¾ã™ã?
089 *
090 * @og.group ãã?ä»–å?åŠ?
091 *
092 * @version 4.0
093 * @author Kazuhiko Hasegawa
094 * @since JDK5.0,
095 */
096 public class MailSenderTag extends CommonTagSupport {
097 //* ã“ã?プãƒã‚°ãƒ©ãƒ??VERSIONæ–?—å?ã‚’è¨å®šã—ã¾ã™ã? {@value} */
098 private static final String VERSION = "5.6.9.3 (2013/10/25)" ;
099
100 private static final long serialVersionUID = 569320131025L ;
101
102 private transient MailTX mail = null;
103 private String host = HybsSystem.sys( "COMMON_MAIL_SERVER" );
104 private String charset = HybsSystem.sys( "MAIL_DEFAULT_CHARSET" ); // 3.5.6.6 (2004/08/23)
105 private String from = null;
106 private String[] to = null;
107 private String[] cc = null;
108 private String[] bcc = null;
109 private String[] replyTo = null;
110 private String subject = null;
111 private String[] filename = null;
112 private String fileURL = HybsSystem.sys( "FILE_URL" );
113
114 private boolean useLDAP = false; // 3.7.1.0 (2005/04/15)
115 // uid Cç¤¾å“¡ç•ªå· ã€employeeNumber 社員番å·
116 // private String ldapKey = "uid"; // 3.7.1.0 (2005/04/26)
117 // private String ldapVals= "cn,mail"; // 3.7.1.0 (2005/04/15)
118 private String ldapKey = HybsSystem.sys( "LDAP_MAILSEND_KEY" ); // 5.6.7.0 (2013/07/27)
119 private String ldapVals= HybsSystem.sys( "LDAP_MAILSEND_VALS" ); // 5.6.7.0 (2013/07/27)
120
121 private boolean useDB = false; // 5.6.9.3 (2013/10/25) GE35ã‹ã‚‰ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾?
122 private final String DBID = HybsSystem.sys( "RESOURCE_DBID" );
123
124 /**
125 * Taglibã®é–‹å§‹ã‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doStartTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
126 *
127 * @return 後続å?ç??æŒ?¤º( EVAL_BODY_BUFFERED )
128 */
129 @Override
130 public int doStartTag() {
131 mail = new MailTX( host,charset );
132 return( EVAL_BODY_BUFFERED ); // Body を評価ã™ã‚‹ã€? extends BodyTagSupport æ™?
133 }
134
135 /**
136 * Taglibã®ã‚¿ã‚°æœ¬ä½“を処ç?™ã‚?doAfterBody() ã‚?オーãƒã?ライドã—ã¾ã™ã?
137 *
138 * @og.rev 3.1.1.0 (2003/03/28) ボディã®å†?®¹ã‚’å–å¾—ã™ã‚‹å?ç?‚’ã€CommonTagSupport ã§è¡Œã†ã€?
139 *
140 * @return 後続å?ç??æŒ?¤º(SKIP_BODY)
141 */
142 @Override
143 public int doAfterBody() {
144 String message = getBodyString();
145
146 mail.setMessage( message );
147
148 return(SKIP_BODY);
149 }
150
151 /**
152 * Taglibã®çµ‚äº?‚¿ã‚°ãŒè¦‹ã¤ã‹ã£ãŸã¨ãã«å‡¦ç?™ã‚?doEndTag() ã‚?オーãƒã?ライドã—ã¾ã™ã?
153 *
154 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()ã§å‘¼ã¶ã€?
155 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
156 * @og.rev 5.6.9.3 (2013/10/25) useDB対�
157 *
158 * @return 後続å?ç??æŒ?¤º
159 */
160 @Override
161 public int doEndTag() {
162 debugPrint(); // 4.0.0 (2005/02/28)
163
164 // 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
165 if( useLDAP ) {
166 String[] vals = StringUtil.csv2Array( ldapVals );
167
168 LDAPSearch serch = new LDAPSearch();
169 serch.setAttributes( vals );
170 serch.init();
171
172 from = setLDAPAddress( serch,from );
173 to = setLDAPAddress( serch,to );
174 cc = setLDAPAddress( serch,cc );
175 bcc = setLDAPAddress( serch,bcc );
176 replyTo = setLDAPAddress( serch,replyTo );
177 }
178 else if( useDB ){ // 5.6.9.3 (2013/10/25) GE35ã‹ã‚‰ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾?
179 String[] from_array = {from};
180 from = getAddressArray( from_array )[0];
181 to = getAddressArray( to );
182 cc = getAddressArray( cc );
183 bcc = getAddressArray( bcc );
184 replyTo = getAddressArray( replyTo );
185 }
186
187 // mail.setHost( host );
188 mail.setFrom( from );
189 mail.setTo( to );
190 mail.setCc( cc );
191 mail.setBcc( bcc );
192 mail.setReplyTo( replyTo );
193 mail.setSubject( subject );
194 // mail.setCharset( charset );
195 mail.setDebug( isDebug() );
196
197 if( filename != null && filename.length > 0 ) {
198 String[] temp = new String[filename.length];
199 String directory = HybsSystem.url2dir( fileURL );
200 for( int i=0; i<temp.length; i++ ) {
201 temp[i] = StringUtil.urlAppend( directory, filename[i] );
202 }
203 mail.setFilename( temp );
204 }
205
206 mail.sendmail() ;
207
208 return(EVAL_PAGE);
209 }
210
211 /**
212 * タグリブオブジェクトをリリースã—ã¾ã™ã?
213 * ã‚ャãƒ?‚·ãƒ¥ã•れã¦å†åˆ©ç”¨ã•れるã?ã§ã€ãƒ•ィールドã?åˆæœŸè¨å®šã‚’行ã„ã¾ã™ã?
214 *
215 * @og.rev 2.0.0.4 (2002/09/27) カスタãƒ?‚¿ã‚°ã® release() メソãƒ?ƒ‰ã‚’ã?追åŠ?
216 * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応ã?release2() ã‚?doEndTag()ã§å‘¼ã¶ã€?
217 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 useLDAP,ldapKey,ldapVals 属æ?追åŠ?
218 * @og.rev 5.6.7.0 (2013/07/27) ldapKey,ldapValsã®å–得をリソースã«å¤‰æ›´
219 * @og.rev 5.6.9.3 (2013/10/25) useDB追�
220 *
221 */
222 @Override
223 protected void release2() {
224 super.release2();
225 mail = null;
226 host = HybsSystem.sys( "COMMON_MAIL_SERVER" );
227 charset = HybsSystem.sys( "MAIL_DEFAULT_CHARSET" ); // 3.5.6.6 (2004/08/23)
228 from = null;
229 to = null;
230 cc = null;
231 bcc = null;
232 replyTo = null;
233 subject = null;
234 fileURL = HybsSystem.sys( "FILE_URL" );
235 filename = null;
236 useLDAP = false; // 3.7.1.0 (2005/04/15)
237 // ldapKey = "uid"; // 3.7.1.0 (2005/04/26)
238 // ldapVals = "cn,mail"; // 3.7.1.0 (2005/04/15)
239 ldapKey = HybsSystem.sys( "LDAP_MAILSEND_KEY" ); // 5.6.7.0 (2013/07/27)
240 ldapVals= HybsSystem.sys( "LDAP_MAILSEND_VALS" ); // 5.6.7.0 (2013/07/27)
241 useDB = false; // 5.6.9.3 (2013/10/25) GE35ã‹ã‚‰ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾?
242 }
243
244 /**
245 * LDAP を利用ã—ãŸãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’è¨å®šã—ç›´ã—ã¾ã™ã?
246 *
247 * LDAPよりã€ldapKeyã‚’ã‚ーã«ã€ldapVals ã‚’è¨å®šå?ã¨ã—ã¦ã€èªã¿è¾¼ã¿ã¾ã™ã?
248 * åˆæœŸå€¤ã¯ã€ldapKeyã¯ã€uid(ユニã?クID) ldapValsã¯ã€cn,mail(åå‰ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹)ã¨ãªã£ã¦ã?¾ã™ã?
249 * from,to,cc,bcc,replyTo ã®è¨å®šå?ã‚’ã?target ã«ã‚»ãƒ?ƒˆã—ã¦ã€æ¤œç´¢ã—ã¾ã™ã?
250 * 通常ã€ã“ã®ãƒ¡ã‚½ãƒ?ƒ‰ã¯ã€useLDAP=true ã®å ´åˆã«å‘¼ã³å‡ºã™ã‚ˆã?«è¨å®šã—ã¾ã™ã?
251 * target ã?null ã‹ã?ã‚¼ãƒæ–?—å?ã?メールアドレス(ã“ã“ã§ã¯ã€?#064; æ–?—ã‚’å«ã‚?‹ã©ã?‹ã§åˆ¤å®?ã®å ´åˆã?
252 * ãã?ã¾ã¾ target ã‚’è¿”ã—ã¾ã™ã?
253 *
254 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
255 *
256 * @param serch LDAPSearchオブジェク�
257 * @param target ldapKeyã‚ーã«å¯¾ã™ã‚‹è¨å®šå?
258 *
259 * @return メールアドレス
260 * @see #setLDAPAddress( LDAPSearch serch, String[] targets )
261 */
262 private String setLDAPAddress( final LDAPSearch serch, final String target ) {
263 final String rtnAdrs ;
264
265 // if( target == null || target.length() == 0 || target.indexOf("@") > 0 ) { return target; }
266 if( target != null && target.indexOf( '@' ) < 0 ) {
267 List<String[]> list = serch.search( ldapKey + "=" + target );
268 if( list.size() == 1 ) {
269 String[] vals = list.get(0);
270 if( ldapVals.indexOf(',') < 0 ) { // 検索値ãŒï¼’ã¤ã®å ´åˆã§ãªã?
271 rtnAdrs = vals[0] ; // メールアドレスã®ã¿
272 }
273 else {
274 rtnAdrs = vals[0] + "<" + vals[1] + ">" ; // "åå‰<aaaa@bbbb>" å½¢å¼?
275 }
276 }
277 else {
278 String errMsg = "LDAP検索ã®çµæžœã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ãŒè¦‹ã¤ã‹ã‚Šã¾ã›ã‚“ã§ã—ãŸã€?
279 + "è¨å®šå?=[" + target + "] , 検索ã‚ー=[" + ldapKey + "] , 検索属æ?=["
280 + ldapVals + "]" ;
281 throw new HybsSystemException( errMsg );
282 }
283 }
284 else {
285 rtnAdrs = target;
286 }
287
288 return rtnAdrs ;
289 }
290
291 /**
292 * LDAP を利用ã—ãŸè¤?•°ã®ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾—ã—ã¾ã™ã?
293 *
294 * LDAPよりã€ldapKeyã‚’ã‚ーã«ã€ldapVals ã‚’è¨å®šå?ã¨ã—ã¦ã€èªã¿è¾¼ã¿ã¾ã™ã?
295 * åˆæœŸå€¤ã¯ã€ldapKeyã¯ã€uid(ユニã?クID) ldapValsã¯ã€cn,mail(åå‰ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹)ã¨ãªã£ã¦ã?¾ã™ã?
296 * from,to,cc,bcc,replyTo ã®è¨å®šå?ã‚’ã?target ã«ã‚»ãƒ?ƒˆã—ã¦ã€æ¤œç´¢ã—ã¾ã™ã?
297 * 通常ã€ã“ã®ãƒ¡ã‚½ãƒ?ƒ‰ã¯ã€useLDAP=true ã®å ´åˆã«å‘¼ã³å‡ºã™ã‚ˆã?«è¨å®šã—ã¾ã™ã?
298 * target ãŒãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã®å ´åˆã?(ã“ã“ã§ã¯ã€?#064; æ–?—ã‚’å«ã‚?‹ã©ã?‹ã§åˆ¤å®?ãã?ã¾ã¾è¿”ã—ã¾ã™ã?
299 *
300 * @og.rev 3.7.1.0 (2005/04/26) LDAP検索 æ–°è¦è¿½åŠ?
301 *
302 * @param serch LDAPSearchオブジェク�
303 * @param targets ldapKeyã‚ーã«å¯¾ã™ã‚‹è¨å®šå?ã®é…å?
304 *
305 * @return è¤?•°ã®ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹(é…å?)
306 * @see #setLDAPAddress( LDAPSearch serch, String target )
307 */
308 private String[] setLDAPAddress( final LDAPSearch serch, final String[] targets ) {
309 if( targets == null || targets.length == 0 ) { return targets; }
310
311 String[] rtn = new String[targets.length];
312
313 for( int i=0; i<targets.length; i++ ) {
314 rtn[i] = setLDAPAddress( serch,targets[i] );
315 }
316 return rtn ;
317 }
318
319 /**
320 * ã€TAG】é?ä¿¡å…??¦?²?¯?)アドレスを指定ã—ã¾ã™ã?
321 *
322 * @og.tag é€ä¿¡å…??¦?²?¯?)アドレスを指定ã—ã¾ã™ã?
323 *
324 * @param fromAdrs é€ä¿¡å…??¦?²?¯?)アドレス
325 */
326 public void setFrom( final String fromAdrs ) {
327 from = nval( getRequestParameter( fromAdrs ), from );
328 }
329
330 /**
331 * ã€TAG】é?ä¿¡å…??´?¯)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
332 *
333 * @og.tag
334 * è¤?•°ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’カンマ区åˆ?‚Šã§ã‚»ãƒ?ƒˆã§ãã¾ã™ã?
335 *
336 * @og.rev 3.5.6.2 (2004/07/05) å…ˆã«é…å?ã«åˆ?§£ã—ã¦ã‹ã‚‰ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾?
337 * @og.rev 3.5.6.4 (2004/07/16) å…ˆã«ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾—ã—ã¦ã‹ã‚‰é…å?ã«åˆ?§£
338 *
339 * @param toAdrs é€ä¿¡å…??´?¯)アドレス(CSVå½¢å¼?
340 */
341 public void setTo( final String toAdrs ) {
342 to = StringUtil.csv2ArrayOnly( getRequestParameter( toAdrs ) );
343 }
344
345 /**
346 * ã€TAG】é?ä¿¡å…??£?£)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
347 *
348 * @og.tag
349 * è¤?•°ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’カンマ区åˆ?‚Šã§ã‚»ãƒ?ƒˆã§ãã¾ã™ã?
350 *
351 * @og.rev 3.5.6.2 (2004/07/05) å…ˆã«é…å?ã«åˆ?§£ã—ã¦ã‹ã‚‰ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾?
352 * @og.rev 3.5.6.4 (2004/07/16) å…ˆã«ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾—ã—ã¦ã‹ã‚‰é…å?ã«åˆ?§£
353 *
354 * @param ccAdrs é€ä¿¡å…??£?£)アドレス(CSVå½¢å¼?
355 */
356 public void setCc( final String ccAdrs ) {
357 cc = StringUtil.csv2ArrayOnly( getRequestParameter( ccAdrs ) );
358 }
359
360 /**
361 * ã€TAG】é?ä¿¡å…??¢?£?£)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
362 *
363 * @og.tag
364 * è¤?•°ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’カンマ区åˆ?‚Šã§ã‚»ãƒ?ƒˆã§ãã¾ã™ã?
365 *
366 * @og.rev 3.5.6.2 (2004/07/05) å…ˆã«é…å?ã«åˆ?§£ã—ã¦ã‹ã‚‰ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾?
367 * @og.rev 3.5.6.4 (2004/07/16) å…ˆã«ãƒªã‚¯ã‚¨ã‚¹ãƒˆå¤‰æ•°ã®å€¤ã‚’å–å¾—ã—ã¦ã‹ã‚‰é…å?ã«åˆ?§£
368 *
369 * @param bccAdrs é€ä¿¡å…??¢?£?£)アドレス(CSVå½¢å¼?
370 */
371 public void setBcc( final String bccAdrs ) {
372 bcc = StringUtil.csv2ArrayOnly( getRequestParameter( bccAdrs ) );
373 }
374
375 /**
376 * ã€TAG】返信å…?replyTo)アドレスをCSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
377 *
378 * @og.tag
379 * è¤?•°ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’カンマ区åˆ?‚Šã§ã‚»ãƒ?ƒˆã§ãã¾ã™ã?
380 *
381 * @og.rev 3.5.6.6 (2004/08/23) æ–°è¦è¿½åŠ?
382 *
383 * @param replyToAdrs 返信�replyTo)アドレス(CSV形�
384 */
385 public void setReplyTo( final String replyToAdrs ) {
386 replyTo = StringUtil.csv2ArrayOnly( getRequestParameter( replyToAdrs ) );
387 }
388
389 /**
390 * ã€TAG】メールサーãƒã?を指定ã—ã¾ã?
391 * (åˆæœŸå€¤:COMMON_MAIL_SERVER[={@og.value org.opengion.hayabusa.common.SystemData#COMMON_MAIL_SERVER}])ã€?
392 *
393 * @og.tag メールサーãƒã?を指定ã—ã¾ã™ã?
394 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®COMMON_MAIL_SERVER[={@og.value org.opengion.hayabusa.common.SystemData#COMMON_MAIL_SERVER}])ã€?
395 *
396 * @og.rev 3.5.6.6 (2004/08/23) åˆæœŸå€¤ã‚’è?æ…®ã™ã‚‹ã‚ˆã†ã«å¤‰æ›´ã€?
397 *
398 * @param hst メールサーãƒã?
399 * @see org.opengion.hayabusa.common.SystemData#COMMON_MAIL_SERVER
400 */
401 public void setHost( final String hst ) {
402 host = nval( getRequestParameter( hst ),host );
403 }
404
405 /**
406 * ã€TAG】タイトルを指定ã—ã¾ã™ã?
407 *
408 * @og.tag タイトルを指定ã—ã¾ã™ã?
409 *
410 * @param subjct タイトル
411 */
412 public void setSubject( final String subjct ) {
413 this.subject = getRequestParameter( subjct );
414 }
415
416 /**
417 * ã€TAG】添付ファイルåã‚’CSVå½¢å¼ã§æŒ?®šã—ã¾ã™ã?
418 *
419 * @og.tag
420 * è¤?•°ãƒ•ァイルをセãƒ?ƒˆã§ãã¾ã™ã?
421 * è¨å®šæ–¹æ³•ã?ã€ã‚«ãƒ³ãƒžã§åŒºåˆ?£ã¦ä¸¦ã¹è¤?•°æŒ?®šã§ãã¾ã™ã?
422 *
423 * @og.rev 3.5.6.6 (2004/08/23) è¤?•°ãƒ•ァイルæŒ?®šæ–¹æ³•ã‚’ã€?‡è¤?ƒªã‚¯ã‚¨ã‚¹ãƒˆã‹ã‚‰ã‚«ãƒ³ãƒžåŒºåˆ?‚Šã«å¤‰æ›´
424 *
425 * @param fname 添付ファイルå?CSVå½¢å¼?
426 */
427 public void setFilename( final String fname ) {
428 filename = StringUtil.csv2ArrayOnly( getRequestParameter( fname ) );
429 }
430
431 /**
432 * ã€TAG】文å—エンコーãƒ?‚£ãƒ³ã‚°ã‚’指定ã—ã¾ã?
433 * (åˆæœŸå€¤:MAIL_DEFAULT_CHARSET[={@og.value org.opengion.hayabusa.common.SystemData#MAIL_DEFAULT_CHARSET}])ã€?
434 *
435 * @og.tag
436 * æ–?—エンコーãƒ?‚£ãƒ³ã‚°ã¯ã€ãƒ¡ãƒ¼ãƒ«æœ¬æ–?«å¯¾ã™ã‚‹ã‚¨ãƒ³ã‚³ãƒ¼ãƒ?‚£ãƒ³ã‚°æŒ?®šã§ã™ã?
437 * ã“れã¯ã€Windows-31J ã€MS932ã€Shift_JIS ã®ã©ã‚Œã‹ãŒæŒ‡å®šã•れãŸå ´åˆã?
438 * 『指定ã?æ–?—コーãƒ?+ 8bit é€ä¿¡ã€ã—ã¾ã™ã?
439 * ãれ以外ã?æŒ?®šã?ã€ã?ISO-2022-JP ã«ç‹¬è‡ªå¤‰æ› + 7bit é€ä¿¡ã€ã«ãªã‚Šã¾ã™ã?
440 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®MAIL_DEFAULT_CHARSET[={@og.value org.opengion.hayabusa.common.SystemData#MAIL_DEFAULT_CHARSET}])ã€?
441 *
442 * @param chset æ–?—エンコーãƒ?‚£ãƒ³ã‚°
443 * @see org.opengion.hayabusa.common.SystemData#MAIL_DEFAULT_CHARSET
444 */
445 public void setCharset( final String chset ) {
446 charset = nval( getRequestParameter( chset ),charset );
447 }
448
449 /**
450 * ã€TAG】添付ファイルã®ã‚»ãƒ¼ãƒ–ディレクトリを指定ã—ã¾ã?
451 * (åˆæœŸå€¤:FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])ã€?
452 *
453 * @og.tag
454 * ã“ã?属æ?ã§æŒ?®šã•れるãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã€æ·»ä»˜ãƒ•ァイルãŒå˜åœ¨ã™ã‚‹ã¨ä»®å®šã—ã¾ã™ã?
455 * æŒ?®šæ–¹æ³•ã?ã€??常㮠fileURL 属æ?ã¨åŒæ§˜ã«ã€å?é ãŒã?'/' (UNIX) ã¾ãŸã?ã€?¼’æ–‡å—ç›®ãŒã?
456 * ":" (Windows)ã®å ´åˆã?ã€æŒ‡å®šã?URLãã?ã¾ã¾ã®ãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã€ãã?§ãªã??åˆã?ã€?
457 * fileURL = "{@USER.ID}" ã¨æŒ?®šã™ã‚‹ã¨ã€FILE_URL 属æ?ã§æŒ?®šã?フォルãƒ??下ã«ã€?
458 * ã•らã«ã€å„個人ID別ã®ãƒ•ォルãƒ?‚’作æ?ã—ã¦ã€ãã“を使用ã—ã¾ã™ã?
459 * (åˆæœŸå€¤:シスãƒ?ƒ 定数ã®FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])ã€?
460 *
461 * @og.rev 4.0.0.0 (2005/01/31) StringUtil.urlAppend メソãƒ?ƒ‰ã®åˆ©ç”¨
462 * @og.rev 4.0.0.0 (2007/11/20) æŒ?®šã•れãŸãƒ?‚£ãƒ¬ã‚¯ãƒˆãƒªåã?æœ?¾ŒãŒ"\"or"/"ã§çµ‚ã‚ã£ã¦ã?ªã??åˆã«ã€?/"ã‚’ä»˜åŠ ã™ã‚‹ã€?
463 *
464 * @param url 添付ファイルã®ã‚»ãƒ¼ãƒ–ディレクトリ
465 * @see org.opengion.hayabusa.common.SystemData#FILE_URL
466 */
467 public void setFileURL( final String url ) {
468 String furl = nval( getRequestParameter( url ),null );
469 if( furl != null ) {
470 char ch = furl.charAt( furl.length()-1 );
471 if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
472 fileURL = StringUtil.urlAppend( fileURL,furl );
473 }
474 }
475
476 /**
477 * ã€TAG】メールアドレスをLDAPを利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)ã€?
478 *
479 * @og.tag
480 * LDAP ã®ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾—ã™ã‚‹å?åˆã?ã€true ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?false ã®å ´åˆã?ã€?
481 * from,to,cc,bcc,replyTo ã®è¨å®šå?ãŒãã®ã¾ã¾ä½¿ç”¨ã•れã¾ã™ã?
482 * 上記アドレスã«ã€?#064; ã‚’å«ã‚??åˆã?ã€LDAP を検索ã›ãšã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã¨ã—ã¦
483 * ãã?ã¾ã¾ä½¿ç”¨ã—ã¾ã™ã?LDAP ã®æ¤œç´¢çµæžœãŒå˜åœ¨ã—ãªã??åˆã?ã€ä¸æ£ãªã‚¢ãƒ‰ãƒ¬ã‚¹ã¨ã—ã¦ã€?
484 * エラーã¨ã—ã¾ã™ã?
485 * åˆæœŸå€¤ã¯ã€false ã§ã™ã?
486 *
487 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
488 *
489 * @param useLDAP メールアドレスをLDAPを利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹ [true:å–å¾—ã™ã‚?false:å–å¾—ã—ãªã„]
490 */
491 public void setUseLDAP( final String useLDAP ) {
492 this.useLDAP = nval( getRequestParameter( useLDAP ),this.useLDAP );
493 }
494
495 /**
496 * ã€TAG】アドレスを検索ã™ã‚‹ã‚ーを指定ã—ã¾ã?åˆæœŸå€¤:uid C社員番å·)ã€?
497 *
498 * @og.tag
499 * LDAP ã®ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾—ã™ã‚‹å?åˆã?ã€æ¤œç´¢ã™ã‚‹ã‚ーを指定ã—ã¾ã™ã?
500 * from,to,cc,bcc,replyTo ã®è¨å®šå?ã‚’ã?ã“ã?ã‚ーã«ã‚»ãƒ?ƒˆã—ã¦ã€æ¤œç´¢ã—ã¾ã™ã?
501 * uid Cç¤¾å“¡ç•ªå· ã€employeeNumber ç¤¾å“¡ç•ªå· ãªã©ãŒè?ãˆã‚‰ã‚Œã¾ã™ã?
502 * åˆæœŸå€¤ã¯ã€uid(C社員番å·)ã§ã™ã?
503 * ã“ã?ã‚ーã§è¤?•°ã®æ¤œç´¢çµæžœãŒå¾—られãŸå ´åˆã?ã€ã‚¨ãƒ©ãƒ¼ã¨ã—ã¾ã™ã?
504 *
505 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
506 *
507 * @param ldapKey アドレスを検索ã™ã‚‹ã‚ー
508 */
509 public void setLdapKey( final String ldapKey ) {
510 this.ldapKey = nval( getRequestParameter( ldapKey ),this.ldapKey );
511 }
512
513 /**
514 * ã€TAG】LDAP検索時ã?属æ?åã‚’æŒ?®šã—ã¾ã?åˆæœŸå€¤:cn,mail)ã€?
515 *
516 * @og.tag
517 * LDAPを検索ã™ã‚‹å ´åˆã?"æ‹?½“è?å?<メールアドレス>å½¢å¼ã?メールアドレスを作æ?ã™ã‚‹
518 * å ´åˆã?検索ã™ã‚‹å±žæ?値を指定ã—ã¾ã™ã?
519 * ã²ã¨ã¤ãªã‚‰ã‚¢ãƒ‰ãƒ¬ã‚¹ã€‚ï¼’ã¤ãªã‚‰åå‰ã¨ã‚¢ãƒ‰ãƒ¬ã‚¹ã®é ?§æŒ?®šã•れãŸã¨èªè˜ã—ã¾ã™ã?
520 *
521 * @og.rev 3.7.1.0 (2005/04/15) LDAP検索 æ–°è¦è¿½åŠ?
522 *
523 * @param ldapVals LDAP検索時ã?属æ?å?
524 */
525 public void setLdapVals( final String ldapVals ) {
526 this.ldapVals = nval( getRequestParameter( ldapVals ),this.ldapVals );
527 }
528
529 /**
530 * ã€TAG】メールアドレスをGE35を利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹[true/false]を指定ã—ã¾ã?åˆæœŸå€¤:false)ã€?
531 *
532 * @og.tag
533 * GE35ã‹ã‚‰ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾—ã™ã‚‹å?åˆã?ã€true ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?false ã®å ´åˆã?ã€?
534 * from,to,cc,bcc,replyTo ã®è¨å®šå?ãŒãã®ã¾ã¾ä½¿ç”¨ã•れã¾ã™ã?
535 * 上記アドレスã«ã€?#064; ã‚’å«ã‚??åˆã?ã€DB を検索ã›ãšã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã¨ã—ã¦
536 * ãã?ã¾ã¾ä½¿ç”¨ã—ã¾ã™ã?DB ã®æ¤œç´¢çµæžœãŒå˜åœ¨ã—ãªã??åˆã?ã€ä¸æ£ãªã‚¢ãƒ‰ãƒ¬ã‚¹ã¨ã—ã¦ã€?
537 * エラーã¨ã—ã¾ã™ã?
538 * useLDAPã¨åŒæ™‚ã«è¨å®šã•れã¦ã?‚‹å ´åˆã?ã€LDAPè¨å®šãŒå„ªå…ˆã•れã¾ã™ã?
539 * åˆæœŸå€¤ã¯ã€false ã§ã™ã?
540 *
541 * @og.rev 5.6.9.3 (2013/10/25) æ–°è¦è¿½åŠ?
542 *
543 * @param flg メールアドレスをGE35を利用ã—ã¦å–å¾—ã™ã‚‹ã‹ã©ã?‹ [true:å–å¾—ã™ã‚?false:å–å¾—ã—ãªã„]
544 */
545 public void setUseDB( final String flg ) {
546 useDB = nval( getRequestParameter( flg ),useDB );
547 }
548
549 /**
550 * シリアライズ用ã®ã‚«ã‚¹ã‚¿ãƒ?‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºæ›¸ãè¾¼ã¿ãƒ¡ã‚½ãƒ?ƒ‰
551 *
552 * @og.rev 4.0.0.0 (2006/09/31) æ–°è¦è¿½åŠ?
553 * @serialData ä¸?ƒ¨ã®ã‚ªãƒ–ジェクトã?ã€ã‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºã•れã¾ã›ã‚“ã€?
554 *
555 * @param strm ObjectOutputStreamオブジェク�
556 * @throws IOException 入出力エラーãŒç™ºç”Ÿã—ãŸå?å?
557 */
558 private void writeObject( final ObjectOutputStream strm ) throws IOException {
559 strm.defaultWriteObject();
560 }
561
562 /**
563 * シリアライズ用ã®ã‚«ã‚¹ã‚¿ãƒ?‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºèªã¿è¾¼ã¿ãƒ¡ã‚½ãƒ?ƒ‰
564 *
565 * ã“ã“ã§ã¯ã€transient 宣è¨?•れãŸå†?ƒ¨å¤‰æ•°ã®å†??åˆæœŸåŒ–ãŒå¿?¦ãªãƒ•ィールドã?ã¿è¨å®šã—ã¾ã™ã?
566 *
567 * @og.rev 4.0.0.0 (2006/09/31) æ–°è¦è¿½åŠ?
568 * @serialData ä¸?ƒ¨ã®ã‚ªãƒ–ジェクトã?ã€ã‚·ãƒªã‚¢ãƒ©ã‚¤ã‚ºã•れã¾ã›ã‚“ã€?
569 *
570 * @param strm ObjectInputStreamオブジェク�
571 * @see #release2()
572 * @throws IOException シリアライズã«é–¢ã™ã‚‹å…¥å‡ºåŠ›ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå?å?
573 * @throws ClassNotFoundException クラスを見ã¤ã‘ã‚‹ã“ã¨ãŒã§ããªã‹ã£ãŸå?å?
574 */
575 private void readObject( final ObjectInputStream strm ) throws IOException , ClassNotFoundException {
576 strm.defaultReadObject();
577 }
578
579 /**
580 * 引数ã®ã‚¢ãƒ‰ãƒ¬ã‚¹é…å?を社員マスタ??E35)ã§å¤‰æ›ã—ã¦è¿”ã—ã¾ã™ã?
581 * グループIDã¯åˆ©ç”¨ã—ã¾ã›ã‚“ã€?
582 *
583 * @og.rev 5.6.9.3 (2013/10/25) æ–°è¦è¿½åŠ?
584 *
585 * @param src 引数é…å?
586 *
587 * @return 変æ›å¾Œã‚¢ãƒ‰ãƒ¬ã‚¹é…å?
588 */
589 public String[] getAddressArray( final String[] src ){
590 if( src == null || src.length == 0 ) { return src; }
591
592 String[] rtn= src.clone();
593
594 for( int i=0; i < src.length; i++ ){
595 String addr = src[i]; // å®›å?ID
596 String[] userAddr = getUserAddr( addr );
597 if ( userAddr != null && userAddr.length > 0 ){
598 if( userAddr[MailPattern.GE35_NAME] != null ){ // å®›å?å?
599 addr = userAddr[MailPattern.GE35_NAME] + "<" + userAddr[MailPattern.GE35_MAIL] + ">";
600 }
601 else{
602 addr = userAddr[MailPattern.GE35_MAIL];
603 }
604
605 rtn[i] = addr;
606
607 }
608 }
609
610 return rtn;
611 }
612
613
614 /**
615 * 社員マスタよりåå‰ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’å–å¾—ã—ã¾ã™ã?
616 * 戻りå? rtn[0]:ユーザーåã? rtn[1]:ユーザーメールアドレス
617 *
618 * @og.rev 5.6.9.3 (2013/10/25) mailSenderã§ã‚?E35を扱ã??
619 *
620 * @param userId ユーザーID
621 *
622 * @return é…å?æ–?—å?(rtn[0]:ユーザーåã? rtn[1]:ユーザーメールアドレス)
623 */
624 private String[] getUserAddr( final String userId ){
625 String[] rtn = null;
626
627 if ( userId.contains( "@" ) ) {
628 rtn = new String[2];
629 rtn[0] = "";
630 rtn[1] = userId;
631 }
632 else {
633 String[] ge35SelArgs = { userId };
634 String[][] ge35Datas = DBUtil.dbExecute( MailPattern.selGE35,ge35SelArgs,getApplicationInfo(), DBID );
635 if ( ge35Datas.length > 0) {
636 rtn = ge35Datas[0];
637 }
638 else {
639 String errMsg = "ユーザーæƒ??å–å¾—ã§ãã¾ã›ã‚“。ユーザーID?? + userId ;
640 throw new HybsSystemException( errMsg );
641 }
642 }
643 return rtn;
644 }
645
646 /**
647 * ã“ã?オブジェクトã?æ–?—å?表ç¾ã‚’è¿”ã—ã¾ã™ã?
648 * 基本çš?«ãƒ?ƒãƒ?‚°ç›®çš?«ä½¿ç”¨ã—ã¾ã™ã?
649 *
650 * @og.rev 5.6.9.3 (2013/10/25) useDBã®å¯¾å¿?
651 *
652 * @return ã“ã?ã‚¯ãƒ©ã‚¹ã®æ–?—å?表ç¾
653 */
654 @Override
655 public String toString() {
656 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
657 .println( "VERSION" ,VERSION )
658 .println( "host" ,host )
659 .println( "charset" ,charset )
660 .println( "from" ,from )
661 .println( "to" ,to )
662 .println( "cc" ,cc )
663 .println( "bcc" ,bcc )
664 .println( "replyTo" ,replyTo )
665 .println( "subject" ,subject )
666 .println( "filename" ,filename )
667 .println( "fileURL" ,fileURL )
668 .println( "useLDAP" ,useLDAP )
669 .println( "ldapKey" ,ldapKey )
670 .println( "ldapVals" ,ldapVals )
671 .println( "useDB" ,useDB ) // 5.6.9.3 (2013/10/25)
672 .println( "Other..." ,getAttributes().getAttribute() )
673 .fixForm().toString() ;
674 }
675 }