|
|
@@ -20,35 +20,20 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class StoreLocalCache {
|
|
|
private StoreProperties storeProperties;
|
|
|
- private final Map<String, ObjectChannel> prefixMap = new HashMap<>();
|
|
|
- private final Map<Integer, ObjectChannel> channelIdMap = new HashMap<>();
|
|
|
private final SpringProperties springProperties;
|
|
|
|
|
|
public StoreLocalCache(SpringProperties springProperties) {
|
|
|
this.springProperties = springProperties;
|
|
|
}
|
|
|
|
|
|
- public void initOssStore(StoreProperties storeProperties, List<ObjectChannel> list) {
|
|
|
+ public void initOssStore(StoreProperties storeProperties) {
|
|
|
this.storeProperties = storeProperties;
|
|
|
- for (ObjectChannel channel : list) {
|
|
|
- String prefix = channel.getPrefix();
|
|
|
- Integer channelId = channel.getChannelId();
|
|
|
- prefixMap.put(prefix, channel);
|
|
|
- channelIdMap.put(channelId, channel);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
public void updateStoreProperties(StoreProperties storeProperties) {
|
|
|
this.storeProperties = storeProperties;
|
|
|
}
|
|
|
|
|
|
- public void addObjectChannel(ObjectChannel channel) {
|
|
|
- String prefix = channel.getPrefix();
|
|
|
- Integer channelId = channel.getChannelId();
|
|
|
- prefixMap.put(prefix, channel);
|
|
|
- channelIdMap.put(channelId, channel);
|
|
|
- }
|
|
|
-
|
|
|
public String getHost() {
|
|
|
return springProperties.getHost();
|
|
|
}
|
|
|
@@ -65,35 +50,6 @@ public class StoreLocalCache {
|
|
|
return storeProperties != null ? storeProperties.getSecretKey() : null;
|
|
|
}
|
|
|
|
|
|
- public ObjectChannel getObjectChannel(int loginUser, int channelId) {
|
|
|
- return channelIdMap.get(channelId);
|
|
|
- }
|
|
|
-
|
|
|
- public int getChannelId(String url) {
|
|
|
- ObjectChannel objectChannel = getObjectChannel(url);
|
|
|
- if (objectChannel == null) {
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- return objectChannel.getChannelId();
|
|
|
- }
|
|
|
-
|
|
|
- public ObjectChannel getObjectChannel(String url) {
|
|
|
- String domain = getDomain();
|
|
|
- String objectName = url.replace("//" + domain + "/", "");
|
|
|
- for (String prefix : prefixMap.keySet()) {
|
|
|
- if (objectName.startsWith(prefix)) {
|
|
|
- return prefixMap.get(prefix);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- public List<ObjectChannel> getObjectChannels() {
|
|
|
- return new ArrayList<>(prefixMap.values());
|
|
|
- }
|
|
|
-
|
|
|
public StoreProperties getStoreProperties() {
|
|
|
return storeProperties;
|
|
|
}
|