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 */
016package org.opengion.hayabusa.taglib;
017
018import org.opengion.hayabusa.common.HybsSystem;
019import org.opengion.hayabusa.common.HybsSystemException;
020import org.opengion.hayabusa.db.DBTableModel;
021import org.opengion.hayabusa.db.DBColumn;
022import org.opengion.hayabusa.db.DBTableModelUtil;
023import org.opengion.hayabusa.resource.LDAPSearch;
024import org.opengion.fukurou.util.ErrorMessage;
025import org.opengion.fukurou.util.StringUtil ;
026import org.opengion.fukurou.util.ToString;                                              // 6.1.1.0 (2015/01/17)
027import org.opengion.fukurou.util.ArraySet;                                              // 6.4.3.4 (2016/03/11)
028
029import static org.opengion.fukurou.util.StringUtil.nval ;
030import static org.opengion.fukurou.system.HybsConst.BR;                 // 6.1.0.0 (2014/12/26) refactoring
031
032import java.util.List;
033import java.util.Locale;
034import java.util.Set;                                                                                   // 6.4.3.4 (2016/03/11)
035
036/**
037 * LDAPの内容を検索するための、ldapQueryタグです。
038 *
039 * 検索した結果は、DBTableModel にセットされるため、
040 * JDBCQuery と同様に、viewタグで表示させることが可能です。
041 *
042 * 下記の項目については、src/resource/システムパラメータ に、予め
043 * 設定しておくことで、タグごとに指定する必要がなくなります。
044 * ・LDAP_INITIAL_CONTEXT_FACTORY
045 * ・LDAP_PROVIDER_URL
046 * ・LDAP_ENTRYDN
047 * ・LDAP_SEARCH_BASE
048 * ・LDAP_SEARCH_SCOPE
049 *
050 * このタグリブでは、検索のみサポートしています。
051 *
052 * @og.formSample
053 * ●形式:
054 *     <og:ldapQuery  debug="false"
055 *         command     = "NEW"                                       NEW,RENEW が使用可能です。
056 *         initctx     = "com.sun.jndi.ldap.LdapCtxFactory"          初期コンテキストファクトリ
057 *         providerURL = "ldap://ldap.opengion.org:389"              サービスプロバイダの構成情報
058 *         entrydn     = "cn=inquiry-sys,o=opengion,c=JP"            属性の取得元のオブジェクトの名前
059 *         password    = "xxxxxx"                                    属性の取得元のオブジェクトのパスワード
060 *         searchbase  = "soouid=employeeuser,o=opengion,c=JP"       検索するコンテキストまたはオブジェクトのベース名
061 *         filter      = "(objectClass=person)"                      検索に使用するフィルタ式。null は不可
062 *         attributes  = "uid,cn,officeName,ou,mail,belongOUID"      属性を識別する属性 IDをCSV形式で指定
063 *         searchScope = "SUBTREE"                                   検索範囲を設定(『OBJECT』『ONELEVEL』『SUBTREE』のどれか)
064 *         maxRowCount = "0"                                         検索時の最大検索数(0は、無制限:デフォルト)
065 *     />
066 * ●body:なし
067 *
068 * ●Tag定義:
069 *   <og:ldapQuery
070 *       initctx            【TAG】初期コンテキストファクトリを指定します (初期値:LDAP_INITIAL_CONTEXT_FACTORY[=com.sun.jndi.ldap.LdapCtxFactory])
071 *       providerURL        【TAG】サービスプロバイダの構成情報を指定します (初期値:LDAP_PROVIDER_URL[=ldap://ldap.opengion.org:389])
072 *       entrydn            【TAG】属性の取得元のオブジェクトの名前を設定します (初期値:LDAP_ENTRYDN[=cn=inquiry-sys,o=opengion,c=JP])
073 *       password           【TAG】属性の取得元のオブジェクトのパスワードを設定します (初期値:LDAP_PASSWORD[=password])
074 *       searchbase         【TAG】検索するコンテキストまたはオブジェクトの名前を設定します (初期値:LDAP_SEARCH_BASE[=soouid=employeeuser,o=opengion,c=JP])
075 *       filter           ○【TAG】検索に使用するフィルタ式(例:belongOUID=61200)(必須)。
076 *       searchScope        【TAG】検索範囲(OBJECT/ONELEVEL/SUBTREE)を設定します (初期値:LDAP_SEARCH_SCOPE[=SUBTREE])
077 *       timeLimit          【TAG】これらの SearchControls の時間制限をミリ秒単位で設定します(初期値:0[無制限])
078 *       derefLinkFlag      【TAG】検索中のリンクへの間接参照を有効または無効[true/false]にします(初期値:false)
079 *       maxRowCount        【TAG】レジストリの最大検索件数をセットします(初期値:0[無制限])
080 *       returningObjFlag   【TAG】結果の一部としてオブジェクトを返すことを有効または無効[true/false]にします(初期値:false)
081 *       attributes         【TAG】検索の一部として返される属性をCSVで複数指定します
082 *       columns            【TAG】作成する DBTableModel のカラム名をCSV形式で指定します
083 *       orderBy            【TAG】検索した結果を表示する表示順をファイル属性名で指定します
084 *       tableId            【TAG】(通常は使いません)結果をDBTableModelに書き込んで、sessionに登録するときのキーを指定します
085 *       command            【TAG】コマンド (NEW,RENEW)をセットします(初期値:NEW)
086 *       displayMsg         【TAG】検索結果を画面上に表示するメッセージリソースIDを指定します(初期値:VIEW_DISPLAY_MSG[={@og.value SystemData#VIEW_DISPLAY_MSG}])
087 *       notfoundMsg        【TAG】検索結果がゼロ件の場合に表示するメッセージリソースIDを指定します(初期値:MSG0077[対象データはありませんでした])
088 *       overflowMsg        【TAG】オーバーフロー時に画面上に表示するメッセージIDを指定します(初期値:MSG0007)
089 *       scope              【TAG】キャッシュする場合のスコープ[request/page/session/application]を指定します(初期値:session)
090 *       mainTrans          【TAG】(通常は使いません)タグで処理される処理がメインとなるトランザクション処理かどうかを指定します(初期値:false)
091 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
092 *   />
093 *
094 * ●使用例
095 *     システムパラメータ に、必要なLDAP定数を定義しておいた場合は、下記のタグで検索できます。
096 *     例では、filter にあいまい検索(*)とAND条件(&(条件A)(条件B)) を指定した例を挙げておきます。
097 *     filter の形式と解釈は、RFC 2254 に準拠しています。
098 *     (RFC 2254 で定義されている演算子のすべてをすべての属性に適用できるわけではありません。)
099 *
100 *      <og:ldapQuery  debug="false"
101 *          command     = "NEW"
102 *          filter      = "(&(cnphoneticlangjp=OPENGION*)(businessName=*COMMON*))"
103 *          attributes  = "uid,cn,officeName,ou,mail,belongOUID"
104 *      />
105 *
106 *    ・queryOption タグの内部に記述すれば、プルダウンメニューを作成することが可能です。
107 *    <og:select name="UID">
108 *        <og:queryOption>
109 *            <og:ldapQuery
110 *                filter      = "(&(|(belongOUID=60000)(belongOUID=70000))(uid=C*))"
111 *                attributes  = "uid,uid,sn"
112 *                orderBy     = "uid"
113 *            />
114 *        </og:queryOption>
115 *    </og:select>
116 *
117 * @og.rev 3.1.0.0 (2003/03/20) LDAPにアクセスできる、LDAPQueryTag.java を新規に作成。
118 * @og.group その他入力
119 *
120 * @version  4.0
121 * @author       Kazuhiko Hasegawa
122 * @since    JDK5.0,
123 */
124public class LDAPQueryTag extends CommonTagSupport {
125        /** このプログラムのVERSION文字列を設定します。   {@value} */
126        private static final String VERSION = "6.4.3.4 (2016/03/11)" ;
127        private static final long serialVersionUID = 643420160311L ;
128
129        /** command 引数に渡す事の出来る コマンド  新規 {@value} */
130        public static final String CMD_NEW       = "NEW" ;
131        /** command 引数に渡す事の出来る コマンド  再検索 {@value} */
132        public static final String CMD_RENEW = "RENEW" ;
133        // 6.4.3.4 (2016/03/11) String配列 から、Setに置き換えます。
134        private static final Set<String> COMMAND_SET = new ArraySet<>( CMD_NEW , CMD_RENEW );
135
136        private static final long       COUNTLIMIT              = 0;    // 返すエントリの最大数。0 の場合、フィルタを満たすエントリをすべて返す
137
138        private String                  initctx                         = HybsSystem.sys( "LDAP_INITIAL_CONTEXT_FACTORY" );
139        private String                  providerURL             = HybsSystem.sys( "LDAP_PROVIDER_URL" );
140        private String                  entrydn                         = HybsSystem.sys( "LDAP_ENTRYDN" );
141        private String                  password                        = HybsSystem.sys( "LDAP_PASSWORD" );            // 4.2.2.0 (2008/05/10)
142        private String                  searchbase                      = HybsSystem.sys( "LDAP_SEARCH_BASE" );
143        private String                  filter                          ;                       // "employeeNumber=87019";
144
145        // 検索範囲。OBJECT_SCOPE、ONELEVEL_SCOPE、SUBTREE_SCOPE のどれか 1 つ
146        private String                  searchScope                     = HybsSystem.sys( "LDAP_SEARCH_SCOPE" );
147        private int                             timeLimit                       ;                       // 結果が返されるまでのミリ秒数。0 の場合、無制限
148        private String[]                attrs                           ;                       // エントリと一緒に返される属性の識別子。null の場合、すべての属性を返す。空の場合、属性を返さない
149        private String[]                columns                         ;                       // DBTableModel を作成する場合のカラム名になります。null の場合は、attributes 属性
150        private boolean                 returningObjFlag        ;                       // true の場合、エントリの名前にバインドされたオブジェクトを返す。false 場合、オブジェクトを返さない
151        private boolean                 derefLinkFlag           ;                       // true の場合、検索中にリンクを間接参照する
152
153        private String                  tableId                         = HybsSystem.TBL_MDL_KEY;       // sessionキー
154        private String                  orderBy                         ;                                                       // ソート項目(csv)
155        private String                  command                         = CMD_NEW;                                      // コマンド
156        private int                             executeCount            ;                                                       // 検索/実行件数
157        private int                             errCode                         = ErrorMessage.OK;                      // Ver4.3.1.1 (2008/09/05) 検索エラーコード
158        private int                     maxRowCount                     ;                                                       // 最大検索数(0は無制限)
159        private String                  displayMsg                      = HybsSystem.sys( "VIEW_DISPLAY_MSG" );
160        private String                  overflowMsg             = "MSG0007";    // 検索結果が、制限行数を超えましたので、残りはカットされました。
161        private String                  notfoundMsg                     = "MSG0077";    // 対象データはありませんでした。
162        private boolean                 isMainTrans                     = true;                 // 5.1.6.0 (2010/05/01) DBLastSqlの処理の見直し
163
164        /**
165         * デフォルトコンストラクター
166         *
167         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
168         */
169        public LDAPQueryTag() { super(); }              // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
170
171        /**
172         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
173         *
174         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
175         * @og.rev 3.6.0.8 (2004/11/19) DBTableModel をセーブする時に、トランザクションチェックを行います。
176         * @og.rev 4.0.0.0 (2007/10/18) メッセージリソース統合( getResource().getMessage ⇒ getResource().getLabel )
177         * @og.rev 4.3.1.1 (2008/09/03) 検索結果の件数、状況コードをリクエスト変数 "DB.COUNT"、"DB.ERR_CODE" にセットする。
178         * @og.rev 5.1.6.0 (2010/05/01) DBLastSqlの処理は、DBTableModelが新規作成された処理でのみ行う。
179         * @og.rev 6.4.3.4 (2016/03/11) String配列 から、Setに置き換えます。
180         *
181         * @return      後続処理の指示
182         */
183        @Override
184        public int doEndTag() {
185                debugPrint();           // 4.0.0 (2005/02/28)
186
187                // QueryOptionTag の内部で記述された場合の処理。
188                final QueryOptionTag queryOption = (QueryOptionTag)findAncestorWithClass( this,QueryOptionTag.class );
189                if( queryOption != null ) {
190                        queryOption.setTableModel( makeDBTable() );
191                        return EVAL_PAGE ;
192                }
193
194                // 通常の LDAPQuery 処理
195                if( check( command, COMMAND_SET ) ) {
196                        useMainTrans( isMainTrans );                    // 5.1.6.0 (2010/05/01) DBLastSqlの処理の見直し
197                        startQueryTransaction( tableId );               // 3.6.0.8 (2004/11/19)
198
199                        final DBTableModel table = makeDBTable();
200
201                        // 3.6.0.8 (2004/11/19) トランザクションチェックを行います。
202                        if( ! commitTableObject( tableId, table ) ) {
203                                jspPrint( "LDAPQueryTag Query処理が割り込まれました。DBTableModel は登録しません。" );
204                                return SKIP_PAGE ;
205                        }
206                        final StringBuilder buf = new StringBuilder( BUFFER_MIDDLE );
207
208                        // 実行件数の表示 command="NEW" のときのみ、displayMsg を表示させます。
209                        // 4.0.0 (2005/11/30) 出力順の変更。一番最初に出力します。
210                        if( CMD_NEW.equals( command ) ) {
211                                if( executeCount > 0 && displayMsg != null && displayMsg.length() > 0 ) {
212                                        buf.append( executeCount )
213                                                .append( getResource().getLabel( displayMsg ) )
214                                                .append( BR );
215                                }
216                                else if( executeCount == 0 && notfoundMsg != null && notfoundMsg.length() > 0 ) {
217                                        buf.append( getResource().getLabel( notfoundMsg ) )
218                                                .append( BR );
219                                }
220                        }
221
222                        if( maxRowCount > 0 && maxRowCount <= executeCount ) {
223                                buf.append( getResource().getLabel( overflowMsg ) )
224                                        .append( BR ).append( CR );
225                        }
226                        // 4.3.1.1 (2008/09/03) 検索結果の件数、エラーコードをセットする。
227                        setRequestAttribute( "DB.COUNT" , String.valueOf( executeCount ) );
228                        setRequestAttribute( "DB.ERR_CODE", String.valueOf( errCode ) );
229
230                        jspPrint( buf.toString() );
231                }
232
233                return EVAL_PAGE ;
234        }
235
236        /**
237         * タグリブオブジェクトをリリースします。
238         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
239         *
240         * @og.rev 2.0.0.4 (2002/09/27) カスタムタグの release() メソッドを、追加
241         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
242         * @og.rev 4.2.2.0 (2008/05/10) password 追加
243         * @og.rev 5.1.6.0 (2010/05/01) DBLastSqlの処理は、DBTableModelが新規作成された処理でのみ行う。
244         *
245         */
246        @Override
247        protected void release2() {
248                super.release2();
249
250                searchScope                     = HybsSystem.sys( "LDAP_SEARCH_SCOPE" );        // 検索範囲。OBJECT_SCOPE、ONELEVEL_SCOPE、SUBTREE_SCOPE のどれか 1 つ
251                timeLimit                       = 0;                    // 結果が返されるまでのミリ秒数。0 の場合、無制限
252                derefLinkFlag           = false;                // true の場合、検索中にリンクを間接参照する
253                returningObjFlag        = false;                // true の場合、エントリの名前にバインドされたオブジェクトを返す。false 場合、オブジェクトを返さない
254                attrs                           = null;                 // エントリと一緒に返される属性の識別子。null の場合、すべての属性を返す。空の場合、属性を返さない
255                columns                         = null;                 // DBTableModel を作成する場合のカラム名になります。null の場合は、attributes 属性
256
257                initctx                         = HybsSystem.sys( "LDAP_INITIAL_CONTEXT_FACTORY" );
258                providerURL             = HybsSystem.sys( "LDAP_PROVIDER_URL" );
259                entrydn                         = HybsSystem.sys( "LDAP_ENTRYDN" );
260                password                        = HybsSystem.sys( "LDAP_PASSWORD" );            // 4.2.2.0 (2008/05/10)
261                searchbase                      = HybsSystem.sys( "LDAP_SEARCH_BASE" );
262                filter                          = null;         // "employeeNumber=87019";
263
264                tableId                         = HybsSystem.TBL_MDL_KEY;       // sessionキー
265                orderBy                         = null;                 // ソート項目(csv)
266                command                         = CMD_NEW;              // コマンド
267                executeCount            = 0;                    // 検索/実行件数
268                errCode                         = ErrorMessage.OK; // Ver4.3.1.1 (2008/09/05) 検索エラーコード
269                maxRowCount                     = 0;                    // 最大検索数(0は無制限)
270                displayMsg                      = HybsSystem.sys( "VIEW_DISPLAY_MSG" );
271                overflowMsg             = "MSG0007";    // 検索結果が、制限行数を超えましたので、残りはカットされました。              */
272                notfoundMsg                     = "MSG0077";    // 対象データはありませんでした。
273                isMainTrans                     = true;                 // 5.1.6.0 (2010/05/01) DBLastSqlの処理の見直し
274        }
275
276        /**
277         * LDPA から、値を取り出し、DBTableModel を作成します。
278         *
279         * @og.rev 4.2.2.0 (2008/05/10) entrydn と、password 処理の追加
280         *
281         * @return      テーブルモデル
282         */
283        private DBTableModel makeDBTable() {
284                if( filter == null ) {
285                        final String errMsg = "S検索フィルターに null が指定されました。" ;
286                        throw new HybsSystemException( errMsg );
287                }
288
289                final LDAPSearch serch = new LDAPSearch();
290                serch.setSearchScope( searchScope ) ;
291                serch.setTimeLimit( timeLimit ) ;
292                serch.setDerefLinkFlag( derefLinkFlag ) ;
293                serch.setReturningObjFlag( returningObjFlag ) ;
294                serch.setMaxRowCount( maxRowCount ) ;
295                serch.setAttributes( attrs ) ;
296                serch.setInitctx( initctx ) ;
297                serch.setProviderURL( providerURL ) ;
298                serch.setSearchbase( searchbase ) ;
299                if( entrydn != null  ) { serch.setEntrydn( entrydn ) ; }        //4 .2.2.0 (2008/05/10)
300                if( password != null ) { serch.setPassword( password ) ; }      //4 .2.2.0 (2008/05/10)
301                serch.setOrderBy( orderBy ) ;
302                serch.init();
303
304                final List<String[]> list = serch.search( filter );
305                executeCount = list.size();
306
307                String[] ids = serch.getAttributes();   // attrs が null の場合、全件。それ以外は、attrs
308
309                // DBTableModel に使用するカラム名の登録
310                if( columns != null && columns.length > 0 ) {
311                        if( ids.length != columns.length ) {
312                                final String errMsg = "attributes 属性とcolumns属性の個数が異なります。"
313                                                        + "attrs=[" + attrs.length + "]:" + StringUtil.array2csv( attrs )
314                                                        + CR
315                                                        + " columns=[" + columns.length + "]:" + StringUtil.array2csv( columns )
316                                                        + CR ;
317                                throw new HybsSystemException( errMsg );
318                        }
319                        for( int i=0; i<columns.length; i++ ) {
320                                // columns にカラム名が設定されている場合のみ、使用する。
321                                if( columns[i] != null && columns[i].length() > 0 ) {
322                                        ids[i] = columns[i];
323                                }
324                        }
325                }
326
327                DBTableModel table = null;
328                if( ids.length > 0 ) {
329                        table = DBTableModelUtil.newDBTable();
330                        table.init( ids.length );
331                        for( int clm=0; clm<ids.length; clm++ ) {
332                                final DBColumn dbColumn = getResource().makeDBColumn( ids[clm] );
333                                table.setDBColumn( clm,dbColumn );
334                        }
335
336                        for( int row=0; row<executeCount; row++ ) {
337                                table.addColumnValues( list.get( row ) );
338                        }
339                }
340                return table ;
341        }
342
343        /**
344         * 【TAG】検索範囲(OBJECT/ONELEVEL/SUBTREE)を設定します
345         *              (初期値:LDAP_SEARCH_SCOPE[={@og.value SystemData#LDAP_SEARCH_SCOPE}])。
346         *
347         * @og.tag
348         * 検索範囲を OBJECT_SCOPE、ONELEVEL_SCOPE、SUBTREE_SCOPE のどれか 1 つです。
349         * 指定文字列は、それぞれ『OBJECT』『ONELEVEL』『SUBTREE』です。
350         * (初期値:システム定数のLDAP_SEARCH_SCOPE[={@og.value SystemData#LDAP_SEARCH_SCOPE}])。
351         *
352         * @param       scope SearchControlsの検索範囲 [OBJECT/ONELEVEL/SUBTREE]
353         * @see         org.opengion.hayabusa.common.SystemData#LDAP_SEARCH_SCOPE
354         */
355        public void setSearchScope( final String scope ) {
356                searchScope = nval( getRequestParameter( scope ), searchScope );
357        }
358
359        /**
360         * 【TAG】これらの SearchControls の時間制限をミリ秒単位で設定します(初期値:0[無制限])。
361         *
362         * @og.tag
363         * 値が 0 の場合、無制限に待つことを意味します。
364         *
365         * @param       limit ミリ秒単位の時間制限(初期値:無制限)
366         */
367        public void setTimeLimit( final String limit ) {
368                timeLimit = nval( getRequestParameter( limit ), timeLimit );
369        }
370
371        /**
372         * 【TAG】検索中のリンクへの間接参照を有効または無効[true/false]にします(初期値:false)。
373         *
374         * @og.tag 検索中のリンクへの間接参照を有効または無効にします。
375         * true:有効で、リンクを間接参照可能になります。
376         * 初期値は、false:無効です。
377         *
378         * @param       deref 間接参照 [true:有効/false:無効]
379         */
380        public void setDerefLinkFlag( final String deref ) {
381                derefLinkFlag = nval( getRequestParameter( deref ), derefLinkFlag );
382        }
383
384        /**
385         * 【TAG】結果の一部としてオブジェクトを返す[true:有効/false:無効]かどうか設定します(初期値:false)。
386         *
387         * @og.tag
388         * true:有効にした場合、オブジェクトが返されます。
389         * false:無効にした場合、オブジェクトの名前およびクラスだけが返されます。
390         * 初期値は、false:無効 です。
391         *
392         * @param       pbjflag オブジェクト返し [true:有効/false:無効]
393         */
394        public void setReturningObjFlag( final String pbjflag ) {
395                returningObjFlag = nval( getRequestParameter( pbjflag ), returningObjFlag );
396        }
397
398        /**
399         * 【TAG】LDAPデータの最大検索件数をセットします(初期値:0[無制限])。
400         *
401         * @og.tag
402         * DBTableModelのデータとして登録する最大検索件数をこの値に設定します。
403         * サーバーのメモリ資源と応答時間の確保の為です。
404         * 初期値は、0 は、無制限です。
405         *
406         * @param       count 最大件数
407         */
408        public void setMaxRowCount( final String count ) {
409                maxRowCount = nval( getRequestParameter( count ),maxRowCount );
410        }
411
412        /**
413         * 【TAG】検索の一部として返される属性をCSVで複数指定します。
414         *
415         * @og.tag
416         * null は属性が何も返されないことを示します。
417         * このメソッドからは、空の配列をセットすることは出来ません。
418         *
419         * @og.rev 3.5.6.2 (2004/07/05) 先に配列に分解してからリクエスト変数の値を取得
420         * @og.rev 3.7.0.4 (2005/03/18) リクエスト変数の値を取得後、分解します。
421         *
422         * @param       val 返される属性を識別する属性ID(CSV形式)
423         */
424        public void setAttributes( final String val ) {
425                final String att = nval( getRequestParameter( val ),null );
426                if( att != null ) {
427                        attrs = StringUtil.csv2Array( att );
428                }
429        }
430
431        /**
432         * 【TAG】作成する DBTableModel のカラム名をCSV形式で指定します。
433         *
434         * @og.tag
435         * なにも指定しない場合は、attributes 属性が使用されます。
436         * LDAP検索結果に、別名をつけるイメージで使用します。
437         *
438         * @og.rev 3.7.1.0 (2005/04/26) 新規追加
439         *
440         * @param       clm カラム名(CSV形式)
441         */
442        public void setColumns( final String clm ) {
443                final String cl = nval( getRequestParameter( clm ),null );
444                if( cl != null ) {
445                        columns = StringUtil.csv2Array( cl );
446                }
447        }
448
449        /**
450         * 【TAG】初期コンテキストファクトリを指定します
451         *              (初期値:LDAP_INITIAL_CONTEXT_FACTORY[={@og.value SystemData#LDAP_INITIAL_CONTEXT_FACTORY}])。
452         *
453         * @og.tag
454         * 例)com.sun.jndi.ldap.LdapCtxFactory
455         * (初期値:システム定数のLDAP_INITIAL_CONTEXT_FACTORY[={@og.value SystemData#LDAP_INITIAL_CONTEXT_FACTORY}])。
456         *
457         * @param       ctx 初期コンテキストファクトリ
458         * @see         org.opengion.hayabusa.common.SystemData#LDAP_INITIAL_CONTEXT_FACTORY
459         */
460        public void setInitctx( final String ctx ) {
461                initctx = nval( getRequestParameter( ctx ), initctx );
462        }
463
464        /**
465         * 【TAG】サービスプロバイダの構成情報を指定します
466         *              (初期値:LDAP_PROVIDER_URL[={@og.value SystemData#LDAP_PROVIDER_URL}])。
467         *
468         * @og.tag
469         * プロトコルとサーバーとポートを指定します。
470         * 例)『ldap://ldap.opengion.org:389』
471         * (初期値:システム定数のLDAP_PROVIDER_URL[={@og.value SystemData#LDAP_PROVIDER_URL}])。
472         *
473         * @param       url サービスプロバイダの構成情報
474         * @see         org.opengion.hayabusa.common.SystemData#LDAP_PROVIDER_URL
475         */
476        public void setProviderURL( final String url ) {
477                providerURL = nval( getRequestParameter( url ), providerURL );
478        }
479
480        /**
481         * 【TAG】検索するコンテキストまたはオブジェクトの名前を設定します
482         *              (初期値:LDAP_SEARCH_BASE[={@og.value SystemData#LDAP_SEARCH_BASE}])。
483         *
484         * @og.tag
485         * 例)『soOUID=employeeuser,o=opengion,c=JP』
486         * (初期値:システム定数のLDAP_SEARCH_BASE[={@og.value SystemData#LDAP_SEARCH_BASE}])。
487         *
488         * @param       base 検索ベース
489         * @see         org.opengion.hayabusa.common.SystemData#LDAP_SEARCH_BASE
490         */
491        public void setSearchbase( final String base ) {
492                searchbase = nval( getRequestParameter( base ), searchbase );
493        }
494
495        /**
496         * 【TAG】検索に使用するフィルタ式(例:belongOUID=61200)。
497         *
498         * @og.tag
499         * 例)『belongOUID=61200』
500         *
501         * @param       siki フィルタ式
502         */
503        public void setFilter( final String siki ) {
504                filter = nval( getRequestParameter( siki ), filter );
505        }
506
507        /**
508         * 【TAG】属性の取得元のオブジェクトの名前を設定します
509         *              (初期値:LDAP_ENTRYDN[={@og.value SystemData#LDAP_ENTRYDN}])。
510         *
511         * @og.tag
512         * 例)『soOUID=opengion-sys,o=opengion,c=JP』
513         * (初期値:システム定数のLDAP_ENTRYDN[={@og.value SystemData#LDAP_ENTRYDN}])。
514         *
515         * @og.rev 4.2.2.0 (2008/05/10) 初期値変更
516         *
517         * @param       dn 取得元のオブジェクトの名前
518         * @see         org.opengion.hayabusa.common.SystemData#LDAP_ENTRYDN
519         */
520        public void setEntrydn( final String dn ) {
521                entrydn = nval( getRequestParameter( dn ), entrydn );
522        }
523
524        /**
525         * 【TAG】属性の取得元のオブジェクトのパスワードを設定します
526         *              (初期値:LDAP_PASSWORD[={@og.value SystemData#LDAP_PASSWORD}])。
527         *
528         * @og.tag
529         * (初期値:システム定数のLDAP_PASSWORD[={@og.value SystemData#LDAP_PASSWORD}])。
530         *
531         * @og.rev 4.2.2.0 (2008/05/10) 新規追加
532         *
533         * @param       pwd パスワード
534         * @see         org.opengion.hayabusa.common.SystemData#LDAP_PASSWORD
535         */
536        public void setPassword( final String pwd ) {
537                password = nval( getRequestParameter( pwd ), password );
538        }
539
540        /**
541         * 【TAG】(通常は使いません)結果のDBTableModelを、sessionに登録するときのキーを指定します
542         *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value HybsSystem#TBL_MDL_KEY}])。
543         *
544         * @og.tag
545         * 検索結果より、DBTableModelオブジェクトを作成します。これを、下流のviewタグ等に
546         * 渡す場合に、通常は、session を利用します。その場合の登録キーです。
547         * query タグを同時に実行して、結果を求める場合、同一メモリに配置される為、
548         * この tableId 属性を利用して、メモリ空間を分けます。
549         *              (初期値:HybsSystem#TBL_MDL_KEY[={@og.value HybsSystem#TBL_MDL_KEY}])。
550         *
551         * @param       id テーブルID (sessionに登録する時のID)
552         */
553        public void setTableId( final String id ) {
554                tableId = nval( getRequestParameter( id ), tableId );
555        }
556
557        /**
558         * 【TAG】検索した結果を表示する表示順をファイル属性名で指定します。
559         *
560         * @og.tag
561         * attributes 属性で指定するキー、または、LDAPから返されたキーについて
562         * その属性でソートします。逆順を行う場合は、DESC を指定のカラム名の後ろに
563         * 付けて下さい。
564         *
565         * @param       ordr    ソートキー
566         */
567        public void setOrderBy( final String ordr ) {
568                orderBy = nval( getRequestParameter( ordr ), orderBy );
569                if( orderBy != null ) { orderBy = orderBy.toUpperCase(Locale.JAPAN) ; }
570        }
571
572        /**
573         * 【TAG】コマンド (NEW,RENEW)をセットします(初期値:NEW)。
574         *
575         * @og.tag
576         * コマンドは,HTMLから(get/post)指定されますので,CMD_xxx で設定される
577         * フィールド定数値のいづれかを、指定できます。
578         * 何も設定されない、または、null の場合は、"NEW" が初期値にセットされます。
579         *
580         * @param       cmd コマンド (public static final 宣言されている文字列)
581         * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.LDAPQueryTag.CMD_NEW">コマンド定数</a>
582         */
583        public void setCommand( final String cmd ) {
584                final String cmd2 = getRequestParameter( cmd );
585                if( cmd2 != null && cmd2.length() > 0 ) { command = cmd2.toUpperCase(Locale.JAPAN); }
586        }
587
588        /**
589         * 【TAG】検索結果を画面上に表示するメッセージリソースIDを指定します
590         *              (初期値:VIEW_DISPLAY_MSG[={@og.value SystemData#VIEW_DISPLAY_MSG}])。
591         *
592         * @og.tag
593         * ここでは、検索結果の件数や登録された件数をまず出力し、
594         * その次に、ここで指定したメッセージをリソースから取得して
595         * 表示します。
596         * 件数を表示させる場合は、displayMsg = "MSG0033"[ 件検索しました] をセットしてください。
597         * 表示させたくない場合は, displayMsg = "" をセットしてください。
598         * (初期値:システム定数のVIEW_DISPLAY_MSG[={@og.value SystemData#VIEW_DISPLAY_MSG}])。
599         *
600         * @param       id 処理結果表示メッセージID
601         */
602        public void setDisplayMsg( final String id ) {
603                displayMsg = getRequestParameter( id );
604        }
605
606        /**
607         * 【TAG】検索結果がゼロ件の場合に表示するメッセージリソースIDを指定します(初期値:MSG0077[対象データはありませんでした])。
608         *
609         * @og.tag
610         * ここでは、検索結果がゼロ件の場合のみ、特別なメッセージを表示させます。
611         * 従来は、displayMsg と兼用で、『0 件検索しました』という表示でしたが、
612         * displayMsg の初期表示は、OFF になりましたので、ゼロ件の場合のみ別に表示させます。
613         * 表示させたくない場合は, notfoundMsg = "" をセットしてください。
614         * 初期値は、MSG0077[対象データはありませんでした]です。
615         *
616         * @param       id ゼロ件時表示メッセージID
617         */
618        public void setNotfoundMsg( final String id ) {
619                final String ids = getRequestParameter( id );
620                if( ids != null ) { notfoundMsg = ids; }
621        }
622
623        /**
624         * 【TAG】検索データが最大検索数をオーバーした場合に表示するメッセージリソースIDを指定します
625         *              (初期値:MSG0007[検索結果が、制限行数を超えましたので、残りはカットされました])。
626         *
627         * @og.tag
628         * 表示させたくない場合は, overflowMsg = "" をセットしてください。
629         *
630         * @param       id 最大検索数オーバー時メッセージID
631         */
632        public void setOverflowMsg( final String id ) {
633                overflowMsg = getRequestParameter( id );
634        }
635
636        /**
637         * 【TAG】(通常は使いません)タグで処理される処理がメインとなるトランザクション処理かどうかを指定します(初期値:false)。
638         *
639         * @og.tag
640         * この値は、ファイルダウンロード処理に影響します。この値がtrueに指定された時にcommitされたDBTableModelが
641         * ファイルダウンロードの対象の表になります。
642         *
643         * このパラメーターは、通常、各タグにより実装され、ユーザーが指定する必要はありません。
644         * 但し、1つのJSP内でDBTableModelが複数生成される場合に、前に処理したDBTableModelについてファイルダウンロードをさせたい
645         * 場合は、後ろでDBTableModelを生成するタグで、明示的にこの値をfalseに指定することで、ファイルダウンロード処理の対象から
646         * 除外することができます。
647         *
648         * @og.rev 5.1.6.0 (2010/05/01) 新規作成
649         *
650         * @param  flag メイントランザクションかどうか [true:メイン/false:その他]
651         */
652        public void setMainTrans( final String flag ) {
653                isMainTrans = nval( getRequestParameter( flag ),isMainTrans );
654        }
655
656        /**
657         * このオブジェクトの文字列表現を返します。
658         * 基本的にデバッグ目的に使用します。
659         *
660         * @return このクラスの文字列表現
661         * @og.rtnNotNull
662         */
663        @Override
664        public String toString() {
665                return ToString.title( this.getClass().getName() )
666                                .println( "VERSION"                             ,VERSION                )
667                                .println( "initctx"                     ,initctx                )
668                                .println( "providerURL"                 ,providerURL    )
669                                .println( "entrydn"                     ,entrydn                )
670                                .println( "searchbase"                  ,searchbase             )
671                                .println( "filter"                              ,filter                 )
672                                .println( "searchScope"                 ,searchScope    )
673                                .println( "COUNTLIMIT"                  ,COUNTLIMIT             )
674                                .println( "timeLimit"                   ,timeLimit              )
675                                .println( "attrs"                               ,attrs                  )
676                                .println( "columns"                             ,columns                )
677                                .println( "returningObjFlag"    ,returningObjFlag)
678                                .println( "derefLinkFlag"               ,derefLinkFlag  )
679                                .println( "tableId"                     ,tableId                )
680                                .println( "orderBy"                             ,orderBy                )
681                                .println( "command"                             ,command                )
682                                .println( "executeCount"                ,executeCount   )
683                                .println( "errCode"                             ,errCode                )
684                                .println( "maxRowCount"                 ,maxRowCount    )
685                                .println( "displayMsg"                  ,displayMsg     )
686                                .println( "overflowMsg"                 ,overflowMsg    )
687                                .println( "Other..."                    ,getAttributes().getAttribute() )
688                                .fixForm().toString() ;
689        }
690}