Révision | 1706 (tree) |
---|---|
l'heure | 2019-03-05 08:48:29 |
Auteur | takahashi_m |
(empty log message)
@@ -1,6 +1,7 @@ | ||
1 | 1 | 5.10.9.1 (2019/03/08) |
2 | - [コンパイラの警告対応] | |
2 | + [コンパイラの警告対応等] | |
3 | 3 | コンパイラの警告を修正します。(アノテーションなど) |
4 | + また、一部引数のfinal化等も行います。 | |
4 | 5 | fukurou.model.FileOperationInfo |
5 | 6 | fukurou.model.CloudFileOperation |
6 | 7 | fukurou.model.FileOperation |
@@ -7,6 +8,7 @@ | ||
7 | 8 | fukutou.model.FileOperationFactory |
8 | 9 | fukurou.util.FileUtil |
9 | 10 | fukurou.security.HybsCryptography |
11 | + hayabusa.io.HybsFileOperationFactory | |
10 | 12 | |
11 | 13 | 5.10.9.0 (2019/03/01) |
12 | 14 | [クラウドストレージ対応] |
@@ -36,8 +36,9 @@ | ||
36 | 36 | // バケット名 |
37 | 37 | protected final String conBucket; |
38 | 38 | |
39 | - private final String UNIMPLEMNTED_ERR="このクラスでは未実装のメソッドです。"; | |
40 | - | |
39 | + private static final String UNIMPLEMNTED_ERR="このクラスでは未実装のメソッドです。"; | |
40 | + private static final char FS = '/' ; | |
41 | + | |
41 | 42 | /** |
42 | 43 | * コンストラクタ |
43 | 44 | * |
@@ -53,7 +54,7 @@ | ||
53 | 54 | this.conBucket = bucket; |
54 | 55 | |
55 | 56 | if (StringUtil.isNull(conBucket)) { |
56 | - String errMsg = "バケット未指定です。hayabusa利用ではシステム変数の「CLOUD_BUCKET」にバケット名を設定して下さい。"; | |
57 | + final String errMsg = "バケット未指定です。hayabusa利用ではシステム変数の「CLOUD_BUCKET」にバケット名を設定して下さい。"; | |
57 | 58 | throw new RuntimeException(errMsg); |
58 | 59 | } |
59 | 60 | } |
@@ -218,7 +219,7 @@ | ||
218 | 219 | * @return 成否フラグ |
219 | 220 | */ |
220 | 221 | @Override |
221 | - public boolean move(String afPath) { | |
222 | + public boolean move(final String afPath) { | |
222 | 223 | boolean flgRtn = false; |
223 | 224 | |
224 | 225 | flgRtn = copy(afPath); |
@@ -279,7 +280,7 @@ | ||
279 | 280 | * @return 成否フラグ |
280 | 281 | */ |
281 | 282 | @Override |
282 | - public boolean renameTo(File dest) { | |
283 | + public boolean renameTo(final File dest) { | |
283 | 284 | return move(dest.getPath()); |
284 | 285 | } |
285 | 286 |
@@ -360,7 +361,7 @@ | ||
360 | 361 | * @return 成否フラグ |
361 | 362 | */ |
362 | 363 | @Override |
363 | - public boolean setLastModified(long time) { | |
364 | + public boolean setLastModified(final long time) { | |
364 | 365 | // クラウドストレージでは、setLastModifiedによる、 |
365 | 366 | // 最終更新時刻の設定はできないので、 |
366 | 367 | // 処理を行わずにtrueを返します。 |
@@ -411,13 +412,14 @@ | ||
411 | 412 | // 「//+」は「/」に置換 |
412 | 413 | rtn = rtn.replaceAll("//+", "/"); |
413 | 414 | // 先頭が「/」の場合は除去 |
414 | - if ("/".equals(rtn.substring(0, 1))) { | |
415 | +// if ("/".equals(rtn.substring(0, 1))) { | |
416 | + if( FS == rtn.charAt(0) ) { | |
415 | 417 | rtn = rtn.substring(1); |
416 | 418 | } |
417 | 419 | // 後尾の「.」は除去 |
418 | 420 | rtn = rTrim(rtn, '.'); |
419 | 421 | // 後尾の「/」は除去 |
420 | - rtn = rTrim(rtn, '/'); | |
422 | + rtn = rTrim(rtn, FS); | |
421 | 423 | |
422 | 424 | return rtn; |
423 | 425 | } |
@@ -430,12 +432,12 @@ | ||
430 | 432 | * @param key キー |
431 | 433 | * @return 親のパス |
432 | 434 | */ |
433 | - protected String drawParent(String key) { | |
434 | - int k = key.lastIndexOf("/"); | |
435 | + protected String drawParent(final String key) { | |
436 | + final int k = key.lastIndexOf(FS); | |
435 | 437 | |
436 | 438 | String rtn = ""; |
437 | 439 | if (k > 0) { |
438 | - rtn = key.substring(0, key.lastIndexOf("/")); | |
440 | + rtn = key.substring(0, key.lastIndexOf(FS)); | |
439 | 441 | } |
440 | 442 | if ("/".equals(File.separator)) { |
441 | 443 | rtn = File.separator + rtn; |
@@ -452,12 +454,12 @@ | ||
452 | 454 | * @param key キー(パス) |
453 | 455 | * @return 名称 |
454 | 456 | */ |
455 | - protected String drawName(String key) { | |
456 | - int k = key.lastIndexOf("/"); | |
457 | + protected String drawName(final String key) { | |
458 | + final int k = key.lastIndexOf(FS); | |
457 | 459 | |
458 | 460 | String rtn = key; |
459 | 461 | if (k > 0) { |
460 | - rtn = key.substring(key.lastIndexOf("/") + 1); | |
462 | + rtn = key.substring(key.lastIndexOf(FS) + 1); | |
461 | 463 | } |
462 | 464 | return rtn; |
463 | 465 | } |
@@ -470,14 +472,15 @@ | ||
470 | 472 | * @param path パス |
471 | 473 | * @return 後尾に「/」ありのパス |
472 | 474 | */ |
473 | - protected String setDirTail(String path) { | |
475 | + protected String setDirTail(final String path) { | |
474 | 476 | if (StringUtil.isNull(path)) { |
475 | 477 | return path; |
476 | 478 | } |
477 | 479 | |
478 | - StringBuilder sb = new StringBuilder(path); | |
479 | - if (!"/".equals(path.substring(path.length() - 1))) { | |
480 | - sb.append("/"); | |
480 | + final StringBuilder sb = new StringBuilder(path); | |
481 | +// if (!"/".equals(path.substring(path.length() - 1))) { | |
482 | + if ( FS != path.charAt(path.length() - 1) ) { | |
483 | + sb.append(FS); | |
481 | 484 | } |
482 | 485 | return sb.toString(); |
483 | 486 | } |
@@ -491,7 +494,7 @@ | ||
491 | 494 | * @param chr 指定文字 |
492 | 495 | * @return 右側から指定文字を除去後の文字列 |
493 | 496 | */ |
494 | - protected String rTrim(final String str, char chr) { | |
497 | + protected String rTrim(final String str, final char chr) { | |
495 | 498 | String rtn = str; |
496 | 499 | int trgPos = 0; |
497 | 500 | for (int i = str.length() - 1; i >= 0; i--) { |
@@ -538,9 +541,9 @@ | ||
538 | 541 | * @param filter フィルタ情報 |
539 | 542 | * @return フィルタ後のリスト |
540 | 543 | */ |
541 | - protected File[] filter(List<File> list, FileFilter filter) { | |
542 | - List<File> files = new ArrayList<File>(); | |
543 | - for (File file : list) { | |
544 | + protected File[] filter(final List<File> list, final FileFilter filter) { | |
545 | + final List<File> files = new ArrayList<File>(); | |
546 | + for (final File file : list) { | |
544 | 547 | if (filter.accept(file)) { |
545 | 548 | files.add(file); |
546 | 549 | } |
@@ -558,10 +561,10 @@ | ||
558 | 561 | * @return InpusStreamをbyte配列に変換した値 |
559 | 562 | * @throws IOException ファイル関連エラー情報 |
560 | 563 | */ |
561 | - protected byte[] toByteArray(InputStream is) throws IOException { | |
562 | - ByteArrayOutputStream output = new ByteArrayOutputStream(); | |
564 | + protected byte[] toByteArray(final InputStream is) throws IOException { | |
565 | + final ByteArrayOutputStream output = new ByteArrayOutputStream(); | |
563 | 566 | try { |
564 | - byte[] b = new byte[BUFFER_SIZE]; | |
567 | + final byte[] b = new byte[BUFFER_SIZE]; | |
565 | 568 | int n = 0; |
566 | 569 | while ((n = is.read(b)) != -1) { |
567 | 570 | output.write(b, 0, n); |
@@ -678,7 +681,7 @@ | ||
678 | 681 | * @return フラグ |
679 | 682 | */ |
680 | 683 | @Override |
681 | - public boolean setReadable(boolean readable) { | |
684 | + public boolean setReadable(final boolean readable) { | |
682 | 685 | throw new RuntimeException(UNIMPLEMNTED_ERR); |
683 | 686 | } |
684 | 687 |
@@ -692,7 +695,7 @@ | ||
692 | 695 | * @return フラグ |
693 | 696 | */ |
694 | 697 | @Override |
695 | - public boolean setReadable(boolean readable, boolean ownerOnly) { | |
698 | + public boolean setReadable(final boolean readable, final boolean ownerOnly) { | |
696 | 699 | throw new RuntimeException(UNIMPLEMNTED_ERR); |
697 | 700 | } |
698 | 701 |
@@ -705,7 +708,7 @@ | ||
705 | 708 | * @return フラグ |
706 | 709 | */ |
707 | 710 | @Override |
708 | - public boolean setWritable(boolean writable) { | |
711 | + public boolean setWritable(final boolean writable) { | |
709 | 712 | throw new RuntimeException(UNIMPLEMNTED_ERR); |
710 | 713 | } |
711 | 714 |
@@ -719,7 +722,7 @@ | ||
719 | 722 | * @return フラグ |
720 | 723 | */ |
721 | 724 | @Override |
722 | - public boolean setWritable(boolean writable, boolean ownerOnly) { | |
725 | + public boolean setWritable(final boolean writable, final boolean ownerOnly) { | |
723 | 726 | throw new RuntimeException(UNIMPLEMNTED_ERR); |
724 | 727 | } |
725 | 728 |
@@ -34,7 +34,7 @@ | ||
34 | 34 | * |
35 | 35 | * @param path ファイルパス |
36 | 36 | */ |
37 | - public FileOperation(String path) { | |
37 | + public FileOperation(final String path) { | |
38 | 38 | super(path); |
39 | 39 | } |
40 | 40 |
@@ -46,7 +46,7 @@ | ||
46 | 46 | * @param bucket バケット名 |
47 | 47 | * @param path ファイルパス |
48 | 48 | */ |
49 | - public FileOperation(String bucket, String path) { | |
49 | + public FileOperation(final String bucket, final String path) { | |
50 | 50 | this(path); |
51 | 51 | this.mybucket = bucket; |
52 | 52 | } |
@@ -84,7 +84,7 @@ | ||
84 | 84 | * @param afPath コピー先 |
85 | 85 | * @return 成否フラグ |
86 | 86 | */ |
87 | - public boolean copy(String afPath) { | |
87 | + public boolean copy(final String afPath) { | |
88 | 88 | boolean flgRtn = false; |
89 | 89 | |
90 | 90 | try { |
@@ -106,7 +106,7 @@ | ||
106 | 106 | * @param afPath 移動先 |
107 | 107 | * @return 成否フラグ |
108 | 108 | */ |
109 | - public boolean move(String afPath) { | |
109 | + public boolean move(final String afPath) { | |
110 | 110 | boolean flgRtn = false; |
111 | 111 | |
112 | 112 | try { |
@@ -120,7 +120,7 @@ | ||
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | - * 保存先のローカル判定 | |
123 | + * 保存先のローカル判定。 | |
124 | 124 | * |
125 | 125 | * 判定結果を返します。 |
126 | 126 | * trueの場合は、ローカル保存。 |
@@ -133,7 +133,7 @@ | ||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * カノニカルファイル取得 | |
136 | + * カノニカルファイル取得。 | |
137 | 137 | * |
138 | 138 | * カノニカルファイル情報を取得します。 |
139 | 139 | * |
@@ -142,12 +142,12 @@ | ||
142 | 142 | */ |
143 | 143 | @Override |
144 | 144 | public FileOperation getCanonicalFile() throws IOException { |
145 | - String canonPath = getCanonicalPath(); | |
146 | - return new FileOperation(canonPath); | |
147 | - } | |
145 | + final String canonPath = getCanonicalPath(); | |
146 | + return new FileOperation(canonPath); | |
147 | + } | |
148 | 148 | |
149 | 149 | /** |
150 | - * バケット名取得 | |
150 | + * バケット名取得。 | |
151 | 151 | * |
152 | 152 | * バケット名を取得します。 |
153 | 153 | * |
@@ -158,7 +158,7 @@ | ||
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | - * プラグイン名取得 | |
161 | + * プラグイン名取得。 | |
162 | 162 | * |
163 | 163 | * プラグイン名を取得します。 |
164 | 164 | * |
@@ -169,13 +169,13 @@ | ||
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
172 | - * プラグイン名のセット | |
172 | + * プラグイン名のセット。 | |
173 | 173 | * |
174 | 174 | * プラグイン名をセットします。 |
175 | 175 | * |
176 | 176 | * @param plugin プラグイン名 |
177 | 177 | */ |
178 | - protected void setPlugin( String plugin ) { | |
178 | + protected void setPlugin( final String plugin ) { | |
179 | 179 | myplugin = plugin; |
180 | 180 | } |
181 | 181 |
@@ -1,6 +1,7 @@ | ||
1 | 1 | package org.opengion.fukurou.model; |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | +import java.util.Locale; | |
4 | 5 | import org.opengion.fukurou.util.StringUtil; |
5 | 6 | |
6 | 7 |
@@ -28,8 +29,9 @@ | ||
28 | 29 | * @param path ファイルパス |
29 | 30 | * @return ファイル操作インスタンス |
30 | 31 | */ |
31 | - public static FileOperation newStorageOperation(String path) { | |
32 | - return newStorageOperation( (String)null, null, path.toString()); | |
32 | + public static FileOperation newStorageOperation(final String path) { | |
33 | +// return newStorageOperation( (String)null, null, path.toString()); | |
34 | + return newStorageOperation( (String)null, null, path); | |
33 | 35 | } |
34 | 36 | |
35 | 37 | /** |
@@ -46,8 +48,8 @@ | ||
46 | 48 | * @param fileName ファイル名 |
47 | 49 | * @return ファイル操作インスタンス |
48 | 50 | */ |
49 | - public static FileOperation newStorageOperation(String plugin, String buket, String dir, String fileName) { | |
50 | - StringBuilder path = new StringBuilder(BUFFER_MIDDLE); | |
51 | + public static FileOperation newStorageOperation(final String plugin, final String buket, final String dir, final String fileName) { | |
52 | + final StringBuilder path = new StringBuilder(BUFFER_MIDDLE); | |
51 | 53 | path.append( dir ); |
52 | 54 | |
53 | 55 | if(fileName != null) { |
@@ -69,20 +71,20 @@ | ||
69 | 71 | * @param path ファイルパス |
70 | 72 | * @return ファイル操作インスタンス |
71 | 73 | */ |
72 | - public static FileOperation newStorageOperation(String plugin, String buket, String path) { | |
74 | + public static FileOperation newStorageOperation(final String plugin, final String buket, final String path) { | |
73 | 75 | FileOperation rtn; |
74 | 76 | String cloudTarget = null; |
75 | 77 | |
76 | - Object[] args = new Object[] { buket, path }; | |
78 | + final Object[] args = new Object[] { buket, path }; | |
77 | 79 | |
78 | 80 | // 対象のクラウドサービスを取得(大文字化)。 |
79 | 81 | // 未指定の場合は、ローカルディレクトリを利用。 |
80 | 82 | if ( plugin != null && plugin.length() > 0 ) { |
81 | - cloudTarget = plugin.toUpperCase(); | |
83 | + cloudTarget = plugin.toUpperCase( Locale.JAPAN ); | |
82 | 84 | } |
83 | 85 | |
84 | 86 | try { |
85 | - StringBuilder sb = new StringBuilder(BUFFER_MIDDLE); | |
87 | + final StringBuilder sb = new StringBuilder(BUFFER_MIDDLE); | |
86 | 88 | |
87 | 89 | if (StringUtil.isNull(cloudTarget) || "DEFAULT".equals(cloudTarget)) { |
88 | 90 | sb.append("org.opengion.fukurou.model.FileOperation"); |
@@ -95,9 +97,10 @@ | ||
95 | 97 | rtn = (FileOperation) Class.forName(sb.toString()) |
96 | 98 | .getConstructor(String.class, String.class) |
97 | 99 | .newInstance(args); |
98 | - } catch (Exception e) { | |
100 | +// } catch (Exception e) { | |
101 | + } catch (final Throwable th) { | |
99 | 102 | // キャッチしたエラー情報をスロー |
100 | - throw new RuntimeException(e); | |
103 | + throw new RuntimeException(th); | |
101 | 104 | } |
102 | 105 | |
103 | 106 | return rtn; |
@@ -118,7 +121,7 @@ | ||
118 | 121 | * @param fileName 子パス |
119 | 122 | * @return 設定をコピーしたのFileOperation |
120 | 123 | */ |
121 | - public static FileOperation newStorageOperation(File file, String dir, String fileName) { | |
124 | + public static FileOperation newStorageOperation(final File file, final String dir, final String fileName) { | |
122 | 125 | String plugin = null; |
123 | 126 | String buket = null; |
124 | 127 |
@@ -135,7 +138,7 @@ | ||
135 | 138 | } |
136 | 139 | |
137 | 140 | /** |
138 | - * インスタンス生成 | |
141 | + * インスタンス生成。 | |
139 | 142 | * |
140 | 143 | * コピーするタイプで、子パスを与えないパターンです。 |
141 | 144 | * |
@@ -143,7 +146,7 @@ | ||
143 | 146 | * @param path パス |
144 | 147 | * @return 設定をコピーしたのFileOperation |
145 | 148 | */ |
146 | - public static FileOperation newStorageOperation(File file, String path) { | |
149 | + public static FileOperation newStorageOperation(final File file, final String path) { | |
147 | 150 | return newStorageOperation( file, path, null); |
148 | 151 | |
149 | 152 | } |
@@ -23,7 +23,7 @@ | ||
23 | 23 | * @author Takahashi Masakazu |
24 | 24 | * @since JDK7.0 |
25 | 25 | */ |
26 | -public class HybsFileOperationFactory { | |
26 | +public final class HybsFileOperationFactory { | |
27 | 27 | private static String defPlugin=HybsSystem.sys("CLOUD_TARGET"); |
28 | 28 | private static String defBucket=HybsSystem.sys("CLOUD_BUCKET"); |
29 | 29 |
@@ -43,7 +43,7 @@ | ||
43 | 43 | * @param path ファイルパス |
44 | 44 | * @return FileOperationインスタンス |
45 | 45 | */ |
46 | - public static FileOperation create(String plugin, String bucket, String path) { | |
46 | + public static FileOperation create(final String plugin, final String bucket, final String path) { | |
47 | 47 | return FileOperationFactory.newStorageOperation( StringUtil.nval(plugin, defPlugin), StringUtil.nval(bucket, defBucket), path ); |
48 | 48 | } |
49 | 49 |
@@ -56,8 +56,8 @@ | ||
56 | 56 | * @param file ファイル名 |
57 | 57 | * @return FileOperationインスタンス |
58 | 58 | */ |
59 | - public static FileOperation create(String plugin, String bucket, String dir, String file) { | |
60 | - StringBuilder sb = new StringBuilder(HybsSystem.BUFFER_SMALL); | |
59 | + public static FileOperation create(final String plugin, final String bucket, final String dir, final String file) { | |
60 | + final StringBuilder sb = new StringBuilder(HybsSystem.BUFFER_SMALL); | |
61 | 61 | sb.append(dir).append(HybsSystem.FS).append(file); |
62 | 62 | return create(plugin, bucket, sb.toString()); |
63 | 63 | } |
@@ -71,8 +71,8 @@ | ||
71 | 71 | * @param file ファイル名 |
72 | 72 | * @return FileOperationインスタンス |
73 | 73 | */ |
74 | - public static FileOperation create(String plugin, String bucket, File dir, String file) { | |
75 | - StringBuilder sb = new StringBuilder(HybsSystem.BUFFER_SMALL); | |
74 | + public static FileOperation create(final String plugin, final String bucket, final File dir, final String file) { | |
75 | + final StringBuilder sb = new StringBuilder(HybsSystem.BUFFER_SMALL); | |
76 | 76 | sb.append(dir.getPath()).append(HybsSystem.FS).append(file); |
77 | 77 | return create(plugin, bucket, sb.toString()); |
78 | 78 | } |