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 * @og.rev 5.10.14.2 (2019/08/23) リネーム処理修正 263 * 264 * @param action アクションコマンド(public static final 宣言されている文字列) 265 * 266 * @return 実行後のデータ 267 */ 268 private boolean actionExec( final String action ) throws IOException { 269 String directory = HybsSystem.url2dir( fileURL ); 270 // 5.10.9.0 (2019/03/01) MODIFY 271// File file = new File( StringUtil.urlAppend( directory,file1 ) ); 272 273 // 5.10.14.2 (2019/08/23) StringUtil.urlAppendを通していなかったため、ネットワークパスの場合の不具合対応 274// File file = HybsFileOperationFactory.create(fromStorageType, fromBucketName, directory, file1); 275 File file = HybsFileOperationFactory.create(fromStorageType, fromBucketName, StringUtil.urlAppend(directory, file1)); 276 277 boolean rtnVal = false; 278 if( action != null ) { 279 if( ACT_CANREAD.equalsIgnoreCase( action ) ) { rtnVal = file.canRead(); } 280 else if( ACT_CANWRITE.equalsIgnoreCase( action ) ) { rtnVal = file.canWrite(); } 281 else if( ACT_CREATENEWFILE.equalsIgnoreCase( action ) ) { rtnVal = file.createNewFile(); } 282 else if( ACT_DELETE.equalsIgnoreCase( action ) ) { rtnVal = file.delete(); } 283 else if( ACT_EXISTS.equalsIgnoreCase( action ) ) { rtnVal = file.exists(); } 284 else if( ACT_ISDIRECTORY.equalsIgnoreCase( action ) ) { rtnVal = file.isDirectory(); } 285 else if( ACT_ISFILE.equalsIgnoreCase( action ) ) { rtnVal = file.isFile(); } 286 else if( ACT_ISHIDDEN.equalsIgnoreCase( action ) ) { rtnVal = file.isHidden(); } 287 else if( ACT_MKDIR.equalsIgnoreCase( action ) ) { 288 if( file.isDirectory() ) { rtnVal = true; } 289 else { rtnVal = file.mkdir(); } 290 } 291 else if( ACT_MKDIRS.equalsIgnoreCase( action ) ) { rtnVal = file.mkdirs(); } 292 else if( ACT_RENAMETO.equalsIgnoreCase( action ) ) { 293 if( file2 != null ) { 294 // 5.10.9.0 (2019/03/01) MODIFY RENAMETOは基準となるファイルのストレージで、ファイル名を変更します。 295 // File newFile = new File( StringUtil.urlAppend( directory,file2 ) ); 296 297 // 5.10.14.2 (2019/08/23) StringUtil.urlAppendを通していなかったため、ネットワークパスの場合の不具合対応 298 // File newFile = HybsFileOperationFactory.create(fromStorageType, fromBucketName, directory, file2); 299 File newFile = HybsFileOperationFactory.create(fromStorageType, fromBucketName, StringUtil.urlAppend(directory, file2)); 300 301 if( newFile.exists() && !newFile.delete() ) { 302 String errMsg = "所定のファイルを削除できませんでした。[" + newFile + "]" ; 303 throw new RuntimeException( errMsg ); 304 } 305 rtnVal = file.renameTo( newFile ); 306 } 307 } 308 // 3.6.0.0 (2004/09/25) ACT_read を追加 309 else if( ACT_READ.equalsIgnoreCase( action ) ) { 310 if( file.isFile() ) { 311 FileString fs = new FileString(); 312 fs.setFilename( StringUtil.urlAppend( directory,file1 ) ); 313 if( encode != null ) { fs.setEncode( encode ); } // 5.1.9.0 (2010/08/01) READ時のエンコード指定 314 String val = fs.getValue(); 315 316 jspPrint( nval( getRequestParameter( val ),"" ) ); 317 rtnVal = true; 318 } 319 else { 320 String errMsg = "ファイルが存在しないか、ファイルではありません。" 321 + HybsSystem.CR 322 + "action=[" + action + "] , " 323 + " fileURL=[" + fileURL + "]" 324 + " directory=[" + directory + "]" 325 + " file1=[" + file1 + "]" ; 326 throw new HybsSystemException( errMsg ); 327 } 328 } 329 // 3.8.5.2 (2006/05/31) ファイルサイズが0Byte以上のファイルが存在するかどうか判定。 330 else if( ACT_EXISTSLENGTH.equalsIgnoreCase( action ) ) { 331 rtnVal = file.exists() && file.length() > 0L ; 332 } 333 // 5.3.6.0 (2011/06/01) ファイルコピー対応 334 // 6.0.0.1 (2014/04/25) These nested if statements could be combined 335 else if( ACT_COPY.equalsIgnoreCase( action ) && file2 != null ) { 336 // 5.10.9.0 (2019/03/01) 337// File newFile = new File( StringUtil.urlAppend( directory,file2 ) ); 338 File newFile = HybsFileOperationFactory.create(toStorageType, toBucketName, StringUtil.urlAppend(directory, file2)); 339 340 if( file.isFile() ) { 341 // FileUtil.copy 側で、toFile のフォルダを作成します。 342 rtnVal = FileUtil.copy( file, newFile ); 343 } 344 else if( file.isDirectory() ) { 345 rtnVal = FileUtil.copyDirectry( file, newFile ); 346 } 347 // 5.7.1.1 (2013/12/13) copy元(file1)のファイルが存在しなければ、エラーにします。 348 else if( !file.exists() ) { 349 String errMsg = "copy元(file1)のファイルが存在しません。" 350 + HybsSystem.CR 351 + "action=[" + action + "] , " 352 + " fileURL=[" + fileURL + "]" 353 + " directory=[" + directory + "]" 354 + " file1=[" + file1 + "]" 355 + " file2=[" + file2 + "]" ; 356 throw new HybsSystemException( errMsg ); 357 } 358 } 359 // 5.9.2.2 (2015/11/20) zip追加 360 else if( ACT_ZIP.equalsIgnoreCase( action ) && file2 != null ){ 361 //あるかないかだけ見る 362 if( file2.toLowerCase().indexOf( ".zip" ) < 0 ){ 363 file2 = file2 + ".zip"; 364 } 365 List<String> ziplist = org.opengion.fukurou.util.ZipFileUtil.compress( file.toString(), file2 ); 366 } 367 } 368 else { 369 String errMsg = "アクションが指定されていません。アクション NULL エラー" 370 + HybsSystem.CR 371 + " file=[" + file1 + "]" ; 372 throw new HybsSystemException( errMsg ); 373 } 374 375 return rtnVal; 376 } 377 378 /** 379 * 【TAG】アクション(canRead,canWrite,createNewFile,delete,exists,isDirectory,isFile,isHidden,mkdir,mkdirs)を指定します。 380 * 381 * @og.tag 382 * アクションは,HTMLから(get/post)指定されますので,ACT_xxx で設定される 383 * フィールド定数値のいづれかを、指定できます。 384 * 処理の結果が、false の場合は、body 要素を表示して終了します。 385 * useStop 属性と、notEquals 属性によって、上記の振る舞いをけることが可能です。 386 * 387 * canRead 読み込めるかどうかを判定。 388 * canWrite 変更できるかどうか判定。 389 * createNewFile 空の新しいファイルを不可分 (atomic) に生成。(そのファイルがまだ存在しない場合だけ) 390 * delete ファイルまたはディレクトリを削除。 391 * renameTo ファイルまたはディレクトリ名を変更。 392 * exists ファイルが存在するかどうか判定。 393 * isDirectory ファイルがディレクトリであるかどうか判定。 394 * isFile ファイルが普通のファイルかどうか判定。 395 * isHidden ファイルが隠しファイルかどうか判定。 396 * mkdir ディレクトリを生成。 397 * mkdirs ディレクトリを複数生成。 398 * read ファイルを読み込んでjspWriterに出力 399 * existsLength ファイルサイズが0Byte以上のファイルが存在するかどうか判定。 400 * copy ファイルまたはディレクトリをコピー(file1 ⇒ file2 にコピー)。 401 * 402 * @og.rev 3.0.0.0 (2002/12/25) ACTION_LIST のチェックを導入 403 * @og.rev 3.5.6.2 (2004/07/05) 文字列の連結にStringBuilderを使用します。 404 * 405 * @param cmd アクション文字列 406 * @see <a href="../../../../constant-values.html#org.opengion.hayabusa.taglib.FileTag.ACT_canRead">アクション定数</a> 407 */ 408 public void setAction( final String cmd ) { 409 action = getRequestParameter( cmd ); 410 411 if( ! check( action, ACTION_LIST ) ) { 412 413 StringBuilder errMsg = new StringBuilder( HybsSystem.BUFFER_MIDDLE ); 414 errMsg.append( "指定のアクションは実行できません。アクションエラー" ); 415 errMsg.append( HybsSystem.CR ); 416 errMsg.append( "action=[" ).append( action ).append( "] " ); 417 errMsg.append( HybsSystem.CR ); 418 419 for( int i=0; i<ACTION_LIST.length; i++ ) { 420 errMsg.append( " | " ); 421 errMsg.append( ACTION_LIST[i] ); 422 } 423 errMsg.append( " | " ); 424 throw new HybsSystemException( errMsg.toString() ); 425 } 426 } 427 428 /** 429 * 【TAG】操作するファイルのディレクトリを指定します 430 * (初期値:FILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。 431 * 432 * @og.tag 433 * この属性で指定されるディレクトリのファイルを操作します。 434 * 指定方法は、通常の fileURL 属性と同様に、先頭が、'/' (UNIX) または、2文字目が、 435 * ":" (Windows)の場合は、指定のURLそのままのディレクトリに、そうでない場合は、 436 * (初期値:システム定数のFILE_URL[={@og.value org.opengion.hayabusa.common.SystemData#FILE_URL}])。 437 * 438 * @og.rev 4.0.0.0 (2005/01/31) urlAppend メソッドの利用 439 * @og.rev 4.0.0.0 (2007/11/20) 指定されたディレクトリ名の最後が"\"or"/"で終わっていない場合に、"/"を付加する。 440 * 441 * @param url ファイルURL 442 * @see org.opengion.hayabusa.common.SystemData#FILE_URL 443 */ 444 public void setFileURL( final String url ) { 445 String furl = nval( getRequestParameter( url ),null ); 446 if( furl != null ) { 447 char ch = furl.charAt( furl.length()-1 ); 448 if( ch != '/' && ch != '\\' ) { furl = furl + "/"; } 449 fileURL = StringUtil.urlAppend( fileURL,furl ); 450 } 451 } 452 453 /** 454 * 【TAG】基準となるファイル名を指定します(コマンドの左辺のファイル名です)。 455 * 456 * @og.tag 457 * コマンドの左辺のファイル名です。 458 * 459 * @param fname ファイル名1 460 */ 461 public void setFile1( final String fname ) { 462 file1 = nval( getRequestParameter( fname ),file1 ); 463 } 464 465 /** 466 * 【TAG】処理結果となるファイル名を指定します(コマンドの右辺のファイル名です)。 467 * 468 * @og.tag 469 * コマンドの右辺のファイル名です。 470 * 471 * @param fname ファイル名2 472 */ 473 public void setFile2( final String fname ) { 474 file2 = nval( getRequestParameter( fname ),file2 ); 475 } 476 477 /** 478 * 【TAG】判定結果を反転させるかどうか[true/false]を指定します(初期値:false)。 479 * 480 * @og.tag 481 * 通常の判定結果において、不成立(false)の場合に、BODY を実行します。 482 * 通常の処理結果の正反対の処理を行います。 483 * 初期値は、通常 (true 以外)です。 484 * 485 * @og.rev 3.8.5.2 (2006/05/31) 新規追加 486 * 487 * @param flag [true:反転する/それ以外:通常] 488 */ 489 public void setNotEquals( final String flag ) { 490 notEquals = nval( getRequestParameter( flag ),notEquals ); 491 } 492 493 /** 494 * 【TAG】エラー時BODYを処理後に停止するかどうか[true/false]を指定します(初期値:true)。 495 * 496 * @og.tag 497 * 処理結果などに応じて、以下の処理を停止したい場合に、使用します。 498 * 通常は、条件を判定後、false の場合に、BODY部を出力(処理)した後に、 499 * 処理を停止します。(useStop="true") 500 * false を指定すると、判定結果に無関係に、以下の処理を実行します。 501 * 処理は継続したいが、警告表示する場合に、useStop="false" を指定します。 502 * 初期値は、停止する ("true")です。 503 * 504 * @og.rev 3.8.5.2 (2006/05/31) 新規追加 505 * 506 * @param flag [true:判定する/それ以外:しない] 507 */ 508 public void setUseStop( final String flag ) { 509 useStop = nval( getRequestParameter( flag ),useStop ); 510 } 511 512 /** 513 * 【TAG】ファイルを読み込む(action="READ")際のエンコードを指定します(初期値:OS依存文字コード)。 514 * 515 * @og.tag 516 * ファイルを読み込む(action="READ")際のエンコードを指定します。 517 * action="READ"以外場合には、この属性値は利用されません。 518 * 指定しない場合は、OS依存文字コードで読み込まれます。 519 * 520 * @og.rev 5.1.9.0 (2010/08/01) 新規作成 521 * 522 * @param enc ファイル読み込みのエンコード 523 */ 524 public void setEncode( final String enc ) { 525 encode = nval( getRequestParameter( enc ),encode ); 526 } 527 528 /** 529 * 【TAG】基準となるファイルのストレージタイプを指定します。 530 * 531 * @og.tag 532 * file1の、 533 * ファイル操作を行うストレージタイプを指定します。 534 * 未設定の場合は、システムリソースのCLOUD_STORAGEを設定します。 535 * defaultが設定された場合は、自身のサーバに処理を行います。 536 * 537 * @param sto クラウドストレージタイプ 538 */ 539 public void setFromStorageType( final String fromSto) { 540 fromStorageType = nval( getRequestParameter( fromSto ), fromStorageType); 541 } 542 543 /** 544 * 【TAG】基準となるファイルのバケット名を指定します。 545 * 546 * @og.tag 547 * file1の、 548 * ファイル操作を行うバケット名を指定します。 549 * 未設定の場合は、システムリソースのCLOUD_BUKETを設定します。 550 * 551 * @param fromBkt バケット名 552 */ 553 public void setFromBucketName( final String fromBkt) { 554 fromBucketName = nval( getRequestParameter( fromBkt ), fromBucketName); 555 } 556 557 /** 558 * 【TAG】処理結果のファイルのストレージタイプを指定します。 559 * 560 * @og.tag 561 * file2の、 562 * ファイル操作を行うクラウドストレージタイプを指定します。 563 * 未設定の場合は、システムリソースのCLOUD_STORAGEを設定します。 564 * defaultが設定された場合は、自身のサーバに処理を行います。 565 * 566 * @param toSto ストレージ名 567 */ 568 public void setToStorageType( final String toSto) { 569 toStorageType = nval( getRequestParameter( toSto ), toStorageType); 570 } 571 572 /** 573 * 【TAG】処理結果のファイルのバケット名を指定します。 574 * 575 * @og.tag 576 * file2の、 577 * ファイル操作を行うバケット名を指定します。 578 * 未設定の場合は、システムリソースのCLOUD_BUKETを設定します。 579 * 580 * @param toBkt バケット名 581 */ 582 public void setToBucketName( final String toBkt) { 583 toBucketName = nval( getRequestParameter( toBkt ), toBucketName); 584 } 585 586 /** 587 * このオブジェクトの文字列表現を返します。 588 * 基本的にデバッグ目的に使用します。 589 * 590 * @og.rev 5.10.9.0 (2019/03/01) 出力対象に、fromStorageType,fromBbucketName,toStorageType,toBucketNameを追加。 591 * 592 * @return このクラスの文字列表現 593 */ 594 @Override 595 public String toString() { 596 return org.opengion.fukurou.util.ToString.title( this.getClass().getName() ) 597 .println( "VERSION" ,VERSION ) 598 .println( "fileURL" ,fileURL ) 599 .println( "file1" ,file1 ) 600 .println( "file2" ,file2 ) 601 .println( "action" ,action ) 602 .println( "rtnCode" ,rtnCode ) 603 .println( "notEquals" ,notEquals ) 604 .println( "useStop" ,useStop ) 605 .println( "fromStorageType" ,fromStorageType ) 606 .println( "fromBucketName" ,fromBucketName ) 607 .println( "toStorageType" ,toStorageType ) 608 .println( "toBucketName" ,toBucketName ) 609 .println( "Other..." ,getAttributes().getAttribute() ) 610 .fixForm().toString() ; 611 } 612}