56
56
import java .util .ArrayList ;
57
57
import java .util .Arrays ;
58
58
import java .util .HashMap ;
59
+ import java .util .Iterator ;
59
60
import java .util .LinkedList ;
60
61
import java .util .List ;
61
62
import java .util .Map ;
@@ -680,7 +681,15 @@ Response createZone(String projectId, ManagedZone zone, String... fields) {
680
681
completeZone .setId (BigInteger .valueOf (Math .abs (ID_GENERATOR .nextLong () % Long .MAX_VALUE )));
681
682
completeZone .setNameServers (randomNameservers ());
682
683
ZoneContainer zoneContainer = new ZoneContainer (completeZone );
683
- zoneContainer .dnsRecords ().set (defaultRecords (completeZone ));
684
+ ImmutableSortedMap <String , ResourceRecordSet > defaultsRecords = defaultRecords (completeZone );
685
+ zoneContainer .dnsRecords ().set (defaultsRecords );
686
+ Change change = new Change ();
687
+ change .setAdditions (ImmutableList .copyOf (defaultsRecords .values ()));
688
+ change .setStatus ("done" );
689
+ change .setId ("0" );
690
+ change .setStartTime (ISODateTimeFormat .dateTime ().withZoneUTC ()
691
+ .print (System .currentTimeMillis ()));
692
+ zoneContainer .changes ().add (change );
684
693
ProjectContainer projectContainer = findProject (projectId );
685
694
ZoneContainer oldValue = projectContainer .zones ().putIfAbsent (
686
695
completeZone .getName (), zoneContainer );
@@ -718,8 +727,9 @@ Response createChange(String projectId, String zoneName, Change change, String..
718
727
completeChange .setDeletions (ImmutableList .copyOf (change .getDeletions ()));
719
728
}
720
729
/* We need to set ID for the change. We are working in concurrent environment. We know that the
721
- element fell on an index between 0 and maxId, so we will reset all IDs in this range (all of
722
- them are valid for the respective objects). */
730
+ element fell on an index between 1 and maxId (index 0 is the default change which creates SOA
731
+ and NS), so we will reset all IDs between 0 and maxId (all of them are valid for the respective
732
+ objects). */
723
733
ConcurrentLinkedQueue <Change > changeSequence = zoneContainer .changes ();
724
734
changeSequence .add (completeChange );
725
735
int maxId = changeSequence .size ();
@@ -728,7 +738,7 @@ Response createChange(String projectId, String zoneName, Change change, String..
728
738
if (index == maxId ) {
729
739
break ;
730
740
}
731
- c .setId (String .valueOf (++ index ));
741
+ c .setId (String .valueOf (index ++ ));
732
742
}
733
743
completeChange .setStatus ("pending" );
734
744
completeChange .setStartTime (ISODateTimeFormat .dateTime ().withZoneUTC ()
0 commit comments