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 static org.opengion.fukurou.util.StringUtil.*;
019
020import java.io.File;
021import java.io.IOException;
022import java.util.List;
023
024import org.opengion.fukurou.util.FileString;
025import org.opengion.fukurou.util.FileUtil;
026import org.opengion.fukurou.util.StringUtil ;
027import org.opengion.hayabusa.common.HybsSystem;
028import org.opengion.hayabusa.common.HybsSystemException;
029import org.opengion.hayabusa.io.HybsFileOperationFactory;
030
031/**
032 * 各種アクションを指定して、ファイル関連の操作をおこなうタグです。
033 *
034 * 各種アクション に応じた振る舞いを行います。
035 * 結果については、false の場合は、body 要素を表示して、終了します。
036 * これは、BODYにエラーメッセージを書いておくことを想定した作りになっています。
037
038 * 判定結果を反転したい場合は、notEquals 属性を使用してください。また、
039 * 結果に応じて、処理を止めたくない場合は、useStop 属性を false に指定することで、
040 * 後続処理を実行できます。
041 *
042 * [各種アクション]
043 *       canRead          読み込めるかどうかを判定。
044 *       canWrite         変更できるかどうか判定。
045 *       createNewFile    空の新しいファイルを不可分 (atomic) に生成。(そのファイルがまだ存在しない場合だけ)
046 *       delete           ファイルまたはディレクトリを削除。
047 *       renameTo         ファイルまたはディレクトリ名を変更。
048 *       exists           ファイルが存在するかどうか判定。
049 *       isDirectory      ファイルがディレクトリであるかどうか判定。
050 *       isFile           ファイルが普通のファイルかどうか判定。
051 *       isHidden         ファイルが隠しファイルかどうか判定。
052 *       mkdir            ディレクトリを生成。
053 *       mkdirs           ディレクトリを複数生成。
054 *       read             ファイルを読み込んでjspWriterに出力
055 *       existsLength     ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
056 *       copy             ファイルまたはディレクトリをコピー(file1 ⇒ file2 にコピー)。
057 *       zip              ファイルまたはディレクトリをZIPファイルに圧縮します。(file1⇒file2)
058 *
059 * @og.formSample
060 * ●形式:<og:file action="…" fileURL="…" >・・・</og:file>
061 * ●body:あり(EVAL_BODY_INCLUDE:BODYをインクルードし、{@XXXX} は解析しません)
062 *
063 * ●Tag定義:
064 *   <og:file
065 *       action           ○【TAG】アクション(canRead,canWrite,createNewFile,delete,exists,isDirectory,isFile,isHidden,mkdir,mkdirs)を指定します(必須)。
066 *       fileURL            【TAG】操作するファイルのディレクトリを指定します (初期値:FILE_URL[=filetemp/])
067 *       file1              【TAG】基準となるファイル名を指定します(コマンドの左辺のファイル名です)
068 *       file2              【TAG】処理結果となるファイル名を指定します(コマンドの右辺のファイル名です)
069 *       notEquals          【TAG】判定結果を反転させるかどうか[true/false]を指定します(初期値:false)
070 *       useStop            【TAG】エラー時BODYを処理後に停止するかどうか[true/false]を指定します(初期値:true)
071 *       encode             【TAG】ファイルを読み込む(action="READ")際のエンコードを指定します(初期値:OS依存文字コード)
072 *       caseKey            【TAG】このタグ自体を利用するかどうかの条件キーを指定します(初期値:null) 5.7.7.2 (2014/06/20)
073 *       caseVal            【TAG】このタグ自体を利用するかどうかの条件値を指定します(初期値:null) 5.7.7.2 (2014/06/20)
074 *       caseNN             【TAG】指定の値が、null/ゼロ文字列 でない場合(Not Null=NN)は、このタグは使用されます(初期値:true) 5.7.7.2 (2014/06/20)
075 *       caseNull           【TAG】指定の値が、null/ゼロ文字列 の場合は、このタグは使用されます(初期値:true) 5.7.7.2 (2014/06/20)
076 *       fromStorageType    【TAG】テンプレートファイルの読み込み元ストレージタイプを指定します。
077 *       fromBucketName      【TAG】テンプレートファイルの読み込み元バケット名を指定します。
078 *       toStorageType          【TAG】生成した帳票の出力先ストレージタイプを指定します。
079 *       toBucketName        【TAG】生成した帳票の出力先バケット名を指定します。
080 *       debug              【TAG】デバッグ情報を出力するかどうか[true/false]を指定します(初期値:false)
081 *   >   ... Body ...
082 *   </og:file>
083 *
084 * ●使用例
085 *    ・ファイルの存在チェック→存在しなければエラーメッセージを表示。
086 *        <og:file action="exists" fileURL="N:/CIR/" file1="{@USER.LKISB}/{@USER.LDNO1KAI}.cir/001.sht">
087 *            <og:message lbl="RKE_0157" comment="回路図が存在しません。" />
088 *        </og:file>
089 *
090 *    ・N:/Filetemp/にユーザーディレクトリが存在しなければ作成。→失敗した場合エラーメッセージを表示。
091 *        <og:file action="mkdir" fileURL="N:/Filetemp/{@USER.ID}" >
092 *            <og:message comment="エラーが発生しました。システム管理者に連絡してください。" />
093 *        </og:file>
094 *
095 *    ・N:/Filetemp/test.txt ファイルの削除。ファイルが存在しなくても処理を続ける。
096 *        <og:file action="delete" fileURL="N:/Filetemp/" file1="test.txt" useStop="false" >
097 *            <og:message comment="ファイルは存在しませんでした。" />
098 *        </og:file>
099 *
100 * @og.rev 5.10.9.0 (2019/03/01) oota クラウドストレージ対応を追加。(Fileクラスを拡張)
101 * 
102 * @og.group その他部品
103 *
104 * @version  4.0
105 * @author       Kazuhiko Hasegawa
106 * @since    JDK5.0,
107 */
108public class FileTag extends CommonTagSupport {
109        //* このプログラムのVERSION文字列を設定します。   {@value} */
110        private static final String VERSION = "5.7.7.2 (2014/06/20)" ;
111
112        private static final long serialVersionUID = 577220140620L ;
113
114        /** action 引数に渡す事の出来る アクションコマンド  読み込めるかどうか {@value} */
115        public static final String ACT_CANREAD  = "canRead" ;
116        /** action 引数に渡す事の出来る アクションコマンド  変更できるかどうか {@value} */
117        public static final String ACT_CANWRITE    = "canWrite" ;
118        /** action 引数に渡す事の出来る アクションコマンド  空の新しいファイルを不可分 (atomic) に生成します (そのファイルがまだ存在しない場合だけ {@value} */
119        public static final String ACT_CREATENEWFILE    = "createNewFile" ;
120        /** action 引数に渡す事の出来る アクションコマンド  ファイルまたはディレクトリを削除{@value}       */
121        public static final String ACT_DELETE    = "delete" ;
122        /** action 引数に渡す事の出来る アクションコマンド  ファイルが存在するかどうか {@value} */
123        public static final String ACT_EXISTS    = "exists" ;
124        /** action 引数に渡す事の出来る アクションコマンド  ファイルがディレクトリであるかどうか{@value}     */
125        public static final String ACT_ISDIRECTORY        = "isDirectory" ;
126        /** action 引数に渡す事の出来る アクションコマンド  ファイルが普通のファイルかどうか{@value}       */
127        public static final String ACT_ISFILE    = "isFile" ;
128        /** action 引数に渡す事の出来る アクションコマンド  ファイルが隠しファイルかどうか {@value} */
129        public static final String ACT_ISHIDDEN    = "isHidden" ;
130        /** action 引数に渡す事の出来る アクションコマンド  ディレクトリを生成します。 {@value} */
131        public static final String ACT_MKDIR    = "mkdir" ;
132        /** action 引数に渡す事の出来る アクションコマンド  ディレクトリを生成します。 {@value} */
133        public static final String ACT_MKDIRS   = "mkdirs" ;
134        /** action 引数に渡す事の出来る アクションコマンド  ファイル名を変更します。 {@value} */
135        public static final String ACT_RENAMETO = "renameTo" ;          // 3.5.6.5 (2004/08/09)
136        /** action 引数に渡す事の出来る アクションコマンド  ファイルを読み込んで表示します。 {@value} */
137        public static final String ACT_READ     = "read" ;              // 3.6.0.0 (2004/09/25)
138        /** action 引数に渡す事の出来る アクションコマンド  ファイルサイズが0Byte以上のファイルが存在するかどうか判定。 {@value} */
139        public static final String ACT_EXISTSLENGTH      = "existsLength" ;             // 3.8.5.2 (2006/05/31)
140        /** action 引数に渡す事の出来る アクションコマンド  ファイルまたはディレクトリをコピーします。 {@value} */
141        public static final String ACT_COPY      = "copy" ;             // 5.3.6.0 (2011/06/01)
142        /** action 引数に渡す事の出来る アクションコマンド  ZIP圧縮します。 {@value} */
143        public static final String ACT_ZIP       = "zip" ;              // 5.9.2.2 (2015/11/20)
144
145        /** action 引数に渡す事の出来る コマンド リスト  */
146        private static final String[] ACTION_LIST = new String[] {
147                ACT_CANREAD , ACT_CANWRITE , ACT_CREATENEWFILE , ACT_DELETE , ACT_EXISTS , ACT_ISDIRECTORY ,
148                ACT_ISFILE , ACT_ISHIDDEN , ACT_MKDIR , ACT_MKDIRS , ACT_RENAMETO , ACT_READ , ACT_EXISTSLENGTH , ACT_COPY , ACT_ZIP };
149
150        private String  fileURL         = HybsSystem.sys( "FILE_URL" );
151        private String  file1           = "";
152        private String  file2           = null;
153        private String  action          = null;
154        private boolean rtnCode         = false;
155
156        private boolean notEquals       = false;        // 3.8.5.2 (2006/05/31) 判定結果を反転させて処理します。
157        private boolean useStop         = true;         // 3.8.5.2 (2006/05/31) エラー時BODYを処理後に停止(true)するかどうか
158
159        private String encode           = null;         // 5.1.9.0 (2010/08/01) READ時のエンコード指定
160
161        private String fromStorageType  = null;         // 5.10.9.0 (2019/03/01) 
162        private String fromBucketName   = null;         // 5.10.9.0 (2019/03/01)
163        private String toStorageType    = null;         // 5.10.9.0 (2019/03/01)
164        private String toBucketName             = null;         // 5.10.9.0 (2019/03/01)
165        
166        /**
167         * Taglibの開始タグが見つかったときに処理する doStartTag() を オーバーライドします。
168         *
169         * @og.rev 3.6.0.0 (2004/09/25) file オブジェクトの作成を actionExec 移動
170         * @og.rev 3.8.5.2 (2006/05/31) notEquals追加。 判定結果を反転させて処理します。
171         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
172         *
173         * @return      後続処理の指示
174         */
175        @Override
176        public int doStartTag() {
177                // 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
178                if( useTag() ) {
179                        try {
180                                rtnCode = notEquals ^ actionExec( action );             // 3.8.5.2 (2006/05/31) 排他的論理和(XOR)
181                        }
182                        catch( IOException ex ) {
183                                String errMsg = "指定のアクションは実行できません。アクションエラー"
184                                                                + HybsSystem.CR
185                                                                + "action=[" + action + "] , "
186                                                                + "  fileURL=[" + fileURL + "]"
187                                                                + "  file1=[" + file1 + "]"
188                                                                + "  file2=[" + file2 + "]" ;
189                                throw new HybsSystemException( errMsg,ex );             // 3.5.5.4 (2004/04/15) 引数の並び順変更
190                        }
191
192                        if( rtnCode ) { return SKIP_BODY ; }                    // Body を評価しない
193                        else {                  return EVAL_BODY_INCLUDE ; }    // Body インクルード( extends TagSupport 時)
194                }
195
196                return SKIP_BODY ;
197        }
198
199        /**
200         * Taglibの終了タグが見つかったときに処理する doEndTag() を オーバーライドします。
201         *
202         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
203         * @og.rev 3.8.5.2 (2006/05/31) useStop 追加。 エラー時BODYを処理後に停止(true)するかどうか
204         * @og.rev 5.7.7.2 (2014/06/20) caseKey,caseVal,caseNN,caseNull 属性を追加
205         *
206         * @return      後続処理の指示
207         */
208        @Override
209        public int doEndTag() {
210                debugPrint();           // 4.0.0 (2005/02/28)
211
212                if( useTag() ) {
213                        return ( useStop && !rtnCode ) ? SKIP_PAGE : EVAL_PAGE ;
214                }
215
216                return EVAL_PAGE ;
217        }
218
219        /**
220         * タグリブオブジェクトをリリースします。
221         * キャッシュされて再利用されるので、フィールドの初期設定を行います。
222         *
223         * @og.rev 2.0.0.4 (2002/09/27) カスタムタグの release() メソッドを、追加
224         * @og.rev 3.1.1.2 (2003/04/04) Tomcat4.1 対応。release2() を doEndTag()で呼ぶ。
225         * @og.rev 3.6.0.0 (2004/09/24) columns 、tableId 、file 削除
226         * @og.rev 3.8.5.2 (2006/05/31) notEquals 、useStop 追加
227         * @og.rev 5.1.9.0 (2010/08/01) READ時のエンコード指定
228         * @og.rev 5.10.9.0 (2019/03/01)  storageType1,bucketName1,storageType2,bucketName2 追加
229         *
230         */
231        @Override
232        protected void release2() {
233                super.release2();
234                fileURL         = HybsSystem.sys( "FILE_URL" );
235                file1           = "";
236                file2           = null;
237                action          = null;
238                rtnCode         = false;
239                notEquals       = false;        // 3.8.5.2 (2006/05/31) 判定結果を反転させて処理します。
240                useStop         = true;         // 3.8.5.2 (2006/05/31) エラー時BODYを処理後に停止(true)するかどうか
241                encode          = null;         // 5.1.9.0 (2010/08/01) READ時のエンコード指定
242                fromStorageType = null;         // 5.10.9.0 (2019/03/01) 
243                fromBucketName  = null;         // 5.10.9.0 (2019/03/01)
244                toStorageType   = null;         // 5.10.9.0 (2019/03/01)
245                toBucketName            = null;         // 5.10.9.0 (2019/03/01)
246        }
247
248        /**
249         * アクションを実行します。
250         * アクションは,指定のアクションコマンドに対応する処理を入力データに
251         * 対して行います。
252         *
253         * @og.rev 3.0.0.0 (2002/12/25) ACTION_LIST のチェックを削除
254         * @og.rev 3.6.0.0 (2004/09/25) ACT_read を追加 , file オブジェクトを移動
255         * @og.rev 3.8.5.2 (2006/05/31) existsLength 追加
256         * @og.rev 4.0.0.0 (2007/11/28) メソッドの戻り値をチェックします。
257         * @og.rev 5.1.9.0 (2010/08/01) READ時のエンコード指定
258         * @og.rev 5.3.6.0 (2011/06/01) ACT_copy 対応
259         * @og.rev 5.7.1.1 (2013/12/13) copy元(file1)のファイルが存在しなければ、エラーにします。
260         * @og.rev 5.9.2.2 (2015/11/12) ACT_ZIP追加
261         * @og.rev 5.10.9.0 (2019/03/01) クラウドストレージ対応。
262         *
263         * @param       action アクションコマンド(public static final 宣言されている文字列)
264         *
265         * @return      実行後のデータ
266         */
267        private boolean actionExec( final String action ) throws IOException {
268                String directory = HybsSystem.url2dir( fileURL );
269                // 5.10.9.0 (2019/03/01) MODIFY
270//              File file = new File( StringUtil.urlAppend( directory,file1 ) );
271                File file = HybsFileOperationFactory.create(fromStorageType, fromBucketName, directory, file1);
272                
273                boolean rtnVal = false;
274                if( action != null ) {
275                        if(      ACT_CANREAD.equalsIgnoreCase(           action ) ) { rtnVal = file.canRead(); }
276                        else if( ACT_CANWRITE.equalsIgnoreCase(          action ) ) { rtnVal = file.canWrite(); }
277                        else if( ACT_CREATENEWFILE.equalsIgnoreCase( action ) ) { rtnVal = file.createNewFile(); }
278                        else if( ACT_DELETE.equalsIgnoreCase(            action ) ) { rtnVal = file.delete(); }
279                        else if( ACT_EXISTS.equalsIgnoreCase(            action ) ) { rtnVal = file.exists(); }
280                        else if( ACT_ISDIRECTORY.equalsIgnoreCase(       action ) ) { rtnVal = file.isDirectory(); }
281                        else if( ACT_ISFILE.equalsIgnoreCase(            action ) ) { rtnVal = file.isFile(); }
282                        else if( ACT_ISHIDDEN.equalsIgnoreCase(          action ) ) { rtnVal = file.isHidden(); }
283                        else if( ACT_MKDIR.equalsIgnoreCase(             action ) ) {
284                                if( file.isDirectory() ) { rtnVal = true; }
285                                else { rtnVal = file.mkdir(); }
286                        }
287                        else if( ACT_MKDIRS.equalsIgnoreCase(            action ) ) { rtnVal = file.mkdirs(); }
288                        else if( ACT_RENAMETO.equalsIgnoreCase(          action ) ) {
289                                if( file2 != null ) {
290                                        // 5.10.9.0 (2019/03/01) MODIFY RENAMETOは基準となるファイルのストレージで、ファイル名を変更します。
291                                        // File newFile = new File( StringUtil.urlAppend( directory,file2 ) );
292                                        File newFile = HybsFileOperationFactory.create(fromStorageType, fromBucketName, directory, file2);
293                                        if( newFile.exists() && !newFile.delete() ) {
294                                                String errMsg = "所定のファイルを削除できませんでした。[" + newFile + "]" ;
295                                                throw new RuntimeException( errMsg );
296                                        }
297                                        rtnVal = file.renameTo( newFile );
298                                }
299                        }
300                        // 3.6.0.0 (2004/09/25) ACT_read を追加
301                        else if( ACT_READ.equalsIgnoreCase(                      action ) ) {
302                                if( file.isFile() ) {
303                                        FileString fs = new FileString();
304                                        fs.setFilename( StringUtil.urlAppend( directory,file1 ) );
305                                        if( encode != null ) { fs.setEncode( encode ); } // 5.1.9.0 (2010/08/01) READ時のエンコード指定
306                                        String val = fs.getValue();
307
308                                        jspPrint( nval( getRequestParameter( val ),"" ) );
309                                        rtnVal = true;
310                                }
311                                else {
312                                        String errMsg = "ファイルが存在しないか、ファイルではありません。"
313                                                        + HybsSystem.CR
314                                                        + "action=[" + action + "] , "
315                                                        + "  fileURL=[" + fileURL + "]"
316                                                        + "  directory=[" + directory + "]"
317                                                        + "  file1=[" + file1 + "]" ;
318                                        throw new HybsSystemException( errMsg );
319                                }
320                        }
321                        // 3.8.5.2 (2006/05/31) ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
322                        else if( ACT_EXISTSLENGTH.equalsIgnoreCase( action ) ) {
323                                rtnVal = file.exists() && file.length() > 0L ;
324                        }
325                        // 5.3.6.0 (2011/06/01) ファイルコピー対応
326                        // 6.0.0.1 (2014/04/25) These nested if statements could be combined
327                        else if( ACT_COPY.equalsIgnoreCase( action ) && file2 != null ) {
328                                // 5.10.9.0 (2019/03/01) 
329//                               File newFile = new File( StringUtil.urlAppend( directory,file2 ) );
330                                File newFile = HybsFileOperationFactory.create(toStorageType, toBucketName, StringUtil.urlAppend(directory, file2));
331                                                
332                                if( file.isFile() ) {
333                                        // FileUtil.copy 側で、toFile のフォルダを作成します。
334                                        rtnVal = FileUtil.copy( file, newFile );
335                                }
336                                else if( file.isDirectory() ) {
337                                        rtnVal = FileUtil.copyDirectry( file, newFile );
338                                }
339                                // 5.7.1.1 (2013/12/13) copy元(file1)のファイルが存在しなければ、エラーにします。
340                                else if( !file.exists() ) {
341                                        String errMsg = "copy元(file1)のファイルが存在しません。"
342                                                        + HybsSystem.CR
343                                                        + "action=[" + action + "] , "
344                                                        + "  fileURL=[" + fileURL + "]"
345                                                        + "  directory=[" + directory + "]"
346                                                        + "  file1=[" + file1 + "]" 
347                                                        + "  file2=[" + file2 + "]" ;
348                                        throw new HybsSystemException( errMsg );
349                                }
350                        }
351                        // 5.9.2.2 (2015/11/20) zip追加
352                        else if( ACT_ZIP.equalsIgnoreCase( action ) && file2 != null ){
353                                //あるかないかだけ見る
354                                if( file2.toLowerCase().indexOf( ".zip" ) < 0 ){ 
355                                        file2 = file2 + ".zip";
356                                }
357                                List<String> ziplist = org.opengion.fukurou.util.ZipFileUtil.compress( file.toString(), file2 );
358                        }
359                }
360                else {
361                        String errMsg = "アクションが指定されていません。アクション NULL エラー"
362                                                        + HybsSystem.CR
363                                                        + "  file=[" + file1 + "]" ;
364                        throw new HybsSystemException( errMsg );
365                }
366
367                return rtnVal;
368        }
369
370        /**
371         * 【TAG】アクション(canRead,canWrite,createNewFile,delete,exists,isDirectory,isFile,isHidden,mkdir,mkdirs)を指定します。
372         *
373         * @og.tag
374         * アクションは,HTMLから(get/post)指定されますので,ACT_xxx で設定される
375         * フィールド定数値のいづれかを、指定できます。
376         * 処理の結果が、false の場合は、body 要素を表示して終了します。
377         * useStop 属性と、notEquals 属性によって、上記の振る舞いをけることが可能です。
378         *
379         * canRead          読み込めるかどうかを判定。
380         * canWrite         変更できるかどうか判定。
381         * createNewFile    空の新しいファイルを不可分 (atomic) に生成。(そのファイルがまだ存在しない場合だけ)
382         * delete           ファイルまたはディレクトリを削除。
383         * renameTo         ファイルまたはディレクトリ名を変更。
384         * exists           ファイルが存在するかどうか判定。
385         * isDirectory      ファイルがディレクトリであるかどうか判定。
386         * isFile           ファイルが普通のファイルかどうか判定。
387         * isHidden         ファイルが隠しファイルかどうか判定。
388         * mkdir            ディレクトリを生成。
389         * mkdirs           ディレクトリを複数生成。
390         * read             ファイルを読み込んでjspWriterに出力
391         * existsLength     ファイルサイズが0Byte以上のファイルが存在するかどうか判定。
392         * copy             ファイルまたはディレクトリをコピー(file1 ⇒ file2 にコピー)。
393         *
394         * @og.rev 3.0.0.0 (2002/12/25) ACTION_LIST のチェックを導入
395         * @og.rev 3.5.6.2 (2004/07/05) 文字列の連結にStringBuilderを使用します。
396         *
397         * @param       cmd アクション文字列
398         * @see         <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.FileTag.ACT_canRead">アクション定数</a>
399         */
400        public void setAction( final String cmd ) {
401                action = getRequestParameter( cmd );
402
403                if( ! check( action, ACTION_LIST ) ) {
404
405                        StringBuilder errMsg = new StringBuilder( HybsSystem.BUFFER_MIDDLE );
406                        errMsg.append( "指定のアクションは実行できません。アクションエラー" );
407                        errMsg.append( HybsSystem.CR );
408                        errMsg.append( "action=[" ).append( action ).append( "] " );
409                        errMsg.append( HybsSystem.CR );
410
411                        for( int i=0; i<ACTION_LIST.length; i++ ) {
412                                errMsg.append( " | " );
413                                errMsg.append( ACTION_LIST[i] );
414                        }
415                        errMsg.append( " | " );
416                        throw new HybsSystemException( errMsg.toString() );
417                }
418        }
419
420        /**
421         * 【TAG】操作するファイルのディレクトリを指定します
422         *              (初期値:FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。
423         *
424         * @og.tag
425         * この属性で指定されるディレクトリのファイルを操作します。
426         * 指定方法は、通常の fileURL 属性と同様に、先頭が、'/' (UNIX) または、2文字目が、
427         * ":" (Windows)の場合は、指定のURLそのままのディレクトリに、そうでない場合は、
428         * (初期値:システム定数のFILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。
429         *
430         * @og.rev 4.0.0.0 (2005/01/31) urlAppend メソッドの利用
431         * @og.rev 4.0.0.0 (2007/11/20) 指定されたディレクトリ名の最後が"\"or"/"で終わっていない場合に、"/"を付加する。
432         *
433         * @param       url ファイルURL
434         * @see         org.opengion.hayabusa.common.SystemData#FILE_URL
435         */
436        public void setFileURL( final String url ) {
437                String furl = nval( getRequestParameter( url ),null );
438                if( furl != null ) {
439                        char ch = furl.charAt( furl.length()-1 );
440                        if( ch != '/' && ch != '\\' ) { furl = furl + "/"; }
441                        fileURL = StringUtil.urlAppend( fileURL,furl );
442                }
443        }
444
445        /**
446         * 【TAG】基準となるファイル名を指定します(コマンドの左辺のファイル名です)。
447         *
448         * @og.tag
449         * コマンドの左辺のファイル名です。
450         *
451         * @param       fname ファイル名1
452         */
453        public void setFile1( final String fname ) {
454                file1 = nval( getRequestParameter( fname ),file1 );
455        }
456
457        /**
458         * 【TAG】処理結果となるファイル名を指定します(コマンドの右辺のファイル名です)。
459         *
460         * @og.tag
461         * コマンドの右辺のファイル名です。
462         *
463         * @param       fname ファイル名2
464         */
465        public void setFile2( final String fname ) {
466                file2 = nval( getRequestParameter( fname ),file2 );
467        }
468
469        /**
470         * 【TAG】判定結果を反転させるかどうか[true/false]を指定します(初期値:false)。
471         *
472         * @og.tag
473         * 通常の判定結果において、不成立(false)の場合に、BODY を実行します。
474         * 通常の処理結果の正反対の処理を行います。
475         * 初期値は、通常 (true 以外)です。
476         *
477         * @og.rev 3.8.5.2 (2006/05/31) 新規追加
478         *
479         * @param   flag  [true:反転する/それ以外:通常]
480         */
481        public void setNotEquals( final String flag ) {
482                notEquals = nval( getRequestParameter( flag ),notEquals );
483        }
484
485        /**
486         * 【TAG】エラー時BODYを処理後に停止するかどうか[true/false]を指定します(初期値:true)。
487         *
488         * @og.tag
489         * 処理結果などに応じて、以下の処理を停止したい場合に、使用します。
490         * 通常は、条件を判定後、false の場合に、BODY部を出力(処理)した後に、
491         * 処理を停止します。(useStop="true")
492         * false を指定すると、判定結果に無関係に、以下の処理を実行します。
493         * 処理は継続したいが、警告表示する場合に、useStop="false" を指定します。
494         * 初期値は、停止する ("true")です。
495         *
496         * @og.rev 3.8.5.2 (2006/05/31) 新規追加
497         *
498         * @param   flag  [true:判定する/それ以外:しない]
499         */
500        public void setUseStop( final String flag ) {
501                useStop = nval( getRequestParameter( flag ),useStop );
502        }
503
504        /**
505         * 【TAG】ファイルを読み込む(action="READ")際のエンコードを指定します(初期値:OS依存文字コード)。
506         *
507         * @og.tag
508         * ファイルを読み込む(action="READ")際のエンコードを指定します。
509         * action="READ"以外場合には、この属性値は利用されません。
510         * 指定しない場合は、OS依存文字コードで読み込まれます。
511         *
512         * @og.rev 5.1.9.0 (2010/08/01) 新規作成
513         *
514         * @param   enc ファイル読み込みのエンコード
515         */
516        public void setEncode( final String enc ) {
517                encode = nval( getRequestParameter( enc ),encode );
518        }
519
520        /**
521         * 【TAG】基準となるファイルのストレージタイプを指定します。
522         * 
523         * @og.tag
524         * file1の、
525         * ファイル操作を行うストレージタイプを指定します。
526         * 未設定の場合は、システムリソースのCLOUD_STORAGEを設定します。
527         * defaultが設定された場合は、自身のサーバに処理を行います。
528         * 
529         * @param sto クラウドストレージタイプ
530         */
531        public void setFromStorageType( final String fromSto) {
532                fromStorageType = nval( getRequestParameter( fromSto ), fromStorageType);
533        }
534        
535        /**
536         * 【TAG】基準となるファイルのバケット名を指定します。
537         * 
538         * @og.tag
539         * file1の、
540         * ファイル操作を行うバケット名を指定します。
541         * 未設定の場合は、システムリソースのCLOUD_BUKETを設定します。
542         * 
543         * @param fromBkt バケット名
544         */
545        public void setFromBucketName( final String fromBkt) {
546                fromBucketName = nval( getRequestParameter( fromBkt ), fromBucketName);
547        }
548        
549        /**
550         * 【TAG】処理結果のファイルのストレージタイプを指定します。
551         * 
552         * @og.tag
553         * file2の、
554         * ファイル操作を行うクラウドストレージタイプを指定します。
555         * 未設定の場合は、システムリソースのCLOUD_STORAGEを設定します。
556         * defaultが設定された場合は、自身のサーバに処理を行います。
557         * 
558         * @param toSto ストレージ名
559         */
560        public void setToStorageType( final String toSto) {
561                toStorageType = nval( getRequestParameter( toSto ), toStorageType);
562        }
563        
564        /**
565         * 【TAG】処理結果のファイルのバケット名を指定します。
566         * 
567         * @og.tag
568         * file2の、
569         * ファイル操作を行うバケット名を指定します。
570         * 未設定の場合は、システムリソースのCLOUD_BUKETを設定します。
571         * 
572         * @param toBkt バケット名
573         */
574        public void setToBucketName( final String toBkt) {
575                toBucketName = nval( getRequestParameter( toBkt ), toBucketName);
576        }
577        
578        /**
579         * このオブジェクトの文字列表現を返します。
580         * 基本的にデバッグ目的に使用します。
581         *
582         * @og.rev 5.10.9.0 (2019/03/01) 出力対象に、fromStorageType,fromBbucketName,toStorageType,toBucketNameを追加。
583         * 
584         * @return このクラスの文字列表現
585         */
586        @Override
587        public String toString() {
588                return org.opengion.fukurou.util.ToString.title( this.getClass().getName() )
589                                .println( "VERSION"             ,VERSION        )
590                                .println( "fileURL"             ,fileURL        )
591                                .println( "file1"               ,file1          )
592                                .println( "file2"               ,file2          )
593                                .println( "action"              ,action         )
594                                .println( "rtnCode"             ,rtnCode        )
595                                .println( "notEquals"   ,notEquals      )
596                                .println( "useStop"             ,useStop        )
597                                .println( "fromStorageType"     ,fromStorageType        )
598                                .println( "fromBucketName"      ,fromBucketName         )
599                                .println( "toStorageType"       ,toStorageType          )
600                                .println( "toBucketName"                ,toBucketName           )
601                                .println( "Other..."    ,getAttributes().getAttribute() )
602                                .fixForm().toString() ;
603        }
604}