143143import org .apache .cloudstack .storage .object .ObjectStore ;
144144import org .apache .cloudstack .storage .object .ObjectStoreEntity ;
145145import org .apache .cloudstack .storage .to .VolumeObjectTO ;
146- import org .apache .commons .collections .CollectionUtils ;
147- import org .apache .commons .collections .MapUtils ;
146+ import org .apache .commons .collections4 .CollectionUtils ;
147+ import org .apache .commons .collections4 .MapUtils ;
148148import org .apache .commons .lang .time .DateUtils ;
149149import org .apache .commons .lang3 .ArrayUtils ;
150150import org .apache .commons .lang3 .BooleanUtils ;
@@ -670,14 +670,16 @@ protected DataStore createLocalStorage(Map<String, Object> poolInfos) throws Con
670670
671671 long capacityBytes = poolInfos .get ("capacityBytes" ) != null ? Long .parseLong (poolInfos .get ("capacityBytes" ).toString ()) : 0 ;
672672
673+ @ SuppressWarnings ("unchecked" ) // the local storage configuration is parsed into untyped maps
674+ Map <String , String > poolDetails = (Map <String , String >) poolInfos .get ("details" );
673675 StoragePoolInfo pInfo = new StoragePoolInfo (poolInfos .get ("uuid" ).toString (),
674676 host .getPrivateIpAddress (),
675677 hostPath ,
676678 hostPath ,
677679 StoragePoolType .Filesystem ,
678680 capacityBytes ,
679681 0 ,
680- ( Map < String , String >) poolInfos . get ( "details" ) ,
682+ poolDetails ,
681683 poolInfos .get ("name" ).toString ());
682684
683685 return createLocalStorage (host , pInfo );
@@ -1030,18 +1032,11 @@ protected Map<String,String> extractUriParamsAsMap(String url) {
10301032 return uriParams ;
10311033 }
10321034
1033- private Map <String , String > extractApiParamAsMap (Map ds ) {
1035+ private Map <String , String > extractApiParamAsMap (Map < String , ? extends Map < String , String >> ds ) {
10341036 Map <String , String > details = new HashMap <>();
10351037 if (ds != null ) {
1036- Collection detailsCollection = ds .values ();
1037- Iterator it = detailsCollection .iterator ();
1038- while (it .hasNext ()) {
1039- HashMap d = (HashMap )it .next ();
1040- Iterator it2 = d .entrySet ().iterator ();
1041- while (it2 .hasNext ()) {
1042- Map .Entry entry = (Map .Entry )it2 .next ();
1043- details .put ((String )entry .getKey (), (String )entry .getValue ());
1044- }
1038+ for (Map <String , String > d : ds .values ()) {
1039+ details .putAll (d );
10451040 }
10461041 }
10471042 return details ;
@@ -1421,9 +1416,8 @@ protected void checkIfStorageAccessGroupsExistsOnZone(long zoneId, List<String>
14211416
14221417 String storageAccessGroupsOnZone = zoneVO .getStorageAccessGroups ();
14231418 List <String > zoneTagsList = parseTags (storageAccessGroupsOnZone );
1424- List <String > newTags = storageAccessGroups ;
14251419
1426- List <String > existingTagsOnZone = ( List < String >) CollectionUtils .intersection (newTags , zoneTagsList );
1420+ List <String > existingTagsOnZone = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , zoneTagsList ) );
14271421
14281422 if (CollectionUtils .isNotEmpty (existingTagsOnZone )) {
14291423 throw new CloudRuntimeException (String .format ("access groups already exist on the zone: %s" , existingTagsOnZone ));
@@ -1439,10 +1433,9 @@ protected void checkIfStorageAccessGroupsExistsOnPod(long podId, List<String> st
14391433
14401434 List <String > podTagsList = parseTags (storageAccessGroupsOnPod );
14411435 List <String > zoneTagsList = parseTags (storageAccessGroupsOnZone );
1442- List <String > newTags = storageAccessGroups ;
14431436
1444- List <String > existingTagsOnPod = ( List < String >) CollectionUtils .intersection (newTags , podTagsList );
1445- List <String > existingTagsOnZone = ( List < String >) CollectionUtils .intersection (newTags , zoneTagsList );
1437+ List <String > existingTagsOnPod = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , podTagsList ) );
1438+ List <String > existingTagsOnZone = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , zoneTagsList ) );
14461439
14471440 if (CollectionUtils .isNotEmpty (existingTagsOnPod ) || CollectionUtils .isNotEmpty (existingTagsOnZone )) {
14481441 String message = "access groups already exist " ;
@@ -1473,11 +1466,10 @@ protected void checkIfStorageAccessGroupsExistsOnCluster(long clusterId, List<St
14731466 List <String > podTagsList = parseTags (storageAccessGroupsOnPod );
14741467 List <String > zoneTagsList = parseTags (storageAccessGroupsOnZone );
14751468 List <String > clusterTagsList = parseTags (storageAccessGroupsOnCluster );
1476- List <String > newTags = storageAccessGroups ;
14771469
1478- List <String > existingTagsOnCluster = ( List < String >) CollectionUtils .intersection (newTags , clusterTagsList );
1479- List <String > existingTagsOnPod = ( List < String >) CollectionUtils .intersection (newTags , podTagsList );
1480- List <String > existingTagsOnZone = ( List < String >) CollectionUtils .intersection (newTags , zoneTagsList );
1470+ List <String > existingTagsOnCluster = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , clusterTagsList ) );
1471+ List <String > existingTagsOnPod = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , podTagsList ) );
1472+ List <String > existingTagsOnZone = new ArrayList <>( CollectionUtils .intersection (storageAccessGroups , zoneTagsList ) );
14811473
14821474 if (CollectionUtils .isNotEmpty (existingTagsOnCluster ) || CollectionUtils .isNotEmpty (existingTagsOnPod ) || CollectionUtils .isNotEmpty (existingTagsOnZone )) {
14831475 String message = "access groups already exist " ;
@@ -1573,14 +1565,14 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
15731565 @ Override
15741566 public Pair <Map <String , String >, Boolean > getStoragePoolNFSMountOpts (StoragePool pool , Map <String , String > details ) {
15751567 boolean details_added = false ;
1576- if (! pool .getPoolType ().equals (Storage .StoragePoolType .NetworkFilesystem )) {
1577- return new Pair <>( details , details_added );
1578- }
1579-
1580- StoragePoolDetailVO nfsMountOpts = _storagePoolDetailsDao . findDetail ( pool . getId (), ApiConstants . NFS_MOUNT_OPTIONS );
1581- if ( nfsMountOpts != null ) {
1582- if ( details == null ) {
1583- details = new HashMap <>() ;
1568+ if (pool .getPoolType ().equals (Storage .StoragePoolType .NetworkFilesystem )) {
1569+ StoragePoolDetailVO nfsMountOpts = _storagePoolDetailsDao . findDetail ( pool . getId (), ApiConstants . NFS_MOUNT_OPTIONS );
1570+ if ( nfsMountOpts != null ) {
1571+ if ( details == null ) {
1572+ details = new HashMap <>( );
1573+ }
1574+ details . put ( ApiConstants . NFS_MOUNT_OPTIONS , nfsMountOpts . getValue ());
1575+ details_added = true ;
15841576 }
15851577 details .put (ApiConstants .NFS_MOUNT_OPTIONS , nfsMountOpts .getValue ());
15861578 details_added = true ;
@@ -4483,7 +4475,7 @@ private void setVolumeObjectTOThrottling(VolumeObjectTO volumeTO, final ServiceO
44834475
44844476 @ Override
44854477 @ ActionEvent (eventType = EventTypes .EVENT_OBJECT_STORE_CREATE , eventDescription = "creating object storage" )
4486- public ObjectStore discoverObjectStore (String name , String url , Long size , String providerName , Map details )
4478+ public ObjectStore discoverObjectStore (String name , String url , Long size , String providerName , Map < String , String > details )
44874479 throws IllegalArgumentException , InvalidParameterValueException {
44884480 DataStoreProvider storeProvider = _dataStoreProviderMgr .getDataStoreProvider (providerName );
44894481
0 commit comments