idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
29,100
public void log ( Level level , T key , long timeout , Object ... args ) { SuppressCache . Value val = cache . putIfAbsent ( key , timeout ) ; if ( val == null ) // key is present and hasn't expired return ; String message = val . count ( ) == 1 ? String . format ( message_format , args ) : String . format ( message_format , args ) + " " + String . format ( suppress_format , val . count ( ) , key , val . age ( ) ) ; switch ( level ) { case error : log . error ( message ) ; break ; case warn : log . warn ( message ) ; break ; case trace : log . trace ( message ) ; break ; } }
Logs a message from a given member if is hasn t been logged for timeout ms
155
17
29,101
@ ManagedOperation public void enableReaping ( long interval ) { if ( task != null ) task . cancel ( false ) ; task = timer . scheduleWithFixedDelay ( new Reaper ( ) , 0 , interval , TimeUnit . MILLISECONDS ) ; }
Runs the reaper every interval ms evicts expired items
57
12
29,102
public int add ( final Message msg , boolean resize ) { if ( msg == null ) return 0 ; if ( index >= messages . length ) { if ( ! resize ) return 0 ; resize ( ) ; } messages [ index ++ ] = msg ; return 1 ; }
Adds a message to the table
55
6
29,103
public int add ( final MessageBatch batch , boolean resize ) { if ( batch == null ) return 0 ; if ( this == batch ) throw new IllegalArgumentException ( "cannot add batch to itself" ) ; int batch_size = batch . size ( ) ; if ( index + batch_size >= messages . length && resize ) resize ( messages . length + batch_size + 1 ) ; int cnt = 0 ; for ( Message msg : batch ) { if ( index >= messages . length ) return cnt ; messages [ index ++ ] = msg ; cnt ++ ; } return cnt ; }
Adds another batch to this one
128
6
29,104
public MessageBatch replace ( Message existing_msg , Message new_msg ) { if ( existing_msg == null ) return this ; for ( int i = 0 ; i < index ; i ++ ) { if ( messages [ i ] != null && messages [ i ] == existing_msg ) { messages [ i ] = new_msg ; break ; } } return this ; }
Replaces a message in the batch with another one
79
10
29,105
public MessageBatch replace ( Predicate < Message > filter , Message replacement , boolean match_all ) { replaceIf ( filter , replacement , match_all ) ; return this ; }
Replaces all messages which match a given filter with a replacement message
38
13
29,106
public int replaceIf ( Predicate < Message > filter , Message replacement , boolean match_all ) { if ( filter == null ) return 0 ; int matched = 0 ; for ( int i = 0 ; i < index ; i ++ ) { if ( filter . test ( messages [ i ] ) ) { messages [ i ] = replacement ; matched ++ ; if ( ! match_all ) break ; } } return matched ; }
Replaces all messages that match a given filter with a replacement message
88
13
29,107
public int transferFrom ( MessageBatch other , boolean clear ) { if ( other == null || this == other ) return 0 ; int capacity = messages . length , other_size = other . size ( ) ; if ( other_size == 0 ) return 0 ; if ( capacity < other_size ) messages = new Message [ other_size ] ; System . arraycopy ( other . messages , 0 , this . messages , 0 , other_size ) ; if ( this . index > other_size ) for ( int i = other_size ; i < this . index ; i ++ ) messages [ i ] = null ; this . index = other_size ; if ( clear ) other . clear ( ) ; return other_size ; }
Transfers messages from other to this batch . Optionally clears the other batch after the transfer
154
19
29,108
public Collection < Message > getMatchingMessages ( final short id , boolean remove ) { return map ( ( msg , batch ) -> { if ( msg != null && msg . getHeader ( id ) != null ) { if ( remove ) batch . remove ( msg ) ; return msg ; } return null ; } ) ; }
Removes and returns all messages which have a header with ID == id
68
14
29,109
public < T > Collection < T > map ( BiFunction < Message , MessageBatch , T > visitor ) { Collection < T > retval = null ; for ( int i = 0 ; i < index ; i ++ ) { try { T result = visitor . apply ( messages [ i ] , this ) ; if ( result != null ) { if ( retval == null ) retval = new ArrayList <> ( ) ; retval . add ( result ) ; } } catch ( Throwable t ) { } } return retval ; }
Applies a function to all messages and returns a list of the function results
114
15
29,110
public int size ( ) { int retval = 0 ; for ( int i = 0 ; i < index ; i ++ ) if ( messages [ i ] != null ) retval ++ ; return retval ; }
Returns the number of non - null messages
44
8
29,111
protected boolean shouldDropUpMessage ( @ SuppressWarnings ( "UnusedParameters" ) Message msg , Address sender ) { if ( discard_all && ! sender . equals ( localAddress ( ) ) ) return true ; if ( ignoredMembers . contains ( sender ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( localAddress + ": dropping message from " + sender ) ; num_up ++ ; return true ; } if ( up > 0 ) { double r = Math . random ( ) ; if ( r < up ) { if ( excludeItself && sender . equals ( localAddress ( ) ) ) { if ( log . isTraceEnabled ( ) ) log . trace ( "excluding myself" ) ; } else { if ( log . isTraceEnabled ( ) ) log . trace ( localAddress + ": dropping message from " + sender ) ; num_up ++ ; return true ; } } } return false ; }
Checks if a message should be passed up or not
202
11
29,112
protected void drain ( ) { Message msg ; while ( ( msg = queue . poll ( ) ) != null ) addAndSendIfSizeExceeded ( msg ) ; _sendBundledMessages ( ) ; }
Takes all messages from the queue adds them to the hashmap and then sends all bundled messages
46
19
29,113
public E buildTextComponent ( ) { final E textComponent = createTextComponent ( ) ; textComponent . setRequired ( required ) ; textComponent . setImmediate ( immediate ) ; textComponent . setReadOnly ( readOnly ) ; textComponent . setEnabled ( enabled ) ; if ( ! StringUtils . isEmpty ( caption ) ) { textComponent . setCaption ( caption ) ; } if ( ! StringUtils . isEmpty ( style ) ) { textComponent . setStyleName ( style ) ; } if ( ! StringUtils . isEmpty ( styleName ) ) { textComponent . addStyleName ( styleName ) ; } if ( ! StringUtils . isEmpty ( prompt ) ) { textComponent . setInputPrompt ( prompt ) ; } if ( maxLengthAllowed > 0 ) { textComponent . setMaxLength ( maxLengthAllowed ) ; } if ( ! StringUtils . isEmpty ( id ) ) { textComponent . setId ( id ) ; } if ( ! validators . isEmpty ( ) ) { validators . forEach ( textComponent :: addValidator ) ; } textComponent . setNullRepresentation ( "" ) ; return textComponent ; }
Build a textfield
252
4
29,114
public void populateTableByDistributionSet ( final DistributionSet distributionSet ) { removeAllItems ( ) ; if ( distributionSet == null ) { return ; } final Container dataSource = getContainerDataSource ( ) ; final List < TargetFilterQuery > filters = distributionSet . getAutoAssignFilters ( ) ; filters . forEach ( query -> { final Object itemId = dataSource . addItem ( ) ; final Item item = dataSource . getItem ( itemId ) ; item . getItemProperty ( TFQ_NAME ) . setValue ( query . getName ( ) ) ; item . getItemProperty ( TFQ_QUERY ) . setValue ( query . getQuery ( ) ) ; } ) ; }
Populate software module metadata .
152
6
29,115
private void createRequiredComponents ( ) { distNameTextField = createTextField ( "textfield.name" , UIComponentIdProvider . DIST_ADD_NAME , DistributionSet . NAME_MAX_SIZE ) ; distVersionTextField = createTextField ( "textfield.version" , UIComponentIdProvider . DIST_ADD_VERSION , DistributionSet . VERSION_MAX_SIZE ) ; distsetTypeNameComboBox = SPUIComponentProvider . getComboBox ( i18n . getMessage ( "label.combobox.type" ) , "" , null , "" , false , "" , i18n . getMessage ( "label.combobox.type" ) ) ; distsetTypeNameComboBox . setImmediate ( true ) ; distsetTypeNameComboBox . setNullSelectionAllowed ( false ) ; distsetTypeNameComboBox . setId ( UIComponentIdProvider . DIST_ADD_DISTSETTYPE ) ; descTextArea = new TextAreaBuilder ( DistributionSet . DESCRIPTION_MAX_SIZE ) . caption ( i18n . getMessage ( "textfield.description" ) ) . style ( "text-area-style" ) . id ( UIComponentIdProvider . DIST_ADD_DESC ) . buildTextComponent ( ) ; reqMigStepCheckbox = SPUIComponentProvider . getCheckBox ( i18n . getMessage ( "checkbox.dist.required.migration.step" ) , "dist-checkbox-style" , null , false , "" ) ; reqMigStepCheckbox . addStyleName ( ValoTheme . CHECKBOX_SMALL ) ; reqMigStepCheckbox . setId ( UIComponentIdProvider . DIST_ADD_MIGRATION_CHECK ) ; }
Create required UI components .
406
5
29,116
private static LazyQueryContainer getDistSetTypeLazyQueryContainer ( ) { final BeanQueryFactory < DistributionSetTypeBeanQuery > dtQF = new BeanQueryFactory <> ( DistributionSetTypeBeanQuery . class ) ; dtQF . setQueryConfiguration ( Collections . emptyMap ( ) ) ; final LazyQueryContainer disttypeContainer = new LazyQueryContainer ( new LazyQueryDefinition ( true , SPUIDefinitions . DIST_TYPE_SIZE , SPUILabelDefinitions . VAR_ID ) , dtQF ) ; disttypeContainer . addContainerProperty ( SPUILabelDefinitions . VAR_NAME , String . class , "" , true , true ) ; return disttypeContainer ; }
Get the LazyQueryContainer instance for DistributionSetTypes .
160
12
29,117
public void resetComponents ( ) { distNameTextField . clear ( ) ; distNameTextField . removeStyleName ( "v-textfield-error" ) ; distVersionTextField . clear ( ) ; distVersionTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT ) ; distsetTypeNameComboBox . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT ) ; distsetTypeNameComboBox . clear ( ) ; distsetTypeNameComboBox . setEnabled ( true ) ; descTextArea . clear ( ) ; reqMigStepCheckbox . clear ( ) ; }
clear all the fields .
169
5
29,118
private CommonDialogWindow getWindow ( final Long editDistId ) { final SaveDialogCloseListener saveDialogCloseListener ; String caption ; resetComponents ( ) ; populateDistSetTypeNameCombo ( ) ; if ( editDistId == null ) { saveDialogCloseListener = new CreateOnCloseDialogListener ( ) ; caption = i18n . getMessage ( "caption.create.new" , i18n . getMessage ( "caption.distribution" ) ) ; } else { saveDialogCloseListener = new UpdateOnCloseDialogListener ( editDistId ) ; caption = i18n . getMessage ( "caption.update" , i18n . getMessage ( "caption.distribution" ) ) ; populateValuesOfDistribution ( editDistId ) ; } return new WindowBuilder ( SPUIDefinitions . CREATE_UPDATE_WINDOW ) . caption ( caption ) . content ( this ) . layout ( formLayout ) . i18n ( i18n ) . saveDialogCloseListener ( saveDialogCloseListener ) . buildCommonDialogWindow ( ) ; }
Internal method to create a window to create or update a DistributionSet .
230
14
29,119
private void populateDistSetTypeNameCombo ( ) { distsetTypeNameComboBox . setContainerDataSource ( getDistSetTypeLazyQueryContainer ( ) ) ; distsetTypeNameComboBox . setItemCaptionPropertyId ( SPUILabelDefinitions . VAR_NAME ) ; distsetTypeNameComboBox . setValue ( getDefaultDistributionSetType ( ) . getId ( ) ) ; }
Populate DistributionSet Type name combo .
95
8
29,120
private void createMaintenanceScheduleControl ( ) { schedule = new TextFieldBuilder ( Action . MAINTENANCE_WINDOW_SCHEDULE_LENGTH ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_SCHEDULE_ID ) . caption ( i18n . getMessage ( "caption.maintenancewindow.schedule" ) ) . validator ( new CronValidator ( ) ) . prompt ( "0 0 3 ? * 6" ) . required ( true , i18n ) . buildTextComponent ( ) ; schedule . addTextChangeListener ( new CronTranslationListener ( ) ) ; }
Text field to specify the schedule .
139
7
29,121
private void createMaintenanceDurationControl ( ) { duration = new TextFieldBuilder ( Action . MAINTENANCE_WINDOW_DURATION_LENGTH ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_DURATION_ID ) . caption ( i18n . getMessage ( "caption.maintenancewindow.duration" ) ) . validator ( new DurationValidator ( ) ) . prompt ( "hh:mm:ss" ) . required ( true , i18n ) . buildTextComponent ( ) ; }
Text field to specify the duration .
119
7
29,122
private void createMaintenanceTimeZoneControl ( ) { // ComboBoxBuilder cannot be used here, because Builder do // 'comboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);' // which interferes our code: 'timeZone.addItems(getAllTimeZones());' timeZone = new ComboBox ( ) ; timeZone . setId ( UIComponentIdProvider . MAINTENANCE_WINDOW_TIME_ZONE_ID ) ; timeZone . setCaption ( i18n . getMessage ( "caption.maintenancewindow.timezone" ) ) ; timeZone . addItems ( getAllTimeZones ( ) ) ; timeZone . setValue ( getClientTimeZone ( ) ) ; timeZone . addStyleName ( ValoTheme . COMBOBOX_SMALL ) ; timeZone . setTextInputAllowed ( false ) ; timeZone . setNullSelectionAllowed ( false ) ; }
Combo box to pick the time zone offset .
211
10
29,123
private static List < String > getAllTimeZones ( ) { final List < String > lst = ZoneId . getAvailableZoneIds ( ) . stream ( ) . map ( id -> ZonedDateTime . now ( ZoneId . of ( id ) ) . getOffset ( ) . getId ( ) . replace ( "Z" , "+00:00" ) ) . distinct ( ) . collect ( Collectors . toList ( ) ) ; lst . sort ( null ) ; return lst ; }
Get list of all time zone offsets supported .
109
9
29,124
private static String getClientTimeZone ( ) { return ZonedDateTime . now ( SPDateTimeUtil . getTimeZoneId ( SPDateTimeUtil . getBrowserTimeZone ( ) ) ) . getOffset ( ) . getId ( ) . replaceAll ( "Z" , "+00:00" ) ; }
Get time zone of the browser client to be used as default .
69
13
29,125
private void createMaintenanceScheduleTranslatorControl ( ) { scheduleTranslator = new LabelBuilder ( ) . id ( UIComponentIdProvider . MAINTENANCE_WINDOW_SCHEDULE_TRANSLATOR_ID ) . name ( i18n . getMessage ( CRON_VALIDATION_ERROR ) ) . buildLabel ( ) ; scheduleTranslator . addStyleName ( ValoTheme . LABEL_TINY ) ; }
Label to translate the cron schedule to human readable format .
100
12
29,126
public void clearAllControls ( ) { schedule . setValue ( "" ) ; duration . setValue ( "" ) ; timeZone . setValue ( getClientTimeZone ( ) ) ; scheduleTranslator . setValue ( i18n . getMessage ( CRON_VALIDATION_ERROR ) ) ; }
Set all the controls to their default values .
65
9
29,127
public void clear ( ) { queryTextField . clear ( ) ; validationIcon . setValue ( FontAwesome . CHECK_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( "hide-status-label" ) ; }
Clears the textfield and resets the validation icon .
54
12
29,128
public void showValidationSuccesIcon ( final String text ) { validationIcon . setValue ( FontAwesome . CHECK_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . SUCCESS_ICON ) ; filterManagementUIState . setFilterQueryValue ( text ) ; filterManagementUIState . setIsFilterByInvalidFilterQuery ( Boolean . FALSE ) ; }
Shows the validation success icon in the textfield
93
10
29,129
public void showValidationFailureIcon ( final String validationMessage ) { validationIcon . setValue ( FontAwesome . TIMES_CIRCLE . getHtml ( ) ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . ERROR_ICON ) ; validationIcon . setDescription ( validationMessage ) ; filterManagementUIState . setFilterQueryValue ( null ) ; filterManagementUIState . setIsFilterByInvalidFilterQuery ( Boolean . TRUE ) ; }
Shows the validation error icon in the textfield
100
10
29,130
public void showValidationInProgress ( ) { validationIcon . setValue ( null ) ; validationIcon . addStyleName ( "show-status-label" ) ; validationIcon . setStyleName ( SPUIStyleDefinitions . TARGET_FILTER_SEARCH_PROGRESS_INDICATOR_STYLE ) ; }
Sets the spinner as progress indicator .
73
9
29,131
@ Bean @ ConditionalOnProperty ( prefix = "hawkbit.server.security.dos.filter" , name = "enabled" , matchIfMissing = true ) public FilterRegistrationBean < DosFilter > dosSystemFilter ( final HawkbitSecurityProperties securityProperties ) { final FilterRegistrationBean < DosFilter > filterRegBean = dosFilter ( Collections . emptyList ( ) , securityProperties . getDos ( ) . getFilter ( ) , securityProperties . getClients ( ) ) ; filterRegBean . setUrlPatterns ( Arrays . asList ( "/system/*" ) ) ; filterRegBean . setOrder ( DOS_FILTER_ORDER ) ; filterRegBean . setName ( "dosSystemFilter" ) ; return filterRegBean ; }
Filter to protect the hawkBit server system management interface against to many requests .
171
15
29,132
public static void addNewMapping ( final Class < ? > type , final String property , final String mapping ) { allowedColmns . computeIfAbsent ( type , k -> new HashMap <> ( ) ) ; allowedColmns . get ( type ) . put ( property , mapping ) ; }
Add new mapping - property name and alias .
65
9
29,133
public void clearUploadTempData ( ) { LOG . debug ( "Cleaning up temp data..." ) ; // delete file system zombies for ( final FileUploadProgress fileUploadProgress : getAllFileUploadProgressValuesFromOverallUploadProcessList ( ) ) { if ( ! StringUtils . isBlank ( fileUploadProgress . getFilePath ( ) ) ) { final boolean deleted = FileUtils . deleteQuietly ( new File ( fileUploadProgress . getFilePath ( ) ) ) ; if ( ! deleted ) { LOG . warn ( "TempFile was not deleted: {}" , fileUploadProgress . getFilePath ( ) ) ; } } } clearFileStates ( ) ; }
Clears all temp data collected while uploading files .
144
10
29,134
public boolean isUploadInProgressForSelectedSoftwareModule ( final Long softwareModuleId ) { for ( final FileUploadId fileUploadId : getAllFileUploadIdsFromOverallUploadProcessList ( ) ) { if ( fileUploadId . getSoftwareModuleId ( ) . equals ( softwareModuleId ) ) { return true ; } } return false ; }
Checks if an upload is in progress for the given Software Module
74
13
29,135
private static < T extends Enum < T > & FieldNameProvider > T getAttributeIdentifierByName ( final Class < T > enumType , final String name ) { try { return Enum . valueOf ( enumType , name . toUpperCase ( ) ) ; } catch ( final IllegalArgumentException e ) { throw new SortParameterUnsupportedFieldException ( e ) ; } }
Returns the attribute identifier for the given name .
83
9
29,136
@ EventListener ( classes = CancelTargetAssignmentEvent . class ) protected void targetCancelAssignmentToDistributionSet ( final CancelTargetAssignmentEvent cancelEvent ) { if ( isNotFromSelf ( cancelEvent ) ) { return ; } sendCancelMessageToTarget ( cancelEvent . getTenant ( ) , cancelEvent . getEntity ( ) . getControllerId ( ) , cancelEvent . getActionId ( ) , cancelEvent . getEntity ( ) . getAddress ( ) ) ; }
Method to send a message to a RabbitMQ Exchange after the assignment of the Distribution set to a Target has been canceled .
105
24
29,137
@ EventListener ( classes = TargetDeletedEvent . class ) protected void targetDelete ( final TargetDeletedEvent deleteEvent ) { if ( isNotFromSelf ( deleteEvent ) ) { return ; } sendDeleteMessage ( deleteEvent . getTenant ( ) , deleteEvent . getControllerId ( ) , deleteEvent . getTargetAddress ( ) ) ; }
Method to send a message to a RabbitMQ Exchange after a Target was deleted .
75
16
29,138
public void setValue ( final Object value ) { if ( ! ( value instanceof Serializable ) ) { throw new IllegalArgumentException ( "The value muste be a instance of " + Serializable . class . getName ( ) ) ; } this . value = ( Serializable ) value ; }
Sets the MgmtSystemTenantConfigurationValueRequest
63
12
29,139
public void populateSMMetadata ( final SoftwareModule swModule ) { removeAllItems ( ) ; if ( null == swModule ) { return ; } selectedSWModuleId = swModule . getId ( ) ; final List < SoftwareModuleMetadata > swMetadataList = softwareModuleManagement . findMetaDataBySoftwareModuleId ( PageRequest . of ( 0 , MAX_METADATA_QUERY ) , selectedSWModuleId ) . getContent ( ) ; if ( ! CollectionUtils . isEmpty ( swMetadataList ) ) { swMetadataList . forEach ( this :: setMetadataProperties ) ; } }
Populate software module metadata table .
133
7
29,140
public void update ( final List < Long > groupTargetCounts , final Long totalTargetCount ) { this . groupTargetCounts = groupTargetCounts ; this . totalTargetCount = totalTargetCount ; if ( groupTargetCounts != null ) { long sum = 0 ; for ( Long targetCount : groupTargetCounts ) { sum += targetCount ; } unassignedTargets = totalTargetCount - sum ; } draw ( ) ; }
Updates the pie chart with new data
95
8
29,141
private Boolean doValidations ( final DragAndDropEvent dragEvent ) { final Component compsource = dragEvent . getTransferable ( ) . getSourceComponent ( ) ; Boolean isValid = Boolean . TRUE ; if ( compsource instanceof Table && ! isComplexFilterViewDisplayed ) { final TableTransferable transferable = ( TableTransferable ) dragEvent . getTransferable ( ) ; final Table source = transferable . getSourceComponent ( ) ; if ( ! source . getId ( ) . equals ( UIComponentIdProvider . DIST_TABLE_ID ) ) { notification . displayValidationError ( i18n . getMessage ( UIMessageIdProvider . MESSAGE_ACTION_NOT_ALLOWED ) ) ; isValid = Boolean . FALSE ; } else { if ( getDropppedDistributionDetails ( transferable ) . size ( ) > 1 ) { notification . displayValidationError ( i18n . getMessage ( "message.onlyone.distribution.dropallowed" ) ) ; isValid = Boolean . FALSE ; } } } else { notification . displayValidationError ( i18n . getMessage ( UIMessageIdProvider . MESSAGE_ACTION_NOT_ALLOWED ) ) ; isValid = Boolean . FALSE ; } return isValid ; }
Validation for drag event .
278
6
29,142
@ Override public ResponseEntity < Void > deleteTenant ( @ PathVariable ( "tenant" ) final String tenant ) { systemManagement . deleteTenant ( tenant ) ; return ResponseEntity . ok ( ) . build ( ) ; }
Deletes the tenant data of a given tenant . USE WITH CARE!
50
14
29,143
@ Override public ResponseEntity < MgmtSystemStatisticsRest > getSystemUsageStats ( ) { final SystemUsageReportWithTenants report = systemManagement . getSystemUsageStatisticsWithTenants ( ) ; final MgmtSystemStatisticsRest result = new MgmtSystemStatisticsRest ( ) . setOverallActions ( report . getOverallActions ( ) ) . setOverallArtifacts ( report . getOverallArtifacts ( ) ) . setOverallArtifactVolumeInBytes ( report . getOverallArtifactVolumeInBytes ( ) ) . setOverallTargets ( report . getOverallTargets ( ) ) . setOverallTenants ( report . getTenants ( ) . size ( ) ) ; result . setTenantStats ( report . getTenants ( ) . stream ( ) . map ( MgmtSystemManagementResource :: convertTenant ) . collect ( Collectors . toList ( ) ) ) ; return ResponseEntity . ok ( result ) ; }
Collects and returns system usage statistics . It provides a system wide overview and tenant based stats .
203
19
29,144
@ Override @ PreAuthorize ( SpringEvalExpressions . HAS_AUTH_SYSTEM_ADMIN ) public ResponseEntity < Collection < MgmtSystemCache > > getCaches ( ) { final Collection < String > cacheNames = cacheManager . getCacheNames ( ) ; return ResponseEntity . ok ( cacheNames . stream ( ) . map ( cacheManager :: getCache ) . map ( this :: cacheRest ) . collect ( Collectors . toList ( ) ) ) ; }
Returns a list of all caches .
104
7
29,145
@ PreAuthorize ( SpringEvalExpressions . HAS_AUTH_SYSTEM_ADMIN ) @ Override public ResponseEntity < Collection < String > > invalidateCaches ( ) { final Collection < String > cacheNames = cacheManager . getCacheNames ( ) ; LOGGER . info ( "Invalidating caches {}" , cacheNames ) ; cacheNames . forEach ( cacheName -> cacheManager . getCache ( cacheName ) . clear ( ) ) ; return ResponseEntity . ok ( cacheNames ) ; }
Invalidates all caches for all tenants .
109
8
29,146
protected void init ( final String labelText ) { setImmediate ( true ) ; addComponent ( new LabelBuilder ( ) . name ( i18n . getMessage ( labelText ) ) . buildLabel ( ) ) ; }
initialize the abstract component .
47
6
29,147
public Map < String , Object > getDeadLetterExchangeArgs ( final String exchange ) { final Map < String , Object > args = Maps . newHashMapWithExpectedSize ( 1 ) ; args . put ( "x-dead-letter-exchange" , exchange ) ; return args ; }
Return the deadletter arguments .
63
6
29,148
public Queue createDeadletterQueue ( final String queueName ) { return new Queue ( queueName , true , false , false , getTTLArgs ( ) ) ; }
Create a deadletter queue with ttl for messages
37
10
29,149
public void updateTarget ( ) { /* save updated entity */ final Target target = targetManagement . update ( entityFactory . target ( ) . update ( controllerId ) . name ( nameTextField . getValue ( ) ) . description ( descTextArea . getValue ( ) ) ) ; /* display success msg */ uINotification . displaySuccess ( i18n . getMessage ( "message.update.success" , target . getName ( ) ) ) ; // publishing through event bus eventBus . publish ( this , new TargetTableEvent ( BaseEntityEventType . UPDATED_ENTITY , target ) ) ; }
Update the Target if modified .
129
6
29,150
public Window getWindow ( final String controllerId ) { final Optional < Target > target = targetManagement . getByControllerID ( controllerId ) ; if ( ! target . isPresent ( ) ) { uINotification . displayWarning ( i18n . getMessage ( "target.not.exists" , controllerId ) ) ; return null ; } populateValuesOfTarget ( target . get ( ) ) ; createNewWindow ( ) ; window . setCaption ( i18n . getMessage ( "caption.update" , i18n . getMessage ( "caption.target" ) ) ) ; window . addStyleName ( "target-update-window" ) ; return window ; }
Returns Target Update window based on the selected Entity Id in the target table .
148
15
29,151
public void resetComponents ( ) { nameTextField . clear ( ) ; nameTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_ERROR ) ; controllerIDTextField . setEnabled ( Boolean . TRUE ) ; controllerIDTextField . removeStyleName ( SPUIStyleDefinitions . SP_TEXTFIELD_ERROR ) ; controllerIDTextField . clear ( ) ; descTextArea . clear ( ) ; editTarget = Boolean . FALSE ; }
clear all fields of Target Edit Window .
107
8
29,152
public static String getColorPickedString ( final SpColorPickerPreview preview ) { final Color color = preview . getColor ( ) ; return "rgb(" + color . getRed ( ) + "," + color . getGreen ( ) + "," + color . getBlue ( ) + ")" ; }
Get color picked value as string .
66
7
29,153
protected HawkbitErrorNotificationMessage buildNotification ( final Throwable ex ) { LOG . error ( "Error in UI: " , ex ) ; final String errorMessage = extractMessageFrom ( ex ) ; final VaadinMessageSource i18n = SpringContextHelper . getBean ( VaadinMessageSource . class ) ; return new HawkbitErrorNotificationMessage ( STYLE , i18n . getMessage ( "caption.error" ) , errorMessage , true ) ; }
Method to build a notification based on an exception .
103
10
29,154
private void assertMetaDataQuota ( final Long moduleId , final int requested ) { final int maxMetaData = quotaManagement . getMaxMetaDataEntriesPerSoftwareModule ( ) ; QuotaHelper . assertAssignmentQuota ( moduleId , requested , maxMetaData , SoftwareModuleMetadata . class , SoftwareModule . class , softwareModuleMetadataRepository :: countBySoftwareModuleId ) ; }
Asserts the meta data quota for the software module with the given ID .
85
16
29,155
public static Specification < JpaAction > hasTargetAssignedArtifact ( final String controllerId , final String sha1Hash ) { return ( actionRoot , query , criteriaBuilder ) -> { final Join < JpaAction , JpaDistributionSet > dsJoin = actionRoot . join ( JpaAction_ . distributionSet ) ; final SetJoin < JpaDistributionSet , JpaSoftwareModule > modulesJoin = dsJoin . join ( JpaDistributionSet_ . modules ) ; final ListJoin < JpaSoftwareModule , JpaArtifact > artifactsJoin = modulesJoin . join ( JpaSoftwareModule_ . artifacts ) ; return criteriaBuilder . and ( criteriaBuilder . equal ( artifactsJoin . get ( JpaArtifact_ . sha1Hash ) , sha1Hash ) , criteriaBuilder . equal ( actionRoot . get ( JpaAction_ . target ) . get ( JpaTarget_ . controllerId ) , controllerId ) ) ; } ; }
Specification which joins all necessary tables to retrieve the dependency between a target and a local file assignment through the assigned action of the target . All actions are included not only active actions .
208
36
29,156
public CommonDialogWindow getWindow ( final E entity , final String metaDatakey ) { selectedEntity = entity ; metadataWindow = new WindowBuilder ( SPUIDefinitions . CREATE_UPDATE_WINDOW ) . caption ( getMetadataCaption ( ) ) . content ( this ) . cancelButtonClickListener ( event -> onCancel ( ) ) . id ( UIComponentIdProvider . METADATA_POPUP_ID ) . layout ( mainLayout ) . i18n ( i18n ) . saveDialogCloseListener ( new SaveOnDialogCloseListener ( ) ) . buildCommonDialogWindow ( ) ; metadataWindow . setHeight ( 550 , Unit . PIXELS ) ; metadataWindow . setWidth ( 800 , Unit . PIXELS ) ; metadataWindow . getMainLayout ( ) . setSizeFull ( ) ; metadataWindow . getButtonsLayout ( ) . setHeight ( "45px" ) ; setUpDetails ( entity . getId ( ) , metaDatakey ) ; return metadataWindow ; }
Returns metadata popup .
219
4
29,157
public void restoreState ( ) { if ( artifactUploadState . areAllUploadsFinished ( ) ) { artifactUploadState . clearUploadTempData ( ) ; hideUploadProgressButton ( ) ; upload . setEnabled ( true ) ; } else if ( artifactUploadState . isAtLeastOneUploadInProgress ( ) ) { showUploadProgressButton ( ) ; } }
Is called when view is shown to the user
78
9
29,158
@ Override public void buttonClick ( final ClickEvent event ) { if ( window . getParent ( ) != null ) { isImplicitClose = true ; UI . getCurrent ( ) . removeWindow ( window ) ; } callback . response ( event . getSource ( ) . equals ( okButton ) ) ; }
TenantAwareEvent handler for button clicks .
66
10
29,159
@ SuppressWarnings ( "unchecked" ) public static < T > Set < T > getTableValue ( final Table table ) { final Object value = table . getValue ( ) ; Set < T > idsReturn ; if ( value == null ) { idsReturn = Collections . emptySet ( ) ; } else if ( value instanceof Collection ) { final Collection < T > ids = ( Collection < T > ) value ; idsReturn = ids . stream ( ) . filter ( Objects :: nonNull ) . collect ( Collectors . toSet ( ) ) ; } else { final T id = ( T ) value ; idsReturn = Collections . singleton ( id ) ; } return idsReturn ; }
Gets the selected item id or in multiselect mode the selected ids .
154
17
29,160
public Set < Long > getSelectedEntitiesByTransferable ( final TableTransferable transferable ) { final Set < Long > selectedEntities = getTableValue ( this ) ; final Set < Long > ids = new HashSet <> ( ) ; final Long transferableData = ( Long ) transferable . getData ( SPUIDefinitions . ITEMID ) ; if ( transferableData == null ) { return ids ; } if ( entityToBeDeletedIsSelectedInTable ( transferableData , selectedEntities ) ) { ids . addAll ( selectedEntities ) ; } else { ids . add ( transferableData ) ; } return ids ; }
Return the entity which should be deleted by a transferable
147
11
29,161
public void selectEntity ( final Long entityId ) { E entity = null ; if ( entityId != null ) { entity = findEntityByTableValue ( entityId ) . orElse ( null ) ; } setLastSelectedEntityId ( entityId ) ; publishSelectedEntityEvent ( entity ) ; }
Finds the entity object of the given entity ID and performs the publishing of the BaseEntityEventType . SELECTED_ENTITY event
64
27
29,162
public void reset ( ) { totalTargetsLabel . setVisible ( false ) ; populateGroupsLegendByTargetCounts ( Collections . emptyList ( ) ) ; if ( groupsLegend . getComponentCount ( ) > MAX_GROUPS_TO_BE_DISPLAYED ) { groupsLegend . getComponent ( MAX_GROUPS_TO_BE_DISPLAYED ) . setVisible ( false ) ; } }
Resets the display of the legend and total targets .
92
11
29,163
public void populateTotalTargets ( final Long totalTargets ) { if ( totalTargets == null ) { totalTargetsLabel . setVisible ( false ) ; } else { totalTargetsLabel . setVisible ( true ) ; totalTargetsLabel . setValue ( getTotalTargetMessage ( totalTargets ) ) ; } }
Displays the total targets or hides the label when null is supplied .
78
14
29,164
public void populateGroupsLegendByTargetCounts ( final List < Long > listOfTargetCountPerGroup ) { loadingLabel . setVisible ( false ) ; for ( int i = 0 ; i < getGroupsWithoutToBeContinuedLabel ( listOfTargetCountPerGroup . size ( ) ) ; i ++ ) { final Component component = groupsLegend . getComponent ( i ) ; final Label label = ( Label ) component ; if ( listOfTargetCountPerGroup . size ( ) > i ) { final Long targetCount = listOfTargetCountPerGroup . get ( i ) ; label . setValue ( getTargetsInGroupMessage ( targetCount , i18n . getMessage ( "textfield.rollout.group.default.name" , i + 1 ) ) ) ; label . setVisible ( true ) ; } else { label . setValue ( "" ) ; label . setVisible ( false ) ; } } showOrHideToBeContinueLabel ( listOfTargetCountPerGroup ) ; unassignedTargetsLabel . setValue ( "" ) ; unassignedTargetsLabel . setVisible ( false ) ; }
Populates the legend based on a list of anonymous groups . They can t have unassigned targets .
245
21
29,165
public void populateGroupsLegendByValidation ( final RolloutGroupsValidation validation , final List < RolloutGroupCreate > groups ) { loadingLabel . setVisible ( false ) ; if ( validation == null ) { return ; } final List < Long > targetsPerGroup = validation . getTargetsPerGroup ( ) ; final long unassigned = validation . getTotalTargets ( ) - validation . getTargetsInGroups ( ) ; final int labelsToUpdate = ( unassigned > 0 ) ? ( getGroupsWithoutToBeContinuedLabel ( groups . size ( ) ) - 1 ) : groupsLegend . getComponentCount ( ) ; for ( int i = 0 ; i < getGroupsWithoutToBeContinuedLabel ( groups . size ( ) ) ; i ++ ) { final Component component = groupsLegend . getComponent ( i ) ; final Label label = ( Label ) component ; if ( targetsPerGroup . size ( ) > i && groups . size ( ) > i && labelsToUpdate > i ) { final Long targetCount = targetsPerGroup . get ( i ) ; final String groupName = groups . get ( i ) . build ( ) . getName ( ) ; label . setValue ( getTargetsInGroupMessage ( targetCount , groupName ) ) ; label . setVisible ( true ) ; } else { label . setValue ( "" ) ; label . setVisible ( false ) ; } } showOrHideToBeContinueLabel ( groups ) ; if ( unassigned > 0 ) { unassignedTargetsLabel . setValue ( getTargetsInGroupMessage ( unassigned , "Unassigned" ) ) ; unassignedTargetsLabel . setVisible ( true ) ; } else { unassignedTargetsLabel . setValue ( "" ) ; unassignedTargetsLabel . setVisible ( false ) ; } }
Populates the legend based on a groups validation and a list of groups that is used for resolving their names . Positions of the groups in the groups list and the validation need to be in correct order . Can have unassigned targets that are displayed on top of the groups list which results in one group less to be displayed
408
65
29,166
public void populateGroupsLegendByGroups ( final List < RolloutGroup > groups ) { loadingLabel . setVisible ( false ) ; for ( int i = 0 ; i < getGroupsWithoutToBeContinuedLabel ( groups . size ( ) ) ; i ++ ) { final Component component = groupsLegend . getComponent ( i ) ; final Label label = ( Label ) component ; if ( groups . size ( ) > i ) { final int targetCount = groups . get ( i ) . getTotalTargets ( ) ; final String groupName = groups . get ( i ) . getName ( ) ; label . setValue ( getTargetsInGroupMessage ( ( long ) targetCount , groupName ) ) ; label . setVisible ( true ) ; } else { label . setValue ( "" ) ; label . setVisible ( false ) ; } } showOrHideToBeContinueLabel ( groups ) ; }
Populates the legend based on a list of groups .
197
11
29,167
private void getTargetFilterStatuses ( ) { unknown = SPUIComponentProvider . getButton ( UIComponentIdProvider . UNKNOWN_STATUS_ICON , TargetUpdateStatus . UNKNOWN . toString ( ) , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_TARGET_STATUS_UNKNOWN ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; inSync = SPUIComponentProvider . getButton ( UIComponentIdProvider . INSYNCH_STATUS_ICON , TargetUpdateStatus . IN_SYNC . toString ( ) , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_STATUS_INSYNC ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; pending = SPUIComponentProvider . getButton ( UIComponentIdProvider . PENDING_STATUS_ICON , TargetUpdateStatus . PENDING . toString ( ) , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_STATUS_PENDING ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; error = SPUIComponentProvider . getButton ( UIComponentIdProvider . ERROR_STATUS_ICON , TargetUpdateStatus . ERROR . toString ( ) , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_STATUS_ERROR ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; registered = SPUIComponentProvider . getButton ( UIComponentIdProvider . REGISTERED_STATUS_ICON , TargetUpdateStatus . REGISTERED . toString ( ) , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_STATUS_REGISTERED ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; overdue = SPUIComponentProvider . getButton ( UIComponentIdProvider . OVERDUE_STATUS_ICON , OVERDUE_CAPTION , i18n . getMessage ( UIMessageIdProvider . TOOLTIP_STATUS_OVERDUE ) , SPUIDefinitions . SP_BUTTON_STATUS_STYLE , false , FontAwesome . SQUARE , SPUIButtonStyleSmall . class ) ; applyStatusBtnStyle ( ) ; unknown . setData ( "filterStatusOne" ) ; inSync . setData ( "filterStatusTwo" ) ; pending . setData ( "filterStatusThree" ) ; error . setData ( "filterStatusFour" ) ; registered . setData ( "filterStatusFive" ) ; overdue . setData ( "filterStatusSix" ) ; unknown . addClickListener ( this ) ; inSync . addClickListener ( this ) ; pending . addClickListener ( this ) ; error . addClickListener ( this ) ; registered . addClickListener ( this ) ; overdue . addClickListener ( this ) ; }
Get - status of FILTER .
762
7
29,168
private void applyStatusBtnStyle ( ) { unknown . addStyleName ( "unknownBtn" ) ; inSync . addStyleName ( "inSynchBtn" ) ; pending . addStyleName ( "pendingBtn" ) ; error . addStyleName ( "errorBtn" ) ; registered . addStyleName ( "registeredBtn" ) ; overdue . addStyleName ( "overdueBtn" ) ; }
Apply - status style .
94
5
29,169
private void processOverdueFilterStatus ( ) { overdueBtnClicked = ! overdueBtnClicked ; managementUIState . getTargetTableFilters ( ) . setOverdueFilterEnabled ( overdueBtnClicked ) ; if ( overdueBtnClicked ) { buttonClicked . addStyleName ( BTN_CLICKED ) ; eventBus . publish ( this , TargetFilterEvent . FILTER_BY_STATUS ) ; } else { buttonClicked . removeStyleName ( BTN_CLICKED ) ; eventBus . publish ( this , TargetFilterEvent . REMOVE_FILTER_BY_STATUS ) ; } }
Process - OVERDUE .
138
6
29,170
private void processCommonFilterStatus ( final TargetUpdateStatus status , final boolean buttonPressed ) { if ( buttonPressed ) { buttonClicked . addStyleName ( BTN_CLICKED ) ; managementUIState . getTargetTableFilters ( ) . getClickedStatusTargetTags ( ) . add ( status ) ; eventBus . publish ( this , TargetFilterEvent . FILTER_BY_STATUS ) ; } else { buttonClicked . removeStyleName ( BTN_CLICKED ) ; managementUIState . getTargetTableFilters ( ) . getClickedStatusTargetTags ( ) . remove ( status ) ; eventBus . publish ( this , TargetFilterEvent . REMOVE_FILTER_BY_STATUS ) ; } }
Process - COMMON PROCESS .
160
7
29,171
private void checkAndCancelExpiredAction ( final Action action ) { if ( action != null && action . hasMaintenanceSchedule ( ) && action . isMaintenanceScheduleLapsed ( ) ) { try { controllerManagement . cancelAction ( action . getId ( ) ) ; } catch ( final CancelActionNotAllowedException e ) { LOG . info ( "Cancel action not allowed exception :{}" , e ) ; } } }
If the action has a maintenance schedule defined but is no longer valid cancel the action .
94
17
29,172
public void populateByRollout ( final Rollout rollout ) { if ( rollout == null ) { return ; } removeAllRows ( ) ; final List < RolloutGroup > groups = rolloutGroupManagement . findByRollout ( PageRequest . of ( 0 , quotaManagement . getMaxRolloutGroupsPerRollout ( ) ) , rollout . getId ( ) ) . getContent ( ) ; for ( final RolloutGroup group : groups ) { final GroupRow groupRow = addGroupRow ( ) ; groupRow . populateByGroup ( group ) ; } updateValidation ( ) ; }
Populate groups by rollout
125
5
29,173
private void setGroupsValidation ( final RolloutGroupsValidation validation ) { final int runningValidation = runningValidationsCounter . getAndSet ( 0 ) ; if ( runningValidation > 1 ) { validateRemainingTargets ( ) ; return ; } groupsValidation = validation ; final int lastIdx = groupRows . size ( ) - 1 ; final GroupRow lastRow = groupRows . get ( lastIdx ) ; if ( groupsValidation != null && groupsValidation . isValid ( ) && validationStatus != ValidationStatus . INVALID ) { lastRow . resetError ( ) ; setValidationStatus ( ValidationStatus . VALID ) ; } else { lastRow . setError ( i18n . getMessage ( "message.rollout.remaining.targets.error" ) ) ; setValidationStatus ( ValidationStatus . INVALID ) ; } // validate the single groups final int maxTargets = quotaManagement . getMaxTargetsPerRolloutGroup ( ) ; final boolean hasRemainingTargetsError = validationStatus == ValidationStatus . INVALID ; for ( int i = 0 ; i < groupRows . size ( ) ; ++ i ) { final GroupRow row = groupRows . get ( i ) ; // do not mask the 'remaining targets' error if ( hasRemainingTargetsError && row . equals ( lastRow ) ) { continue ; } row . resetError ( ) ; final Long count = groupsValidation . getTargetsPerGroup ( ) . get ( i ) ; if ( count != null && count > maxTargets ) { row . setError ( i18n . getMessage ( MESSAGE_ROLLOUT_MAX_GROUP_SIZE_EXCEEDED , maxTargets ) ) ; setValidationStatus ( ValidationStatus . INVALID ) ; } } }
YOU SHOULD NOT CALL THIS METHOD MANUALLY . It s only for the callback . Only 1 runningValidation should be executed . If this runningValidation is done then this method is called . Maybe then a new runningValidation is executed .
410
50
29,174
@ Override public String getMinPollingTime ( ) { return systemSecurityContext . runAsSystem ( ( ) -> tenantConfigurationManagement . getConfigurationValue ( TenantConfigurationKey . MIN_POLLING_TIME_INTERVAL , String . class ) . getValue ( ) ) ; }
Returns the configured minimum polling interval .
61
7
29,175
@ EventBusListenerMethod ( scope = EventScope . UI ) public void onEvent ( final PinUnpinEvent event ) { final Optional < Long > pinnedDist = managementUIState . getTargetTableFilters ( ) . getPinnedDistId ( ) ; if ( event == PinUnpinEvent . PIN_DISTRIBUTION && pinnedDist . isPresent ( ) ) { displayCountLabel ( pinnedDist . get ( ) ) ; } else { setValue ( "" ) ; displayTargetCountStatus ( ) ; } }
TenantAwareEvent Listener for Pinning Distribution .
109
12
29,176
public String getMessage ( final Locale local , final String code , final Object ... args ) { try { return source . getMessage ( code , args , local ) ; } catch ( final NoSuchMessageException ex ) { LOG . error ( "Failed to retrieve message!" , ex ) ; return code ; } }
Tries to resolve the message based on the provided Local . Returns message code if fitting message could not be found .
66
23
29,177
public static void verifyRolloutGroupConditions ( final RolloutGroupConditions conditions ) { if ( conditions . getSuccessCondition ( ) == null ) { throw new ValidationException ( "Rollout group is missing success condition" ) ; } if ( conditions . getSuccessAction ( ) == null ) { throw new ValidationException ( "Rollout group is missing success action" ) ; } }
Verifies that the required success condition and action are actually set .
82
13
29,178
public static RolloutGroup verifyRolloutGroupHasConditions ( final RolloutGroup group ) { if ( group . getTargetPercentage ( ) < 1F || group . getTargetPercentage ( ) > 100F ) { throw new ValidationException ( "Target percentage has to be between 1 and 100" ) ; } if ( group . getSuccessCondition ( ) == null ) { throw new ValidationException ( "Rollout group is missing success condition" ) ; } if ( group . getSuccessAction ( ) == null ) { throw new ValidationException ( "Rollout group is missing success action" ) ; } return group ; }
Verifies that the group has the required success condition and action and a falid target percentage .
133
19
29,179
public static void verifyRolloutGroupParameter ( final int amountGroup , final QuotaManagement quotaManagement ) { if ( amountGroup <= 0 ) { throw new ValidationException ( "The amount of groups cannot be lower than zero" ) ; } else if ( amountGroup > quotaManagement . getMaxRolloutGroupsPerRollout ( ) ) { throw new QuotaExceededException ( "The amount of groups cannot be greater than " + quotaManagement . getMaxRolloutGroupsPerRollout ( ) ) ; } }
Verify if the supplied amount of groups is in range
110
11
29,180
public static void verifyRolloutInStatus ( final Rollout rollout , final Rollout . RolloutStatus status ) { if ( ! rollout . getStatus ( ) . equals ( status ) ) { throw new RolloutIllegalStateException ( "Rollout is not in status " + status . toString ( ) ) ; } }
Verifies that the Rollout is in the required status .
68
12
29,181
public static List < Long > getGroupsByStatusIncludingGroup ( final List < RolloutGroup > groups , final RolloutGroup . RolloutGroupStatus status , final RolloutGroup group ) { return groups . stream ( ) . filter ( innerGroup -> innerGroup . getStatus ( ) . equals ( status ) || innerGroup . equals ( group ) ) . map ( RolloutGroup :: getId ) . collect ( Collectors . toList ( ) ) ; }
Filters the groups of a Rollout to match a specific status and adds a group to the result .
98
21
29,182
public static String getAllGroupsTargetFilter ( final List < RolloutGroup > groups ) { if ( groups . stream ( ) . anyMatch ( group -> StringUtils . isEmpty ( group . getTargetFilterQuery ( ) ) ) ) { return "" ; } return "(" + groups . stream ( ) . map ( RolloutGroup :: getTargetFilterQuery ) . distinct ( ) . sorted ( ) . collect ( Collectors . joining ( "),(" ) ) + ")" ; }
Creates an RSQL expression that matches all targets in the provided groups . Links all target filter queries with OR .
103
23
29,183
public static String getOverlappingWithGroupsTargetFilter ( final String baseFilter , final List < RolloutGroup > groups , final RolloutGroup group ) { final String groupFilter = group . getTargetFilterQuery ( ) ; // when any previous group has the same filter as the target group the // overlap is 100% if ( isTargetFilterInGroups ( groupFilter , groups ) ) { return concatAndTargetFilters ( baseFilter , groupFilter ) ; } final String previousGroupFilters = getAllGroupsTargetFilter ( groups ) ; if ( ! StringUtils . isEmpty ( previousGroupFilters ) ) { if ( ! StringUtils . isEmpty ( groupFilter ) ) { return concatAndTargetFilters ( baseFilter , groupFilter , previousGroupFilters ) ; } else { return concatAndTargetFilters ( baseFilter , previousGroupFilters ) ; } } if ( ! StringUtils . isEmpty ( groupFilter ) ) { return concatAndTargetFilters ( baseFilter , groupFilter ) ; } else { return baseFilter ; } }
Creates an RSQL Filter that matches all targets that are in the provided group and in the provided groups .
229
22
29,184
private void decorate ( final Map < String , String > controllerAttibs ) { final VaadinMessageSource i18n = SpringContextHelper . getBean ( VaadinMessageSource . class ) ; final Label title = new Label ( i18n . getMessage ( "label.target.controller.attrs" ) , ContentMode . HTML ) ; title . addStyleName ( SPUIDefinitions . TEXT_STYLE ) ; targetAttributesLayout . addComponent ( title ) ; if ( HawkbitCommonUtil . isNotNullOrEmpty ( controllerAttibs ) ) { for ( final Map . Entry < String , String > entry : controllerAttibs . entrySet ( ) ) { targetAttributesLayout . addComponent ( SPUIComponentProvider . createNameValueLabel ( entry . getKey ( ) + ": " , entry . getValue ( ) ) ) ; } } }
Custom Decorate .
191
4
29,185
@ SuppressWarnings ( { "squid:S2221" , "squid:S00112" } ) public < T > T runAsSystemAsTenant ( final Callable < T > callable , final String tenant ) { final SecurityContext oldContext = SecurityContextHolder . getContext ( ) ; try { LOG . debug ( "entering system code execution" ) ; return tenantAware . runAsTenant ( tenant , ( ) -> { try { setSystemContext ( SecurityContextHolder . getContext ( ) ) ; return callable . call ( ) ; } catch ( final RuntimeException e ) { throw e ; } catch ( final Exception e ) { throw new RuntimeException ( e ) ; } } ) ; } finally { SecurityContextHolder . setContext ( oldContext ) ; LOG . debug ( "leaving system code execution" ) ; } }
The callable API throws a Exception and not a specific one
187
12
29,186
protected DmfTenantSecurityToken createTenantSecruityTokenVariables ( final HttpServletRequest request ) { final String requestURI = request . getRequestURI ( ) ; if ( pathExtractor . match ( request . getContextPath ( ) + CONTROLLER_REQUEST_ANT_PATTERN , requestURI ) ) { LOG . debug ( "retrieving principal from URI request {}" , requestURI ) ; final Map < String , String > extractUriTemplateVariables = pathExtractor . extractUriTemplateVariables ( request . getContextPath ( ) + CONTROLLER_REQUEST_ANT_PATTERN , requestURI ) ; final String controllerId = extractUriTemplateVariables . get ( CONTROLLER_ID_PLACE_HOLDER ) ; final String tenant = extractUriTemplateVariables . get ( TENANT_PLACE_HOLDER ) ; if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Parsed tenant {} and controllerId {} from path request {}" , tenant , controllerId , requestURI ) ; } return createTenantSecruityTokenVariables ( request , tenant , controllerId ) ; } else if ( pathExtractor . match ( request . getContextPath ( ) + CONTROLLER_DL_REQUEST_ANT_PATTERN , requestURI ) ) { LOG . debug ( "retrieving path variables from URI request {}" , requestURI ) ; final Map < String , String > extractUriTemplateVariables = pathExtractor . extractUriTemplateVariables ( request . getContextPath ( ) + CONTROLLER_DL_REQUEST_ANT_PATTERN , requestURI ) ; final String tenant = extractUriTemplateVariables . get ( TENANT_PLACE_HOLDER ) ; if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Parsed tenant {} from path request {}" , tenant , requestURI ) ; } return createTenantSecruityTokenVariables ( request , tenant , "anonymous" ) ; } else { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "request {} does not match the path pattern {}, request gets ignored" , requestURI , CONTROLLER_REQUEST_ANT_PATTERN ) ; } return null ; } }
Extracts tenant and controllerId from the request URI as path variables .
510
15
29,187
@ SuppressWarnings ( "unchecked" ) public < T > T convertMessage ( @ NotNull final Message message , final Class < T > clazz ) { checkMessageBody ( message ) ; message . getMessageProperties ( ) . getHeaders ( ) . put ( AbstractJavaTypeMapper . DEFAULT_CLASSID_FIELD_NAME , clazz . getName ( ) ) ; return ( T ) rabbitTemplate . getMessageConverter ( ) . fromMessage ( message ) ; }
Is needed to convert a incoming message to is originally object type .
107
13
29,188
public static List < GrantedAuthority > createAllAuthorityList ( ) { return SpPermission . getAllAuthorities ( ) . stream ( ) . map ( SimpleGrantedAuthority :: new ) . collect ( Collectors . toList ( ) ) ; }
Returns all authorities .
54
4
29,189
public static Button getButton ( final String id , final String buttonName , final String buttonDesc , final String style , final boolean setStyle , final Resource icon , final Class < ? extends SPUIButtonDecorator > buttonDecoratorclassName ) { Button button = null ; SPUIButtonDecorator buttonDecorator = null ; try { // Create instance buttonDecorator = buttonDecoratorclassName . newInstance ( ) ; // Decorate button button = buttonDecorator . decorate ( new SPUIButton ( id , buttonName , buttonDesc ) , style , setStyle , icon ) ; } catch ( final InstantiationException exception ) { LOG . error ( "Error occured while creating Button decorator-" + buttonName , exception ) ; } catch ( final IllegalAccessException exception ) { LOG . error ( "Error occured while acessing Button decorator-" + buttonName , exception ) ; } return button ; }
Get Button - Factory Approach for decoration .
201
8
29,190
public static String getPinButtonStyle ( ) { final StringBuilder pinStyle = new StringBuilder ( ValoTheme . BUTTON_BORDERLESS_COLORED ) ; pinStyle . append ( ' ' ) ; pinStyle . append ( ValoTheme . BUTTON_SMALL ) ; pinStyle . append ( ' ' ) ; pinStyle . append ( ValoTheme . BUTTON_ICON_ONLY ) ; pinStyle . append ( ' ' ) ; pinStyle . append ( "pin-icon" ) ; return pinStyle . toString ( ) ; }
Get the style required .
120
5
29,191
public static Panel getDistributionSetInfo ( final DistributionSet distributionSet , final String caption , final String style1 , final String style2 ) { return new DistributionSetInfoPanel ( distributionSet , caption , style1 , style2 ) ; }
Get DistributionSet Info Panel .
50
6
29,192
public static Label createNameValueLabel ( final String label , final String ... values ) { final String valueStr = StringUtils . arrayToDelimitedString ( values , " " ) ; final Label nameValueLabel = new Label ( getBoldHTMLText ( label ) + valueStr , ContentMode . HTML ) ; nameValueLabel . setSizeFull ( ) ; nameValueLabel . addStyleName ( SPUIDefinitions . TEXT_STYLE ) ; nameValueLabel . addStyleName ( "label-style" ) ; return nameValueLabel ; }
Method to CreateName value labels .
119
7
29,193
public static VerticalLayout getDetailTabLayout ( ) { final VerticalLayout layout = new VerticalLayout ( ) ; layout . setSpacing ( true ) ; layout . setMargin ( true ) ; layout . setImmediate ( true ) ; return layout ; }
Layout of tabs in detail tabsheet .
54
8
29,194
public static Link getLink ( final String id , final String name , final String resource , final FontAwesome icon , final String targetOpen , final String style ) { final Link link = new Link ( name , new ExternalResource ( resource ) ) ; link . setId ( id ) ; link . setIcon ( icon ) ; link . setDescription ( name ) ; link . setTargetName ( targetOpen ) ; if ( style != null ) { link . setStyleName ( style ) ; } return link ; }
Method to create a link .
105
6
29,195
public CommonDialogWindow createUpdateSoftwareModuleWindow ( final Long baseSwModuleId ) { this . baseSwModuleId = baseSwModuleId ; resetComponents ( ) ; populateTypeNameCombo ( ) ; populateValuesOfSwModule ( ) ; return createWindow ( ) ; }
Creates window for update software module .
59
8
29,196
private void populateValuesOfSwModule ( ) { if ( baseSwModuleId == null ) { return ; } editSwModule = Boolean . TRUE ; softwareModuleManagement . get ( baseSwModuleId ) . ifPresent ( swModule -> { nameTextField . setValue ( swModule . getName ( ) ) ; versionTextField . setValue ( swModule . getVersion ( ) ) ; vendorTextField . setValue ( swModule . getVendor ( ) ) ; descTextArea . setValue ( swModule . getDescription ( ) ) ; softwareModuleType = new LabelBuilder ( ) . name ( swModule . getType ( ) . getName ( ) ) . caption ( i18n . getMessage ( UIMessageIdProvider . CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE ) ) . buildLabel ( ) ; } ) ; }
fill the data of a softwareModule in the content of the window
182
13
29,197
public void addItems ( final List < SuggestTokenDto > suggestions , final VTextField textFieldWidget , final PopupPanel popupPanel , final TextFieldSuggestionBoxServerRpc suggestionServerRpc ) { for ( int index = 0 ; index < suggestions . size ( ) ; index ++ ) { final SuggestTokenDto suggestToken = suggestions . get ( index ) ; final MenuItem mi = new MenuItem ( suggestToken . getSuggestion ( ) , true , new ScheduledCommand ( ) { @ Override public void execute ( ) { final String tmpSuggestion = suggestToken . getSuggestion ( ) ; final TokenStartEnd tokenStartEnd = tokenMap . get ( tmpSuggestion ) ; final String text = textFieldWidget . getValue ( ) ; final StringBuilder builder = new StringBuilder ( text ) ; builder . replace ( tokenStartEnd . getStart ( ) , tokenStartEnd . getEnd ( ) + 1 , tmpSuggestion ) ; textFieldWidget . setValue ( builder . toString ( ) , true ) ; popupPanel . hide ( ) ; textFieldWidget . setFocus ( true ) ; suggestionServerRpc . suggest ( builder . toString ( ) , textFieldWidget . getCursorPos ( ) ) ; } } ) ; tokenMap . put ( suggestToken . getSuggestion ( ) , new TokenStartEnd ( suggestToken . getStart ( ) , suggestToken . getEnd ( ) ) ) ; Roles . getListitemRole ( ) . set ( mi . getElement ( ) ) ; WidgetUtil . sinkOnloadForImages ( mi . getElement ( ) ) ; addItem ( mi ) ; } }
Adds suggestions to the suggestion menu bar .
350
8
29,198
public static < T > T getBean ( final String beanName , final Class < T > beanClazz ) { return context . getBean ( beanName , beanClazz ) ; }
method to return a certain bean by its class and name .
41
12
29,199
private static String [ ] getDsFilterNameAndVersionEntries ( final String filterString ) { final int semicolonIndex = filterString . indexOf ( ' ' ) ; final String dsFilterName = semicolonIndex != - 1 ? filterString . substring ( 0 , semicolonIndex ) : ( filterString + "%" ) ; final String dsFilterVersion = semicolonIndex != - 1 ? ( filterString . substring ( semicolonIndex + 1 ) + "%" ) : "%" ; return new String [ ] { ! StringUtils . isEmpty ( dsFilterName ) ? dsFilterName : "%" , dsFilterVersion } ; }
field when the semicolon is present
146
8