@@ -639,31 +639,28 @@ public List<BackupSchedule> listBackupSchedules(ListBackupScheduleCmd cmd) {
639639 Long scheduleId = cmd .getId ();
640640 Long vmId = cmd .getVmId ();
641641 Long accountId ;
642+ String accountName = cmd .getAccountName ();
642643 Long domainId = cmd .getDomainId ();
643644 Long projectId = cmd .getProjectId ();
644645 String strIntervalType = cmd .getIntervalType ();
645646 List <Long > domainsList = new ArrayList <>();
646647
647648 Integer intervalTypeOrdinal = null ;
648649 if (strIntervalType != null ) {
649- logger .trace ("Searching for informed [{}] interval type in valid intervals: {}" , strIntervalType , DateUtil .IntervalType .values ());
650+ logger .debug ("Searching for informed [{}] interval type in valid intervals: {}" , strIntervalType , DateUtil .IntervalType .values ());
650651 DateUtil .IntervalType intervalType = DateUtil .IntervalType .getIntervalType (strIntervalType );
651652
652653 if (intervalType == null ) {
653654 logger .error ("The informed interval type [{}] was invalid, thus an exception is being thrown." );
654655 throw new InvalidParameterValueException (String .format ("No valid interval type was found for [%s]." , strIntervalType ));
655656 }
656657
657- logger .trace ("Interval type {} was found in valid interval types." , intervalType .name ());
658+ logger .debug ("Interval type {} was found in valid interval types." , intervalType .name ());
658659 intervalTypeOrdinal = intervalType .ordinal ();
659660 }
660661
661662 if (domainId != null ) {
662- if (projectId != null ) {
663- throw new InvalidParameterValueException ("Domain and projectId can't be specified together" );
664- }
665-
666- logger .trace ("Searching for domain with ID [{}]." , domainId );
663+ logger .debug ("Searching for domain with ID [{}]." , domainId );
667664 Domain domain = domainDao .findById (domainId );
668665
669666 if (domain == null ) {
@@ -677,24 +674,23 @@ public List<BackupSchedule> listBackupSchedules(ListBackupScheduleCmd cmd) {
677674 }
678675
679676 accountId = caller .getAccountId ();
680- if (cmd .getAccountName () != null ) {
681- String accName = cmd .getAccountName ();
682677
678+ if (accountName != null ) {
683679 if (projectId != null ) {
684680 throw new InvalidParameterValueException ("Account and projectId can't be specified together" );
685681 }
686682
687- logger .info ("Searching for account with name [{}]." , accName );
688- accountId = accountManager .finalizeAccountIdAndCheckCallerAccess (accName , domainId , null );
683+ logger .debug ("Searching for account with name [{}]." , accountName );
684+ accountId = accountManager .finalizeAccountIdAndCheckCallerAccess (accountName , domainId , null );
689685 }
690686
691687 if (projectId != null ) {
692- logger .info ("Searching for project with ID [{}]" , projectId );
688+ logger .debug ("Searching for project with ID [{}]" , projectId );
693689 accountId = accountManager .finalizeAccountIdAndCheckCallerAccess (null , null , projectId );
694690 }
695691
696692 if (vmId != null ) {
697- logger .trace ("Searching for VM with ID [{}]." , vmId );
693+ logger .debug ("Searching for VM with ID [{}]." , vmId );
698694 final VMInstanceVO vm = findVmById (vmId );
699695
700696 logger .debug ("Validating if backup is enabled in the VM's zone." );
@@ -709,8 +705,14 @@ public List<BackupSchedule> listBackupSchedules(ListBackupScheduleCmd cmd) {
709705 }
710706
711707 if (domainsList .isEmpty ()) {
712- logger .info ("Defaulting schedule listing to the caller account's domain as it was not informed previously." );
713- domainsList .add (caller .getDomainId ());
708+ if (accountName == null && projectId == null ) {
709+ logger .info ("Defaulting schedule listing to the caller account's domain as it was not informed previously." );
710+ domainsList .add (caller .getDomainId ());
711+ } else {
712+ Account account = accountDao .findById (accountId );
713+ logger .info ("Defaulting schedule listing domain to [{}] as it is the domain of informed account [{}]." , account .getDomainId (), account .getUuid ());
714+ domainsList .add (account .getDomainId ());
715+ }
714716 }
715717
716718 if (cmd .listAll () && accountId .equals (caller .getAccountId ()) && accountManager .isAdmin (accountId )) {
0 commit comments