protected void writeObjectHeader ( List < Object > list ) { // action list . add ( "{\"" + getOperation ( ) + "\":{" ) ; // flag indicating whether a comma needs to be added between fields boolean commaMightBeNeeded = false ; commaMightBeNeeded = addExtractorOrDynamicValue ( list , getMetadataExtractorOrFallback ( Metadata . INDEX , indexExtractor ) , "" , commaMightBeNeeded ) ; commaMightBeNeeded = addExtractorOrDynamicValue ( list , getMetadataExtractorOrFallback ( Metadata . TYPE , typeExtractor ) , "\"_type\":" , commaMightBeNeeded ) ; commaMightBeNeeded = id ( list , commaMightBeNeeded ) ; commaMightBeNeeded = addExtractorOrDynamicValue ( list , getMetadataExtractorOrFallback ( Metadata . PARENT , parentExtractor ) , requestParameterNames . parent , commaMightBeNeeded ) ; commaMightBeNeeded = addExtractorOrDynamicValueAsFieldWriter ( list , getMetadataExtractorOrFallback ( Metadata . ROUTING , routingExtractor ) , requestParameterNames . routing , commaMightBeNeeded ) ; commaMightBeNeeded = addExtractorOrDynamicValue ( list , getMetadataExtractorOrFallback ( Metadata . TTL , ttlExtractor ) , "\"_ttl\":" , commaMightBeNeeded ) ; commaMightBeNeeded = addExtractorOrDynamicValue ( list , getMetadataExtractorOrFallback ( Metadata . TIMESTAMP , timestampExtractor ) , "\"_timestamp\":" , commaMightBeNeeded ) ; // version & version_type fields Object versionField = getMetadataExtractorOrFallback ( Metadata . VERSION , versionExtractor ) ; if ( versionField != null ) { if ( commaMightBeNeeded ) { list . add ( "," ) ; commaMightBeNeeded = false ; } commaMightBeNeeded = true ; list . add ( requestParameterNames . version ) ; list . add ( versionField ) ; // version_type - only needed when a version is specified Object versionTypeField = getMetadataExtractorOrFallback ( Metadata . VERSION_TYPE , versionTypeExtractor ) ; if ( versionTypeField != null ) { if ( commaMightBeNeeded ) { list . add ( "," ) ; commaMightBeNeeded = false ; } commaMightBeNeeded = true ; list . add ( requestParameterNames . versionType ) ; list . add ( versionTypeField ) ; } } // useful for update command otherHeader ( list , commaMightBeNeeded ) ; list . add ( "}}\n" ) ; }
write action & metadata header