From d4888e1a182f364d66cc42787598871e81959654 Mon Sep 17 00:00:00 2001 From: devezhao-mbp Date: Wed, 29 Apr 2020 21:25:45 +0800 Subject: [PATCH] better code --- .../helper/AesPreferencesConfigurer.java | 17 ++-------- .../com/rebuild/server/helper/KVStorage.java | 20 ++++------- src/main/java/com/rebuild/utils/AES.java | 34 +++---------------- 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/rebuild/server/helper/AesPreferencesConfigurer.java b/src/main/java/com/rebuild/server/helper/AesPreferencesConfigurer.java index 851d86f70..7a00115b6 100644 --- a/src/main/java/com/rebuild/server/helper/AesPreferencesConfigurer.java +++ b/src/main/java/com/rebuild/server/helper/AesPreferencesConfigurer.java @@ -1,19 +1,8 @@ /* -rebuild - Building your business-systems freely. -Copyright (C) 2018 devezhao +Copyright (c) REBUILD and its owners. All rights reserved. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +rebuild is dual-licensed under commercial and open source licenses (GPLv3). +See LICENSE and COMMERCIAL in the project root for license information. */ package com.rebuild.server.helper; diff --git a/src/main/java/com/rebuild/server/helper/KVStorage.java b/src/main/java/com/rebuild/server/helper/KVStorage.java index ed13638ac..35b29a25f 100644 --- a/src/main/java/com/rebuild/server/helper/KVStorage.java +++ b/src/main/java/com/rebuild/server/helper/KVStorage.java @@ -1,19 +1,8 @@ /* -rebuild - Building your business-systems freely. -Copyright (C) 2018-2019 devezhao +Copyright (c) REBUILD and its owners. All rights reserved. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +rebuild is dual-licensed under commercial and open source licenses (GPLv3). +See LICENSE and COMMERCIAL in the project root for license information. */ package com.rebuild.server.helper; @@ -87,7 +76,9 @@ public class KVStorage { * @return */ protected static String getValue(final String key, boolean reload, Object defaultValue) { + String value = null; + if (Application.serversReady()) { value = Application.getCommonCache().get(key); if (value != null && !reload) { @@ -119,6 +110,7 @@ public class KVStorage { Application.getCommonCache().put(key, value); } } + return value; } } diff --git a/src/main/java/com/rebuild/utils/AES.java b/src/main/java/com/rebuild/utils/AES.java index f594734ba..e90e5f068 100644 --- a/src/main/java/com/rebuild/utils/AES.java +++ b/src/main/java/com/rebuild/utils/AES.java @@ -1,19 +1,8 @@ /* -rebuild - Building your business-systems freely. -Copyright (C) 2018 devezhao +Copyright (c) REBUILD and its owners. All rights reserved. -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . +rebuild is dual-licensed under commercial and open source licenses (GPLv3). +See LICENSE and COMMERCIAL in the project root for license information. */ package com.rebuild.utils; @@ -86,7 +75,7 @@ public class AES { try { return decrypt(input); } catch (RebuildException ex) { - Application.LOG.warn("Decrypt error : " + input); + LOG.warn("Decrypting error (Use blank input) : " + input); return StringUtils.EMPTY; } } @@ -110,20 +99,7 @@ public class AES { } return new String(output); } - - /** - * @param input - * @return - */ - public static String decryptNothrow(String input) { - try { - return decrypt(input); - } catch (RebuildException ex) { - LOG.warn("Decrypting error (Use blank input) : " + input); - return StringUtils.EMPTY; - } - } - + /** * 通过 `-Drbpass=KEY` 指定 AES 秘钥 *