4242import javax .inject .Inject ;
4343import javax .naming .ConfigurationException ;
4444
45+ import org .apache .cloudstack .framework .config .ConfigDepot ;
4546import org .apache .commons .codec .binary .Base64 ;
4647import org .apache .log4j .Logger ;
4748
@@ -713,6 +714,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
713714 @ Inject
714715 ConfigurationServer _configServer ;
715716 @ Inject
717+ ConfigDepot _configDepot ;
718+ @ Inject
716719 UserVmManager _userVmMgr ;
717720 @ Inject
718721 VolumeDataFactory _volFactory ;
@@ -1680,15 +1683,6 @@ public Pair<List<? extends Configuration>, Integer> searchForConfigurations(List
16801683 throw new InvalidParameterValueException ("cannot handle multiple IDs, provide only one ID corresponding to the scope" );
16811684 }
16821685
1683- if (scope != null && !scope .isEmpty ()) {
1684- // getting the list of parameters at requested scope
1685- if (id == null ) {
1686- throw new InvalidParameterValueException ("Invalid id null, id is needed corresponding to the scope" );
1687- }
1688- List <ConfigurationVO > configList = _configServer .getConfigListByScope (scope , id );
1689- return new Pair <List <? extends Configuration >, Integer >(configList , configList .size ());
1690- }
1691-
16921686 if (keyword != null ) {
16931687 SearchCriteria <ConfigurationVO > ssc = _configDao .createSearchCriteria ();
16941688 ssc .addOr ("name" , SearchCriteria .Op .LIKE , "%" + keyword + "%" );
@@ -1712,7 +1706,28 @@ public Pair<List<? extends Configuration>, Integer> searchForConfigurations(List
17121706 // hidden configurations are not displayed using the search API
17131707 sc .addAnd ("category" , SearchCriteria .Op .NEQ , "Hidden" );
17141708
1709+ if (scope != null && !scope .isEmpty ()) {
1710+ // getting the list of parameters at requested scope
1711+ if (id == null ) {
1712+ throw new InvalidParameterValueException ("Invalid id null, id is needed corresponding to the scope" );
1713+ }
1714+ sc .addAnd ("scope" , SearchCriteria .Op .EQ , scope );
1715+ }
1716+
17151717 Pair <List <ConfigurationVO >, Integer > result = _configDao .searchAndCount (sc , searchFilter );
1718+
1719+ if (scope != null && !scope .isEmpty ()) {
1720+ // Populate values corresponding the resource id
1721+ List <ConfigurationVO > configVOList = new ArrayList <ConfigurationVO >();
1722+ for (ConfigurationVO param : result .first ()){
1723+ ConfigurationVO configVo = _configDao .findByName (param .getName ());
1724+ configVo .setValue (_configDepot .get (param .getName ()).valueIn (id ).toString ());
1725+ configVOList .add (configVo );
1726+ }
1727+
1728+ return new Pair <List <? extends Configuration >, Integer >(configVOList , configVOList .size ());
1729+ }
1730+
17161731 return new Pair <List <? extends Configuration >, Integer >(result .first (), result .second ());
17171732 }
17181733
0 commit comments