|
17 | 17 | package com.cloud.api.query.dao; |
18 | 18 |
|
19 | 19 | import java.util.ArrayList; |
| 20 | +import java.util.Arrays; |
20 | 21 | import java.util.List; |
21 | 22 |
|
22 | 23 | import javax.inject.Inject; |
@@ -196,16 +197,24 @@ public StoragePoolResponse newStoragePoolResponse(StoragePoolJoinVO pool, boolea |
196 | 197 | public StoragePoolResponse setStoragePoolResponse(StoragePoolResponse response, StoragePoolJoinVO sp) { |
197 | 198 | String tag = sp.getTag(); |
198 | 199 | if (tag != null) { |
199 | | - if (response.getTags() != null && response.getTags().length() > 0) { |
200 | | - response.setTags(response.getTags() + "," + tag); |
| 200 | + if (response.getTags() != null && !response.getTags().isEmpty()) { |
| 201 | + List<String> tagsList = new ArrayList<>(Arrays.asList(response.getTags().split(","))); |
| 202 | + if (!tagsList.contains(tag)) { |
| 203 | + tagsList.add(tag); |
| 204 | + } |
| 205 | + response.setTags(String.join(",", tagsList)); |
201 | 206 | } else { |
202 | 207 | response.setTags(tag); |
203 | 208 | } |
204 | 209 | } |
205 | 210 | String storageAccessGroup = sp.getStorageAccessGroup(); |
206 | 211 | if (storageAccessGroup != null) { |
207 | | - if (response.getStorageAccessGroups() != null && response.getStorageAccessGroups().length() > 0) { |
208 | | - response.setStorageAccessGroups(response.getStorageAccessGroups() + "," + storageAccessGroup); |
| 212 | + if (response.getStorageAccessGroups() != null && !response.getStorageAccessGroups().isEmpty()) { |
| 213 | + List<String> groupList = new ArrayList<>(Arrays.asList(response.getStorageAccessGroups().split(","))); |
| 214 | + if (!groupList.contains(storageAccessGroup)) { |
| 215 | + groupList.add(storageAccessGroup); |
| 216 | + } |
| 217 | + response.setStorageAccessGroups(String.join(",", groupList)); |
209 | 218 | } else { |
210 | 219 | response.setStorageAccessGroups(storageAccessGroup); |
211 | 220 | } |
|
0 commit comments